hw_x86_64: Restore registers to client context values

Set the stack pointer to the R8 field in the client context to enable
restoring registers by popping values of the stack.

After this step the only remaining registers that do not contain client
values are RAX, RSP and RIP.

Note that the client value of RAX is pop'd to the global buffer region as
the register will still be used by subsequent steps. It will be restored to
the value in the buffer area just prior to resuming client code execution.
This commit is contained in:
Adrian-Ken Rueegsegger 2015-02-18 00:37:52 +01:00 committed by Christian Helmuth
parent 60e799f7b4
commit 172dec209b
1 changed files with 18 additions and 0 deletions

View File

@ -97,6 +97,24 @@
mov %rbx, %fs
mov %rbx, %gs
/* Restore register values from client context */
lea R8_OFFSET(%rax), %rsp
popq %r8
popq %r9
popq %r10
popq %r11
popq %r12
popq %r13
popq %r14
popq %r15
popq _mt_buffer
popq %rbx
popq %rcx
popq %rdx
popq %rdi
popq %rsi
popq %rbp
1: jmp 1b
/* end of the mode transition code */