On Wed Sep 24, 2025 at 12:14 PM CEST, Grygorii Strashko wrote:
> From: Grygorii Strashko <[email protected]>
>
> Since commit b99227347230 ("x86: Fix AMD_SVM and INTEL_VMX dependency") the
> HVM Intel VT-x support can be disabled, but it still keeps VMX
> code partially built-in. Particularly in HVM code there are two places:
>
> 1) hvm/dom0_build.c
>  dom0_construct_pvh()->pvh_populate_p2m()
>     ...
>     if ( cpu_has_vmx && paging_mode_hap(d) && !vmx_unrestricted_guest(v) )
>     {
>         ...
>         [unreachable for !cpu_has_vmx case]
>         rc = pvh_setup_vmx_realmode_helpers(d);
>
> pvh_setup_vmx_realmode_helpers() allocates memory and configures
>  HVM_PARAM_VM86_TSS_SIZED
>  HVM_PARAM_IDENT_PT
>
> 2) hvm/hvm.c
>  hvm_set_param()
>     ...
>     case HVM_PARAM_IDENT_PT:
>
>         if ( !paging_mode_hap(d) || !cpu_has_vmx )
>         {
>             d->arch.hvm.params[index] = value;
>             break;
>         }
>         [unreachable for !cpu_has_vmx case]
>         ...

nit: These (1) and (2) are rather large for a commit message. I wouldn't mind
if they went away and the rest of the commit message was adjusted to make it
a bit leaner.

Either way, with or without this change...

>
> Hence HVM_PARAM_IDENT_PT/HVM_PARAM_VM86_TSS_SIZED are used only by VMX code
> above code become unreachable in !cpu_has_vmx case and can be optimazed
> when !CONFIG_INTEL_VMX.
>
> Replace "cpu_has_vmx" with using_vmx() to account !CONFIG_INTEL_VMX and allow
> compiler DCE to optimize code.
>
> Signed-off-by: Grygorii Strashko <[email protected]>

... Reviewed-by: Alejandro Vallejo <[email protected]>

Cheers,
Alejandro

Reply via email to