[PATCH] x86_64: Allow nesting of int3 by default for kprobes

This unbreaks recursive kprobes which didn't work anymore
due to an earlier patch which converted the debug entry point
to use an IST.

This also allows nesting of the debug entry point too.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Andi Kleen 2006-01-16 01:56:39 +01:00 committed by Linus Torvalds
parent aa41eb9915
commit 5f8efbb96f
4 changed files with 14 additions and 17 deletions

View file

@ -43,6 +43,7 @@ int main(void)
ENTRY(irqcount); ENTRY(irqcount);
ENTRY(cpunumber); ENTRY(cpunumber);
ENTRY(irqstackptr); ENTRY(irqstackptr);
ENTRY(data_offset);
BLANK(); BLANK();
#undef ENTRY #undef ENTRY
#ifdef CONFIG_IA32_EMULATION #ifdef CONFIG_IA32_EMULATION
@ -66,8 +67,6 @@ int main(void)
DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address)); DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
DEFINE(pbe_next, offsetof(struct pbe, next)); DEFINE(pbe_next, offsetof(struct pbe, next));
BLANK(); BLANK();
#if DEBUG_STKSZ > EXCEPTION_STKSZ DEFINE(TSS_ist, offsetof(struct tss_struct, ist));
DEFINE(DEBUG_IST, DEBUG_STACK);
#endif
return 0; return 0;
} }

View file

@ -41,6 +41,7 @@
#include <asm/unistd.h> #include <asm/unistd.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/hw_irq.h> #include <asm/hw_irq.h>
#include <asm/page.h>
.code64 .code64
@ -674,9 +675,6 @@ ENTRY(spurious_interrupt)
/* error code is on the stack already */ /* error code is on the stack already */
/* handle NMI like exceptions that can happen everywhere */ /* handle NMI like exceptions that can happen everywhere */
#ifndef DEBUG_IST
# define DEBUG_IST 0
#endif
.macro paranoidentry sym, ist=0 .macro paranoidentry sym, ist=0
SAVE_ALL SAVE_ALL
cld cld
@ -695,11 +693,11 @@ ENTRY(spurious_interrupt)
movq ORIG_RAX(%rsp),%rsi movq ORIG_RAX(%rsp),%rsi
movq $-1,ORIG_RAX(%rsp) movq $-1,ORIG_RAX(%rsp)
.if \ist .if \ist
subq $EXCEPTION_STACK_SIZE, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp) subq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
.endif .endif
call \sym call \sym
.if \ist .if \ist
addq $EXCEPTION_STACK_SIZE, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp) addq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
.endif .endif
cli cli
.endm .endm
@ -918,7 +916,7 @@ KPROBE_ENTRY(debug)
INTR_FRAME INTR_FRAME
pushq $0 pushq $0
CFI_ADJUST_CFA_OFFSET 8 CFI_ADJUST_CFA_OFFSET 8
paranoidentry do_debug, DEBUG_IST paranoidentry do_debug, DEBUG_STACK
jmp paranoid_exit jmp paranoid_exit
CFI_ENDPROC CFI_ENDPROC
.previous .text .previous .text
@ -976,7 +974,7 @@ KPROBE_ENTRY(int3)
INTR_FRAME INTR_FRAME
pushq $0 pushq $0
CFI_ADJUST_CFA_OFFSET 8 CFI_ADJUST_CFA_OFFSET 8
paranoidentry do_int3, DEBUG_IST paranoidentry do_int3, DEBUG_STACK
jmp paranoid_exit jmp paranoid_exit
CFI_ENDPROC CFI_ENDPROC
.previous .text .previous .text

View file

@ -26,6 +26,13 @@
#define IRQSTACK_ORDER 2 #define IRQSTACK_ORDER 2
#define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER) #define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER)
#define STACKFAULT_STACK 1
#define DOUBLEFAULT_STACK 2
#define NMI_STACK 3
#define DEBUG_STACK 4
#define MCE_STACK 5
#define N_EXCEPTION_STACKS 5 /* hw limit: 7 */
#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1)) #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
#define LARGE_PAGE_SIZE (1UL << PMD_SHIFT) #define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)

View file

@ -273,13 +273,6 @@ struct thread_struct {
#define INIT_MMAP \ #define INIT_MMAP \
{ &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL } { &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
#define STACKFAULT_STACK 1
#define DOUBLEFAULT_STACK 2
#define NMI_STACK 3
#define DEBUG_STACK 4
#define MCE_STACK 5
#define N_EXCEPTION_STACKS 5 /* hw limit: 7 */
#define start_thread(regs,new_rip,new_rsp) do { \ #define start_thread(regs,new_rip,new_rsp) do { \
asm volatile("movl %0,%%fs; movl %0,%%es; movl %0,%%ds": :"r" (0)); \ asm volatile("movl %0,%%fs; movl %0,%%es; movl %0,%%ds": :"r" (0)); \
load_gs_index(0); \ load_gs_index(0); \