diff options
author | Alexander van Heukelum <heukelum@fastmail.fm> | 2008-10-03 16:00:32 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-13 04:33:22 -0400 |
commit | 699d2937d45d9dabc1772d0d07501ccc43885c23 (patch) | |
tree | 56bc2da85a2a0737d86df18a5c1e02d646df37e1 | |
parent | 3d2a71a596bd9c761c8487a2178e95f8a61da083 (diff) |
traps: x86: converge trap_init functions
- set_system_gate on i386 is really set_system_trap_gate
- set_system_gate on x86_64 is really set_system_intr_gate
- ist=0 means no special stack switch is done:
- introduce STACKFAULT_STACK, DOUBLEFAULT_STACK, NMI_STACK,
DEBUG_STACK and MCE_STACK as on x86_64.
- use the _ist variants with XXX_STACK set to zero
- remove set_system_gate
Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
traps: x86: correct copy/paste bug: a trap is a GATE_TRAP
Fix copy/paste/forgot-to-edit bug in desc.h.
Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/x86/kernel/traps_32.c | 16 | ||||
-rw-r--r-- | arch/x86/kernel/traps_64.c | 6 | ||||
-rw-r--r-- | include/asm-x86/desc.h | 14 | ||||
-rw-r--r-- | include/asm-x86/page_32.h | 6 |
4 files changed, 23 insertions, 19 deletions
diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c index 953172af6e51..2c7ea3827713 100644 --- a/arch/x86/kernel/traps_32.c +++ b/arch/x86/kernel/traps_32.c | |||
@@ -847,10 +847,12 @@ void __init trap_init(void) | |||
847 | #endif | 847 | #endif |
848 | 848 | ||
849 | set_intr_gate(0, ÷_error); | 849 | set_intr_gate(0, ÷_error); |
850 | set_intr_gate(1, &debug); | 850 | set_intr_gate_ist(1, &debug, DEBUG_STACK); |
851 | set_intr_gate(2, &nmi); | 851 | set_intr_gate_ist(2, &nmi, NMI_STACK); |
852 | set_system_intr_gate(3, &int3); /* int3 can be called from all */ | 852 | /* int3 can be called from all */ |
853 | set_system_intr_gate(4, &overflow); /* int4 can be called from all */ | 853 | set_system_intr_gate_ist(3, &int3, DEBUG_STACK); |
854 | /* int4 can be called from all */ | ||
855 | set_system_intr_gate(4, &overflow); | ||
854 | set_intr_gate(5, &bounds); | 856 | set_intr_gate(5, &bounds); |
855 | set_intr_gate(6, &invalid_op); | 857 | set_intr_gate(6, &invalid_op); |
856 | set_intr_gate(7, &device_not_available); | 858 | set_intr_gate(7, &device_not_available); |
@@ -858,14 +860,14 @@ void __init trap_init(void) | |||
858 | set_intr_gate(9, &coprocessor_segment_overrun); | 860 | set_intr_gate(9, &coprocessor_segment_overrun); |
859 | set_intr_gate(10, &invalid_TSS); | 861 | set_intr_gate(10, &invalid_TSS); |
860 | set_intr_gate(11, &segment_not_present); | 862 | set_intr_gate(11, &segment_not_present); |
861 | set_intr_gate(12, &stack_segment); | 863 | set_intr_gate_ist(12, &stack_segment, STACKFAULT_STACK); |
862 | set_intr_gate(13, &general_protection); | 864 | set_intr_gate(13, &general_protection); |
863 | set_intr_gate(14, &page_fault); | 865 | set_intr_gate(14, &page_fault); |
864 | set_intr_gate(15, &spurious_interrupt_bug); | 866 | set_intr_gate(15, &spurious_interrupt_bug); |
865 | set_intr_gate(16, &coprocessor_error); | 867 | set_intr_gate(16, &coprocessor_error); |
866 | set_intr_gate(17, &alignment_check); | 868 | set_intr_gate(17, &alignment_check); |
867 | #ifdef CONFIG_X86_MCE | 869 | #ifdef CONFIG_X86_MCE |
868 | set_intr_gate(18, &machine_check); | 870 | set_intr_gate_ist(18, &machine_check, MCE_STACK); |
869 | #endif | 871 | #endif |
870 | set_intr_gate(19, &simd_coprocessor_error); | 872 | set_intr_gate(19, &simd_coprocessor_error); |
871 | 873 | ||
@@ -881,7 +883,7 @@ void __init trap_init(void) | |||
881 | printk("done.\n"); | 883 | printk("done.\n"); |
882 | } | 884 | } |
883 | 885 | ||
884 | set_system_gate(SYSCALL_VECTOR, &system_call); | 886 | set_system_trap_gate(SYSCALL_VECTOR, &system_call); |
885 | 887 | ||
886 | /* Reserve all the builtin and the syscall vector: */ | 888 | /* Reserve all the builtin and the syscall vector: */ |
887 | for (i = 0; i < FIRST_EXTERNAL_VECTOR; i++) | 889 | for (i = 0; i < FIRST_EXTERNAL_VECTOR; i++) |
diff --git a/arch/x86/kernel/traps_64.c b/arch/x86/kernel/traps_64.c index a851eca6d04c..ea091dfe0cd3 100644 --- a/arch/x86/kernel/traps_64.c +++ b/arch/x86/kernel/traps_64.c | |||
@@ -647,9 +647,9 @@ void __init trap_init(void) | |||
647 | set_intr_gate_ist(1, &debug, DEBUG_STACK); | 647 | set_intr_gate_ist(1, &debug, DEBUG_STACK); |
648 | set_intr_gate_ist(2, &nmi, NMI_STACK); | 648 | set_intr_gate_ist(2, &nmi, NMI_STACK); |
649 | /* int3 can be called from all */ | 649 | /* int3 can be called from all */ |
650 | set_system_gate_ist(3, &int3, DEBUG_STACK); | 650 | set_system_intr_gate_ist(3, &int3, DEBUG_STACK); |
651 | /* int4 can be called from all */ | 651 | /* int4 can be called from all */ |
652 | set_system_gate(4, &overflow); | 652 | set_system_intr_gate(4, &overflow); |
653 | set_intr_gate(5, &bounds); | 653 | set_intr_gate(5, &bounds); |
654 | set_intr_gate(6, &invalid_op); | 654 | set_intr_gate(6, &invalid_op); |
655 | set_intr_gate(7, &device_not_available); | 655 | set_intr_gate(7, &device_not_available); |
@@ -669,7 +669,7 @@ void __init trap_init(void) | |||
669 | set_intr_gate(19, &simd_coprocessor_error); | 669 | set_intr_gate(19, &simd_coprocessor_error); |
670 | 670 | ||
671 | #ifdef CONFIG_IA32_EMULATION | 671 | #ifdef CONFIG_IA32_EMULATION |
672 | set_system_gate(IA32_SYSCALL_VECTOR, ia32_syscall); | 672 | set_system_intr_gate(IA32_SYSCALL_VECTOR, ia32_syscall); |
673 | #endif | 673 | #endif |
674 | /* | 674 | /* |
675 | * Should be a barrier for any external CPU state: | 675 | * Should be a barrier for any external CPU state: |
diff --git a/include/asm-x86/desc.h b/include/asm-x86/desc.h index ebc307817e98..f06adac7938c 100644 --- a/include/asm-x86/desc.h +++ b/include/asm-x86/desc.h | |||
@@ -351,20 +351,16 @@ static inline void set_system_intr_gate(unsigned int n, void *addr) | |||
351 | _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS); | 351 | _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS); |
352 | } | 352 | } |
353 | 353 | ||
354 | static inline void set_trap_gate(unsigned int n, void *addr) | 354 | static inline void set_system_trap_gate(unsigned int n, void *addr) |
355 | { | 355 | { |
356 | BUG_ON((unsigned)n > 0xFF); | 356 | BUG_ON((unsigned)n > 0xFF); |
357 | _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS); | 357 | _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS); |
358 | } | 358 | } |
359 | 359 | ||
360 | static inline void set_system_gate(unsigned int n, void *addr) | 360 | static inline void set_trap_gate(unsigned int n, void *addr) |
361 | { | 361 | { |
362 | BUG_ON((unsigned)n > 0xFF); | 362 | BUG_ON((unsigned)n > 0xFF); |
363 | #ifdef CONFIG_X86_32 | 363 | _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS); |
364 | _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS); | ||
365 | #else | ||
366 | _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS); | ||
367 | #endif | ||
368 | } | 364 | } |
369 | 365 | ||
370 | static inline void set_task_gate(unsigned int n, unsigned int gdt_entry) | 366 | static inline void set_task_gate(unsigned int n, unsigned int gdt_entry) |
@@ -379,7 +375,7 @@ static inline void set_intr_gate_ist(int n, void *addr, unsigned ist) | |||
379 | _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS); | 375 | _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS); |
380 | } | 376 | } |
381 | 377 | ||
382 | static inline void set_system_gate_ist(int n, void *addr, unsigned ist) | 378 | static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist) |
383 | { | 379 | { |
384 | BUG_ON((unsigned)n > 0xFF); | 380 | BUG_ON((unsigned)n > 0xFF); |
385 | _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS); | 381 | _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS); |
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h index 5d6a68a1067a..e8d80d1de237 100644 --- a/include/asm-x86/page_32.h +++ b/include/asm-x86/page_32.h | |||
@@ -20,6 +20,12 @@ | |||
20 | #endif | 20 | #endif |
21 | #define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) | 21 | #define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) |
22 | 22 | ||
23 | #define STACKFAULT_STACK 0 | ||
24 | #define DOUBLEFAULT_STACK 1 | ||
25 | #define NMI_STACK 0 | ||
26 | #define DEBUG_STACK 0 | ||
27 | #define MCE_STACK 0 | ||
28 | #define N_EXCEPTION_STACKS 1 | ||
23 | 29 | ||
24 | #ifdef CONFIG_X86_PAE | 30 | #ifdef CONFIG_X86_PAE |
25 | /* 44=32+12, the limit we can fit into an unsigned long pfn */ | 31 | /* 44=32+12, the limit we can fit into an unsigned long pfn */ |