mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Avoid clobbering the red zone when running on the new context's stack in
_amd64_restore_context().
This commit is contained in:
parent
4559c1817b
commit
bf1d6a62b0
2 changed files with 10 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue