mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-06 22:01:29 +00:00
[LibOS] Modify restore_context() to avoid clobbering redzone.
restore_context() happens to use %rsp - 8 to return which is in redzone. which clobbers redzone. It shouldn't be clobered. So far it seems we're simply lucky. Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
This commit is contained in:
committed by
Don Porter
parent
6e0d803285
commit
8cb262d0c0
@@ -1253,8 +1253,10 @@ void restore_context (struct shim_context * context)
|
||||
|
||||
debug("restore context: SP = %p, IP = %p\n", context->sp, context->ret_ip);
|
||||
|
||||
regs[nregs] = (void *) context->sp - 8;
|
||||
*(void **) (context->sp - 8) = context->ret_ip;
|
||||
regs[nregs] = (void *) context->sp;
|
||||
/* don't clobber redzone. If sigaltstack is used,
|
||||
* this area won't be clobbered by signal context */
|
||||
*(void **) (context->sp - 128 - 8) = context->ret_ip;
|
||||
|
||||
/* Ready to resume execution, re-enable preemption. */
|
||||
shim_tcb_t * tcb = SHIM_GET_TLS();
|
||||
@@ -1279,6 +1281,6 @@ void restore_context (struct shim_context * context)
|
||||
"popq %%rbp\r\n"
|
||||
"popq %%rsp\r\n"
|
||||
"movq $0, %%rax\r\n"
|
||||
"retq\r\n"
|
||||
"jmp *-128-8(%%rsp)\r\n"
|
||||
:: "g"(®s) : "memory");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user