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

[PATCH 07/12] x86: Migrate x86_emulate/ to use cpu_vendor()


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Date: Fri, 6 Feb 2026 17:15:30 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=C+acfGxRyaaJDoExPDPojLHYDy13h9jJLSyZO4Cf1eQ=; b=O4P3DV4QpjmDOSPOtYhSoyzpCrPnva5bGfbbgASKkmT1i+CeWEXNQQ/f3SLDPvObuNWNguTn67qLrd+qEO5eJl4jiImzUkbdk36k+QYPWy38mC206+hTx8ZpxylTGBZQuuHTwkt/sbqo7O07RPRsamPI/HQWg4TE2NfvFb7x4BzwnL9uHAlJsfoRVls+zxnusOnVU230RyTHNXLrODMoc+C3U0RGdoX0mCcFU4bn5n380pSlXqZHHFzTOk0mDg6W/Qa8NlahQlqc9MwOeB3HTWOxkGv2DvRPGlKI6eSTS8xVaBBg5MQQ1uoyILU4DN8POd7JyiETfcQ/1awz2W9TTw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=izP9oK2J4DMFiOFY5a56QNBEog9cSEpiu768GoEa0XgRENYbWqD77G7FMi8S+V3uq282wbv/+AwQMtE3VX9kXvXpPXVOIQ0DIpONsoX0RnKDkTrtnXy2aWvsiF+Ua3xy1T8lltDJzcLEQWaoVGY/gRejtK21lJdfltFcFR8nbje0edvkwdCgqe0pO6QKDwjhY4zG8FhKGkM29w8+E0/NSOqQ9rbCDnvi2lr8AszOu7Uj4MZJ0DztmMTFE4v32EXNGcud6kwNZNY4MGg0V+VQvz8UdYBSx89kihCCRvKChja5ksUzJbmdyLT0ApfL6VuC67oEms4ZtGHHUV1cF97Afg==
  • Cc: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>
  • Delivery-date: Fri, 06 Feb 2026 16:16:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

... but keep the current behaviour of using the policy vendor when
compiled for userspace, where cross-vendor configurations are expected.

Not a functional change.

Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
---
 xen/arch/x86/x86_emulate/private.h     | 6 +++++-
 xen/arch/x86/x86_emulate/x86_emulate.c | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/private.h 
b/xen/arch/x86/x86_emulate/private.h
index 24c79c4e8f..1b6fc48ab6 100644
--- a/xen/arch/x86/x86_emulate/private.h
+++ b/xen/arch/x86/x86_emulate/private.h
@@ -15,6 +15,7 @@
 # include <xen/kernel.h>
 
 # include <asm/cpu-user-regs.h>
+# include <asm/cpufeature.h>
 # include <asm/endbr.h>
 # include <asm/msr-index.h>
 # include <asm/stubs.h>
@@ -30,8 +31,11 @@ void BUG(void);
 #  define X86EMUL_NO_SIMD
 # endif
 
+# define x86emul_cpu(cp) ({ (void)(cp); cpu_vendor(); })
+
 #else /* !__XEN__ */
 # include "x86-emulate.h"
+# define x86emul_cpu(cp) ((cp)->x86_vendor)
 #endif
 
 #ifdef __i386__
@@ -520,7 +524,7 @@ in_protmode(
 static inline bool
 _amd_like(const struct cpu_policy *cp)
 {
-    return cp->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON);
+    return x86emul_cpu(cp) & (X86_VENDOR_AMD | X86_VENDOR_HYGON);
 }
 
 static inline bool
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c 
b/xen/arch/x86/x86_emulate/x86_emulate.c
index 7751a67130..fcd8cbccc9 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -3104,7 +3104,7 @@ x86_emulate(
          * in fact risking to make guest OSes vulnerable to the equivalent of
          * XSA-7 (CVE-2012-0217).
          */
-        generate_exception_if(cp->x86_vendor == X86_VENDOR_INTEL &&
+        generate_exception_if((x86emul_cpu(cp) == X86_VENDOR_INTEL) &&
                               op_bytes == 8 && 
!is_canonical_address(_regs.rcx),
                               X86_EXC_GP, 0);
 #endif
-- 
2.43.0




 


Rackspace

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