From 5b6748b4c90f711bbfcbb1127e42d75a20cecc7f Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Sat, 29 Oct 2011 20:42:45 +0400 Subject: [PATCH] restore: Call for sigreturn Prepare the stack value and do a syscall. Still it fails because of stack corruption I think and due to lack of setup of several important values on thread-info area. Signed-off-by: Cyrill Gorcunov --- restorer.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/restorer.c b/restorer.c index e6a226bde..8f811fad2 100644 --- a/restorer.c +++ b/restorer.c @@ -301,8 +301,6 @@ self_len_end: sys_close(fd_core); - goto core_restore_end; - /* * We need to prepare a valid sigframe here, so * after sigreturn the kernel will pick up the @@ -355,8 +353,22 @@ self_len_end: /* FIXME: What with cr2 and friends which are rest there? */ - /* Finally call for sigreturn */ - sys_rt_sigreturn(); + write_hex_n(__LINE__); + + /* + * Prepare the stack and call for sigreturn, + * pure assembly since we don't need any additional + * code insns from gcc. + */ + asm volatile( + "movq %0, %%rax \t\n" + "movq %%rax, %%rsp \t\n" + "movl $"__stringify(__NR_rt_sigreturn)", %%eax \t\n" + "syscall \t\n" + : + : "r"((long)rt_sigframe + sizeof(*rt_sigframe)) + : "rax","rsp","memory"); + core_restore_end: write_hex_n(sys_getpid());