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