sort x86_basic_regs into user_regs_struct's order
This commit is contained in:
@ -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)
|
||||||
|
|||||||
@ -24,39 +24,45 @@
|
|||||||
#define USER_CS (48 + 3)
|
#define USER_CS (48 + 3)
|
||||||
#define USER_DS (56 + 3)
|
#define USER_DS (56 + 3)
|
||||||
|
|
||||||
#define PUSH_ALL_REGS \
|
/* struct x86_user_context */
|
||||||
pushq %rbp; \
|
#define RAX_OFFSET 80
|
||||||
pushq %rax; \
|
#define ERROR_OFFSET 120
|
||||||
pushq %rbx; \
|
#define RSP_OFFSET 152
|
||||||
pushq %rcx; \
|
|
||||||
pushq %rdx; \
|
#define PUSH_ALL_REGS \
|
||||||
pushq %rsi; \
|
pushq %rdi; \
|
||||||
pushq %rdi; \
|
pushq %rsi; \
|
||||||
pushq %r8; \
|
pushq %rdx; \
|
||||||
pushq %r9; \
|
pushq %rcx; \
|
||||||
pushq %r10; \
|
pushq %rax; \
|
||||||
pushq %r11; \
|
pushq %r8; \
|
||||||
pushq %r12; \
|
pushq %r9; \
|
||||||
pushq %r13; \
|
pushq %r10; \
|
||||||
pushq %r14; \
|
pushq %r11; \
|
||||||
pushq %r15;
|
pushq %rbx; \
|
||||||
#define POP_ALL_REGS \
|
pushq %rbp; \
|
||||||
popq %r15; \
|
pushq %r12; \
|
||||||
popq %r14; \
|
pushq %r13; \
|
||||||
popq %r13; \
|
pushq %r14; \
|
||||||
popq %r12; \
|
pushq %r15
|
||||||
popq %r11; \
|
|
||||||
popq %r10; \
|
#define POP_ALL_REGS \
|
||||||
popq %r9; \
|
popq %r15; \
|
||||||
popq %r8; \
|
popq %r14; \
|
||||||
popq %rdi; \
|
popq %r13; \
|
||||||
popq %rsi; \
|
popq %r12; \
|
||||||
popq %rdx; \
|
popq %rbp; \
|
||||||
popq %rcx; \
|
popq %rbx; \
|
||||||
popq %rbx; \
|
popq %r11; \
|
||||||
popq %rax; \
|
popq %r10; \
|
||||||
popq %rbp
|
popq %r9; \
|
||||||
|
popq %r8; \
|
||||||
|
popq %rax; \
|
||||||
|
popq %rcx; \
|
||||||
|
popq %rdx; \
|
||||||
|
popq %rsi; \
|
||||||
|
popq %rdi
|
||||||
|
|
||||||
.data
|
.data
|
||||||
.globl generic_common_handlers
|
.globl generic_common_handlers
|
||||||
generic_common_handlers:
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user