public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joerg Roedel <joro@8bytes.org>
To: hpa@zytor.com
Cc: mingo@redhat.com, tglx@linutronix.de, linux-kernel@vger.kernel.org
Subject: Setup code crashes my old 486 box
Date: Wed, 13 Aug 2008 00:47:03 +0200	[thread overview]
Message-ID: <20080812224703.GV31439@8bytes.org> (raw)

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


             reply	other threads:[~2008-08-12 22:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-12 22:47 Joerg Roedel [this message]
2008-08-12 22:57 ` Setup code crashes my old 486 box 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

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=20080812224703.GV31439@8bytes.org \
    --to=joro@8bytes.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    /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