login
Header Space

 
 

[PATCH REPOST] [3/3] Replace macro recursion with more conventional loop

Previous thread: Re: Google's Summer of Code? by Casey Schaufler on Tuesday, March 4, 2008 - 5:11 pm. (2 messages)

Next thread: preempt bug in set_pmd_pfn? by Jeremy Fitzhardinge on Tuesday, March 4, 2008 - 5:13 pm. (17 messages)
To: <tglx@...>, <linux-kernel@...>
Date: Tuesday, March 4, 2008 - 5:13 pm

All of early setup runs with interrupts disabled, so there is no 
need to set up early exception handlers for vectors &gt;= 32

That saves some text size

Signed-off-by: Andi Kleen &lt;ak@suse.de&gt;

---
 arch/x86/kernel/head64.c  |    2 +-
 arch/x86/kernel/head_64.S |    6 ++----
 include/asm-x86/segment.h |    3 ++-
 3 files changed, 5 insertions(+), 6 deletions(-)

Index: linux/arch/x86/kernel/head64.c
===================================================================
--- linux.orig/arch/x86/kernel/head64.c
+++ linux/arch/x86/kernel/head64.c
@@ -91,7 +91,7 @@ void __init x86_64_start_kernel(char * r
 	/* Cleanup the over mapped high alias */
 	cleanup_highmap();
 
-	for (i = 0; i &lt; IDT_ENTRIES; i++) {
+	for (i = 0; i &lt; NUM_EXCEPTION_VECTORS; i++) {
 #ifdef CONFIG_EARLY_PRINTK
 		set_intr_gate(i, &amp;early_idt_handlers[i]);
 #else
Index: linux/include/asm-x86/segment.h
===================================================================
--- linux.orig/include/asm-x86/segment.h
+++ linux/include/asm-x86/segment.h
@@ -191,13 +191,14 @@
 #define SEGMENT_TI_MASK		0x4
 
 #define IDT_ENTRIES 256
+#define NUM_EXCEPTION_VECTORS 32
 #define GDT_SIZE (GDT_ENTRIES * 8)
 #define GDT_ENTRY_TLS_ENTRIES 3
 #define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
 
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
-extern const char early_idt_handlers[IDT_ENTRIES][10];
+extern const char early_idt_handlers[NUM_EXCEPTION_VECTORS][10];
 #endif
 #endif
 
Index: linux/arch/x86/kernel/head_64.S
===================================================================
--- linux.orig/arch/x86/kernel/head_64.S
+++ linux/arch/x86/kernel/head_64.S
@@ -278,10 +278,8 @@ bad_address:
 
 	.globl early_idt_handlers
 early_idt_handlers:
-	early_idt_tramp 0, 63
-	early_idt_tramp 64, 127
-	early_idt_tramp 128, 191
-	early_idt_tramp 192, 255
+	.set maxe,NUM_EXCEPTION_VECTORS-1
+	early_idt_tramp 0,maxe
 #endif
 
 ENTRY(early_idt_handler)
--
To: <tglx@...>, <linux-kernel@...>
Date: Tuesday, March 4, 2008 - 5:13 pm

The early exception handlers are currently set up using a macro
recursion. Replace that with a standard loop.

Noop patch, just a cleanup.

Signed-off-by: Andi Kleen &lt;ak@suse.de&gt;

---
 arch/x86/kernel/head_64.S |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Index: linux/arch/x86/kernel/head_64.S
===================================================================
--- linux.orig/arch/x86/kernel/head_64.S
+++ linux/arch/x86/kernel/head_64.S
@@ -269,18 +269,17 @@ bad_address:
 
 	.section ".init.text","ax"
 #ifdef CONFIG_EARLY_PRINTK
-.macro early_idt_tramp first, last
-	.ifgt \last-\first
-	early_idt_tramp \first, \last-1
-	.endif
-	movl $\last,%esi
+.macro early_idt_tramp i
+	movl $\i,%esi
 	jmp early_idt_handler
 .endm
-
 	.globl early_idt_handlers
 early_idt_handlers:
-	.set maxe,NUM_EXCEPTION_VECTORS-1
-	early_idt_tramp 0,maxe
+	i = 0
+	.rept NUM_EXCEPTION_VECTORS
+	early_idt_tramp i
+	i = i+1
+	.endr
 #endif
 
 ENTRY(early_idt_handler)
--
To: <tglx@...>, <linux-kernel@...>
Date: Tuesday, March 4, 2008 - 5:13 pm

Currently they are in .text.head because the rest of head_64.S. 
.text.head is not removed as init data, but the early exception handlers
should be because they are not needed after early boot of the BP. 
So move them over.

Signed-off-by: Andi Kleen &lt;ak@suse.de&gt;

---
 arch/x86/kernel/head_64.S |    2 ++
 1 file changed, 2 insertions(+)

Index: linux/arch/x86/kernel/head_64.S
===================================================================
--- linux.orig/arch/x86/kernel/head_64.S
+++ linux/arch/x86/kernel/head_64.S
@@ -267,6 +267,7 @@ ENTRY(secondary_startup_64)
 bad_address:
 	jmp bad_address
 
+	.section ".init.text","ax"
 #ifdef CONFIG_EARLY_PRINTK
 .macro early_idt_tramp first, last
 	.ifgt \last-\first
@@ -325,6 +326,7 @@ early_idt_msg:
 early_idt_ripmsg:
 	.asciz "RIP %s\n"
 #endif /* CONFIG_EARLY_PRINTK */
+	.previous
 
 .balign PAGE_SIZE
 
--
Previous thread: Re: Google's Summer of Code? by Casey Schaufler on Tuesday, March 4, 2008 - 5:11 pm. (2 messages)

Next thread: preempt bug in set_pmd_pfn? by Jeremy Fitzhardinge on Tuesday, March 4, 2008 - 5:13 pm. (17 messages)
speck-geostationary