Commit 9e6a062c authored by Alexander Kartashov's avatar Alexander Kartashov Committed by Pavel Emelyanov

vdso: share the vDSO proxy initialization between all architectures

This patch splits the file arch/x86/vdso.c into machine-independent
and machine-dependent parts by moving the routine vdso_init()
from the file vdso.c. The routine seems to be suitable for all
architectures supporting the vDSO.

The ARM version of the routine is moved to the source vdso-stub.c
that is supposed to be the vDSO proxy stub implementation for
architectures that don't provide the vDSO. The build scripts are
adjusted as well to enable selection between the full-fledged
and stub vDSO proxy implementations.
Signed-off-by: 's avatarAlexander Kartashov <alekskartashov@parallels.com>
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: 's avatarChristopher Covington <cov@codeaurora.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7c42c9b5
...@@ -35,6 +35,8 @@ OBJCOPY := $(CROSS_COMPILE)objcopy ...@@ -35,6 +35,8 @@ OBJCOPY := $(CROSS_COMPILE)objcopy
CFLAGS += $(USERCFLAGS) CFLAGS += $(USERCFLAGS)
VDSO_O := vdso.o
# #
# Fetch ARCH from the uname if not yet set # Fetch ARCH from the uname if not yet set
# #
...@@ -69,6 +71,8 @@ ifeq ($(shell echo $(ARCH) | sed -e 's/arm.*/arm/'),arm) ...@@ -69,6 +71,8 @@ ifeq ($(shell echo $(ARCH) | sed -e 's/arm.*/arm/'),arm)
ifeq ($(ARMV),7) ifeq ($(ARMV),7)
USERCFLAGS += -march=armv7-a USERCFLAGS += -march=armv7-a
endif endif
VDSO_O := vdso-stub.o
endif endif
SRCARCH ?= $(ARCH) SRCARCH ?= $(ARCH)
...@@ -117,6 +121,7 @@ CRIU-INC := lib/criu.h include/criu-plugin.h include/criu-log.h protobuf/rpc.pro ...@@ -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 CC MAKE CFLAGS LIBS SRCARCH DEFINES MAKEFLAGS CRIU-SO
export SRC_DIR SYSCALL-LIB SH RM ARCH_DIR OBJCOPY LDARCH LD export SRC_DIR SYSCALL-LIB SH RM ARCH_DIR OBJCOPY LDARCH LD
export cflags-y export cflags-y
export VDSO_O
include Makefile.inc include Makefile.inc
include Makefile.config include Makefile.config
......
...@@ -62,6 +62,7 @@ obj-y += $(ARCH_DIR)/vdso.o ...@@ -62,6 +62,7 @@ obj-y += $(ARCH_DIR)/vdso.o
obj-y += cr-service.o obj-y += cr-service.o
obj-y += sd-daemon.o obj-y += sd-daemon.o
obj-y += plugin.o obj-y += plugin.o
obj-y += $(VDSO_O)
ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),clean)
incdeps := y incdeps := y
......
...@@ -13,14 +13,6 @@ ...@@ -13,14 +13,6 @@
#endif #endif
#define LOG_PREFIX "vdso: " #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, int parasite_fixup_vdso(struct parasite_ctl *ctl, pid_t pid,
struct vm_area_list *vma_area_list) struct vm_area_list *vma_area_list)
{ {
......
...@@ -27,55 +27,6 @@ ...@@ -27,55 +27,6 @@
#endif #endif
#define LOG_PREFIX "vdso: " #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 * Find out proxy vdso vma and drop it from the list. Also
* fix vdso status on vmas if wrong status found. * fix vdso status on vmas if wrong status found.
......
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#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;
}
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#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);
}
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