Re: [PATCH 2/4] KVM: nVMX: Make VMPTRST return eVMCS GPA when it is used

[email protected]
Newsgroups org.kernel.vger.kvm
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Compilation failure when CONFIG_KVM_HYPERV is disabled.
--

--- Patch [2]: [PATCH 2/4] KVM: nVMX: Make VMPTRST return eVMCS GPA when it is used ---
commit e9f713cf2125ef734863ce5fc9c30ea6f602ede7
Author: Vitaly Kuznetsov <[email protected]>

KVM: nVMX: Make VMPTRST return eVMCS GPA when it is used
    
This commit changes the behavior of VMPTRST to return the eVMCS GPA when
eVMCS is active. This aligns KVM's behavior with genuine Hyper-V instead of
returning 1 without skipping the instruction.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=221841

> 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.

> +	else
> +		current_vmptr = to_vmx(vcpu)->nested.current_vmptr;
>  
>  	if (get_vmx_mem_address(vcpu, exit_qual, instr_info,
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.