sort x86_basic_regs into user_regs_struct's order

This commit is contained in:
NAKAMURA Gou
2015-02-25 21:22:48 +09:00
parent fab2c2aa97
commit 4aa8ba2eef
2 changed files with 50 additions and 46 deletions

View File

@ -179,9 +179,9 @@ struct tss64 {
} __attribute__((packed)); } __attribute__((packed));
struct x86_basic_regs { struct x86_basic_regs {
unsigned long r15, r14, r13, r12, r11, r10, r9, r8; unsigned long r15, r14, r13, r12, rbp, rbx, r11, r10;
unsigned long rdi, rsi, rdx, rcx, rbx, rax, rbp; unsigned long r9, r8, rax, rcx, rdx, rsi, rdi, error;
unsigned long error, rip, cs, rflags, rsp, ss; unsigned long rip, cs, rflags, rsp, ss;
}; };
#define REGS_GET_STACK_POINTER(regs) (((struct x86_regs *)regs)->rsp) #define REGS_GET_STACK_POINTER(regs) (((struct x86_regs *)regs)->rsp)

View File

@ -24,38 +24,44 @@
#define USER_CS (48 + 3) #define USER_CS (48 + 3)
#define USER_DS (56 + 3) #define USER_DS (56 + 3)
/* struct x86_user_context */
#define RAX_OFFSET 80
#define ERROR_OFFSET 120
#define RSP_OFFSET 152
#define PUSH_ALL_REGS \ #define PUSH_ALL_REGS \
pushq %rbp; \
pushq %rax; \
pushq %rbx; \
pushq %rcx; \
pushq %rdx; \
pushq %rsi; \
pushq %rdi; \ pushq %rdi; \
pushq %rsi; \
pushq %rdx; \
pushq %rcx; \
pushq %rax; \
pushq %r8; \ pushq %r8; \
pushq %r9; \ pushq %r9; \
pushq %r10; \ pushq %r10; \
pushq %r11; \ pushq %r11; \
pushq %rbx; \
pushq %rbp; \
pushq %r12; \ pushq %r12; \
pushq %r13; \ pushq %r13; \
pushq %r14; \ pushq %r14; \
pushq %r15; pushq %r15
#define POP_ALL_REGS \ #define POP_ALL_REGS \
popq %r15; \ popq %r15; \
popq %r14; \ popq %r14; \
popq %r13; \ popq %r13; \
popq %r12; \ popq %r12; \
popq %rbp; \
popq %rbx; \
popq %r11; \ popq %r11; \
popq %r10; \ popq %r10; \
popq %r9; \ popq %r9; \
popq %r8; \ popq %r8; \
popq %rdi; \
popq %rsi; \
popq %rdx; \
popq %rcx; \
popq %rbx; \
popq %rax; \ popq %rax; \
popq %rbp popq %rcx; \
popq %rdx; \
popq %rsi; \
popq %rdi
.data .data
.globl generic_common_handlers .globl generic_common_handlers
@ -75,7 +81,7 @@ vector=vector+1
common_interrupt: common_interrupt:
PUSH_ALL_REGS PUSH_ALL_REGS
movq 120(%rsp), %rdi movq ERROR_OFFSET(%rsp), %rdi
movq %rsp, %rsi movq %rsp, %rsi
call handle_interrupt /* Enter C code */ call handle_interrupt /* Enter C code */
POP_ALL_REGS POP_ALL_REGS
@ -91,7 +97,7 @@ page_fault:
cld cld
PUSH_ALL_REGS PUSH_ALL_REGS
movq %cr2, %rdi movq %cr2, %rdi
movq 120(%rsp),%rsi movq ERROR_OFFSET(%rsp),%rsi
movq %rsp,%rdx movq %rsp,%rdx
movq __page_fault_handler_address(%rip), %rax movq __page_fault_handler_address(%rip), %rax
andq %rax, %rax andq %rax, %rax
@ -116,7 +122,7 @@ general_protection_exception:
.globl x86_syscall .globl x86_syscall
x86_syscall: x86_syscall:
cld cld
movq %rsp, %gs:24 movq %rsp, %gs:X86_CPU_LOCAL_OFFSET_USTACK
movq %gs:(X86_CPU_LOCAL_OFFSET_SP0), %rsp movq %gs:(X86_CPU_LOCAL_OFFSET_SP0), %rsp
pushq $(USER_DS) pushq $(USER_DS)
@ -124,21 +130,19 @@ x86_syscall:
pushq %r11 pushq %r11
pushq $(USER_CS) pushq $(USER_CS)
pushq %rcx pushq %rcx
pushq $0 pushq %rax /* error code (= system call number) */
movq %gs:24, %rcx
movq %rcx, 32(%rsp)
PUSH_ALL_REGS PUSH_ALL_REGS
movq 104(%rsp), %rdi movq %gs:X86_CPU_LOCAL_OFFSET_USTACK, %rcx
movq %rcx, RSP_OFFSET(%rsp)
movq RAX_OFFSET(%rsp), %rdi
movw %ss, %ax movw %ss, %ax
movw %ax, %ds movw %ax, %ds
movq %rsp, %rsi movq %rsp, %rsi
callq *__x86_syscall_handler(%rip) callq *__x86_syscall_handler(%rip)
1: 1:
movq %rax, 104(%rsp) movq %rax, RAX_OFFSET(%rsp)
POP_ALL_REGS POP_ALL_REGS
#ifdef USE_SYSRET #ifdef USE_SYSRET
movq 8(%rsp), %rcx
movq 24(%rsp), %r11
movq 32(%rsp), %rsp movq 32(%rsp), %rsp
sysretq sysretq
#else #else