[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] x86/hvm: revise "cpu_has_vmx" usage for !CONFIG_INTEL_VMX case



commit 092cec0885f407a679f84ad7b30134578ecc481b
Author:     Grygorii Strashko <grygorii_strashko@xxxxxxxx>
AuthorDate: Wed Nov 19 10:11:35 2025 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Nov 19 10:11:35 2025 +0100

    x86/hvm: revise "cpu_has_vmx" usage for !CONFIG_INTEL_VMX case
    
    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]
            ...
    
    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 <grygorii_strashko@xxxxxxxx>
    Reviewed-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/hvm/dom0_build.c | 2 +-
 xen/arch/x86/hvm/hvm.c        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
index 5551f90448..5ac2cf8394 100644
--- a/xen/arch/x86/hvm/dom0_build.c
+++ b/xen/arch/x86/hvm/dom0_build.c
@@ -473,7 +473,7 @@ static int __init pvh_populate_p2m(struct domain *d)
         }
     }
 
-    if ( cpu_has_vmx && paging_mode_hap(d) && !vmx_unrestricted_guest(v) )
+    if ( using_vmx() && paging_mode_hap(d) && !vmx_unrestricted_guest(v) )
     {
         /*
          * Since Dom0 cannot be migrated, we will only setup the
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 0c60faa39d..f1035fc9f6 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4299,7 +4299,7 @@ static int hvm_set_param(struct domain *d, uint32_t 
index, uint64_t value)
          * Only actually required for VT-x lacking unrestricted_guest
          * capabilities.  Short circuit the pause if possible.
          */
-        if ( !paging_mode_hap(d) || !cpu_has_vmx )
+        if ( !paging_mode_hap(d) || !using_vmx() )
         {
             d->arch.hvm.params[index] = value;
             break;
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.