x86_64 debug_stack nested patch (again)
PATCH 1/1 x86_64 debug_stack nested patch (again)
Hi,
In x86_64 platform, INT1 and INT3 trap stack is IST stack called DEBUG_STACK, when INT1/INT3 trap happens, system will switch to DEBUG_STACK by hardware. Current DEBUG_STACK size is 4K, when int1/int3 trap happens, kernel will minus current DEBUG_STACK IST value by 4k. But if int3/int1 trap is nested, it will destroy other vector's IST stack. This patch modifies this, it sets DEBUG_STACK size as 8K and allows two level of nested int1/int3 trap.
Kprobe DEBUG_STACK may be nested, because kprobe hanlder may be probed
by other kprobes. This patch is against 2.6.17-rc3. Thanks jbeulich for pointing out error in the first patch.
include/asm-x86_64/page.h +1 -1
@@ -20,7 +20,7 @@#define EXCEPTION_STACK_ORDER 0#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER) -#define DEBUG_STACK_ORDER EXCEPTION_STACK_ORDER +#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)#define IRQSTACK_ORDER 2
Thanks
bibo,mao
Quoted 17 lines · bibo,mao
Hi,
Inx86_64platform, INT1 and INT3 trap stack is IST stack calledDEBUG_STACK, when INT1/INT3 trap happens, system will switch toDEBUG_STACKby hardware. CurrentDEBUG_STACKsize is 4K, when int1/int3 trap happens, kernel will minus currentDEBUG_STACKIST value by 4k. But if int3/int1 trap is nested, it will destroy other vector's IST stack. This patch modifies this, it setsDEBUG_STACKsize as 8K and allows two level of nested int1/int3 trap.Kprobe
DEBUG_STACKmay be nested, because kprobe hanlder may be probed
by other kprobes. This patch is against 2.6.17-rc3. Thanks jbeulich for pointing out error in the first patch.Signed-off-by bibo, mao <[email protected]>
include/asm-x86_64/page.h line 26
Quoted 8 lines
include/asm-x86_64/page.h +1
-1@@ -20,7 +20,7 @@#define EXCEPTION_STACK_ORDER 0#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER) -#define DEBUG_STACK_ORDER EXCEPTION_STACK_ORDER +#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)#define IRQSTACK_ORDER 2
So.... why not do it this way?
include/asm-x86_64/page.h renamed from include/asm-x86_64/page.h~x86_64-kprobes-debug_stack-nesting-fix +8 -0
@@ -20,7 +20,15 @@#define EXCEPTION_STACK_ORDER 0#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER) +#ifdef CONFIG_KPROBES +/* +* kprobes uses an 8k stack because int1/int3 exceptions can nest +*/ +#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1) +#else #define DEBUG_STACK_ORDER EXCEPTION_STACK_ORDER +#endif +#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)#define IRQSTACK_ORDER 2
_
Quoted 21 lines · Andrew Morton
Quoted 20 lines · bibo,mao
Hi,
Inx86_64platform, INT1 and INT3 trap stack is IST stack calledDEBUG_STACK, when INT1/INT3 trap happens, system will switch toDEBUG_STACKby hardware. CurrentDEBUG_STACKsize is 4K, when int1/int3 trap happens, kernel will minus currentDEBUG_STACKIST value by 4k. But if int3/int1 trap is nested, it will destroy other vector's IST stack. This patch modifies this, it setsDEBUG_STACKsize as 8K and allows two level of nested int1/int3 trap.Kprobe
DEBUG_STACKmay be nested, because kprobe hanlder may be probed
by other kprobes. This patch is against 2.6.17-rc3. Thanks jbeulich for pointing out error in the first patch.Signed-off-by bibo, mao <[email protected]>include/asm-x86_64/page.h +0
-0@@ -20,7 +20,7 @@#define EXCEPTION_STACK_ORDER 0#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
Quoted 7 lines
include/asm-x86_64/page.h line 34
Quoted 5 lines
include/asm-x86_64/page.h +1
-1-#define DEBUG_STACK_ORDER EXCEPTION_STACK_ORDER +#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)#define IRQSTACK_ORDER 2So.... why not do it this way?
Last time we discussed this I was told it could nest upto 3 or 4 times So that still wouldn't work.
If anything they should decrease the int3/debug stack to 2K, then 8K might be enough.
Or even better would be to fix kprobes to not do that.
I think paranoidentry would need to be fixed for that too.
-Andi
Sorry for late reply, interrupt is disabled when int3/int1 trap happens and NMI is not permitted for kprobe in x86_64 platform,nest level of kprobe is 2 at most. So that will work well if DEBUG_STACK is set to 8K when CONFIG_KPROBE option is set.
Thanks
bibo,mao
Quoted 40 lines · Andi Kleen
Quoted 15 lines · Andrew Morton
Quoted 14 lines · bibo,mao
Hi,
Inx86_64platform, INT1 and INT3 trap stack is IST stack calledDEBUG_STACK,
when INT1/INT3 trap happens, system will switch toDEBUG_STACKby hardware. CurrentDEBUG_STACKsize is 4K, when int1/int3 trap happens, kernel will minus currentDEBUG_STACKIST value by 4k. But if int3/int1 trap is nested, it will destroy other vector's IST stack. This patch modifies this, it setsDEBUG_STACKsize as 8K and allows two level of nested int1/int3 trap.Kprobe
DEBUG_STACKmay be nested, because kprobe hanlder may be probed by other kprobes. This patch is against 2.6.17-rc3. Thanks jbeulich for pointing out error in the first patch.Signed-off-by bibo, mao <[email protected]>include/asm-x86_64/page.h +0
-0@@ -20,7 +20,7 @@#define EXCEPTION_STACK_ORDER 0#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)Quoted 6 lines
include/asm-x86_64/page.h line 34
Quoted 5 lines
include/asm-x86_64/page.h +1
-1-#define DEBUG_STACK_ORDER EXCEPTION_STACK_ORDER +#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)#define IRQSTACK_ORDER 2So.... why not do it this way?
Last time we discussed this I was told it could nest upto 3 or 4 times So that still wouldn't work.
If anything they should decrease the int3/debug stack to 2K, then 8K might be enough.
Or even better would be to fix kprobes to not do that.
I think paranoidentry would need to be fixed for that too.
(quoted diff) +0
-2-Andi -To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/