diff options
author | tjr <tjr@FreeBSD.org> | 2004-06-07 21:25:16 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2004-06-07 21:25:16 +0000 |
commit | bdd43780eb39d1fee337e602d016b6e3b0114ba2 (patch) | |
tree | 2dcef51980e9fd6c8f42da383ad65057a8d4a345 /lib/libkse | |
parent | 217bb961dbcafb033404a3a249ee50691ff5bd88 (diff) | |
download | FreeBSD-src-bdd43780eb39d1fee337e602d016b6e3b0114ba2.zip FreeBSD-src-bdd43780eb39d1fee337e602d016b6e3b0114ba2.tar.gz |
Avoid clobbering the red zone when running on the new context's stack in
_amd64_restore_context().
Diffstat (limited to 'lib/libkse')
-rw-r--r-- | lib/libkse/arch/amd64/amd64/context.S | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/libkse/arch/amd64/amd64/context.S b/lib/libkse/arch/amd64/amd64/context.S index 58c622b..2510021 100644 --- a/lib/libkse/arch/amd64/amd64/context.S +++ b/lib/libkse/arch/amd64/amd64/context.S @@ -109,6 +109,8 @@ __FBSDID("$FreeBSD$"); #define MC_RFLAGS (22 * 8) #define MC_RSP (23 * 8) +#define REDZONE 128 /* size of the red zone */ + /* * _amd64_ctx_save(mcontext_t *mcp) * @@ -188,6 +190,7 @@ ENTRY(_amd64_restore_context) 4: fninit fldcw MC_FP_CW_OFFSET(%rdi) 5: movq MC_RSP(%rdi), %rsp /* switch to context stack */ + subq $REDZONE, %rsp movq MC_RIP(%rdi), %rax /* return address on stack */ pushq %rax movq MC_RDI(%rdi), %rax /* rdi on stack */ @@ -207,4 +210,6 @@ ENTRY(_amd64_restore_context) popq %rsi /* restore rsi, rdx, and rdi */ popq %rdx popq %rdi + leaq (8 + REDZONE)(%rsp), %rsp + jmp *-(8 + REDZONE)(%rsp) /* jump to return address */ 7: ret |