public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Setup code crashes my old 486 box
@ 2008-08-12 22:47 Joerg Roedel
  2008-08-12 22:57 ` H. Peter Anvin
  0 siblings, 1 reply; 8+ messages in thread
From: Joerg Roedel @ 2008-08-12 22:47 UTC (permalink / raw)
  To: hpa; +Cc: mingo, tglx, linux-kernel

Hello,

yesterday I tried to reactivate my old 486 box and wanted to install a
current Linux with latest kernel on it. But it turned out that the
latest kernel does not boot because the machine crashes early in the
setup code.
After some debugging it turned out that the problem is the query_ist()
function. If this interrupt with that function is called the machine
simply locks up. It looks like a BIOS bug. Looking for a workaround for
this problem I wrote the attached patch. It checks for the CPUID
instruction and if it is not implemented it does not call the speedstep
BIOS function. As far as I know speedstep should be available since some
Pentium earliest.
Is this an acceptable workaround or is there a better one for this?

Regards,

Joerg

Here is the patch which makes the kernel boot on my old box again:

From: Joerg Roedel <joro@8bytes.org>

This patch adds a check to the query_ist function to check for the cpuid
instruction before calling the speedstep init code. This works around a
buggy 486 BIOS which crashes the machine on the speedstep BIOS initcall.

Signed-off-by: Joerg Roedel <joro@8bytes.org>
---
 arch/x86/boot/main.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
index 2296164..3bf5fa0 100644
--- a/arch/x86/boot/main.c
+++ b/arch/x86/boot/main.c
@@ -68,11 +68,58 @@ static void keyboard_set_repeat(void)
 		     : : "ecx", "edx", "esi", "edi");
 }
 
+static unsigned read_flags(void)
+{
+	unsigned eax;
+
+	asm volatile("pushf\n\t"
+		     "popl %%eax\n\t"
+		     : "=a" (eax));
+
+	return eax;
+}
+
+static inline void write_flags(unsigned f)
+{
+	asm volatile("pushl %0\n\t"
+		     "popf\n\t"
+		     : : "r" (f));
+}
+
+static int has_cpuid(void)
+{
+	unsigned f = read_flags();
+	unsigned id_mask = (1 << 21);
+
+	write_flags(f | id_mask);
+	f = read_flags() & id_mask;
+	if (!f)
+		return 0;
+	f = read_flags() & ~id_mask;
+	write_flags(f);
+	f = read_flags() & id_mask;
+	if (f)
+		return 0;
+
+	return 1;
+}
+
+static int no_ist_check(void)
+{
+	if (!has_cpuid())
+		return 1;
+
+	return 0;
+}
+
 /*
  * Get Intel SpeedStep (IST) information.
  */
 static void query_ist(void)
 {
+	if (no_ist_check())
+		return;
+
 	asm("int $0x15"
 	    : "=a" (boot_params.ist_info.signature),
 	      "=b" (boot_params.ist_info.command),
-- 
1.5.4.3


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

end of thread, other threads:[~2008-08-13 15:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-12 22:47 Setup code crashes my old 486 box Joerg Roedel
2008-08-12 22:57 ` H. Peter Anvin
2008-08-12 22:55   ` Alan Cox
2008-08-13  0:21     ` H. Peter Anvin
2008-08-13  8:07   ` Joerg Roedel
2008-08-13 10:00     ` Ingo Molnar
2008-08-13 10:40       ` Joerg Roedel
2008-08-13 15:33     ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox