From 40862a81ebf72cd92dfd1539b90548f9e08291b2 Mon Sep 17 00:00:00 2001 From: Adrian-Ken Rueegsegger Date: Wed, 18 Feb 2015 00:26:33 +0100 Subject: [PATCH] hw_x86_64: Prepare interrupt stack frame in mode transition buffer Setup an IA-32e interrupt stack frame in the mode transition buffer region. It will be used to perform the mode switch to userspace using the iret instruction. For detailed information about the IA-32e interrupt stack frame refer to Intel SDM Vol. 3A, figure 6-8. --- repos/base-hw/src/core/spec/x86_64/mode_transition.s | 10 ++++++++++ 1 file changed, 10 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 a3c742d9c..cc5c216c6 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 @@ -75,6 +75,16 @@ .global _mt_user_entry_pic _mt_user_entry_pic: + + /* Prepare stack frame in mt buffer (Intel SDM Vol. 3A, figure 6-8) */ + mov _mt_client_context_ptr, %rax + mov $_mt_buffer+BUFFER_SIZE, %rsp + pushq $0x23 + pushq SP_OFFSET(%rax) + pushq $0x3000 /* XXX: Set Interrupt Enable flag */ + pushq $0x1b + pushq (%rax) + 1: jmp 1b /* end of the mode transition code */