mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
vdso: Fetch page frame number on init
We will need it in parasite code to detect run time vdso area. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
f267443134
commit
bc66eb535c
@@ -9,6 +9,7 @@
|
||||
#define LOG_PREFIX "vdso: "
|
||||
|
||||
struct vdso_symtable vdso_sym_rt = VDSO_SYMTABLE_INIT;
|
||||
u64 vdso_pfn = VDSO_BAD_PFN;
|
||||
|
||||
int vdso_init(void)
|
||||
{
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include "crtools.h"
|
||||
#include "kerndat.h"
|
||||
#include "vdso.h"
|
||||
#include "util.h"
|
||||
#include "log.h"
|
||||
#include "mem.h"
|
||||
|
||||
@@ -24,6 +25,7 @@
|
||||
#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)
|
||||
{
|
||||
@@ -65,7 +67,31 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s)
|
||||
|
||||
int vdso_init(void)
|
||||
{
|
||||
int ret = -1, fd;
|
||||
off_t off;
|
||||
|
||||
if (vdso_fill_self_symtable(&vdso_sym_rt))
|
||||
return -1;
|
||||
return 0;
|
||||
|
||||
fd = open_proc(getpid(), "pagemap");
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
off = (vdso_sym_rt.vma_start / PAGE_SIZE) * sizeof(u64);
|
||||
if (lseek(fd, off, SEEK_SET) != off) {
|
||||
pr_perror("Failed to seek address %lx\n", vdso_sym_rt.vma_start);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = read(fd, &vdso_pfn, sizeof(vdso_pfn));
|
||||
if (ret < 0 || ret != sizeof(vdso_pfn)) {
|
||||
pr_perror("Can't read pme for pid %d", getpid());
|
||||
ret = -1;
|
||||
} else {
|
||||
vdso_pfn = PME_PFRAME(vdso_pfn);
|
||||
ret = 0;
|
||||
}
|
||||
out:
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "asm/vdso.h"
|
||||
#include "asm/int.h"
|
||||
|
||||
#define VDSO_PROT (PROT_READ | PROT_EXEC)
|
||||
|
||||
@@ -26,6 +27,7 @@ enum {
|
||||
#define VDSO_SYMBOL_TIME_NAME "__vdso_time"
|
||||
|
||||
#define VDSO_BAD_ADDR (-1ul)
|
||||
#define VDSO_BAD_PFN (-1ull)
|
||||
|
||||
struct vdso_symbol {
|
||||
char name[32];
|
||||
@@ -67,6 +69,7 @@ static inline unsigned long vdso_vma_size(struct vdso_symtable *t)
|
||||
}
|
||||
|
||||
extern struct vdso_symtable vdso_sym_rt;
|
||||
extern u64 vdso_pfn;
|
||||
extern int vdso_init(void);
|
||||
|
||||
#endif /* __CR_VDSO_H__ */
|
||||
|
Reference in New Issue
Block a user