1
2
3
4
5
6
7
8
9#ifndef _ASM_S390_GMAP_H
10#define _ASM_S390_GMAP_H
11
12
13#define GMAP_NOTIFY_SHADOW 0x2
14#define GMAP_NOTIFY_MPROT 0x1
15
16
17#define _SEGMENT_ENTRY_GMAP_IN 0x8000
18#define _SEGMENT_ENTRY_GMAP_UC 0x4000
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42struct gmap {
43 struct list_head list;
44 struct list_head crst_list;
45 struct mm_struct *mm;
46 struct radix_tree_root guest_to_host;
47 struct radix_tree_root host_to_guest;
48 spinlock_t guest_table_lock;
49 atomic_t ref_count;
50 unsigned long *table;
51 unsigned long asce;
52 unsigned long asce_end;
53 void *private;
54 bool pfault_enabled;
55
56 struct radix_tree_root host_to_rmap;
57 struct list_head children;
58 struct list_head pt_list;
59 spinlock_t shadow_lock;
60 struct gmap *parent;
61 unsigned long orig_asce;
62 int edat_level;
63 bool removed;
64 bool initialized;
65};
66
67
68
69
70
71
72struct gmap_rmap {
73 struct gmap_rmap *next;
74 unsigned long raddr;
75};
76
77#define gmap_for_each_rmap(pos, head) \
78 for (pos = (head); pos; pos = pos->next)
79
80#define gmap_for_each_rmap_safe(pos, n, head) \
81 for (pos = (head); n = pos ? pos->next : NULL, pos; pos = n)
82
83
84
85
86
87struct gmap_notifier {
88 struct list_head list;
89 struct rcu_head rcu;
90 void (*notifier_call)(struct gmap *gmap, unsigned long start,
91 unsigned long end);
92};
93
94static inline int gmap_is_shadow(struct gmap *gmap)
95{
96 return !!gmap->parent;
97}
98
99struct gmap *gmap_create(struct mm_struct *mm, unsigned long limit);
100void gmap_remove(struct gmap *gmap);
101struct gmap *gmap_get(struct gmap *gmap);
102void gmap_put(struct gmap *gmap);
103
104void gmap_enable(struct gmap *gmap);
105void gmap_disable(struct gmap *gmap);
106struct gmap *gmap_get_enabled(void);
107int gmap_map_segment(struct gmap *gmap, unsigned long from,
108 unsigned long to, unsigned long len);
109int gmap_unmap_segment(struct gmap *gmap, unsigned long to, unsigned long len);
110unsigned long __gmap_translate(struct gmap *, unsigned long gaddr);
111unsigned long gmap_translate(struct gmap *, unsigned long gaddr);
112int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr);
113int gmap_fault(struct gmap *, unsigned long gaddr, unsigned int fault_flags);
114void gmap_discard(struct gmap *, unsigned long from, unsigned long to);
115void __gmap_zap(struct gmap *, unsigned long gaddr);
116void gmap_unlink(struct mm_struct *, unsigned long *table, unsigned long vmaddr);
117
118int gmap_read_table(struct gmap *gmap, unsigned long gaddr, unsigned long *val);
119
120struct gmap *gmap_shadow(struct gmap *parent, unsigned long asce,
121 int edat_level);
122int gmap_shadow_valid(struct gmap *sg, unsigned long asce, int edat_level);
123int gmap_shadow_r2t(struct gmap *sg, unsigned long saddr, unsigned long r2t,
124 int fake);
125int gmap_shadow_r3t(struct gmap *sg, unsigned long saddr, unsigned long r3t,
126 int fake);
127int gmap_shadow_sgt(struct gmap *sg, unsigned long saddr, unsigned long sgt,
128 int fake);
129int gmap_shadow_pgt(struct gmap *sg, unsigned long saddr, unsigned long pgt,
130 int fake);
131int gmap_shadow_pgt_lookup(struct gmap *sg, unsigned long saddr,
132 unsigned long *pgt, int *dat_protection, int *fake);
133int gmap_shadow_page(struct gmap *sg, unsigned long saddr, pte_t pte);
134
135void gmap_register_pte_notifier(struct gmap_notifier *);
136void gmap_unregister_pte_notifier(struct gmap_notifier *);
137void gmap_pte_notify(struct mm_struct *, unsigned long addr, pte_t *,
138 unsigned long bits);
139
140int gmap_mprotect_notify(struct gmap *, unsigned long start,
141 unsigned long len, int prot);
142
143void gmap_sync_dirty_log_pmd(struct gmap *gmap, unsigned long dirty_bitmap[4],
144 unsigned long gaddr, unsigned long vmaddr);
145#endif
146