Commit 676708e3 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

vdso: Put CONFIG_VDSO where needed

Guard vDSO code with CONFIG_VDSO, no need to even build it
on archs which do not support vDSO handling.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarAlexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 89faae1e
......@@ -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 = &current->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);
......
......@@ -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);
......
......@@ -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) \
......
......@@ -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;
......
......@@ -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;
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.
*/
#ifdef CONFIG_VDSO
static unsigned long vdso_rt_size;
void __export_unmap(void)
{
sys_munmap(bootstrap_start, bootstrap_len - vdso_rt_size);
}
#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
}
/*
......
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