linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86 boot time check for cpu features
@ 2000-11-03  2:21 Brian Gerst
  2000-11-03 12:54 ` Alan Cox
  0 siblings, 1 reply; 10+ messages in thread
From: Brian Gerst @ 2000-11-03  2:21 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Linux kernel mailing list

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]

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.

-- 

						Brian Gerst

[-- Attachment #2: reqdflags.diff --]
[-- Type: text/plain, Size: 2326 bytes --]

diff -ur linux-2.4.0t10/arch/i386/boot/setup.S linux/arch/i386/boot/setup.S
--- linux-2.4.0t10/arch/i386/boot/setup.S	Tue Oct 31 17:06:34 2000
+++ linux/arch/i386/boot/setup.S	Thu Nov  2 21:04:01 2000
@@ -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
diff -ur linux-2.4.0t10/arch/i386/config.in linux/arch/i386/config.in
--- linux-2.4.0t10/arch/i386/config.in	Tue Oct 31 17:06:34 2000
+++ linux/arch/i386/config.in	Thu Nov  2 18:53:59 2000
@@ -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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86 boot time check for cpu features
  2000-11-03  2:21 [PATCH] x86 boot time check for cpu features Brian Gerst
@ 2000-11-03 12:54 ` Alan Cox
  2000-11-03 13:51   ` Brian Gerst
  2000-11-03 23:08   ` Brian Gerst
  0 siblings, 2 replies; 10+ messages in thread
From: Alan Cox @ 2000-11-03 12:54 UTC (permalink / raw)
  To: Brian Gerst; +Cc: Linus Torvalds, Linux kernel mailing list

> +	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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86 boot time check for cpu features
  2000-11-03 12:54 ` Alan Cox
@ 2000-11-03 13:51   ` Brian Gerst
  2000-11-03 23:08   ` Brian Gerst
  1 sibling, 0 replies; 10+ messages in thread
From: Brian Gerst @ 2000-11-03 13:51 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linus Torvalds, Linux kernel mailing list

Alan Cox wrote:
> 
> > +     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 ?

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.

-- 

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86 boot time check for cpu features
  2000-11-03 12:54 ` Alan Cox
  2000-11-03 13:51   ` Brian Gerst
@ 2000-11-03 23:08   ` Brian Gerst
  2000-11-04  0:23     ` Alan Cox
  1 sibling, 1 reply; 10+ messages in thread
From: Brian Gerst @ 2000-11-03 23:08 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linus Torvalds, Linux kernel mailing list

Alan Cox wrote:
> 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.

-- 

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86 boot time check for cpu features
  2000-11-03 23:08   ` Brian Gerst
@ 2000-11-04  0:23     ` Alan Cox
  2000-11-04  1:28       ` Brian Gerst
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Cox @ 2000-11-04  0:23 UTC (permalink / raw)
  To: Brian Gerst; +Cc: Alan Cox, Linus Torvalds, Linux kernel mailing list

> Alan Cox wrote:
> > 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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86 boot time check for cpu features
  2000-11-04  0:23     ` Alan Cox
@ 2000-11-04  1:28       ` Brian Gerst
  0 siblings, 0 replies; 10+ messages in thread
From: Brian Gerst @ 2000-11-04  1:28 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linus Torvalds, Linux kernel mailing list

Alan Cox wrote:
> 
> > Alan Cox wrote:
> > > 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..

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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86 boot time check for cpu features
  2000-11-04  1:02 davej
@ 2000-11-04  2:53 ` Brian Gerst
  2000-11-04  2:07   ` davej
  0 siblings, 1 reply; 10+ messages in thread
From: Brian Gerst @ 2000-11-04  2:53 UTC (permalink / raw)
  To: davej; +Cc: Linux Kernel Mailing List

davej@suse.de wrote:
> 
> Brian Gerst wrote...
> >> 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.
> 
> That bug fix is for the earlier Cyrix 6x86 if I'm not mistaken.
> The MII is a different monster.

According to the docs on VIA's site, the MII's cpuid can still be turned
off, but it is on by default at reset.  I wouldn't trust the BIOS to not
screw it up.

--

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86 boot time check for cpu features
  2000-11-04  2:53 ` Brian Gerst
@ 2000-11-04  2:07   ` davej
  0 siblings, 0 replies; 10+ messages in thread
From: davej @ 2000-11-04  2:07 UTC (permalink / raw)
  To: Brian Gerst; +Cc: Linux Kernel Mailing List

On Fri, 3 Nov 2000, Brian Gerst wrote:

> > That bug fix is for the earlier Cyrix 6x86 if I'm not mistaken.
> > The MII is a different monster.
> According to the docs on VIA's site, the MII's cpuid can still be turned
> off, but it is on by default at reset.  I wouldn't trust the BIOS to not
> screw it up.

Err, what? If it's on by default...
A old BIOS that doesn't know about it won't switch it off.
A BIOS that does know about it will leave it (or maybe offer an option to
 disable it)

If neither of the above are true (Ie, a BIOS bug) and it's switched off
by the time Linux boots, I think we'd have heard about it by now, as MII
users would notice a lack of features.

regards,

Dave.

-- 
| Dave Jones <davej@suse.de>  http://www.suse.de/~davej
| SuSE Labs

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86 boot time check for cpu features
@ 2000-11-04  1:02 davej
  2000-11-04  2:53 ` Brian Gerst
  0 siblings, 1 reply; 10+ messages in thread
From: davej @ 2000-11-04  1:02 UTC (permalink / raw)
  To: Linux Kernel Mailing List

Brian Gerst wrote...
>> 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.

That bug fix is for the earlier Cyrix 6x86 if I'm not mistaken.
The MII is a different monster.

d.

-- 
| Dave Jones <davej@suse.de>  http://www.suse.de/~davej
| SuSE Labs

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86 boot time check for cpu features
@ 2000-11-04  1:01 davej
  0 siblings, 0 replies; 10+ messages in thread
From: davej @ 2000-11-04  1:01 UTC (permalink / raw)
  To: Linux Kernel Mailing List

Alan Cox wrote..

> > 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.

That was my understanding also.

d.

-- 
| Dave Jones <davej@suse.de>  http://www.suse.de/~davej
| SuSE Labs

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2000-11-04  2:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-03  2:21 [PATCH] x86 boot time check for cpu features Brian Gerst
2000-11-03 12:54 ` Alan Cox
2000-11-03 13:51   ` Brian Gerst
2000-11-03 23:08   ` Brian Gerst
2000-11-04  0:23     ` Alan Cox
2000-11-04  1:28       ` Brian Gerst
2000-11-04  1:01 davej
2000-11-04  1:02 davej
2000-11-04  2:53 ` Brian Gerst
2000-11-04  2:07   ` davej

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).