mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 13:58:34 +00:00
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: Alexander Kartashov <alekskartashov@parallels.com> Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org> Reviewed-by: Christopher Covington <cov@codeaurora.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
7c42c9b5b6
commit
9e6a062c43
5
Makefile
5
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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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.
|
||||
|
23
vdso-stub.c
Normal file
23
vdso-stub.c
Normal file
@ -0,0 +1,23 @@
|
||||
#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;
|
||||
}
|
64
vdso.c
Normal file
64
vdso.c
Normal file
@ -0,0 +1,64 @@
|
||||
#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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user