lkml.org 
[lkml]   [2012]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 1/3] boot: fortify early_idt_handlers definition

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

From: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>

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@oss.ntt.co.jp>
---

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
\
 
 \ /
  Last update: 2012-03-09 10:55    [W:0.996 / U:0.948 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site