Commit c66551bf authored by Florian Schmaus's avatar Florian Schmaus
Browse files

[Context] Use 'jmp' instead of 'ret' to kickoff the context

parent ba7564c3
......@@ -74,12 +74,11 @@ Context::Context(func_t mainFunction)
setEmptyHook();
// We write the real kickoff function's address at
// TOS - 2 so it's called after this context has been actived.
// This also ensures that the stack is correctly aligned for
// SSE operations, which require the stack to be 8-byte, but
// not 16-byte aligned.
alphaFunctionIpLocation = savedStackpointer = (uintptr_t*)tos - 2;
// TOS is 16-byte aligned, however we need the initial
// savedStackpointer to be 8-byte aligned because will later jmp to
// it. We also save a pointer to very first function this context is
// going to execute a this initial stackpointer value.
alphaFunctionIpLocation = savedStackpointer = (uintptr_t*)tos - 1;
void** alphaSavedIp = reinterpret_cast<void**>(savedStackpointer);
void (*f)() = &kickoff;
......
......@@ -58,6 +58,5 @@ switch_context:
; which must point to a word which represent the memory address
; where we want to continue.
mov rsp, [rdi]
; Pop the memory address where to continue from the
; stack. Which means: Continue at [rsp].
ret
; Jump to the address rsp currently points at.
jmp [rsp]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment