LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: whiteheadm@acm.org
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andy Lutomirski <luto@kernel.org>,
	x86@kernel.org, Peter Zijlstra <peterz@infradead.org>
Subject: Re: [REGRESSION]: x86/idt: Move early IDT setup out of 32-bit asm
Date: Mon, 16 Oct 2017 12:25:56 +0200 (CEST)
Message-ID: <alpine.DEB.2.20.1710161210290.1973@nanos> (raw)
In-Reply-To: <CAP8WD_a-6DpEzHrsQ4YrKkKmypkXW1WOBxcHj0OJcRvjmSC29A@mail.gmail.com>

Matthew,

On Sat, 14 Oct 2017, tedheadster wrote:

>   I bisected a bug to commit 87e81786b13b267c4355e0d23e33c7e4c08fa63f.
> On first generation i486 processors it immediately resets the system
> after the "Booting the kernel" message.

Duh. Took me a while to understand whats going on. The patch below should
fix that issue.

Thanks,

	tglx

8<------------------

Subject: x86/idt: Initialize early IDT before cr4_init_shadow()
From: Thomas Gleixner <tglx@linutronix.de>
Date: Mon, 16 Oct 2017 12:12:16 +0200

Moving the early IDT setup out of assembly code breaks the boot on first
generation 486 systems.

The reason is that the call to setup of these handlers was added after the
call to cr4_init_shadow().

cr4_init_shadow() tries to read CR4 which is not available on those
systems. The accessor function uses a extable fixup to handle the resulting
fault. As the IDT is not set up yet, the cr4 read exception causes an
instantaneous reboot for obvious reasons.

Call idt_setup_early_handler() before cr4_init_shadow() so IDT is set up
before the first exception hits.

Fixes: 87e81786b13b ("x86/idt: Move early IDT setup out of 32-bit asm")
Reported-by:  Matthew Whitehead <whiteheadm@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/kernel/head32.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/arch/x86/kernel/head32.c
+++ b/arch/x86/kernel/head32.c
@@ -30,10 +30,11 @@ static void __init i386_default_early_se
 
 asmlinkage __visible void __init i386_start_kernel(void)
 {
-	cr4_init_shadow();
-
+	/* Make sure IDT is set up before any exception happens */
 	idt_setup_early_handler();
 
+	cr4_init_shadow();
+
 	sanitize_boot_params(&boot_params);
 
 	x86_early_init_platform_quirks();

  reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-14 16:04 tedheadster
2017-10-16 10:25 ` Thomas Gleixner [this message]
2017-10-16 16:10   ` tedheadster
2017-10-16 18:52   ` [tip:x86/urgent] x86/idt: Initialize early IDT before cr4_init_shadow() tip-bot for Thomas Gleixner

Reply instructions:

You may reply publically 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=alpine.DEB.2.20.1710161210290.1973@nanos \
    --to=tglx@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=peterz@infradead.org \
    --cc=whiteheadm@acm.org \
    --cc=x86@kernel.org \
    /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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git