forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PATCH] i386: Verify important CPUID bits in real mode
Check some CPUID bits that are needed for compiler generated early in boot. When the system is still in real mode before changing the VESA BIOS mode it is possible to still display an visible error message on the screen. Similar to x86-64. Includes cleanups from Eric Biederman Signed-off-by: Andi Kleen <[email protected]>
- Loading branch information
Andi Kleen
authored and
Andi Kleen
committed
May 2, 2007
1 parent
484ad39
commit c7f81c9
Showing
5 changed files
with
139 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* Check if CPU has some minimum CPUID bits | ||
This runs in 16bit mode so that the caller can still use the BIOS | ||
to output errors on the screen */ | ||
#include <asm/cpufeature.h> | ||
|
||
verify_cpu: | ||
pushfl # Save caller passed flags | ||
pushl $0 # Kill any dangerous flags | ||
popfl | ||
|
||
#if CONFIG_X86_MINIMUM_CPU_MODEL >= 4 | ||
pushfl | ||
orl $(1<<18),(%esp) # try setting AC | ||
popfl | ||
pushfl | ||
popl %eax | ||
testl $(1<<18),%eax | ||
jz bad | ||
#endif | ||
#if REQUIRED_MASK1 != 0 | ||
pushfl # standard way to check for cpuid | ||
popl %eax | ||
movl %eax,%ebx | ||
xorl $0x200000,%eax | ||
pushl %eax | ||
popfl | ||
pushfl | ||
popl %eax | ||
cmpl %eax,%ebx | ||
pushfl # standard way to check for cpuid | ||
popl %eax | ||
movl %eax,%ebx | ||
xorl $0x200000,%eax | ||
pushl %eax | ||
popfl | ||
pushfl | ||
popl %eax | ||
cmpl %eax,%ebx | ||
jz bad # REQUIRED_MASK1 != 0 requires CPUID | ||
|
||
movl $0x0,%eax # See if cpuid 1 is implemented | ||
cpuid | ||
cmpl $0x1,%eax | ||
jb bad # no cpuid 1 | ||
|
||
movl $0x1,%eax # Does the cpu have what it takes | ||
cpuid | ||
|
||
#if CONFIG_X86_MINIMUM_CPU_MODEL > 4 | ||
#error add proper model checking here | ||
#endif | ||
|
||
andl $REQUIRED_MASK1,%edx | ||
xorl $REQUIRED_MASK1,%edx | ||
jnz bad | ||
#endif /* REQUIRED_MASK1 */ | ||
|
||
popfl | ||
xor %eax,%eax | ||
ret | ||
|
||
bad: | ||
popfl | ||
movl $1,%eax | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef _ASM_REQUIRED_FEATURES_H | ||
#define _ASM_REQUIRED_FEATURES_H 1 | ||
|
||
/* Define minimum CPUID feature set for kernel These bits are checked | ||
really early to actually display a visible error message before the | ||
kernel dies. Only add word 0 bits here | ||
Some requirements that are not in CPUID yet are also in the | ||
CONFIG_X86_MINIMUM_CPU mode which is checked too. | ||
The real information is in arch/i386/Kconfig.cpu, this just converts | ||
the CONFIGs into a bitmask */ | ||
|
||
#ifdef CONFIG_X86_PAE | ||
#define NEED_PAE (1<<X86_FEATURE_PAE) | ||
#else | ||
#define NEED_PAE 0 | ||
#endif | ||
|
||
#ifdef CONFIG_X86_CMOV | ||
#define NEED_CMOV (1<<X86_FEATURE_CMOV) | ||
#else | ||
#define NEED_CMOV 0 | ||
#endif | ||
|
||
#ifdef CONFIG_X86_CMPXCHG64 | ||
#define NEED_CMPXCHG64 (1<<X86_FEATURE_CX8) | ||
#else | ||
#define NEED_CMPXCHG64 0 | ||
#endif | ||
|
||
#define REQUIRED_MASK1 (NEED_PAE|NEED_CMOV|NEED_CMPXCHG64) | ||
|
||
#endif |