[CRIU] [PATCH 09/14] restore: set up correct sa_restorer for SIGCHLD handler (v3)
Andrey Vagin
avagin at openvz.org
Mon Mar 25 10:37:52 EDT 2013
Alexander, could you help me with ARM? I found in glibc sources, that
sa_restoer should look like this:
ports/sysdeps/unix/sysv/linux/arm/sigrestorer.S
....
ENTRY(__cr_restore_rt)
CFI
mov r7, $SYS_ify(rt_sigreturn)
swi 0x0
.fnend
END(__cr_restore_rt)
v2: Move architecture-dependent code in the proper place
v3: Don't add a separate handler for collecting zombies
Cc: Alexander Kartashov <alekskartashov at parallels.com>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
arch/arm/include/asm/types.h | 2 ++
arch/x86/include/asm/types.h | 2 ++
arch/x86/syscall-common-x86-64.S | 5 +++++
pie/restorer.c | 9 ++++++++-
4 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/types.h b/arch/arm/include/asm/types.h
index 715d1c8..5a97cdf 100644
--- a/arch/arm/include/asm/types.h
+++ b/arch/arm/include/asm/types.h
@@ -99,6 +99,8 @@ static inline void ksigfillset(k_rtsigset_t *set)
set->sig[i] = (unsigned long)-1;
}
+#define SA_RESTORER 0x04000000
+
typedef struct {
rt_sighandler_t rt_sa_handler;
unsigned long rt_sa_flags;
diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h
index 79fd448..83e351b 100644
--- a/arch/x86/include/asm/types.h
+++ b/arch/x86/include/asm/types.h
@@ -108,6 +108,8 @@ static inline void ksigfillset(k_rtsigset_t *set)
set->sig[i] = (unsigned long)-1;
}
+#define SA_RESTORER 0x04000000
+
typedef struct {
rt_sighandler_t rt_sa_handler;
unsigned long rt_sa_flags;
diff --git a/arch/x86/syscall-common-x86-64.S b/arch/x86/syscall-common-x86-64.S
index a549207..b93c312 100644
--- a/arch/x86/syscall-common-x86-64.S
+++ b/arch/x86/syscall-common-x86-64.S
@@ -14,3 +14,8 @@ ENTRY(__syscall_common)
syscall
ret
END(__syscall_common)
+
+ENTRY(__cr_restore_rt)
+ movq $__NR_rt_sigreturn, %rax
+ syscall
+END(__cr_restore_rt)
diff --git a/pie/restorer.c b/pie/restorer.c
index 84616fb..17f2ac3 100644
--- a/pie/restorer.c
+++ b/pie/restorer.c
@@ -11,6 +11,7 @@
#include <unistd.h>
#include <sched.h>
#include <sys/resource.h>
+#include <signal.h>
#include "compiler.h"
#include "asm/types.h"
@@ -39,6 +40,9 @@
static struct task_entries *task_entries;
static futex_t thread_inprogress;
+extern void cr_restore_rt (void) asm ("__cr_restore_rt")
+ __attribute__ ((visibility ("hidden")));
+
static void sigchld_handler(int signal, siginfo_t *siginfo, void *data)
{
char *r;
@@ -433,8 +437,11 @@ long __export_restore_task(struct task_restore_core_args *args)
rt_sigaction_t act;
task_entries = args->task_entries;
- sys_sigaction(SIGCHLD, NULL, &act, sizeof(k_rtsigset_t));
+
+ ksigfillset(&act.rt_sa_mask);
act.rt_sa_handler = sigchld_handler;
+ act.rt_sa_flags = SA_SIGINFO | SA_RESTORER | SA_RESTART;
+ act.rt_sa_restorer = cr_restore_rt;
sys_sigaction(SIGCHLD, &act, NULL, sizeof(k_rtsigset_t));
log_set_fd(args->logfd);
--
1.7.11.7
More information about the CRIU
mailing list