Re: [PATCH 2/4] KVM: nVMX: Make VMPTRST return eVMCS GPA when it is used
Sean Christopherson <[email protected]>
| Newsgroups | dev.linux.lists.sashiko-reviews,org.kernel.vger.kvm |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Aug 14, 2026, [email protected] wrote: > > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c > > index c78c67525ac9b..d13a4d47bc68f 100644 > > --- a/arch/x86/kvm/vmx/nested.c > > +++ b/arch/x86/kvm/vmx/nested.c > [ ... ] > > @@ -5958,8 +5958,14 @@ static int handle_vmptrst(struct kvm_vcpu *vcpu) > > if (!nested_vmx_check_permission(vcpu)) > > return 1; > > > > - if (unlikely(nested_vmx_is_evmptr12_valid(to_vmx(vcpu)))) > > - return 1; > > + /* > > + * Hyper-V TLFS does not specify the behavior of VMPTRST when eVMCS is used > > + * but genuine Hyper-V seems to be returning eVMCS GPA. > > + */ > > + if (nested_vmx_is_evmptr12_valid(to_vmx(vcpu))) > > + current_vmptr = to_vmx(vcpu)->nested.hv_evmcs_vmptr; > > [Severity: Low] > Will this cause a build failure when CONFIG_KVM_HYPERV is disabled? > > Because nested_vmx_is_evmptr12_valid() is a static inline function rather > than a preprocessor macro, the compiler still evaluates and type-checks > this branch even when the helper is hardcoded to return false. If the > hv_evmcs_vmptr member in struct nested_vmx is conditionally compiled based > on CONFIG_KVM_HYPERV, the compiler will fail to find it here. Yep. arch/x86/kvm/vmx/nested.c: In function ‘handle_vmptrst’: arch/x86/kvm/vmx/nested.c:5971:53: error: ‘struct nested_vmx’ has no member named ‘hv_evmcs_vmptr’ 5971 | current_vmptr = to_vmx(vcpu)->nested.hv_evmcs_vmptr; | ^