qubes-linux-kernel/patches.xen/xen3-stack-unwind

125 lines
3.5 KiB
Plaintext
Raw Normal View History

Subject: DWARF2 EH-frame based stack unwinding
From: jbeulich@novell.com
Patch-mainline: no
This includes reverting f1883f86dea84fe47a71a39fc1afccc005915ed8.
Update Jan 17 2009 jeffm:
- Something in 2.6.29-rc1 tweaked the frame pointer code somehow, so I fixed
that up.
Automatically created from "patches.suse/stack-unwind" by xen-port-patches.py
--- head-2010-03-15.orig/arch/x86/include/mach-xen/asm/system.h 2010-02-24 12:33:54.000000000 +0100
+++ head-2010-03-15/arch/x86/include/mach-xen/asm/system.h 2010-01-25 13:43:44.000000000 +0100
@@ -122,12 +122,22 @@ do { \
#define __switch_canary_iparam
#endif /* CC_STACKPROTECTOR */
+/* The stack unwind code needs this but it pollutes traces otherwise */
+#ifdef CONFIG_UNWIND_INFO
+#define THREAD_RETURN_SYM \
+ ".globl thread_return\n" \
+ "thread_return:\n\t"
+#else
+#define THREAD_RETURN_SYM
+#endif
+
/* Save restore flags to clear handle leaking NT */
#define switch_to(prev, next, last) \
asm volatile(SAVE_CONTEXT \
"movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \
"movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */ \
"call __switch_to\n\t" \
+ THREAD_RETURN_SYM \
"movq "__percpu_arg([current_task])",%%rsi\n\t" \
__switch_canary \
"movq %P[thread_info](%%rsi),%%r8\n\t" \
--- head-2010-03-15.orig/arch/x86/kernel/entry_32-xen.S 2010-01-28 14:42:29.000000000 +0100
+++ head-2010-03-15/arch/x86/kernel/entry_32-xen.S 2010-01-25 15:45:18.000000000 +0100
@@ -1271,6 +1271,41 @@ END(spurious_interrupt_bug)
*/
.popsection
+#ifdef CONFIG_STACK_UNWIND
+ENTRY(arch_unwind_init_running)
+ CFI_STARTPROC
+ movl 4(%esp), %edx
+ movl (%esp), %ecx
+ leal 4(%esp), %eax
+ movl %ebx, PT_EBX(%edx)
+ xorl %ebx, %ebx
+ movl %ebx, PT_ECX(%edx)
+ movl %ebx, PT_EDX(%edx)
+ movl %esi, PT_ESI(%edx)
+ movl %edi, PT_EDI(%edx)
+ movl %ebp, PT_EBP(%edx)
+ movl %ebx, PT_EAX(%edx)
+ movl $__USER_DS, PT_DS(%edx)
+ movl $__USER_DS, PT_ES(%edx)
+ movl $__KERNEL_PERCPU, PT_FS(%edx)
+ movl $__KERNEL_STACK_CANARY, PT_GS(%edx)
+ movl %eax, PT_OLDESP(%edx)
+ movl 16(%esp), %eax
+ movl %ebx, PT_ORIG_EAX(%edx)
+ movl %ecx, PT_EIP(%edx)
+ movl 12(%esp), %ecx
+ movl $__KERNEL_CS, PT_CS(%edx)
+ movl %eax, 12(%esp)
+ movl 8(%esp), %eax
+ movl %ecx, 8(%esp)
+ movl %ebx, PT_EFLAGS(%edx)
+ movl PT_EBX(%edx), %ebx
+ movl $__KERNEL_DS, PT_OLDSS(%edx)
+ jmpl *%eax
+ CFI_ENDPROC
+ENDPROC(arch_unwind_init_running)
+#endif
+
ENTRY(kernel_thread_helper)
pushl $0 # fake return address for unwinder
CFI_STARTPROC
--- head-2010-03-15.orig/arch/x86/kernel/entry_64-xen.S 2010-03-17 14:25:44.000000000 +0100
+++ head-2010-03-15/arch/x86/kernel/entry_64-xen.S 2010-03-17 14:27:13.000000000 +0100
@@ -1160,6 +1160,40 @@ ENTRY(call_softirq)
CFI_ENDPROC
END(call_softirq)
+#ifdef CONFIG_STACK_UNWIND
+ENTRY(arch_unwind_init_running)
+ CFI_STARTPROC
+ movq %r15, R15(%rdi)
+ movq %r14, R14(%rdi)
+ xchgq %rsi, %rdx
+ movq %r13, R13(%rdi)
+ movq %r12, R12(%rdi)
+ xorl %eax, %eax
+ movq %rbp, RBP(%rdi)
+ movq %rbx, RBX(%rdi)
+ movq (%rsp), %r9
+ xchgq %rdx, %rcx
+ movq %rax, R11(%rdi)
+ movq %rax, R10(%rdi)
+ movq %rax, R9(%rdi)
+ movq %rax, R8(%rdi)
+ movq %rax, RAX(%rdi)
+ movq %rax, RCX(%rdi)
+ movq %rax, RDX(%rdi)
+ movq %rax, RSI(%rdi)
+ movq %rax, RDI(%rdi)
+ movq %rax, ORIG_RAX(%rdi)
+ movq %r9, RIP(%rdi)
+ leaq 8(%rsp), %r9
+ movq $__KERNEL_CS, CS(%rdi)
+ movq %rax, EFLAGS(%rdi)
+ movq %r9, RSP(%rdi)
+ movq $__KERNEL_DS, SS(%rdi)
+ jmpq *%rcx
+ CFI_ENDPROC
+END(arch_unwind_init_running)
+#endif
+
/*
* Some functions should be protected against kprobes
*/