From 31a605f94b9ed20ff849214730697f9fab00fe02 Mon Sep 17 00:00:00 2001 From: "Balazs Gerofi bgerofi@riken.jp" Date: Thu, 10 Jul 2014 13:53:12 +0900 Subject: [PATCH] push/pop r15 when entering/leaving kernel space (fix for bug #53: r15 wasn't propagated during fork()) --- arch/x86/kernel/include/registers.h | 2 +- arch/x86/kernel/interrupt.S | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/include/registers.h b/arch/x86/kernel/include/registers.h index 97889b6e..0e9dca07 100644 --- a/arch/x86/kernel/include/registers.h +++ b/arch/x86/kernel/include/registers.h @@ -136,7 +136,7 @@ struct tss64 { } __attribute__((packed)); struct x86_regs { - unsigned long r11, r10, r9, r8; + unsigned long r15, r11, r10, r9, r8; unsigned long rdi, rsi, rdx, rcx, rbx, rax, rbp; unsigned long error, rip, cs, rflags, rsp, ss; }; diff --git a/arch/x86/kernel/interrupt.S b/arch/x86/kernel/interrupt.S index e814afa4..d0a0838b 100644 --- a/arch/x86/kernel/interrupt.S +++ b/arch/x86/kernel/interrupt.S @@ -35,8 +35,10 @@ pushq %r8; \ pushq %r9; \ pushq %r10; \ - pushq %r11; + pushq %r11; \ + pushq %r15; #define POP_ALL_REGS \ + popq %r15; \ popq %r11; \ popq %r10; \ popq %r9; \ @@ -67,7 +69,7 @@ vector=vector+1 common_interrupt: PUSH_ALL_REGS - movq 88(%rsp), %rdi + movq 96(%rsp), %rdi movq %rsp, %rsi call handle_interrupt /* Enter C code */ POP_ALL_REGS @@ -83,7 +85,7 @@ page_fault: cld PUSH_ALL_REGS movq %cr2, %rdi - movq 88(%rsp),%rsi + movq 96(%rsp),%rsi movq %rsp,%rdx movq __page_fault_handler_address(%rip), %rax andq %rax, %rax @@ -120,13 +122,13 @@ x86_syscall: movq %gs:24, %rcx movq %rcx, 32(%rsp) PUSH_ALL_REGS - movq 72(%rsp), %rdi + movq 80(%rsp), %rdi movw %ss, %ax movw %ax, %ds movq %rsp, %rsi callq *__x86_syscall_handler(%rip) 1: - movq %rax, 72(%rsp) + movq %rax, 80(%rsp) POP_ALL_REGS #ifdef USE_SYSRET movq 8(%rsp), %rcx