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