Commit 164a9f71 authored by Jason Andryuk's avatar Jason Andryuk Committed by Ingo Molnar
Browse files

x86/xen: Fix __xen_hypercall_setfunc()



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: 3d37d939 ("x86/cpufeatures: Add {REQUIRED,DISABLED} feature configs")
Suggested-by: default avatarJuergen Gross <jgross@suse.com>
Signed-off-by: default avatarJason Andryuk <jason.andryuk@amd.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "Xin Li (Intel)" <xin@zytor.com>
Link: https://lore.kernel.org/r/20250410193106.16353-1-jason.andryuk@amd.com
parent 0c7cae12
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -103,10 +103,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
@@ -118,7 +114,6 @@ noinstr void *__xen_hypercall_setfunc(void)
	 */
	instrumentation_begin();

	if (!boot_cpu_has(X86_FEATURE_CPUID))
	xen_get_vendor();

	if ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||