From 172dec209bddc3fa0432a4cc6e8ddfb5f8d9b0ad Mon Sep 17 00:00:00 2001 From: Adrian-Ken Rueegsegger Date: Wed, 18 Feb 2015 00:37:52 +0100 Subject: [PATCH] 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. --- .../src/core/spec/x86_64/mode_transition.s | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/repos/base-hw/src/core/spec/x86_64/mode_transition.s b/repos/base-hw/src/core/spec/x86_64/mode_transition.s index 1bfbdea40..0883118b6 100644 --- a/repos/base-hw/src/core/spec/x86_64/mode_transition.s +++ b/repos/base-hw/src/core/spec/x86_64/mode_transition.s @@ -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 */