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

[PATCH] x86/xen: Fix __xen_hypercall_setfunc


  • To: Juergen Gross <jgross@xxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, "Ingo Molnar" <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, <x86@xxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, "Xin Li (Intel)" <xin@xxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Thu, 10 Apr 2025 15:31:05 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com 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=Pa4MOdUShz/tEi4WMru8zb9VdFMJu4Ipe3WHYaFMUBw=; b=bdJj5Yp+/+K/s+1fPDHGSsV//HC8sJP18j/gCD4EulmL6+jk4sd52dm5UOdG1bEUk9Hlv0612KF+n1p53L5gmSocrCnZu19YIq52ZXT4ojrDgLZoaxCGb+P74t3g9cRvfknZwNz5gx1mVEhGZ1k4OX3+b6W3NFVEVUYhymNLUN0RArriaaeq0aq90biXS5Sx2OAz05lbC93k5BZaDh0Im6UwsKI/Rg992bnGIgMWSw3Ps7wPpXevkofSla+9ExjcvACS3NEmK40uR8HH5Jt3hq4VgJpHvgmL0WE5EPwQCO/qmVjxAfdGV5XA/65+Q9gFVe0f/Ox2teMTxKeUZHr57A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=US9aVunn52ngKamsga510U9fMy/pCwnqwZoDzOSq6AKEn4r3u8imkGSHu9oxVJr1slWZfKyiDUWH8Ux9sqQK3UuUDHKuVvEgZCU0dNuVfPWqD68svoHzhm68KNDXqnpdgpAdkaIWSJDbNuZCT0s+vHhQh4WW/3v/f4WjsprITHVFI3azU1+LAPkLeo69Kz4MmlP+jGD58iXNmhFG8VviTcWsFYPCY1Dnx20VJZcaWkM3C6dWPe5tmzrk3JCW0nEWmLvRTfx8jv41r+SASCIiPGJKYMHaOQngPylETpxzplgrwXKYmUcAW+05onaTIbutFTwjecuTQnyBNOHYJeA4iw==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <linux-kernel@xxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 10 Apr 2025 19:30:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hypercall detection is failing with xen_hypercall_intel() chosen even on
an AMD processor.  Looking at the disassembly, the call to
xen_get_vendor() was removed.

The check for boot_cpu_has(X86_FEATURE_CPUID) was used as a proxy for
the x86_vendor having been set.  When
CONFIG_X86_REQUIRED_FEATURE_CPUID=y (the default value), DCE eliminates
the call to xen_get_vendor().  An uninitialized value 0 means
X86_VENDOR_INTEL, so the Intel function is always returned.

Remove the if and always call xen_get_vendor() to avoid this issue.

Fixes: 3d37d9396eb3 ("x86/cpufeatures: Add {REQUIRED,DISABLED} feature configs")
Suggested-by: Juergen Gross <jgross@xxxxxxxx>
Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
I think the Fixes is correct in that it default enables requiring the
feature.  There were a lot of other changes to how headers were
generated as well.
---
 arch/x86/xen/enlighten.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 43dcd8c7badc..6a5cae915eb1 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -100,10 +100,6 @@ noinstr void *__xen_hypercall_setfunc(void)
        void (*func)(void);
 
        /*
-        * Xen is supported only on CPUs with CPUID, so testing for
-        * X86_FEATURE_CPUID is a test for early_cpu_init() having been
-        * run.
-        *
         * Note that __xen_hypercall_setfunc() is noinstr only due to a nasty
         * dependency chain: it is being called via the xen_hypercall static
         * call when running as a PVH or HVM guest. Hypercalls need to be
@@ -115,8 +111,7 @@ noinstr void *__xen_hypercall_setfunc(void)
         */
        instrumentation_begin();
 
-       if (!boot_cpu_has(X86_FEATURE_CPUID))
-               xen_get_vendor();
+       xen_get_vendor();
 
        if ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
             boot_cpu_data.x86_vendor == X86_VENDOR_HYGON))
-- 
2.34.1




 


Rackspace

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