[PATCH 1/3] boot: fortify early_idt_handlers definition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Subject: [PATCH 1/3] boot: fortify early_idt_handlers definition

From: Fernando Luis Vazquez Cao <fernando@xxxxxxxxxxxxx>

The current definition is too brittle which makes it easy to screw things up
when modifying the code. Add some comments while at it.

Signed-off-by: Fernando Luis Vazquez Cao <fernando@xxxxxxxxxxxxx>
---

diff -urNp linux-3.3-rc6-orig/arch/x86/include/asm/segment.h linux-3.3-rc6/arch/x86/include/asm/segment.h
--- linux-3.3-rc6-orig/arch/x86/include/asm/segment.h	2012-01-05 08:55:44.000000000 +0900
+++ linux-3.3-rc6/arch/x86/include/asm/segment.h	2012-03-09 17:50:40.965438325 +0900
@@ -210,8 +210,10 @@
 #define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
 
 #ifdef __KERNEL__
+#define EARLY_IDT_HANDLER_SIZE 16
 #ifndef __ASSEMBLY__
-extern const char early_idt_handlers[NUM_EXCEPTION_VECTORS][10];
+extern const char
+	early_idt_handlers[NUM_EXCEPTION_VECTORS][EARLY_IDT_HANDLER_SIZE];
 #endif
 #endif
 
diff -urNp linux-3.3-rc6-orig/arch/x86/kernel/head_64.S linux-3.3-rc6/arch/x86/kernel/head_64.S
--- linux-3.3-rc6-orig/arch/x86/kernel/head_64.S	2012-03-09 17:48:04.563492864 +0900
+++ linux-3.3-rc6/arch/x86/kernel/head_64.S	2012-03-09 18:06:13.329009305 +0900
@@ -272,11 +272,20 @@ bad_address:
 	.section ".init.text","ax"
 #ifdef CONFIG_EARLY_PRINTK
 	.globl early_idt_handlers
+	.align EARLY_IDT_HANDLER_SIZE
 early_idt_handlers:
 	i = 0
 	.rept NUM_EXCEPTION_VECTORS
 	movl $i, %esi
 	jmp early_idt_handler
+	/*
+	 * early_idt_handlers is treated as a
+	 * [NUM_EXCEPTION_VECTORS][EARLY_IDT_HANDLER_SIZE] array from C code
+	 * so we have to make sure that each handler fits in its
+	 * EARLY_IDT_HANDLER_SIZE bytes long slot. Handlers shorter than that
+	 * will be taken care of by the align directive below.
+	 */
+	.align EARLY_IDT_HANDLER_SIZE
 	i = i + 1
 	.endr
 #endif

[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux