[PATCH v7 054/120] x86/xen: Use parsed CPUID(0x1)

"Ahmed S. Darwish" <[email protected]> Thu, 28 May 2026 17:38:16 +0200
Newsgroups dev.linux.lists.x86-cpuid,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
For Xen init, use parsed CPUID(0x1) instead of manual bitwise operations
and a direct CPUID query.

Signed-off-by: Ahmed S. Darwish <[email protected]>
---
 arch/x86/xen/enlighten_pv.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 223e9a2eb2d5..4883d6095436 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -369,15 +369,13 @@ static bool __init xen_check_mwait(void)
 
 static bool __init xen_check_xsave(void)
 {
-	unsigned int cx, xsave_mask;
+	const struct leaf_0x1_0 *l1 = cpuid_leaf(&boot_cpu_data, 0x1);
 
-	cx = cpuid_ecx(1);
-
-	xsave_mask = (1 << (X86_FEATURE_XSAVE % 32)) |
-		     (1 << (X86_FEATURE_OSXSAVE % 32));
+	if (!l1)
+		return false;
 
 	/* Xen will set CR4.OSXSAVE if supported and not disabled by force */
-	return (cx & xsave_mask) == xsave_mask;
+	return l1->xsave && l1->osxsave;
 }
 
 static void __init xen_init_capabilities(void)
-- 
2.54.0