Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 53930
b: refs/heads/master
c: c7f81c9
h: refs/heads/master
v: v3
  • Loading branch information
Andi Kleen authored and Andi Kleen committed May 2, 2007
1 parent f09b37d commit 6a473c9
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 484ad393659f20d784a3a93613fb3fd3d9f171fa
refs/heads/master: c7f81c9453375d6416658995eafd3397cb9bba1d
22 changes: 20 additions & 2 deletions trunk/arch/i386/Kconfig.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,19 @@ config X86_L1_CACHE_SHIFT
default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX
default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MVIAC7

config X86_XADD
bool
depends on !M386
default y

config RWSEM_GENERIC_SPINLOCK
bool
depends on M386
depends on !X86_XADD
default y

config RWSEM_XCHGADD_ALGORITHM
bool
depends on !M386
depends on X86_XADD
default y

config ARCH_HAS_ILOG2_U32
Expand Down Expand Up @@ -331,3 +336,16 @@ config X86_TSC
bool
depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2) && !X86_NUMAQ
default y

# this should be set for all -march=.. options where the compiler
# generates cmov.
config X86_CMOV
bool
depends on (MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7)
default y

config X86_MINIMUM_CPU_MODEL
int
default "4" if X86_XADD || X86_CMPXCHG || X86_BSWAP
default "0"

17 changes: 17 additions & 0 deletions trunk/arch/i386/boot/setup.S
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,24 @@ good_sig:

loader_panic_mess: .string "Wrong loader, giving up..."

# check minimum cpuid
# we do this here because it is the last place we can actually
# show a user visible error message. Later the video modus
# might be already messed up.
loader_ok:
call verify_cpu
testl %eax,%eax
jz cpu_ok
lea cpu_panic_mess,%si
call prtstr
1: jmp 1b

cpu_panic_mess:
.asciz "PANIC: CPU too old for this kernel."

#include "../kernel/verify_cpu.S"

cpu_ok:
# Get memory size (extended mem, kB)

xorl %eax, %eax
Expand Down
65 changes: 65 additions & 0 deletions trunk/arch/i386/kernel/verify_cpu.S
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
3 changes: 3 additions & 0 deletions trunk/include/asm-i386/cpufeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
#ifndef __ASM_I386_CPUFEATURE_H
#define __ASM_I386_CPUFEATURE_H

#ifndef __ASSEMBLY__
#include <linux/bitops.h>
#endif
#include <asm/required-features.h>

#define NCAPINTS 7 /* N 32-bit words worth of info */

Expand Down
34 changes: 34 additions & 0 deletions trunk/include/asm-i386/required-features.h
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

0 comments on commit 6a473c9

Please sign in to comment.