Re: [PATCH] x86/hyper-v: Don't WARN on VM-Enter if eVMCS sees VMFUNC[63:32] != 0
From: Manuel Andreas
Date: Wed Oct 21 2026 - 07:43:10 EST
On 10/21/26 00:56, Sean Christopherson wrote:
> I think the WARN is correct, this code is broken. Unless I'm missing some eVMCS
> magic/quirk, this, and the secondary controls check, should be conditioned on the
> field actually being used.
>
> This, over two patches?
>
> diff --git a/arch/x86/kvm/vmx/hyperv.c b/arch/x86/kvm/vmx/hyperv.c
> index fa41d036acd4..a1daf8f2ec5a 100644
> --- a/arch/x86/kvm/vmx/hyperv.c
> +++ b/arch/x86/kvm/vmx/hyperv.c
> @@ -169,7 +169,8 @@ int nested_evmcs_check_controls(struct vmcs12 *vmcs12)
> vmcs12->cpu_based_vm_exec_control)))
> return -EINVAL;
>
> - if (CC(!nested_evmcs_is_valid_controls(EVMCS_2NDEXEC,
> + if (nested_cpu_has(vmcs12, CPU_BASED_ACTIVATE_SECONDARY_CONTROLS) &&
> + CC(!nested_evmcs_is_valid_controls(EVMCS_2NDEXEC,
> vmcs12->secondary_vm_exec_control)))
> return -EINVAL;
>
> @@ -186,11 +187,10 @@ int nested_evmcs_check_controls(struct vmcs12 *vmcs12)
> * controls in bits 63:32, i.e. dropping those bits on the consistency
> * check is intentional.
> */
> - if (WARN_ON_ONCE(vmcs12->vm_function_control >> 32))
> - return -EINVAL;
> -
> - if (CC(!nested_evmcs_is_valid_controls(EVMCS_VMFUNC,
> - vmcs12->vm_function_control)))
> + if (nested_cpu_has_vmfunc(vmcs12) &&
> + (WARN_ON_ONCE(vmcs12->vm_function_control >> 32) ||
> + CC(!nested_evmcs_is_valid_controls(EVMCS_VMFUNC,
> + vmcs12->vm_function_control))))
> return -EINVAL;
>
> return 0;
>
>
Looks sane to me. However, I still don't see a reason for this being a
WARN at all, what exactly is the intended signal here?
Best,
Manuel