[CRIU] [PATCH 3/4] vdso: Put CONFIG_VDSO where needed
Cyrill Gorcunov
gorcunov at openvz.org
Mon May 26 00:50:14 PDT 2014
Guard vDSO code with CONFIG_VDSO, no need to even build it
on archs which do not support vDSO handling.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
cr-restore.c | 8 ++++++++
include/parasite-syscall.h | 3 +++
include/restorer.h | 5 ++++-
pie/parasite.c | 5 +++++
pie/restorer.c | 29 ++++++++++++++++++++++-------
5 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index 530d2c44fa8d..77388476daa9 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -2286,9 +2286,11 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
void *tcp_socks_mem;
unsigned long tcp_socks;
+#ifdef CONFIG_VDSO
unsigned long vdso_rt_vma_size = 0;
unsigned long vdso_rt_size = 0;
unsigned long vdso_rt_delta = 0;
+#endif
struct vm_area_list self_vmas;
struct vm_area_list *vmas = ¤t->rst->vmas;
@@ -2351,6 +2353,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
TASK_ENTRIES_SIZE +
rst_mem_remap_size();
+#ifdef CONFIG_VDSO
/*
* Figure out how much memory runtime vdso will need.
*/
@@ -2361,6 +2364,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
}
restore_bootstrap_len += vdso_rt_size;
+#endif
/*
* Restorer is a blob (code + args) that will get mapped in some
@@ -2440,7 +2444,9 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
task_args->bootstrap_start = (void *)exec_mem_hint;
task_args->bootstrap_len = restore_bootstrap_len;
+#ifdef CONFIG_VDSO
task_args->vdso_rt_size = vdso_rt_size;
+#endif
task_args->premmapped_addr = (unsigned long) current->rst->premmapped_addr;
task_args->premmapped_len = current->rst->premmapped_len;
@@ -2547,6 +2553,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
}
+#ifdef CONFIG_VDSO
/*
* Restorer needs own copy of vdso parameters. Runtime
* vdso must be kept non intersecting with anything else,
@@ -2556,6 +2563,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
mem += rst_mem_remap_size();
task_args->vdso_rt_parked_at = (unsigned long)mem + vdso_rt_delta;
task_args->vdso_sym_rt = vdso_sym_rt;
+#endif
new_sp = restorer_stack(task_args->t);
diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h
index 1fdb87b0254b..71534da58349 100644
--- a/include/parasite-syscall.h
+++ b/include/parasite-syscall.h
@@ -4,6 +4,7 @@
#include "asm/types.h"
#include "pid.h"
#include "list.h"
+#include "config.h"
#define BUILTIN_SYSCALL_SIZE 8
@@ -118,8 +119,10 @@ extern int __parasite_execute_syscall(struct parasite_ctl *ctl,
user_regs_struct_t *regs);
extern bool arch_can_dump_task(pid_t pid);
+#ifdef CONFIG_VFDO
extern int parasite_fixup_vdso(struct parasite_ctl *ctl, pid_t pid,
struct vm_area_list *vma_area_list);
+#endif
extern int parasite_stop_on_syscall(int tasks, int sys_nr);
extern int parasite_unmap(struct parasite_ctl *ctl, unsigned long addr);
diff --git a/include/restorer.h b/include/restorer.h
index 0041e609bb6a..bdb2adc9b5e3 100644
--- a/include/restorer.h
+++ b/include/restorer.h
@@ -13,6 +13,7 @@
#include "util.h"
#include "asm/restorer.h"
#include "rst_info.h"
+#include "config.h"
#include "posix-timer.h"
#include "shmem.h"
@@ -118,7 +119,6 @@ struct task_restore_args {
void *bootstrap_start;
unsigned long bootstrap_len;
- unsigned long vdso_rt_size;
struct itimerval itimers[3];
@@ -145,8 +145,11 @@ struct task_restore_args {
int fd_last_pid; /* sys.ns_last_pid for threads rst */
+#ifdef CONFIG_VDSO
+ unsigned long vdso_rt_size;
struct vdso_symtable vdso_sym_rt; /* runtime vdso symbols */
unsigned long vdso_rt_parked_at; /* safe place to keep vdso */
+#endif
} __aligned(64);
#define RESTORE_ALIGN_STACK(start, size) \
diff --git a/pie/parasite.c b/pie/parasite.c
index 1a6f9838b310..40974911e7fb 100644
--- a/pie/parasite.c
+++ b/pie/parasite.c
@@ -8,6 +8,7 @@
#include "syscall.h"
#include "parasite.h"
+#include "config.h"
#include "fcntl.h"
#include "prctl.h"
#include "lock.h"
@@ -324,6 +325,7 @@ err:
return 0;
}
+#ifdef CONFIG_VDSO
static int parasite_check_vdso_mark(struct parasite_vdso_vma_entry *args)
{
struct vdso_mark *m = (void *)args->start;
@@ -338,6 +340,7 @@ static int parasite_check_vdso_mark(struct parasite_vdso_vma_entry *args)
return 0;
}
+#endif
static int __parasite_daemon_reply_ack(unsigned int cmd, int err)
{
@@ -459,9 +462,11 @@ static noinline __used int noinline parasite_daemon(void *args)
case PARASITE_CMD_DUMP_TTY:
ret = parasite_dump_tty(args);
break;
+#ifdef CONFIG_VDSO
case PARASITE_CMD_CHECK_VDSO_MARK:
ret = parasite_check_vdso_mark(args);
break;
+#endif
default:
pr_err("Unknown command in parasite daemon thread leader: %d\n", m.cmd);
ret = -1;
diff --git a/pie/restorer.c b/pie/restorer.c
index 2cbc2fa9c81f..9afa480aed4f 100644
--- a/pie/restorer.c
+++ b/pie/restorer.c
@@ -18,6 +18,7 @@
#include "compiler.h"
#include "asm/types.h"
#include "syscall.h"
+#include "config.h"
#include "prctl.h"
#include "log.h"
#include "util.h"
@@ -538,16 +539,23 @@ static void restore_posix_timers(struct task_restore_args *args)
}
static void *bootstrap_start;
static unsigned int bootstrap_len;
-static unsigned long vdso_rt_size;
+/*
+ * sys_munmap must not return here. The controll process must
+ * trap us on the exit from sys_munmap.
+ */
+#ifdef CONFIG_VDSO
+static unsigned long vdso_rt_size;
void __export_unmap(void)
{
sys_munmap(bootstrap_start, bootstrap_len - vdso_rt_size);
- /*
- * sys_munmap must not return here. The controll process must
- * trap us on the exit from sys_munmap.
- */
}
+#else
+void __export_unmap(void)
+{
+ sys_munmap(bootstrap_start, bootstrap_len);
+}
+#endif
/*
* This function unmaps all VMAs, which don't belong to
@@ -628,7 +636,10 @@ long __export_restore_task(struct task_restore_args *args)
bootstrap_start = args->bootstrap_start;
bootstrap_len = args->bootstrap_len;
+
+#ifdef CONFIG_VDSO
vdso_rt_size = args->vdso_rt_size;
+#endif
task_entries = args->task_entries;
@@ -645,10 +656,12 @@ long __export_restore_task(struct task_restore_args *args)
pr_info("Switched to the restorer %d\n", my_pid);
+#ifdef CONFIG_VDSO
if (vdso_remap("rt-vdso", args->vdso_sym_rt.vma_start,
args->vdso_rt_parked_at,
vdso_vma_size(&args->vdso_sym_rt)))
goto core_restore_end;
+#endif
if (unmap_old_vmas((void *)args->premmapped_addr, args->premmapped_len,
bootstrap_start, bootstrap_len))
@@ -673,12 +686,13 @@ long __export_restore_task(struct task_restore_args *args)
if (vma_remap(vma_premmaped_start(vma_entry),
vma_entry->start, vma_entry_len(vma_entry)))
goto core_restore_end;
-
+#ifdef CONFIG_VDSO
if (vma_entry_is(vma_entry, VMA_AREA_VDSO)) {
if (vdso_proxify("left dumpee", &args->vdso_sym_rt,
vma_entry, args->vdso_rt_parked_at))
goto core_restore_end;
}
+#endif
}
/* Shift private vma-s to the right */
@@ -700,12 +714,13 @@ long __export_restore_task(struct task_restore_args *args)
if (vma_remap(vma_premmaped_start(vma_entry),
vma_entry->start, vma_entry_len(vma_entry)))
goto core_restore_end;
-
+#ifdef CONFIG_VDSO
if (vma_entry_is(vma_entry, VMA_AREA_VDSO)) {
if (vdso_proxify("right dumpee", &args->vdso_sym_rt,
vma_entry, args->vdso_rt_parked_at))
goto core_restore_end;
}
+#endif
}
/*
--
1.9.3
More information about the CRIU
mailing list