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

[XEN][PATCH] x86/hvm: revise "cpu_has_vmx" usage for !CONFIG_INTEL_VMX case


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Wed, 24 Sep 2025 10:14:19 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LLmc699oXlLG5mSYjMYHmCNDmt537LCCPHJmUJDwiL8=; b=WL1Ldt6ym2doOHJiaAOTZXj+bIDK2RIRALpwF7jJ9lSX0izRMw4TSkkUjw4h7e7sIn5BFJ/3Xm9ZLqGxt4UnRSdaHlX+0eSrlxBTn5G2gRNvkXbvk26q5YS7rKkCjBjGfZv6lJJARjP7pSahazuH9IOWXDAwklNS87/dTqAUP1vbK94aSwvEluk4M7DfBiJs7dIvYPPei5abuQeR7wkisPTFgkshsulEGYmKj1q9vM6A/D+OoTuQgIKD57lfAJU3fmuFPT2Lu+5j7/LmRtQYdwQeNgKWz/eqpHZLnfmtEp5vxamlCiFR9O+R39l8BtOqo+cMNhI1A8jZO4ISjhQiTA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=krCuK+3v9RYXOsfcQ0DdZRaHdsK1q4uFb5hYTzQzKUwLob9/IEcAyzyNrEvw3MqLZ0EFUIH56OuR3KaekYkUjW+sNDMgRXGqk4ojbgzDUKh08OTZcIleSaP0+KLMtvGtIrVbxXz9ayUzbWNySle6efcifQmKzQxtINah+H7SUhVL4ctov3+pTgk+/E3VXu1de/5EZGehMk+RBli88kgRZ/JdJiiTHwy1S8Hb6Vp7GX0dW4ZgPAaIvsffK+O+16zuR93LjR1Wsl7WGbNxrIgnsIRrQCUkNtJdN3ugTYonP/yZmj0csvnlLqbjPatgbo6ZQ++M2zULPAqtUB3A4HCH5w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Grygorii Strashko <grygorii_strashko@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Delivery-date: Wed, 24 Sep 2025 10:14:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcLTv95iVXlAGVVkGmfKuqtAYpwg==
  • Thread-topic: [XEN][PATCH] x86/hvm: revise "cpu_has_vmx" usage for !CONFIG_INTEL_VMX case

From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>

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>
---
add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-604 (-604)
Function                                     old     new   delta
hvm_set_param                               1602    1473    -129
dom0_construct_pvh                          4438    3963    -475
Total: Before=3567191, After=3566587, chg -0.02%

 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 5551f9044836..5ac2cf8394d8 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 95a80369b9b8..70331aeec9a0 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4302,7 +4302,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;
-- 
2.34.1



 


Rackspace

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