0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _ASM_S390_GMAP_H
0010 #define _ASM_S390_GMAP_H
0011
0012 #include <linux/radix-tree.h>
0013 #include <linux/refcount.h>
0014
0015
0016 #define GMAP_NOTIFY_SHADOW 0x2
0017 #define GMAP_NOTIFY_MPROT 0x1
0018
0019
0020 #define _SEGMENT_ENTRY_GMAP_IN 0x8000
0021 #define _SEGMENT_ENTRY_GMAP_UC 0x4000
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 struct gmap {
0047 struct list_head list;
0048 struct list_head crst_list;
0049 struct mm_struct *mm;
0050 struct radix_tree_root guest_to_host;
0051 struct radix_tree_root host_to_guest;
0052 spinlock_t guest_table_lock;
0053 refcount_t ref_count;
0054 unsigned long *table;
0055 unsigned long asce;
0056 unsigned long asce_end;
0057 void *private;
0058 bool pfault_enabled;
0059
0060 unsigned long guest_handle;
0061
0062 struct radix_tree_root host_to_rmap;
0063 struct list_head children;
0064 struct list_head pt_list;
0065 spinlock_t shadow_lock;
0066 struct gmap *parent;
0067 unsigned long orig_asce;
0068 int edat_level;
0069 bool removed;
0070 bool initialized;
0071 };
0072
0073
0074
0075
0076
0077
0078 struct gmap_rmap {
0079 struct gmap_rmap *next;
0080 unsigned long raddr;
0081 };
0082
0083 #define gmap_for_each_rmap(pos, head) \
0084 for (pos = (head); pos; pos = pos->next)
0085
0086 #define gmap_for_each_rmap_safe(pos, n, head) \
0087 for (pos = (head); n = pos ? pos->next : NULL, pos; pos = n)
0088
0089
0090
0091
0092
0093 struct gmap_notifier {
0094 struct list_head list;
0095 struct rcu_head rcu;
0096 void (*notifier_call)(struct gmap *gmap, unsigned long start,
0097 unsigned long end);
0098 };
0099
0100 static inline int gmap_is_shadow(struct gmap *gmap)
0101 {
0102 return !!gmap->parent;
0103 }
0104
0105 struct gmap *gmap_create(struct mm_struct *mm, unsigned long limit);
0106 void gmap_remove(struct gmap *gmap);
0107 struct gmap *gmap_get(struct gmap *gmap);
0108 void gmap_put(struct gmap *gmap);
0109
0110 void gmap_enable(struct gmap *gmap);
0111 void gmap_disable(struct gmap *gmap);
0112 struct gmap *gmap_get_enabled(void);
0113 int gmap_map_segment(struct gmap *gmap, unsigned long from,
0114 unsigned long to, unsigned long len);
0115 int gmap_unmap_segment(struct gmap *gmap, unsigned long to, unsigned long len);
0116 unsigned long __gmap_translate(struct gmap *, unsigned long gaddr);
0117 unsigned long gmap_translate(struct gmap *, unsigned long gaddr);
0118 int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr);
0119 int gmap_fault(struct gmap *, unsigned long gaddr, unsigned int fault_flags);
0120 void gmap_discard(struct gmap *, unsigned long from, unsigned long to);
0121 void __gmap_zap(struct gmap *, unsigned long gaddr);
0122 void gmap_unlink(struct mm_struct *, unsigned long *table, unsigned long vmaddr);
0123
0124 int gmap_read_table(struct gmap *gmap, unsigned long gaddr, unsigned long *val);
0125
0126 struct gmap *gmap_shadow(struct gmap *parent, unsigned long asce,
0127 int edat_level);
0128 int gmap_shadow_valid(struct gmap *sg, unsigned long asce, int edat_level);
0129 int gmap_shadow_r2t(struct gmap *sg, unsigned long saddr, unsigned long r2t,
0130 int fake);
0131 int gmap_shadow_r3t(struct gmap *sg, unsigned long saddr, unsigned long r3t,
0132 int fake);
0133 int gmap_shadow_sgt(struct gmap *sg, unsigned long saddr, unsigned long sgt,
0134 int fake);
0135 int gmap_shadow_pgt(struct gmap *sg, unsigned long saddr, unsigned long pgt,
0136 int fake);
0137 int gmap_shadow_pgt_lookup(struct gmap *sg, unsigned long saddr,
0138 unsigned long *pgt, int *dat_protection, int *fake);
0139 int gmap_shadow_page(struct gmap *sg, unsigned long saddr, pte_t pte);
0140
0141 void gmap_register_pte_notifier(struct gmap_notifier *);
0142 void gmap_unregister_pte_notifier(struct gmap_notifier *);
0143
0144 int gmap_mprotect_notify(struct gmap *, unsigned long start,
0145 unsigned long len, int prot);
0146
0147 void gmap_sync_dirty_log_pmd(struct gmap *gmap, unsigned long dirty_bitmap[4],
0148 unsigned long gaddr, unsigned long vmaddr);
0149 int gmap_mark_unmergeable(void);
0150 void s390_unlist_old_asce(struct gmap *gmap);
0151 int s390_replace_asce(struct gmap *gmap);
0152 void s390_uv_destroy_pfns(unsigned long count, unsigned long *pfns);
0153 int __s390_uv_destroy_range(struct mm_struct *mm, unsigned long start,
0154 unsigned long end, bool interruptible);
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165 static inline void s390_uv_destroy_range(struct mm_struct *mm, unsigned long start,
0166 unsigned long end)
0167 {
0168 (void)__s390_uv_destroy_range(mm, start, end, false);
0169 }
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183 static inline int s390_uv_destroy_range_interruptible(struct mm_struct *mm, unsigned long start,
0184 unsigned long end)
0185 {
0186 return __s390_uv_destroy_range(mm, start, end, true);
0187 }
0188 #endif