All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: stsp <stsp2@yandex.ru>, Maxim Levitsky <mlevitsk@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	kvm@vger.kernel.org
Subject: Re: [PATCH v2] KVM: X86: Fix exception untrigger on ret to user
Date: Wed, 7 Jul 2021 01:45:52 +0200	[thread overview]
Message-ID: <b1976445-1b88-8a6c-24ee-8a3844db3885@redhat.com> (raw)
In-Reply-To: <dc6a64d0-a77e-b85e-6a8e-c5ca3b42dd59@yandex.ru>

On 07/07/21 01:06, stsp wrote:
> What I ask is how SHOULD the
> KVM_SET_REGS and KVM_SET_SREGS
> behave when someone (mistakenly)
> calls them with the exception pending.
> Should they return an error
> instead of canceling exception?

In theory, KVM_SET_REGS and KVM_SET_SREGS should do nothing but set the 
value of the registers.  They not should clear either 
vcpu->arch.exception.pending or vcpu->arch.exception.injected.  I'm wary 
of changing that and breaking users of KVM, though.

In this case the problem is that, with a pending exception, you should 
not inject the interrupt (doesn't matter if it's with KVM_SET_REGS or 
KVM_INTERRUPT).  Raising a page fault is part of executing the previous 
instruction, and interrupts are only recognized at instruction 
boundaries.  Therefore, you need to test ready_for_interrupt_injection, 
and possibly use request_interrupt_window, before calling KVM_SET_REGS.

The patch you identified as the culprit does have a bug, but that's 
fixed in kvm_cpu_accept_dm_intr as I suggested in the other thread.

Paolo


  reply	other threads:[~2021-07-06 23:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28 12:48 [PATCH v2] KVM: X86: Fix exception untrigger on ret to user Stas Sergeev
2021-06-28 14:29 ` Maxim Levitsky
2021-06-28 15:09   ` stsp
2021-06-28 16:50     ` Jim Mattson
2021-06-28 17:00       ` stsp
2021-07-06 11:49   ` Maxim Levitsky
2021-07-06 12:06     ` stsp
2021-07-06 20:29       ` Maxim Levitsky
2021-07-06 21:50         ` stsp
2021-07-06 23:00           ` Maxim Levitsky
2021-07-06 23:06             ` stsp
2021-07-06 23:45               ` Paolo Bonzini [this message]
2021-07-06 23:51                 ` stsp
2021-07-07  0:13                   ` Paolo Bonzini
2021-07-07 16:16               ` Jim Mattson
2021-07-07 16:34                 ` stsp
2021-07-07 16:46                   ` Jim Mattson
2021-07-07 16:58                     ` stsp
2021-07-07 17:39                       ` Jim Mattson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b1976445-1b88-8a6c-24ee-8a3844db3885@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jan.kiszka@siemens.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=mlevitsk@redhat.com \
    --cc=seanjc@google.com \
    --cc=stsp2@yandex.ru \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.