Commit b08f3fae authored by Pavel Emelyanov's avatar Pavel Emelyanov

vdso: Reduce the amount of in-code ifdef-s

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Reviewed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent c0970b59
...@@ -2848,9 +2848,6 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core) ...@@ -2848,9 +2848,6 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
task_args->bootstrap_start = (void *)exec_mem_hint; task_args->bootstrap_start = (void *)exec_mem_hint;
task_args->bootstrap_len = restore_bootstrap_len; 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_addr = (unsigned long)rsti(current)->premmapped_addr;
task_args->premmapped_len = rsti(current)->premmapped_len; task_args->premmapped_len = rsti(current)->premmapped_len;
...@@ -2984,6 +2981,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core) ...@@ -2984,6 +2981,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
mem += rst_mem_remap_size(); mem += rst_mem_remap_size();
task_args->vdso_rt_parked_at = (unsigned long)mem + vdso_rt_delta; task_args->vdso_rt_parked_at = (unsigned long)mem + vdso_rt_delta;
task_args->vdso_sym_rt = vdso_sym_rt; task_args->vdso_sym_rt = vdso_sym_rt;
task_args->vdso_rt_size = vdso_rt_size;
#endif #endif
new_sp = restorer_stack(task_args->t); new_sp = restorer_stack(task_args->t);
......
...@@ -480,6 +480,12 @@ static int parasite_check_vdso_mark(struct parasite_vdso_vma_entry *args) ...@@ -480,6 +480,12 @@ static int parasite_check_vdso_mark(struct parasite_vdso_vma_entry *args)
return 0; 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 #endif
static int __parasite_daemon_reply_ack(unsigned int cmd, int err) static int __parasite_daemon_reply_ack(unsigned int cmd, int err)
...@@ -609,11 +615,9 @@ static noinline __used int noinline parasite_daemon(void *args) ...@@ -609,11 +615,9 @@ static noinline __used int noinline parasite_daemon(void *args)
case PARASITE_CMD_CHECK_AIOS: case PARASITE_CMD_CHECK_AIOS:
ret = parasite_check_aios(args); ret = parasite_check_aios(args);
break; break;
#ifdef CONFIG_VDSO
case PARASITE_CMD_CHECK_VDSO_MARK: case PARASITE_CMD_CHECK_VDSO_MARK:
ret = parasite_check_vdso_mark(args); ret = parasite_check_vdso_mark(args);
break; break;
#endif
default: default:
pr_err("Unknown command in parasite daemon thread leader: %d\n", m.cmd); pr_err("Unknown command in parasite daemon thread leader: %d\n", m.cmd);
ret = -1; ret = -1;
......
...@@ -649,16 +649,14 @@ static unsigned int bootstrap_len; ...@@ -649,16 +649,14 @@ static unsigned int bootstrap_len;
*/ */
#ifdef CONFIG_VDSO #ifdef CONFIG_VDSO
static unsigned long vdso_rt_size; static unsigned long vdso_rt_size;
void __export_unmap(void)
{
sys_munmap(bootstrap_start, bootstrap_len - vdso_rt_size);
}
#else #else
#define vdso_rt_size (0)
#endif
void __export_unmap(void) 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 * This function unmaps all VMAs, which don't belong to
...@@ -805,10 +803,8 @@ long __export_restore_task(struct task_restore_args *args) ...@@ -805,10 +803,8 @@ long __export_restore_task(struct task_restore_args *args)
pr_info("Switched to the restorer %d\n", my_pid); 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)) if (vdso_do_park(&args->vdso_sym_rt, args->vdso_rt_parked_at, vdso_rt_size))
goto core_restore_end; goto core_restore_end;
#endif
if (unmap_old_vmas((void *)args->premmapped_addr, args->premmapped_len, if (unmap_old_vmas((void *)args->premmapped_addr, args->premmapped_len,
bootstrap_start, bootstrap_len)) bootstrap_start, bootstrap_len))
......
...@@ -149,13 +149,11 @@ static int parse_vmflags(char *buf, struct vma_area *vma_area) ...@@ -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. */ /* vmsplice doesn't work for VM_IO and VM_PFNMAP mappings. */
if (_vmflag_match(tok, "io") || _vmflag_match(tok, "pf")) { if (_vmflag_match(tok, "io") || _vmflag_match(tok, "pf")) {
#ifdef CONFIG_VDSO
/* /*
* VVAR area mapped by the kernel as * VVAR area mapped by the kernel as
* VM_IO | VM_PFNMAP| VM_DONTEXPAND | VM_DONTDUMP * VM_IO | VM_PFNMAP| VM_DONTEXPAND | VM_DONTDUMP
*/ */
if (!vma_area_is(vma_area, VMA_AREA_VVAR)) if (!vma_area_is(vma_area, VMA_AREA_VVAR))
#endif
vma_area->e->status |= VMA_UNSUPP; vma_area->e->status |= VMA_UNSUPP;
} }
...@@ -336,6 +334,36 @@ int parse_self_maps_lite(struct vm_area_list *vms) ...@@ -336,6 +334,36 @@ int parse_self_maps_lite(struct vm_area_list *vms)
return 0; 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, static int handle_vma(pid_t pid, struct vma_area *vma_area,
char *file_path, DIR *map_files_dir, char *file_path, DIR *map_files_dir,
struct vma_file_info *vfi, struct vma_file_info *vfi,
...@@ -353,23 +381,11 @@ static int handle_vma(pid_t pid, struct vma_area *vma_area, ...@@ -353,23 +381,11 @@ static int handle_vma(pid_t pid, struct vma_area *vma_area,
!strcmp(file_path, "[vectors]")) { !strcmp(file_path, "[vectors]")) {
vma_area->e->status |= VMA_AREA_VSYSCALL; vma_area->e->status |= VMA_AREA_VSYSCALL;
} else if (!strcmp(file_path, "[vdso]")) { } else if (!strcmp(file_path, "[vdso]")) {
#ifdef CONFIG_VDSO if (handle_vdso_vma(vma_area))
vma_area->e->status |= VMA_AREA_REGULAR; goto err;
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
} else if (!strcmp(file_path, "[vvar]")) { } else if (!strcmp(file_path, "[vvar]")) {
#ifdef CONFIG_VDSO if (handle_vvar_vma(vma_area))
vma_area->e->status |= VMA_AREA_REGULAR; goto err;
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
} else if (!strcmp(file_path, "[heap]")) { } else if (!strcmp(file_path, "[heap]")) {
vma_area->e->status |= VMA_AREA_REGULAR | VMA_AREA_HEAP; vma_area->e->status |= VMA_AREA_REGULAR | VMA_AREA_HEAP;
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment