[PATCH v7 053/120] x86/mm/pti: Use standard CPUID(0x1) types

"Ahmed S. Darwish" <[email protected]> Thu, 28 May 2026 17:38:15 +0200
Newsgroups dev.linux.lists.x86-cpuid,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Use standard CPUID(0x1) types from x86-cpuid-db instead of a manual bitwise
operation.

Note, keep issuing a direct CPUID query since disabling a feature bit like
X86_FEATURE_PCID will disable its backing cached CPUID bit in the future.

Signed-off-by: Ahmed S. Darwish <[email protected]>
---
 arch/x86/mm/pti.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 598f553cc871..1f0a5e84cdca 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -631,13 +631,16 @@ void __init pti_init(void)
 	pr_info("enabled\n");
 
 #ifdef CONFIG_X86_32
+	struct leaf_0x1_0 l1;
+
 	/*
 	 * We check for X86_FEATURE_PCID here. But the init-code will
 	 * clear the feature flag on 32 bit because the feature is not
 	 * supported on 32 bit anyway. To print the warning we need to
 	 * check with cpuid directly again.
 	 */
-	if (cpuid_ecx(0x1) & BIT(17)) {
+	cpuid_read(0x1, &l1);
+	if (l1.pcid) {
 		/* Use printk to work around pr_fmt() */
 		printk(KERN_WARNING "\n");
 		printk(KERN_WARNING "************************************************************\n");
-- 
2.54.0