linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Gerst <bgerst@didntduck.org>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Linux kernel mailing list <linux-kernel@vger.kernel.org>
Subject: [PATCH] x86 boot time check for cpu features
Date: Thu, 02 Nov 2000 21:21:35 -0500	[thread overview]
Message-ID: <3A02212F.8B1BA2DC@didntduck.org> (raw)

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

             reply	other threads:[~2000-11-03  2:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-03  2:21 Brian Gerst [this message]
2000-11-03 12:54 ` [PATCH] x86 boot time check for cpu features 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3A02212F.8B1BA2DC@didntduck.org \
    --to=bgerst@didntduck.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).