[CRIU] [PATCH 6/7] compel: Split arch_fetch_sas helper
Cyrill Gorcunov
gorcunov at openvz.org
Mon Mar 13 09:52:18 PDT 2017
Make it into two helpers which do the same
but with different types, for thread leader
and separate threads.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
compel/arch/aarch64/src/lib/infect.c | 9 +++++++--
compel/arch/arm/src/lib/infect.c | 9 +++++++--
compel/arch/ppc64/src/lib/infect.c | 9 +++++++--
compel/arch/x86/src/lib/infect.c | 17 ++++++++++++-----
compel/include/infect-priv.h | 3 ++-
compel/src/lib/infect.c | 2 +-
6 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/compel/arch/aarch64/src/lib/infect.c b/compel/arch/aarch64/src/lib/infect.c
index 166ec2363b63..11f9bb84b767 100644
--- a/compel/arch/aarch64/src/lib/infect.c
+++ b/compel/arch/aarch64/src/lib/infect.c
@@ -140,17 +140,22 @@ bool arch_can_dump_task(struct parasite_ctl *ctl)
return true;
}
-int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
+int arch_fetch_sas(struct parasite_ctl *ctl, stack_t *rsas)
{
long ret;
int err;
err = compel_syscall(ctl, __NR_sigaltstack,
- &ret, 0, (unsigned long)&s->uc.uc_stack,
+ &ret, 0, (unsigned long)rsas,
0, 0, 0, 0);
return err ? err : ret;
}
+int arch_fetch_sas_for_sigframe(struct parasite_ctl *ctl, struct rt_sigframe *s)
+{
+ return arch_fetch_sas(ctl, (stack_t *)&s->uc.uc_stack);
+}
+
/*
* Range for task size calculated from the following Linux kernel files:
* arch/arm64/include/asm/memory.h
diff --git a/compel/arch/arm/src/lib/infect.c b/compel/arch/arm/src/lib/infect.c
index 27d258bc3e0c..43c5add4e3f5 100644
--- a/compel/arch/arm/src/lib/infect.c
+++ b/compel/arch/arm/src/lib/infect.c
@@ -160,17 +160,22 @@ bool arch_can_dump_task(struct parasite_ctl *ctl)
return true;
}
-int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
+int arch_fetch_sas(struct parasite_ctl *ctl, stack_t *rsas)
{
long ret;
int err;
err = compel_syscall(ctl, __NR_sigaltstack,
- &ret, 0, (unsigned long)&s->sig.uc.uc_stack,
+ &ret, 0, (unsigned long)rsas,
0, 0, 0, 0);
return err ? err : ret;
}
+int arch_fetch_sas_for_sigframe(struct parasite_ctl *ctl, struct rt_sigframe *s)
+{
+ return arch_fetch_sas(ctl, (stack_t *)&s->sig.uc.uc_stack);
+}
+
/*
* Range for task size calculated from the following Linux kernel files:
* arch/arm/include/asm/memory.h
diff --git a/compel/arch/ppc64/src/lib/infect.c b/compel/arch/ppc64/src/lib/infect.c
index 32175174be89..9f70d195b3d4 100644
--- a/compel/arch/ppc64/src/lib/infect.c
+++ b/compel/arch/ppc64/src/lib/infect.c
@@ -442,17 +442,22 @@ bool arch_can_dump_task(struct parasite_ctl *ctl)
return true;
}
-int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
+int arch_fetch_sas(struct parasite_ctl *ctl, stack_t *rsas)
{
long ret;
int err;
err = compel_syscall(ctl, __NR_sigaltstack,
- &ret, 0, (unsigned long)&s->uc.uc_stack,
+ &ret, 0, (unsigned long)rsas,
0, 0, 0, 0);
return err ? err : ret;
}
+int arch_fetch_sas_for_sigframe(struct parasite_ctl *ctl, struct rt_sigframe *s)
+{
+ return arch_fetch_sas(ctl, (stack_t *)&s->uc.uc_stack);
+}
+
/*
* Copied for the Linux kernel arch/powerpc/include/asm/processor.h
*
diff --git a/compel/arch/x86/src/lib/infect.c b/compel/arch/x86/src/lib/infect.c
index 23a96df86795..7af93afb4002 100644
--- a/compel/arch/x86/src/lib/infect.c
+++ b/compel/arch/x86/src/lib/infect.c
@@ -419,21 +419,28 @@ bool arch_can_dump_task(struct parasite_ctl *ctl)
return true;
}
-int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
+int arch_fetch_sas(struct parasite_ctl *ctl, stack_t *rsas)
{
int native = compel_mode_native(ctl);
- void *where = native ?
- (void *)&s->native.uc.uc_stack :
- (void *)&s->compat.uc.uc_stack;
long ret;
int err;
err = compel_syscall(ctl, __NR(sigaltstack, !native),
- &ret, 0, (unsigned long)where,
+ &ret, 0, (unsigned long)rsas,
0, 0, 0, 0);
return err ? err : ret;
}
+int arch_fetch_sas_for_sigframe(struct parasite_ctl *ctl, struct rt_sigframe *s)
+{
+ int native = compel_mode_native(ctl);
+ void *where = native ?
+ (void *)&s->native.uc.uc_stack :
+ (void *)&s->compat.uc.uc_stack;
+
+ return arch_fetch_sas(ctl, where);
+}
+
/* Copied from the gdb header gdb/nat/x86-dregs.h */
/* Debug registers' indices. */
diff --git a/compel/include/infect-priv.h b/compel/include/infect-priv.h
index 892099eaf245..50564eed793d 100644
--- a/compel/include/infect-priv.h
+++ b/compel/include/infect-priv.h
@@ -63,7 +63,8 @@ extern void *remote_mmap(struct parasite_ctl *ctl,
int flags, int fd, off_t offset);
extern bool arch_can_dump_task(struct parasite_ctl *ctl);
extern int get_task_regs(pid_t pid, user_regs_struct_t *regs, save_regs_t save, void *arg);
-extern int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s);
+extern int arch_fetch_sas(struct parasite_ctl *ctl, stack_t *rsas);
+extern int arch_fetch_sas_for_sigframe(struct parasite_ctl *ctl, struct rt_sigframe *s);
extern int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe,
user_regs_struct_t *regs,
user_fpregs_struct_t *fpregs);
diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c
index 3386fa06afd9..72de801acbd7 100644
--- a/compel/src/lib/infect.c
+++ b/compel/src/lib/infect.c
@@ -909,7 +909,7 @@ int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned l
ctl->r_thread_stack = ctl->remote_map + p;
}
- ret = arch_fetch_sas(ctl, ctl->rsigframe);
+ ret = arch_fetch_sas_for_sigframe(ctl, ctl->rsigframe);
if (ret) {
pr_err("Can't fetch sigaltstack for task %d (ret %d)",
ctl->rpid, ret);
--
2.7.4
More information about the CRIU
mailing list