From: Maxim Levitsky <mlevitsk@redhat.com>
To: Sean Christopherson <seanjc@google.com>
Cc: kvm@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>,
x86@kernel.org, Borislav Petkov <bp@alien8.de>,
Paolo Bonzini <pbonzini@redhat.com>,
Ingo Molnar <mingo@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Joerg Roedel <joro@8bytes.org>,
Wanpeng Li <wanpengli@tencent.com>,
"H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org, Jim Mattson <jmattson@google.com>
Subject: Re: [PATCH v2 3/3] KVM: VMX: read idt_vectoring_info a bit earlier
Date: Thu, 21 Jan 2021 19:04:00 +0200 [thread overview]
Message-ID: <c6b1dec841182178c41a564fb822a615acc97762.camel@redhat.com> (raw)
In-Reply-To: <YADhzRqE6QHmTOkx@google.com>
On Thu, 2021-01-14 at 16:29 -0800, Sean Christopherson wrote:
> On Thu, Jan 14, 2021, Maxim Levitsky wrote:
> > This allows it to be printed correctly by the trace print
>
> It'd be helpful to explicitly say which tracepoint, and explain that the value
> is read by vmx_get_exit_info(). It's far from obvious how this gets consumed.
>
> > that follows.
> >
>
> Fixes: dcf068da7eb2 ("KVM: VMX: Introduce generic fastpath handler")
>
> > Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> > ---
> > arch/x86/kvm/vmx/vmx.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> > index 2af05d3b05909..9b6e7dbf5e2bd 100644
> > --- a/arch/x86/kvm/vmx/vmx.c
> > +++ b/arch/x86/kvm/vmx/vmx.c
> > @@ -6771,6 +6771,8 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu)
> > }
> >
> > vmx->exit_reason = vmcs_read32(VM_EXIT_REASON);
> > + vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
>
> Hrm, it probably makes sense to either do the VMREAD conditionally, or to
> zero idt_vectoring_info in the vmx->fail path. I don't care about the cycles
> on VM-Exit consistency checks, just that this would hide that the field is valid
> if and only if VM-Enter fully succeeded. A third option would be to add a
> comment saying that it's unnecessary if VM-Enter failed, but faster in the
> common case to just do the VMREAD.
Allright, I will add this.
Best regards,
Maxim Levitsky
>
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 2af05d3b0590..3c172c05570a 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -6774,13 +6774,15 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu)
> if (unlikely((u16)vmx->exit_reason == EXIT_REASON_MCE_DURING_VMENTRY))
> kvm_machine_check();
>
> + if (likely(!(vmx->exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY)))
> + vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
> +
> trace_kvm_exit(vmx->exit_reason, vcpu, KVM_ISA_VMX);
>
> if (unlikely(vmx->exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY))
> return EXIT_FASTPATH_NONE;
>
> vmx->loaded_vmcs->launched = 1;
> - vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
>
> vmx_recover_nmi_blocking(vmx);
> vmx_complete_interrupts(vmx);
>
>
> > +
> > if (unlikely((u16)vmx->exit_reason == EXIT_REASON_MCE_DURING_VMENTRY))
> > kvm_machine_check();
> >
> > @@ -6780,7 +6782,6 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu)
> > return EXIT_FASTPATH_NONE;
> >
> > vmx->loaded_vmcs->launched = 1;
> > - vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
> >
> > vmx_recover_nmi_blocking(vmx);
> > vmx_complete_interrupts(vmx);
> > --
> > 2.26.2
> >
next prev parent reply other threads:[~2021-01-21 17:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-14 20:54 [PATCH v2 0/3] VMX: more nested fixes Maxim Levitsky
2021-01-14 20:54 ` [PATCH v2 1/3] KVM: nVMX: Always call sync_vmcs02_to_vmcs12_rare on migration Maxim Levitsky
2021-01-14 23:58 ` Sean Christopherson
2021-01-21 14:59 ` Paolo Bonzini
2021-01-14 20:54 ` [PATCH v2 2/3] KVM: nVMX: add kvm_nested_vmlaunch_resume tracepoint Maxim Levitsky
2021-01-15 0:14 ` Sean Christopherson
2021-01-15 13:48 ` Paolo Bonzini
2021-01-15 16:30 ` Sean Christopherson
2021-01-21 17:00 ` Maxim Levitsky
2021-01-21 16:58 ` Maxim Levitsky
2021-01-21 17:02 ` Maxim Levitsky
2021-01-14 20:54 ` [PATCH v2 3/3] KVM: VMX: read idt_vectoring_info a bit earlier Maxim Levitsky
2021-01-15 0:29 ` Sean Christopherson
2021-01-21 17:04 ` Maxim Levitsky [this message]
2021-01-21 15:00 ` [PATCH v2 0/3] VMX: more nested fixes Paolo Bonzini
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=c6b1dec841182178c41a564fb822a615acc97762.camel@redhat.com \
--to=mlevitsk@redhat.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--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=vkuznets@redhat.com \
--cc=wanpengli@tencent.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).