diff options
Diffstat (limited to 'trapasm.S')
-rw-r--r-- | trapasm.S | 78 |
1 files changed, 35 insertions, 43 deletions
@@ -25,7 +25,7 @@ alltraps: push %rbx push %rax - cmpw $KCSEG, CSOFF(%rsp) # compare to saved cs + cmpw $SEG_KCODE, CSOFF(%rsp) # compare to saved cs jz 1f swapgs @@ -36,7 +36,7 @@ alltraps: .globl trapret trapret: cli - cmpw $KCSEG, CSOFF(%rsp) # compare to saved cs + cmpw $SEG_KCODE, CSOFF(%rsp) # compare to saved cs jz 1f swapgs @@ -58,11 +58,12 @@ trapret: add $16, %rsp # discard trapnum and errorcode iretq + #PAGEBREAK! -# syscall_entry jumps here after syscall instruction +# syscall jumps here after syscall instruction .globl sysentry -sysentry: # Build trap frame. +sysentry: # Build syscall frame. // load kernel stack address swapgs movq %rax, %gs:0 // save %rax in syscallno of cpu entry @@ -75,63 +76,54 @@ sysentry: # Build trap frame. movq %rax, %rsp movq %gs:0, %rax // restore rax - // push usp to make a valid trapframe - push $(UDSEG|0x3) push %gs:8 - // safe eflags and eip - push %r11 - push $(UCSEG|0x3) push %rcx - // push errno and trapno to make stack look like a trap - push $0 - push $64 + push %r11 + push %rax - // push values on kernel stack - push %r15 - push %r14 + push %rbp + push %rbx + push %r12 push %r13 - push %r12 - push %r11 - push %r10 + push %r14 + push %r15 + push %r9 - push %r8 - push %rdi - push %rsi - push %rbp + push %r8 + push %r10 push %rdx - push %rcx - push %rbx - push %rax - + push %rsi + push %rdi + mov %rsp, %rdi # frame in arg1 - call trap -#PAGEBREAK! - -# Return falls through to trapret... + call syscall + # fall through to sysexit + .globl sysexit sysexit: # to make sure we don't get any interrupts on the user stack while in # supervisor mode. insufficient? (see vunerability reports for sysret) cli - - pop %rax - pop %rbx - pop %rcx - pop %rdx - pop %rbp - pop %rsi + pop %rdi + pop %rsi + pop %rdx + pop %r10 pop %r8 pop %r9 - pop %r10 - pop %r11 - pop %r12 - pop %r13 - pop %r14 + pop %r15 + pop %r14 + pop %r13 + pop %r12 + pop %rbx + pop %rbp + + pop %rax + pop %r11 + pop %rcx - add $(5*8), %rsp # discard trapnum, errorcode, rip, cs and rflags mov (%rsp),%rsp # switch to the user stack # there are two more values on the stack, but we don't care about them swapgs |