diff --git a/Makefile b/Makefile index bda808dc8..99ea75205 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,8 @@ OBJCOPY := $(CROSS_COMPILE)objcopy CFLAGS += $(USERCFLAGS) +VDSO_O := vdso.o + # # Fetch ARCH from the uname if not yet set # @@ -69,6 +71,8 @@ ifeq ($(shell echo $(ARCH) | sed -e 's/arm.*/arm/'),arm) ifeq ($(ARMV),7) USERCFLAGS += -march=armv7-a endif + + VDSO_O := vdso-stub.o endif SRCARCH ?= $(ARCH) @@ -117,6 +121,7 @@ CRIU-INC := lib/criu.h include/criu-plugin.h include/criu-log.h protobuf/rpc.pro export CC MAKE CFLAGS LIBS SRCARCH DEFINES MAKEFLAGS CRIU-SO export SRC_DIR SYSCALL-LIB SH RM ARCH_DIR OBJCOPY LDARCH LD export cflags-y +export VDSO_O include Makefile.inc include Makefile.config diff --git a/Makefile.crtools b/Makefile.crtools index 6effc3e09..619e9a04c 100644 --- a/Makefile.crtools +++ b/Makefile.crtools @@ -62,6 +62,7 @@ obj-y += $(ARCH_DIR)/vdso.o obj-y += cr-service.o obj-y += sd-daemon.o obj-y += plugin.o +obj-y += $(VDSO_O) ifneq ($(MAKECMDGOALS),clean) incdeps := y diff --git a/arch/arm/vdso.c b/arch/arm/vdso.c index eae846d6d..4d4e28a1a 100644 --- a/arch/arm/vdso.c +++ b/arch/arm/vdso.c @@ -13,14 +13,6 @@ #endif #define LOG_PREFIX "vdso: " -struct vdso_symtable vdso_sym_rt = VDSO_SYMTABLE_INIT; -u64 vdso_pfn = VDSO_BAD_PFN; - -int vdso_init(void) -{ - return 0; -} - int parasite_fixup_vdso(struct parasite_ctl *ctl, pid_t pid, struct vm_area_list *vma_area_list) { diff --git a/arch/x86/vdso.c b/arch/x86/vdso.c index 0a59e23b2..d240ba5ba 100644 --- a/arch/x86/vdso.c +++ b/arch/x86/vdso.c @@ -27,55 +27,6 @@ #endif #define LOG_PREFIX "vdso: " -struct vdso_symtable vdso_sym_rt = VDSO_SYMTABLE_INIT; -u64 vdso_pfn = VDSO_BAD_PFN; - -static int vdso_fill_self_symtable(struct vdso_symtable *s) -{ - char buf[512]; - int ret = -1; - FILE *maps; - - VDSO_INIT_SYMTABLE(s); - - maps = fopen("/proc/self/maps", "r"); - if (!maps) { - pr_perror("Can't open self-vma"); - return -1; - } - - while (fgets(buf, sizeof(buf), maps)) { - unsigned long start, end; - - if (strstr(buf, "[vdso]") == NULL) - continue; - - ret = sscanf(buf, "%lx-%lx", &start, &end); - if (ret != 2) { - ret = -1; - pr_err("Can't find vDSO bounds\n"); - break; - } - - s->vma_start = start; - s->vma_end = end; - - ret = vdso_fill_symtable((void *)start, end - start, s); - break; - } - - fclose(maps); - return ret; -} - -int vdso_init(void) -{ - if (vdso_fill_self_symtable(&vdso_sym_rt)) - return -1; - - return vaddr_to_pfn(vdso_sym_rt.vma_start, &vdso_pfn); -} - /* * Find out proxy vdso vma and drop it from the list. Also * fix vdso status on vmas if wrong status found. diff --git a/vdso-stub.c b/vdso-stub.c new file mode 100644 index 000000000..60aa72d75 --- /dev/null +++ b/vdso-stub.c @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +#include "vdso.h" +#include "log.h" +#include "util.h" + +#ifdef LOG_PREFIX +# undef LOG_PREFIX +#endif +#define LOG_PREFIX "vdso: " + + +struct vdso_symtable vdso_sym_rt = VDSO_SYMTABLE_INIT; +u64 vdso_pfn = VDSO_BAD_PFN; + + +int vdso_init(void) +{ + return 0; +} diff --git a/vdso.c b/vdso.c new file mode 100644 index 000000000..d887e786e --- /dev/null +++ b/vdso.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include + +#include "vdso.h" +#include "log.h" +#include "util.h" + +#ifdef LOG_PREFIX +# undef LOG_PREFIX +#endif +#define LOG_PREFIX "vdso: " + + +struct vdso_symtable vdso_sym_rt = VDSO_SYMTABLE_INIT; +u64 vdso_pfn = VDSO_BAD_PFN; + +static int vdso_fill_self_symtable(struct vdso_symtable *s) +{ + char buf[512]; + int ret = -1; + FILE *maps; + + VDSO_INIT_SYMTABLE(s); + + maps = fopen("/proc/self/maps", "r"); + if (!maps) { + pr_perror("Can't open self-vma"); + return -1; + } + + while (fgets(buf, sizeof(buf), maps)) { + unsigned long start, end; + + if (strstr(buf, "[vdso]") == NULL) + continue; + + ret = sscanf(buf, "%lx-%lx", &start, &end); + if (ret != 2) { + ret = -1; + pr_err("Can't find vDSO bounds\n"); + break; + } + + s->vma_start = start; + s->vma_end = end; + + ret = vdso_fill_symtable((void *)start, end - start, s); + break; + } + + fclose(maps); + return ret; +} + +int vdso_init(void) +{ + if (vdso_fill_self_symtable(&vdso_sym_rt)) + return -1; + + return vaddr_to_pfn(vdso_sym_rt.vma_start, &vdso_pfn); +} +