From: Maxim Levitsky <mlevitsk@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, kvm@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Sean Christopherson <seanjc@google.com>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
linux-kernel@vger.kernel.org, x86@kernel.org,
Dave Hansen <dave.hansen@linux.intel.com>
Subject: Re: [PATCH v3 1/4] KVM: x86: refactor req_immediate_exit logic
Date: Tue, 28 Nov 2023 08:41:51 +0200 [thread overview]
Message-ID: <4ca6dc2cf030f15193efbe2b364bf196692cd167.camel@redhat.com> (raw)
In-Reply-To: <0c626505-a358-4d13-99e3-144356d136b3@redhat.com>
On Fri, 2023-11-24 at 17:07 +0100, Paolo Bonzini wrote:
> On 9/28/23 12:36, Maxim Levitsky wrote:
> > @@ -4176,6 +4176,9 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
> > clgi();
> > kvm_load_guest_xsave_state(vcpu);
> >
> > + if (vcpu->arch.req_immediate_exit)
> > + smp_send_reschedule(vcpu->cpu);
> > +
>
> This code is in a non-standard situation where IF=1 but interrupts are
> effectively disabled. Better something like:
>
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index beea99c8e8e0..3b945de2d880 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -4148,8 +4148,11 @@ static __no_kcsan fastpath_t svm_vcpu_run(
> * is enough to force an immediate vmexit.
> */
> disable_nmi_singlestep(svm);
> + vcpu->arch.req_immediate_exit = true;
> + }
> +
> + if (vcpu->arch.req_immediate_exit)
> smp_send_reschedule(vcpu->cpu);
> - }
>
> pre_svm_run(vcpu);
>
>
> Paolo
>
Actually IF=0 at that point. We disable IF before we call svm_vcpu_run, at
vcpu_enter_guest().
Then we disable GIF, and we re-enable IF only right before VMRUN, in fact vmrun is
in the interrupt shadow although that doesn't really matter since GIF=0.
However I don't mind implementing the change you suggested, I don't think it will
affect anything.
Best regards,
Maxim Levitsky
next prev parent reply other threads:[~2023-11-28 6:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-28 10:36 [PATCH v3 0/4] KVM: x86: tracepoint updates Maxim Levitsky
2023-09-28 10:36 ` [PATCH v3 1/4] KVM: x86: refactor req_immediate_exit logic Maxim Levitsky
2023-11-24 16:07 ` Paolo Bonzini
2023-11-28 6:41 ` Maxim Levitsky [this message]
2023-09-28 10:36 ` [PATCH v3 2/4] KVM: x86: add more information to the kvm_entry tracepoint Maxim Levitsky
2023-11-24 16:08 ` Paolo Bonzini
2023-09-28 10:36 ` [PATCH v3 3/4] KVM: x86: add information about pending requests to kvm_exit tracepoint Maxim Levitsky
2023-11-24 16:08 ` Paolo Bonzini
2023-09-28 10:36 ` [PATCH v3 4/4] KVM: x86: add new nested vmexit tracepoints Maxim Levitsky
2023-11-24 16:11 ` Paolo Bonzini
2023-11-28 6:42 ` Maxim Levitsky
2023-10-17 12:12 ` [PATCH v3 0/4] KVM: x86: tracepoint updates Maxim Levitsky
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=4ca6dc2cf030f15193efbe2b364bf196692cd167.camel@redhat.com \
--to=mlevitsk@redhat.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox