Skip to contentSkip to conversation

x86 boot time check for cpu features

PATCH In review Brian Gerst 2 participants 6 messages Nov 3, 2000 – Nov 4, 2000

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86 boot time check for cpu features

This patch allows the real mode setup code to check for required features (such as cmov, pae, etc.) that would normally just cause the boot process to silently hang. Tested with a K6-2 (no cmov) and an Athlon (has cmov), needs testing on a CPU without cpuid.

Signature · 1 line
						Brian Gerst
arch/i386/boot/setup.S +49 -0
diff -ur linux-2.4.0t10/arch/i386/boot/setup.S linux/arch/i386/boot/setup.S
@@ -364,6 +364,55 @@
 	xorw	%bx, %bx
 	int	$0x16
 
+/* This is butt ugly, but it works. */
+#ifdef CONFIG_X86_CMOV
+# define REQD_CMOV	0x00008000
+#else
+# define REQD_CMOV	0
+#endif
+#ifdef CONFIG_X86_PAE
+# define REQD_PAE	0x00000040
+#else
+# define REQD_PAE	0
+#endif
+#define REQD_FLAGS REQD_CMOV|REQD_PAE
+
+#if REQD_FLAGS
+/*
+ * We must check this here while we can still get a message to the console
+ * because instructions for newer processors (ie. cmovcc) may be present
+ * in C code.
+ */
+	pushfl
+	popl	%eax
+	xorl	$0x200000, %eax			# check ID flag
+	pushl	%eax
+	popfl
+	pushfl
+	popl	%edx
+	xorl	%edx, %eax
+	testl	$0x200000, %eax
+	jnz	cpuid_fail
+	xorl	%eax, %eax
+	cpuid
+	cmpl 	$1, %eax
+	jb	cpuid_fail
+	movl	$1, %eax
+	cpuid
+	andl	$REQD_FLAGS, %edx
+	cmpl	$REQD_FLAGS, %edx
+	je	cpuid_pass
+cpuid_fail:
+	pushw	%cs
+	popw	%ds
+	lea	cpuid_fail_msg, %si
+	call	prtstr
+1:	jmp	1b
+cpuid_fail_msg:
+	.string	"Required CPU features are not present - compile kernel for the proper CPU type."
+cpuid_pass:
+#endif
+	
 # Check for video adapter and its parameters and allow the
 # user to browse video modes.
 	call	video				# NOTE: we need %ds pointing
arch/i386/config.in +3 -0
diff -ur linux-2.4.0t10/arch/i386/config.in linux/arch/i386/config.in
@@ -82,6 +82,7 @@
    define_bool CONFIG_X86_GOOD_APIC y
    define_bool CONFIG_X86_PGE y
    define_bool CONFIG_X86_USE_PPRO_CHECKSUM y
+   define_bool CONFIG_X86_CMOV y
 fi
 if [ "$CONFIG_M686FXSR" = "y" ]; then
    define_int  CONFIG_X86_L1_CACHE_SHIFT 5
@@ -91,6 +92,7 @@
    define_bool CONFIG_X86_USE_PPRO_CHECKSUM y
    define_bool CONFIG_X86_FXSR y
    define_bool CONFIG_X86_XMM y
+   define_bool CONFIG_X86_CMOV y
 fi
 if [ "$CONFIG_MK6" = "y" ]; then
    define_int  CONFIG_X86_L1_CACHE_SHIFT 5
@@ -105,6 +107,7 @@
    define_bool CONFIG_X86_USE_3DNOW y
    define_bool CONFIG_X86_PGE y
    define_bool CONFIG_X86_USE_PPRO_CHECKSUM y
+   define_bool CONFIG_X86_CMOV y
 fi
 if [ "$CONFIG_MCRUSOE" = "y" ]; then
    define_int  CONFIG_X86_L1_CACHE_SHIFT 5
#1 lore raw

arch/i386/boot/setup.S line 413

Quoted 6 lines
arch/i386/boot/setup.S +6 -0
+	lea	cpuid_fail_msg, %si
+	call	prtstr
+1:	jmp	1b
+cpuid_fail_msg:
+	.string	"Required CPU features are not present - compile kernel for the proper CPU type."
+cpuid_pass:

Only one very minor suggestion

1: hlt
j 1b

Q: are any of the things you test present in processors only after we
do magic 'cpuid' enable invocations ?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
Quoted 10 lines · Alan Cox

arch/i386/boot/setup.S line 413

Quoted 7 lines
arch/i386/boot/setup.S +6 -0
+     lea     cpuid_fail_msg, %si
+     call    prtstr
+1:   jmp     1b
+cpuid_fail_msg:
+     .string "Required CPU features are not present - compile kernel for the proper CPU type."
+cpuid_pass:

Only one very minor suggestion

Quoted 5 lines

1: hlt
j 1b

Q: are any of the things you test present in processors only after we
do magic 'cpuid' enable invocations ?

AFAIK, none of the braindead chips have cmov instructions or PAE support (only PentiumPro+ and Athlon do). If someone can prove me wrong I'd like to know.

Signature · 5 lines
						Brian Gerst
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#3 lore raw
In reply to Alan Cox
Quoted 2 lines · Alan Cox

Q: are any of the things you test present in processors only after we
do magic 'cpuid' enable invocations ?

Hmm, after a bit more investigation, it appears that the Cyrix MII processors support cmov instructions, even though we currently don't compile for that processor with -march=i686. Please ignore this patch until I can come up with something better.

Signature · 5 lines
						Brian Gerst
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#4 lore raw
Quoted 8 lines
Quoted 2 lines · Alan Cox

Q: are any of the things you test present in processors only after we
do magic 'cpuid' enable invocations ?

Hmm, after a bit more investigation, it appears that the Cyrix MII processors support cmov instructions, even though we currently don't compile for that processor with -march=i686. Please ignore this patch until I can come up with something better.

I believe the MII always has CPUID enabled. It was the older Cyrixes that did not. DaveJ is the guru..

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#5 lore raw
Quoted 5 lines · Alan Cox
Quoted 5 lines
Quoted 2 lines · Alan Cox

Q: are any of the things you test present in processors only after we
do magic 'cpuid' enable invocations ?

Quoted 7 lines
Quoted 4 lines

Hmm, after a bit more investigation, it appears that the Cyrix MII processors support cmov instructions, even though we currently don't compile for that processor with -march=i686. Please ignore this patch until I can come up with something better.

I believe the MII always has CPUID enabled. It was the older Cyrixes that did not. DaveJ is the guru..

Well, according to comments in bugs.h, some broken BIOSes disable cpuid.

--

Brian Gerst
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/