Branch data Line data Source code
1 : : #ifndef __CR_VDSO_H__
2 : : #define __CR_VDSO_H__
3 : :
4 : : #include <sys/mman.h>
5 : : #include <stdbool.h>
6 : :
7 : : #include "asm/vdso.h"
8 : : #include "asm/int.h"
9 : :
10 : : #define VDSO_PROT (PROT_READ | PROT_EXEC)
11 : :
12 : :
13 : : #define VDSO_BAD_ADDR (-1ul)
14 : : #define VDSO_BAD_PFN (-1ull)
15 : :
16 : : struct vdso_symbol {
17 : : char name[32];
18 : : unsigned long offset;
19 : : };
20 : :
21 : : #define VDSO_SYMBOL_INIT \
22 : : { .offset = VDSO_BAD_ADDR, }
23 : :
24 : : /* Check if symbol present in symtable */
25 : : static inline bool vdso_symbol_empty(struct vdso_symbol *s)
26 : : {
27 : : return s->offset == VDSO_BAD_ADDR && s->name[0] == '\0';
28 : : }
29 : :
30 : : struct vdso_symtable {
31 : : unsigned long vma_start;
32 : : unsigned long vma_end;
33 : : struct vdso_symbol symbols[VDSO_SYMBOL_MAX];
34 : : };
35 : :
36 : : #define VDSO_SYMTABLE_INIT \
37 : : { \
38 : : .vma_start = VDSO_BAD_ADDR, \
39 : : .vma_end = VDSO_BAD_ADDR, \
40 : : .symbols = { \
41 : : [0 ... VDSO_SYMBOL_MAX - 1] = \
42 : : (struct vdso_symbol)VDSO_SYMBOL_INIT, \
43 : : }, \
44 : : }
45 : :
46 : : #define VDSO_INIT_SYMTABLE(symtable) \
47 : : *(symtable) = (struct vdso_symtable)VDSO_SYMTABLE_INIT
48 : :
49 : : /* Size of VMA associated with vdso */
50 : : static inline unsigned long vdso_vma_size(struct vdso_symtable *t)
51 : : {
52 : 347 : return t->vma_end - t->vma_start;
53 : : }
54 : :
55 : : /*
56 : : * Special mark which allows to identify runtime vdso where
57 : : * calls from proxy vdso are redirected. This mark usually
58 : : * placed at the start of vdso area where Elf header lives.
59 : : * Since such runtime vdso is solevey used by proxy and
60 : : * nobody else is supposed to access it, it's more-less
61 : : * safe to screw the Elf header with @signature and
62 : : * @proxy_addr.
63 : : *
64 : : * The @proxy_addr deserves a few comments. When we redirect
65 : : * the calls from proxy to runtime vdso, on next checkpoint
66 : : * it won't be possible to find which VMA is proxy, thus
67 : : * we save its address in the member.
68 : : */
69 : : struct vdso_mark {
70 : : u64 signature;
71 : : unsigned long proxy_addr;
72 : : };
73 : :
74 : : /* Magic number (criuvdso) */
75 : : #define VDSO_MARK_SIGNATURE (0x6f73647675697263ULL)
76 : :
77 : : static inline bool is_vdso_mark(void *addr)
78 : : {
79 : : struct vdso_mark *m = addr;
80 : :
81 : : return m->signature == VDSO_MARK_SIGNATURE &&
82 : : m->proxy_addr != VDSO_BAD_ADDR;
83 : : }
84 : :
85 : : static inline void vdso_put_mark(void *where, unsigned long proxy_addr)
86 : : {
87 : : struct vdso_mark *m = where;
88 : :
89 : : m->signature = VDSO_MARK_SIGNATURE;
90 : : m->proxy_addr = proxy_addr;
91 : : }
92 : :
93 : : extern struct vdso_symtable vdso_sym_rt;
94 : : extern u64 vdso_pfn;
95 : : extern int vdso_init(void);
96 : : extern int vdso_remap(char *who, unsigned long from, unsigned long to, size_t size);
97 : : extern int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t);
98 : : extern int vdso_proxify(char *who, struct vdso_symtable *sym_rt, VmaEntry *vma_entry, unsigned long vdso_rt_parked_at);
99 : :
100 : : #endif /* __CR_VDSO_H__ */
|