public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@amd64.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Glauber de Oliveira Costa <gcosta@redhat.com>
Subject: [PATCH 3/3] x86, extable: Handle early exceptions
Date: Thu, 19 Apr 2012 11:26:30 +0200	[thread overview]
Message-ID: <20120419092630.GD29542@aftab> (raw)
In-Reply-To: <20120419092255.GA29542@aftab>

From: Borislav Petkov <bp@alien8.de>
Date: Sun, 1 Apr 2012 11:33:29 +0200
Subject: [PATCH 3/3] x86, extable: Handle early exceptions

Now that all is in place, wire in exception handling into the early IDT
handler.

Also, move the sorting of the main exception table earlier in the boot
process now that we handle exceptions in the early IDT handler too.

Signed-off-by: Borislav Petkov <bp@alien8.de>
---
 arch/x86/kernel/head64.c  |    6 ++++++
 arch/x86/kernel/head_64.S |    5 +++++
 arch/x86/mm/extable.c     |   12 ++++++++++++
 init/main.c               |    1 -
 4 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 3a3b779f41d3..20860aa44747 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -13,6 +13,7 @@
 #include <linux/start_kernel.h>
 #include <linux/io.h>
 #include <linux/memblock.h>
+#include <linux/module.h>	/* sort_main_extable() */
 
 #include <asm/processor.h>
 #include <asm/proto.h>
@@ -79,6 +80,11 @@ void __init x86_64_start_kernel(char * real_mode_data)
 
 	max_pfn_mapped = KERNEL_IMAGE_SIZE >> PAGE_SHIFT;
 
+	/* We're going to enable the initial exception handlers and we need the
+	 * exception table sorted prior to that.
+	 */
+	sort_main_extable();
+
 	for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) {
 #ifdef CONFIG_EARLY_PRINTK
 		set_intr_gate(i, &early_idt_handlers[i]);
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 40f4eb3766d1..7e6661d97e9d 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -282,6 +282,11 @@ early_idt_handlers:
 #endif
 
 ENTRY(early_idt_handler)
+	call early_fixup_exception
+	cmpq $0, %rax
+	jz 2f
+	retq
+2:
 #ifdef CONFIG_EARLY_PRINTK
 	cmpl $2,early_recursion_flag(%rip)
 	jz  1f
diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
index 08aecb0d3132..f8ed1ce07f4c 100644
--- a/arch/x86/mm/extable.c
+++ b/arch/x86/mm/extable.c
@@ -19,6 +19,18 @@ static void pnp_bios_is_crap(unsigned long cs)
 #endif
 }
 
+asmlinkage int early_fixup_exception(struct pt_regs *regs)
+{
+	const struct exception_table_entry *fixup;
+
+	fixup = search_main_extable(regs->ip);
+	if (!fixup)
+		return 0;
+
+	regs->ip = fixup->fixup;
+	return 1;
+}
+
 int fixup_exception(struct pt_regs *regs)
 {
 	const struct exception_table_entry *fixup;
diff --git a/init/main.c b/init/main.c
index ff49a6dacfbb..8ef10a2e2892 100644
--- a/init/main.c
+++ b/init/main.c
@@ -517,7 +517,6 @@ asmlinkage void __init start_kernel(void)
 	setup_log_buf(0);
 	pidhash_init();
 	vfs_caches_init_early();
-	sort_main_extable();
 	trap_init();
 	mm_init();
 
-- 
1.7.5.3.401.gfb674

-- 
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551

  parent reply	other threads:[~2012-04-19  9:26 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-19  0:16 [PATCH 0/5] RFC: x86: Early exception table support H. Peter Anvin
2012-04-19  0:16 ` [PATCH 1/5] x86, nop: Make the ASM_NOP* macros work from assembly H. Peter Anvin
2012-04-19  9:29   ` Borislav Petkov
2012-04-20  0:24   ` [tip:x86/extable] " tip-bot for H. Peter Anvin
2012-04-19  0:16 ` [PATCH 2/5] x86: Add symbolic constant for exceptions with error code H. Peter Anvin
2012-04-19  9:30   ` Borislav Petkov
2012-04-20  0:25   ` [tip:x86/extable] " tip-bot for H. Peter Anvin
2012-04-19  0:16 ` [PATCH 3/5] x86, paravirt: Replace GET_CR2_INTO_RCX with GET_CR2_INTO_RAX H. Peter Anvin
2012-04-20  0:26   ` [tip:x86/extable] " tip-bot for H. Peter Anvin
2012-04-19  0:16 ` [PATCH 4/5] x86-64: Handle exception table entries during early boot H. Peter Anvin
2012-04-19 13:02   ` Borislav Petkov
2012-04-19 16:59     ` H. Peter Anvin
2012-04-19 17:16       ` Borislav Petkov
2012-04-20  0:29         ` [tip:x86/extable] x86, doc: Revert "x86: Document rdmsr_safe restrictions" tip-bot for H. Peter Anvin
2012-04-20  0:28   ` [tip:x86/extable] x86-64: Handle exception table entries during early boot tip-bot for H. Peter Anvin
2012-04-19  0:16 ` [PATCH 5/5] x86-32: " H. Peter Anvin
2012-04-20  0:28   ` [tip:x86/extable] " tip-bot for H. Peter Anvin
2012-04-19  9:22 ` [PATCH 0/5] RFC: x86: Early exception table support Borislav Petkov
2012-04-19  9:24   ` [PATCH 1/3] x86, extable: Cleanup fixup_exception Borislav Petkov
2012-04-19  9:25   ` [PATCH 2/3] x86, extable: Carve out the main extable searching routine Borislav Petkov
2012-04-19  9:26   ` Borislav Petkov [this message]
2012-04-19 17:02     ` [PATCH 3/3] x86, extable: Handle early exceptions H. Peter Anvin
2012-04-19 17:27       ` Linus Torvalds
2012-04-19 17:38         ` Borislav Petkov
2012-04-19 17:59           ` H. Peter Anvin
2012-04-19 18:25             ` Linus Torvalds
2012-04-19 18:55               ` H. Peter Anvin
2012-04-19 20:17                 ` David Daney
2012-04-19 20:20                   ` H. Peter Anvin
2012-04-19 20:26                     ` H. Peter Anvin
2012-04-19 20:40                       ` David Daney
2012-04-19 21:47                       ` Linus Torvalds
2012-04-19 22:16                   ` H. Peter Anvin
2012-04-19 22:47                     ` Tony Luck
2012-04-19 22:58                       ` Linus Torvalds
2012-04-19 23:10                         ` H. Peter Anvin
2012-04-19 23:26                           ` Tony Luck
2012-04-19 23:35                             ` H. Peter Anvin
2012-04-20  8:26                             ` Andreas Schwab
2012-04-19 18:11           ` Linus Torvalds
2012-04-20  8:46             ` Borislav Petkov
2012-04-19 17:54       ` H. Peter Anvin
2012-04-20  0:27 ` [tip:x86/extable] x86, extable: Add early_fixup_exception() tip-bot for 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=20120419092630.GD29542@aftab \
    --to=bp@amd64.org \
    --cc=gcosta@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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
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