aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/boot/cpuflags.c
diff options
context:
space:
mode:
authorUros Bizjak <[email protected]>2025-03-07 09:10:03 +0000
committerIngo Molnar <[email protected]>2025-03-08 19:36:26 +0000
commit558fc8e1869ca6e1eb99a1e2b52f6c35424d4adf (patch)
tree65852b5ae97806474ee9bc49e88c3f8fec9d179d /arch/x86/boot/cpuflags.c
parentx86/bootflag: Replace open-coded parity calculation with parity8() (diff)
downloadkernel-558fc8e1869ca6e1eb99a1e2b52f6c35424d4adf.tar.gz
kernel-558fc8e1869ca6e1eb99a1e2b52f6c35424d4adf.zip
x86/boot: Do not test if AC and ID eflags are changeable on x86_64
The test for the changeabitily of AC and ID EFLAGS is used to distinguish between i386 and i486 processors (AC) and to test for CPUID instruction support (ID). Skip these tests on x86_64 processors as they always supports CPUID. Also change the return type of has_eflag() to bool. Signed-off-by: Uros Bizjak <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Nick Desaulniers <[email protected]> Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'arch/x86/boot/cpuflags.c')
-rw-r--r--arch/x86/boot/cpuflags.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/arch/x86/boot/cpuflags.c b/arch/x86/boot/cpuflags.c
index d75237ba7ce9..2150a016176f 100644
--- a/arch/x86/boot/cpuflags.c
+++ b/arch/x86/boot/cpuflags.c
@@ -29,40 +29,32 @@ static int has_fpu(void)
return fsw == 0 && (fcw & 0x103f) == 0x003f;
}
+#ifdef CONFIG_X86_32
/*
* For building the 16-bit code we want to explicitly specify 32-bit
* push/pop operations, rather than just saying 'pushf' or 'popf' and
- * letting the compiler choose. But this is also included from the
- * compressed/ directory where it may be 64-bit code, and thus needs
- * to be 'pushfq' or 'popfq' in that case.
+ * letting the compiler choose.
*/
-#ifdef __x86_64__
-#define PUSHF "pushfq"
-#define POPF "popfq"
-#else
-#define PUSHF "pushfl"
-#define POPF "popfl"
-#endif
-
-int has_eflag(unsigned long mask)
+bool has_eflag(unsigned long mask)
{
unsigned long f0, f1;
- asm volatile(PUSHF " \n\t"
- PUSHF " \n\t"
+ asm volatile("pushfl \n\t"
+ "pushfl \n\t"
"pop %0 \n\t"
"mov %0,%1 \n\t"
"xor %2,%1 \n\t"
"push %1 \n\t"
- POPF " \n\t"
- PUSHF " \n\t"
+ "popfl \n\t"
+ "pushfl \n\t"
"pop %1 \n\t"
- POPF
+ "popfl"
: "=&r" (f0), "=&r" (f1)
: "ri" (mask));
return !!((f0^f1) & mask);
}
+#endif
void cpuid_count(u32 id, u32 count, u32 *a, u32 *b, u32 *c, u32 *d)
{