[CRIU] [PATCH 5/7] sigframe: Use blkset from ctl
Pavel Emelyanov
xemul at virtuozzo.com
Mon Sep 26 03:20:40 PDT 2016
When constructing sigframe for parasite, we my use ctl's blkset,
not the CoreEntry's one. This simplifies further patching.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/cr-restore.c | 9 +++++++--
criu/include/sigframe.h | 1 +
criu/parasite-syscall.c | 2 +-
criu/sigframe.c | 16 +++++++---------
4 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 7358794..1ab01d8 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -3053,6 +3053,7 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
for (i = 0; i < current->nr_threads; i++) {
CoreEntry *tcore;
struct rt_sigframe *sigframe;
+ k_rtsigset_t *blkset = NULL;
thread_args[i].pid = current->threads[i].virt;
thread_args[i].siginfo_n = siginfo_priv_nr[i];
@@ -3064,8 +3065,12 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
if (thread_args[i].pid == pid) {
task_args->t = thread_args + i;
tcore = core;
- } else
+ blkset = (void *)&tcore->tc->blk_sigset;
+ } else {
tcore = current->core[i];
+ if (tcore->thread_core->has_blk_sigset)
+ blkset = (void *)&tcore->thread_core->blk_sigset;
+ }
if ((tcore->tc || tcore->ids) && thread_args[i].pid != pid) {
pr_err("Thread has optional fields present %d\n",
@@ -3102,7 +3107,7 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
thread_args[i].mz = mz + i;
sigframe = (struct rt_sigframe *)&mz[i].rt_sigframe;
- if (construct_sigframe(sigframe, sigframe, tcore))
+ if (construct_sigframe(sigframe, sigframe, blkset, tcore))
goto err;
if (thread_args[i].pid != pid)
diff --git a/criu/include/sigframe.h b/criu/include/sigframe.h
index 6ee5fd7..1bb0fb9 100644
--- a/criu/include/sigframe.h
+++ b/criu/include/sigframe.h
@@ -52,6 +52,7 @@ struct rt_ucontext {
extern int construct_sigframe(struct rt_sigframe *sigframe,
struct rt_sigframe *rsigframe,
+ k_rtsigset_t *blkset,
CoreEntry *core);
#endif /* __CR_SIGFRAME_H__ */
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index cebb740..bbbcb0c 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -1439,7 +1439,7 @@ static int parasite_start_daemon(struct parasite_ctl *ctl, struct pstree_item *i
return -1;
}
- if (construct_sigframe(ctl->sigframe, ctl->rsigframe, item->core[0]))
+ if (construct_sigframe(ctl->sigframe, ctl->rsigframe, &ctl->orig.sigmask, item->core[0]))
return -1;
if (parasite_init_daemon(ctl))
diff --git a/criu/sigframe.c b/criu/sigframe.c
index be471a8..1304d36 100644
--- a/criu/sigframe.c
+++ b/criu/sigframe.c
@@ -27,10 +27,17 @@ static inline void setup_sas(struct rt_sigframe* sigframe, ThreadSasEntry *sas)
int construct_sigframe(struct rt_sigframe *sigframe,
struct rt_sigframe *rsigframe,
+ k_rtsigset_t *blkset,
CoreEntry *core)
{
k_rtsigset_t *blk_sigset;
+ blk_sigset = RT_SIGFRAME_UC_SIGMASK(sigframe);
+ if (blk_sigset)
+ memcpy(blk_sigset, blkset, sizeof(k_rtsigset_t));
+ else
+ memset(blk_sigset, 0, sizeof(k_rtsigset_t));
+
/*
* Copy basic register set in the first place: this will set
* rt_sigframe type: native/compat.
@@ -38,15 +45,6 @@ int construct_sigframe(struct rt_sigframe *sigframe,
if (restore_gpregs(sigframe, CORE_THREAD_ARCH_INFO(core)->gpregs))
return -1;
- blk_sigset = RT_SIGFRAME_UC_SIGMASK(sigframe);
- if (core->tc)
- memcpy(blk_sigset, &core->tc->blk_sigset, sizeof(k_rtsigset_t));
- else if (core->thread_core->has_blk_sigset) {
- memcpy(blk_sigset,
- &core->thread_core->blk_sigset, sizeof(k_rtsigset_t));
- } else
- memset(blk_sigset, 0, sizeof(k_rtsigset_t));
-
if (restore_fpu(sigframe, core))
return -1;
--
2.5.0
More information about the CRIU
mailing list