This adds static information about the code regions where the stack pointer cannot be relied upon. Kernel debuggers may then use this information to determine which stack to switch to when having a need to switch off of namely the NMI stack. From: Jan Beulich Index: 2.6.14-nlkd/arch/x86_64/ia32/ia32entry.S =================================================================== --- 2.6.14-nlkd.orig/arch/x86_64/ia32/ia32entry.S 2005-11-09 11:12:58.000000000 +0100 +++ 2.6.14-nlkd/arch/x86_64/ia32/ia32entry.S 2005-11-04 17:18:10.000000000 +0100 @@ -60,6 +60,7 @@ ENTRY(ia32_sysenter_target) CFI_REGISTER rsp,rbp swapgs movq %gs:pda_kernelstack, %rsp +0: STACK_INVALID ia32_sysenter_target, 0b addq $(PDA_STACKOFFSET),%rsp sti movl %ebp,%ebp /* zero extension */ @@ -169,6 +170,7 @@ ENTRY(ia32_cstar_target) movl %esp,%r8d CFI_REGISTER rsp,r8 movq %gs:pda_kernelstack,%rsp +0: STACK_INVALID ia32_cstar_target, 0b sti SAVE_ARGS 8,1,1 movl %eax,%eax /* zero extension */ @@ -211,8 +213,10 @@ cstar_do_call: /*CFI_REGISTER rflags,r11*/ movl RSP-ARGOFFSET(%rsp),%esp CFI_RESTORE rsp +0: STACK_INVALID 0b, 1f swapgs sysretl +1: cstar_tracesys: CFI_RESTORE_STATE Index: 2.6.14-nlkd/arch/x86_64/kernel/entry.S =================================================================== --- 2.6.14-nlkd.orig/arch/x86_64/kernel/entry.S 2005-11-09 10:45:26.000000000 +0100 +++ 2.6.14-nlkd/arch/x86_64/kernel/entry.S 2005-11-07 14:56:02.000000000 +0100 @@ -190,6 +190,7 @@ ENTRY(system_call) swapgs movq %rsp,%gs:pda_oldrsp movq %gs:pda_kernelstack,%rsp +0: STACK_INVALID system_call, 0b sti SAVE_ARGS 8,1 movq %rax,ORIG_RAX-ARGOFFSET(%rsp) @@ -224,8 +225,10 @@ sysret_check: RESTORE_ARGS 0,-ARG_SKIP,1 /*CFI_REGISTER rflags,r11*/ movq %gs:pda_oldrsp,%rsp +0: STACK_INVALID 0b, 1f swapgs sysretq +1: /* Handle reschedules */ /* edx: work, edi: workmask */ Index: 2.6.14-nlkd/arch/x86_64/kernel/vmlinux.lds.S =================================================================== --- 2.6.14-nlkd.orig/arch/x86_64/kernel/vmlinux.lds.S 2005-11-09 11:12:58.000000000 +0100 +++ 2.6.14-nlkd/arch/x86_64/kernel/vmlinux.lds.S 2005-11-04 16:19:33.000000000 +0100 @@ -30,6 +30,13 @@ SECTIONS _etext = .; /* End of text section */ +#ifdef CONFIG_NLKD + . = ALIGN(8); /* RSP invalid table */ + __start___stack_invalid = .; + __stack_invalid : AT(ADDR(__stack_invalid) - LOAD_OFFSET) { *(__stack_invalid) } + __stop___stack_invalid = .; +#endif + . = ALIGN(16); /* Exception table */ __start___ex_table = .; __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) } Index: 2.6.14-nlkd/include/asm-x86_64/calling.h =================================================================== --- 2.6.14-nlkd.orig/include/asm-x86_64/calling.h 2005-11-09 11:12:58.000000000 +0100 +++ 2.6.14-nlkd/include/asm-x86_64/calling.h 2005-11-07 10:25:38.000000000 +0100 @@ -158,6 +158,17 @@ RESTORE_ARGS 0,\addskip .endm +#ifndef MODULE + .macro STACK_INVALID from, to +# ifdef CONFIG_NLKD + .section __stack_invalid, "a", @progbits + .align 8 + .quad \from, \to + .previous +# endif + .endm +#endif + .macro icebp .byte 0xf1 .endm