From: Sean Christopherson <seanjc@google.com>
To: Kai Huang <kai.huang@intel.com>
Cc: "pbonzini@redhat.com" <pbonzini@redhat.com>,
"vkuznets@redhat.com" <vkuznets@redhat.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
Guang Zeng <guang.zeng@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Yuan Yao <yuan.yao@intel.com>
Subject: Re: [PATCH v3 07/15] KVM: nVMX: Use KVM-governed feature framework to track "nested VMX enabled"
Date: Wed, 16 Aug 2023 07:42:35 -0700 [thread overview]
Message-ID: <ZNzgWwUNy/2J3SV2@google.com> (raw)
In-Reply-To: <55bfeecb59787369d57c2704785af13604e63a62.camel@intel.com>
On Wed, Aug 16, 2023, Kai Huang wrote:
> On Tue, 2023-08-15 at 13:36 -0700, Sean Christopherson wrote:
> > Track "VMX exposed to L1" via a governed feature flag instead of using a
> > dedicated helper to provide the same functionality. The main goal is to
> > drive convergence between VMX and SVM with respect to querying features
> > that are controllable via module param (SVM likes to cache nested
> > features), avoiding the guest CPUID lookups at runtime is just a bonus
> > and unlikely to provide any meaningful performance benefits.
> >
> > No functional change intended.
> >
> >
> [...]
>
> >
> > -/*
> > - * nested_vmx_allowed() checks whether a guest should be allowed to use VMX
> > - * instructions and MSRs (i.e., nested VMX). Nested VMX is disabled for
> > - * all guests if the "nested" module option is off, and can also be disabled
> > - * for a single guest by disabling its VMX cpuid bit.
> > - */
> > -bool nested_vmx_allowed(struct kvm_vcpu *vcpu)
> > -{
> > - return nested && guest_cpuid_has(vcpu, X86_FEATURE_VMX);
> > -}
> > -
> >
>
> [...]
>
> > @@ -7750,13 +7739,15 @@ static void vmx_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
> > guest_cpuid_has(vcpu, X86_FEATURE_XSAVE))
> > kvm_governed_feature_check_and_set(vcpu, X86_FEATURE_XSAVES);
> >
> > + kvm_governed_feature_check_and_set(vcpu, X86_FEATURE_VMX);
> > +
> >
>
> Nit:
>
> nested_vmx_allowed() also checks 'nested' global variable. However
> kvm_governed_feature_check_and_set() is called unconditionally. Although IIUC
> it should never actually set the VMX governed bit when 'nested=0', it's not that
> obvious in _this_ patch.
Yeah, 100% agree after re-reading this patch without context. I had to go search
the code to remember where "nested" is checked. :-)
> Should we explicitly call this out in the changelog so git blamers can
> understand this more easily in the future?
Yep, I'll add a blurb to point out the dependency in vmx_set_cpu_caps().
Thanks!
next prev parent reply other threads:[~2023-08-16 14:43 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-15 20:36 [PATCH v3 00/15] KVM: x86: Add "governed" X86_FEATURE framework Sean Christopherson
2023-08-15 20:36 ` [PATCH v3 01/15] KVM: x86: Add a framework for enabling KVM-governed x86 features Sean Christopherson
2023-08-16 1:36 ` Huang, Kai
2023-08-16 14:20 ` Sean Christopherson
2023-08-16 22:46 ` Huang, Kai
2023-08-16 23:01 ` Yuan Yao
2023-08-17 2:11 ` Binbin Wu
2023-08-15 20:36 ` [PATCH v3 02/15] KVM: x86/mmu: Use KVM-governed feature framework to track "GBPAGES enabled" Sean Christopherson
2023-08-16 2:10 ` Yuan Yao
2023-08-15 20:36 ` [PATCH v3 03/15] KVM: VMX: Recompute "XSAVES enabled" only after CPUID update Sean Christopherson
2023-08-16 2:26 ` Yuan Yao
2023-08-15 20:36 ` [PATCH v3 04/15] KVM: VMX: Check KVM CPU caps, not just VMX MSR support, for XSAVE enabling Sean Christopherson
2023-08-16 8:07 ` Yuan Yao
2023-08-15 20:36 ` [PATCH v3 05/15] KVM: VMX: Rename XSAVES control to follow KVM's preferred "ENABLE_XYZ" Sean Christopherson
2023-08-16 7:50 ` Vitaly Kuznetsov
2023-08-16 14:15 ` Sean Christopherson
2023-08-15 20:36 ` [PATCH v3 06/15] KVM: x86: Use KVM-governed feature framework to track "XSAVES enabled" Sean Christopherson
2023-08-16 2:58 ` Yuan Yao
2023-08-16 3:21 ` Yuan Yao
2023-08-15 20:36 ` [PATCH v3 07/15] KVM: nVMX: Use KVM-governed feature framework to track "nested VMX enabled" Sean Christopherson
2023-08-16 2:25 ` Huang, Kai
2023-08-16 2:45 ` Huang, Kai
2023-08-16 14:42 ` Sean Christopherson [this message]
2023-08-15 20:36 ` [PATCH v3 08/15] KVM: nSVM: Use KVM-governed feature framework to track "NRIPS enabled" Sean Christopherson
2023-08-16 6:18 ` Yuan Yao
2023-08-15 20:36 ` [PATCH v3 09/15] KVM: nSVM: Use KVM-governed feature framework to track "TSC scaling enabled" Sean Christopherson
2023-08-16 6:35 ` Yuan Yao
2023-08-16 13:44 ` Sean Christopherson
2023-08-16 23:03 ` Yuan Yao
2023-08-15 20:36 ` [PATCH v3 10/15] KVM: nSVM: Use KVM-governed feature framework to track "vVM{SAVE,LOAD} enabled" Sean Christopherson
2023-08-15 20:36 ` [PATCH v3 11/15] KVM: nSVM: Use KVM-governed feature framework to track "LBRv enabled" Sean Christopherson
2023-08-15 20:36 ` [PATCH v3 12/15] KVM: nSVM: Use KVM-governed feature framework to track "Pause Filter enabled" Sean Christopherson
2023-08-16 7:24 ` Yuan Yao
2023-08-15 20:36 ` [PATCH v3 13/15] KVM: nSVM: Use KVM-governed feature framework to track "vGIF enabled" Sean Christopherson
2023-08-16 7:27 ` Yuan Yao
2023-08-15 20:36 ` [PATCH v3 14/15] KVM: nSVM: Use KVM-governed feature framework to track "vNMI enabled" Sean Christopherson
2023-08-15 20:36 ` [PATCH v3 15/15] KVM: x86: Disallow guest CPUID lookups when IRQs are disabled Sean Christopherson
2023-08-18 0:09 ` [PATCH v3 00/15] KVM: x86: Add "governed" X86_FEATURE framework Sean Christopherson
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=ZNzgWwUNy/2J3SV2@google.com \
--to=seanjc@google.com \
--cc=guang.zeng@intel.com \
--cc=kai.huang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=vkuznets@redhat.com \
--cc=yuan.yao@intel.com \
/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