[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:
Isaku Yamahata
2019-02-11 16:17:50 -05:00
committed by Don Porter
parent 6e0d803285
commit 8cb262d0c0
+5 -3
View File
@@ -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"(&regs) : "memory");
}