[CRIU] [PATCH] vdso: Reduce the amount of in-code ifdef-s
Pavel Emelyanov
xemul at parallels.com
Fri Jun 5 01:48:43 PDT 2015
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
diff --git a/cr-restore.c b/cr-restore.c
index aa00dc2..9792044 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -2848,9 +2848,6 @@ 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)rsti(current)->premmapped_addr;
task_args->premmapped_len = rsti(current)->premmapped_len;
@@ -2984,6 +2981,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;
+ task_args->vdso_rt_size = vdso_rt_size;
#endif
new_sp = restorer_stack(task_args->t);
diff --git a/pie/parasite.c b/pie/parasite.c
index 9961b2f..1ceb821 100644
--- a/pie/parasite.c
+++ b/pie/parasite.c
@@ -480,6 +480,12 @@ static int parasite_check_vdso_mark(struct parasite_vdso_vma_entry *args)
return 0;
}
+#else
+static inline int parasite_check_vdso_mark(struct parasite_vdso_vma_entry *args)
+{
+ pr_err("Unexpected VDSO check command\n");
+ return -1;
+}
#endif
static int __parasite_daemon_reply_ack(unsigned int cmd, int err)
@@ -609,11 +615,9 @@ static noinline __used int noinline parasite_daemon(void *args)
case PARASITE_CMD_CHECK_AIOS:
ret = parasite_check_aios(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 8713c6a..e2af72c 100644
--- a/pie/restorer.c
+++ b/pie/restorer.c
@@ -649,16 +649,14 @@ static unsigned int bootstrap_len;
*/
#ifdef CONFIG_VDSO
static unsigned long vdso_rt_size;
-void __export_unmap(void)
-{
- sys_munmap(bootstrap_start, bootstrap_len - vdso_rt_size);
-}
#else
+#define vdso_rt_size (0)
+#endif
+
void __export_unmap(void)
{
- sys_munmap(bootstrap_start, bootstrap_len);
+ sys_munmap(bootstrap_start, bootstrap_len - vdso_rt_size);
}
-#endif
/*
* This function unmaps all VMAs, which don't belong to
@@ -805,10 +803,8 @@ long __export_restore_task(struct task_restore_args *args)
pr_info("Switched to the restorer %d\n", my_pid);
-#ifdef CONFIG_VDSO
if (vdso_do_park(&args->vdso_sym_rt, args->vdso_rt_parked_at, vdso_rt_size))
goto core_restore_end;
-#endif
if (unmap_old_vmas((void *)args->premmapped_addr, args->premmapped_len,
bootstrap_start, bootstrap_len))
diff --git a/proc_parse.c b/proc_parse.c
index e6ea957..9795689 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -149,13 +149,11 @@ static int parse_vmflags(char *buf, struct vma_area *vma_area)
/* vmsplice doesn't work for VM_IO and VM_PFNMAP mappings. */
if (_vmflag_match(tok, "io") || _vmflag_match(tok, "pf")) {
-#ifdef CONFIG_VDSO
/*
* VVAR area mapped by the kernel as
* VM_IO | VM_PFNMAP| VM_DONTEXPAND | VM_DONTDUMP
*/
if (!vma_area_is(vma_area, VMA_AREA_VVAR))
-#endif
vma_area->e->status |= VMA_UNSUPP;
}
@@ -336,6 +334,36 @@ int parse_self_maps_lite(struct vm_area_list *vms)
return 0;
}
+#ifdef CONFIG_VDSO
+static inline int handle_vdso_vma(struct vma_area *vma)
+{
+ vma->e->status |= VMA_AREA_REGULAR;
+ if ((vma->e->prot & VDSO_PROT) == VDSO_PROT)
+ vma->e->status |= VMA_AREA_VDSO;
+ return 0;
+}
+
+static inline int handle_vvar_vma(struct vma_area *vma)
+{
+ vma->e->status |= VMA_AREA_REGULAR;
+ if ((vma->e->prot & VVAR_PROT) == VVAR_PROT)
+ vma->e->status |= VMA_AREA_VVAR;
+ return 0;
+}
+#else
+static inline int handle_vdso_vma(struct vma_area *vma)
+{
+ pr_warn_once("Found vDSO area without support\n");
+ return -1;
+}
+
+static inline int handle_vvar_vma(struct vma_area *vma)
+{
+ pr_warn_once("Found VVAR area without support\n");
+ return -1;
+}
+#endif
+
static int handle_vma(pid_t pid, struct vma_area *vma_area,
char *file_path, DIR *map_files_dir,
struct vma_file_info *vfi,
@@ -353,23 +381,11 @@ static int handle_vma(pid_t pid, struct vma_area *vma_area,
!strcmp(file_path, "[vectors]")) {
vma_area->e->status |= VMA_AREA_VSYSCALL;
} else if (!strcmp(file_path, "[vdso]")) {
-#ifdef CONFIG_VDSO
- vma_area->e->status |= VMA_AREA_REGULAR;
- if ((vma_area->e->prot & VDSO_PROT) == VDSO_PROT)
- vma_area->e->status |= VMA_AREA_VDSO;
-#else
- pr_warn_once("Found vDSO area without support\n");
- goto err;
-#endif
+ if (handle_vdso_vma(vma_area))
+ goto err;
} else if (!strcmp(file_path, "[vvar]")) {
-#ifdef CONFIG_VDSO
- vma_area->e->status |= VMA_AREA_REGULAR;
- if ((vma_area->e->prot & VVAR_PROT) == VVAR_PROT)
- vma_area->e->status |= VMA_AREA_VVAR;
-#else
- pr_warn_once("Found VVAR area without support\n");
- goto err;
-#endif
+ if (handle_vvar_vma(vma_area))
+ goto err;
} else if (!strcmp(file_path, "[heap]")) {
vma_area->e->status |= VMA_AREA_REGULAR | VMA_AREA_HEAP;
} else {
More information about the CRIU
mailing list