1 #ifndef _ASM_X86_64_UNWIND_H
2 #define _ASM_X86_64_UNWIND_H
5 * Copyright (C) 2002-2006 Novell, Inc.
6 * Jan Beulich <jbeulich@novell.com>
7 * This code is released under version 2 of the GNU GPL.
10 #ifdef CONFIG_STACK_UNWIND
12 #include <linux/sched.h>
13 #include <asm/ptrace.h>
14 #include <asm/uaccess.h>
15 #include <asm/vsyscall.h>
17 struct unwind_frame_info
20 struct task_struct
*task
;
23 #define UNW_PC(frame) (frame)->regs.rip
24 #define UNW_SP(frame) (frame)->regs.rsp
25 #ifdef CONFIG_FRAME_POINTER
26 #define UNW_FP(frame) (frame)->regs.rbp
27 #define FRAME_RETADDR_OFFSET 8
28 #define FRAME_LINK_OFFSET 0
29 #define STACK_BOTTOM(tsk) (((tsk)->thread.rsp0 - 1) & ~(THREAD_SIZE - 1))
30 #define STACK_TOP(tsk) ((tsk)->thread.rsp0)
32 /* Might need to account for the special exception and interrupt handling
33 stacks here, since normally
34 EXCEPTION_STACK_ORDER < THREAD_ORDER < IRQSTACK_ORDER,
35 but the construct is needed only for getting across the stack switch to
36 the interrupt stack - thus considering the IRQ stack itself is unnecessary,
37 and the overhead of comparing against all exception handling stacks seems
39 #define STACK_LIMIT(ptr) (((ptr) - 1) & ~(THREAD_SIZE - 1))
41 #define UNW_REGISTER_INFO \
60 static inline void arch_unw_init_frame_info(struct unwind_frame_info
*info
,
61 /*const*/ struct pt_regs
*regs
)
66 static inline void arch_unw_init_blocked(struct unwind_frame_info
*info
)
68 extern const char thread_return
[];
70 memset(&info
->regs
, 0, sizeof(info
->regs
));
71 info
->regs
.rip
= (unsigned long)thread_return
;
72 info
->regs
.cs
= __KERNEL_CS
;
73 __get_user(info
->regs
.rbp
, (unsigned long *)info
->task
->thread
.rsp
);
74 info
->regs
.rsp
= info
->task
->thread
.rsp
;
75 info
->regs
.ss
= __KERNEL_DS
;
78 extern int arch_unwind_init_running(struct unwind_frame_info
*,
79 int (*callback
)(struct unwind_frame_info
*,
83 static inline int arch_unw_user_mode(const struct unwind_frame_info
*info
)
85 #if 0 /* This can only work when selector register saves/restores
86 are properly annotated (and tracked in UNW_REGISTER_INFO). */
87 return user_mode(&info
->regs
);
89 return (long)info
->regs
.rip
>= 0
90 || (info
->regs
.rip
>= VSYSCALL_START
&& info
->regs
.rip
< VSYSCALL_END
)
91 || (long)info
->regs
.rsp
>= 0;
97 #define UNW_PC(frame) ((void)(frame), 0)
99 static inline int arch_unw_user_mode(const void *info
)
106 #endif /* _ASM_X86_64_UNWIND_H */