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

[PATCH v1 22/28] x86/hvm: avic: ensure SVM AVIC supports xAPIC operation only


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: dmukhin@xxxxxxxx
  • Date: Wed, 4 Nov 2026 17:33:39 -0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 205.220.161.53) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=ford.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ford.com; dkim=pass (signature was verified) header.d=saarlouis.ford.com; dkim=pass (signature was verified) header.d=ford.com; arc=none (0)
  • 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=yfWzWSdEQkaEo9tnDH8JrNq7bLBhhcFF+YBxmutS6Ek=; b=tIuuZYXW8veKg8vIZnXJH9kSXncCyIkhObEAawhiKKt+lzYprylFuY6ER8p5u64ux7mmGViRYxDxDsC2gAjx1ud4cm1p5kbSMOeSZ1YHQ0UjzGZIpqDvIh8nRqxGEGRlwKOaduCrkC2BhIOtmTI7JxVS2TjtqgkOoKdX+NUpimJPAWBBWFRNbAt0rY3qVaX1p4e/uWfbUvPLyV08v6wn5u7+JbYlIlER7WY2UGeLjewU+S73dt5m5a/f1C7LNRQI/a5B00xnw0jpQhdZ2D8k4vuv5CdFPX9/b2o1TdUKpN++1Huv3XkPhL40skZZrKL3E1gPKENExAee2xJiHH7KkA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tiSpvNlMnVwqUrVNfvoHduFz9O1fOaXAUUHlJvbNDUPrajIH2dAGKOPqpPqzT8mqraG59UbnyflUac6+7+S/bq62PWBTzogS4OYLx1b3V2hmhUHp+TY8YDa/GjU3qllENV3c8yq5cPvxV+j9IXngCWIcALvpnT5B7haDXKIai8yvPU+OWdToFh9XrR2gMHLueMRiWH7I4hdk2Za7a7LnMHoZwjFECQx5h0Ndad2Ai2w218TUqyNVcNvCiKRMgR+oLXyjoriRj8VwpPiYMMn+UfdbuoDt2flcGxGARVeupI6bwUK9v9/WHdBdwV4p+fzvom/FW1TvlifDWOUBWqWaqg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=ppford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=selector2-azureford-onmicrosoft-com header.d=azureford.onmicrosoft.com header.i="@azureford.onmicrosoft.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=ppserprodsaar header.d=saarlouis.ford.com header.i="@saarlouis.ford.com" header.h="Cc:Content-Transfer-Encoding:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=ppfserpocford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"
  • Cc: andrew.cooper3@xxxxxxxxxx, jason.andryuk@xxxxxxx, jbeulich@xxxxxxxx, roger@xxxxxxxxxxxxxx, teddy.astie@xxxxxxxxxx, dmukhin@xxxxxxx, Denis Mukhin <dmukhin@xxxxxxxx>
  • Delivery-date: Thu, 05 Nov 2026 01:35:14 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Pser-m365-app: SER-APP

From: Denis Mukhin <dmukhin@xxxxxxxx>

xAVIC does not support x2APIC operation (yet).

Until x2APIC mode is supported, don't advertise x2APIC to HVM
guests when SVM AVIC is enabled.

Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
 xen/arch/x86/cpu-policy.c          |  3 ++-
 xen/arch/x86/hvm/svm/svm.c         | 12 ++++++++++++
 xen/arch/x86/hvm/vmx/vmx.c         |  4 ++++
 xen/arch/x86/include/asm/hvm/hvm.h | 15 ++++++++++++++-
 4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index 48a3185eed8d..ca9b1a523570 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -764,7 +764,8 @@ static void __init calculate_hvm_max_policy(void)
      * (x2)APIC isn't enabled.
      */
     __set_bit(X86_FEATURE_APIC, fs);
-    __set_bit(X86_FEATURE_X2APIC, fs);
+    if ( hvm_x2apic_supported() )
+        __set_bit(X86_FEATURE_X2APIC, fs);
 
     /*
      * We don't support EFER.LMSLE at all.  AMD has dropped the feature from
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index f2eb01799c63..667e8b05eecc 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2478,6 +2478,10 @@ static struct hvm_function_table __initdata_cf_clobber 
svm_function_table = {
     .tsc_scaling = {
         .max_ratio = ~TSC_RATIO_RSVD_BITS,
     },
+
+    .caps = {
+        .x2apic = true,
+    },
 };
 
 static void __init print_svm_features(void)
@@ -2523,6 +2527,14 @@ static void __init svm_avic_start(void)
     svm_function_table.debug_posted_intr = svm_avic_hvm_debug_posted_intr;
 
     svm_function_table.caps.virtual_intr_delivery = true;
+
+    /*
+     * xAVIC does not support x2APIC operation.
+     *
+     * Until x2AVIC/hybrid AVIC support is implemented, don't expose
+     * x2APIC to guests when SVM AVIC is enabled.
+     */
+    svm_function_table.caps.x2apic = false;
 }
 
 const struct hvm_function_table * __init start_svm(void)
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 3c7374a9ff42..bad43b38efea 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2916,6 +2916,10 @@ static struct hvm_function_table __initdata_cf_clobber 
vmx_function_table = {
     .tsc_scaling = {
         .max_ratio = VMX_TSC_MULTIPLIER_MAX,
     },
+
+    .caps = {
+        .x2apic = true,
+    },
 };
 
 /* Handle VT-d posted-interrupt when VCPU is blocked. */
diff --git a/xen/arch/x86/include/asm/hvm/hvm.h 
b/xen/arch/x86/include/asm/hvm/hvm.h
index d44f136fae8f..b701fc003ced 100644
--- a/xen/arch/x86/include/asm/hvm/hvm.h
+++ b/xen/arch/x86/include/asm/hvm/hvm.h
@@ -119,7 +119,9 @@ struct hvm_function_table {
              virtual_intr_delivery:1,
 
              /* Nested virt capabilities */
-             nested_virt:1;
+             nested_virt:1,
+
+             x2apic:1;
     } caps;
 
     /*
@@ -716,6 +718,11 @@ static inline bool hvm_nested_virt_supported(void)
     return hvm_funcs.caps.nested_virt;
 }
 
+static inline bool hvm_x2apic_supported(void)
+{
+    return hvm_funcs.caps.x2apic;
+}
+
 #ifdef CONFIG_ALTP2M
 /* updates the current hardware p2m */
 static inline void altp2m_vcpu_update_p2m(struct vcpu *v)
@@ -905,6 +912,12 @@ static inline bool hvm_nested_virt_supported(void)
     return false;
 }
 
+static inline bool hvm_x2apic_supported(void)
+{
+    ASSERT_UNREACHABLE();
+    return false;
+}
+
 static inline bool nhvm_vmcx_hap_enabled(const struct vcpu *v)
 {
     ASSERT_UNREACHABLE();
-- 
2.55.0




 


Rackspace

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