diff options
author | Frans Kaashoek <[email protected]> | 2018-09-29 08:30:50 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2018-09-29 08:34:41 -0400 |
commit | 3bfcaeaf015ffe0d92937c023e9a0086909a0161 (patch) | |
tree | da9f7348ceff53f913ce82209e91959a8c347ebd /trapasm.S | |
parent | 322990649b35c893931a9ce67d4ccb25883c7446 (diff) | |
download | xv6-labs-3bfcaeaf015ffe0d92937c023e9a0086909a0161.tar.gz xv6-labs-3bfcaeaf015ffe0d92937c023e9a0086909a0161.tar.bz2 xv6-labs-3bfcaeaf015ffe0d92937c023e9a0086909a0161.zip |
Make sysexit and trapret paths the same, so that forkret can return through
either path. This helped tracking down a bug: use 144 instead of 32 to find cs
in trapframe so that gs is correctly saved and restored.
For good measure update linker script, because newer versions of GCC sometimes
places symbols passed end.
Diffstat (limited to 'trapasm.S')
-rw-r--r-- | trapasm.S | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -22,7 +22,7 @@ alltraps: push %rbx push %rax - cmpw $KCSEG, 32(%rsp) # compare to saved cs + cmpw $KCSEG, 144(%rsp) # compare to saved cs jz 1f swapgs @@ -33,7 +33,7 @@ alltraps: .globl trapret trapret: cli - cmpw $KCSEG, 32(%rsp) # compare to saved cs + cmpw $KCSEG, 144(%rsp) # compare to saved cs jz 1f swapgs @@ -72,12 +72,12 @@ sysentry: # Build trap frame. movq %rax, %rsp movq %gs:0, %rax // restore rax - // push usp - push $0 + // push usp to make a valid trapframe + push $(UDSEG|0x3) push %gs:8 // safe eflags and eip push %r11 - push $UCSEG + push $(UCSEG|0x3) push %rcx // push errno and trapno to make stack look like a trap push $0 @@ -130,6 +130,7 @@ sysexit: 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 sysretq |