Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[deliverable/linux.git] / arch / s390 / include / asm / gmap.h
CommitLineData
1e133ab2
MS
1/*
2 * KVM guest address space mapping code
3 *
4 * Copyright IBM Corp. 2007, 2016
5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
6 */
7
8#ifndef _ASM_S390_GMAP_H
9#define _ASM_S390_GMAP_H
10
11/**
12 * struct gmap_struct - guest address space
4be130a0 13 * @list: list head for the mm->context gmap list
1e133ab2
MS
14 * @crst_list: list of all crst tables used in the guest address space
15 * @mm: pointer to the parent mm_struct
16 * @guest_to_host: radix tree with guest to host address translation
17 * @host_to_guest: radix tree with pointer to segment table entries
18 * @guest_table_lock: spinlock to protect all entries in the guest page table
6ea427bb 19 * @ref_count: reference counter for the gmap structure
1e133ab2
MS
20 * @table: pointer to the page directory
21 * @asce: address space control element for gmap page table
22 * @pfault_enabled: defines if pfaults are applicable for the guest
4be130a0
MS
23 * @host_to_rmap: radix tree with gmap_rmap lists
24 * @children: list of shadow gmap structures
25 * @pt_list: list of all page tables used in the shadow guest address space
26 * @shadow_lock: spinlock to protect the shadow gmap list
27 * @parent: pointer to the parent gmap for shadow guest address spaces
28 * @orig_asce: ASCE for which the shadow page table has been created
5b062bd4 29 * @edat_level: edat level to be used for the shadow translation
4be130a0 30 * @removed: flag to indicate if a shadow guest address space has been removed
0f7f8489 31 * @initialized: flag to indicate if a shadow guest address space can be used
1e133ab2
MS
32 */
33struct gmap {
34 struct list_head list;
35 struct list_head crst_list;
36 struct mm_struct *mm;
37 struct radix_tree_root guest_to_host;
38 struct radix_tree_root host_to_guest;
39 spinlock_t guest_table_lock;
6ea427bb 40 atomic_t ref_count;
1e133ab2
MS
41 unsigned long *table;
42 unsigned long asce;
43 unsigned long asce_end;
44 void *private;
45 bool pfault_enabled;
4be130a0
MS
46 /* Additional data for shadow guest address spaces */
47 struct radix_tree_root host_to_rmap;
48 struct list_head children;
49 struct list_head pt_list;
50 spinlock_t shadow_lock;
51 struct gmap *parent;
52 unsigned long orig_asce;
5b062bd4 53 int edat_level;
4be130a0 54 bool removed;
0f7f8489 55 bool initialized;
1e133ab2
MS
56};
57
4be130a0
MS
58/**
59 * struct gmap_rmap - reverse mapping for shadow page table entries
60 * @next: pointer to next rmap in the list
61 * @raddr: virtual rmap address in the shadow guest address space
62 */
63struct gmap_rmap {
64 struct gmap_rmap *next;
65 unsigned long raddr;
66};
67
68#define gmap_for_each_rmap(pos, head) \
69 for (pos = (head); pos; pos = pos->next)
70
71#define gmap_for_each_rmap_safe(pos, n, head) \
72 for (pos = (head); n = pos ? pos->next : NULL, pos; pos = n)
73
1e133ab2
MS
74/**
75 * struct gmap_notifier - notify function block for page invalidation
76 * @notifier_call: address of callback function
77 */
78struct gmap_notifier {
79 struct list_head list;
8ecb1a59 80 struct rcu_head rcu;
414d3b07
MS
81 void (*notifier_call)(struct gmap *gmap, unsigned long start,
82 unsigned long end);
1e133ab2
MS
83};
84
4be130a0
MS
85static inline int gmap_is_shadow(struct gmap *gmap)
86{
87 return !!gmap->parent;
88}
89
6ea427bb
MS
90struct gmap *gmap_create(struct mm_struct *mm, unsigned long limit);
91void gmap_remove(struct gmap *gmap);
92struct gmap *gmap_get(struct gmap *gmap);
93void gmap_put(struct gmap *gmap);
94
1e133ab2
MS
95void gmap_enable(struct gmap *gmap);
96void gmap_disable(struct gmap *gmap);
37d9df98 97struct gmap *gmap_get_enabled(void);
1e133ab2
MS
98int gmap_map_segment(struct gmap *gmap, unsigned long from,
99 unsigned long to, unsigned long len);
100int gmap_unmap_segment(struct gmap *gmap, unsigned long to, unsigned long len);
101unsigned long __gmap_translate(struct gmap *, unsigned long gaddr);
102unsigned long gmap_translate(struct gmap *, unsigned long gaddr);
103int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr);
104int gmap_fault(struct gmap *, unsigned long gaddr, unsigned int fault_flags);
105void gmap_discard(struct gmap *, unsigned long from, unsigned long to);
106void __gmap_zap(struct gmap *, unsigned long gaddr);
107void gmap_unlink(struct mm_struct *, unsigned long *table, unsigned long vmaddr);
108
4be130a0
MS
109int gmap_read_table(struct gmap *gmap, unsigned long gaddr, unsigned long *val);
110
5b062bd4
DH
111struct gmap *gmap_shadow(struct gmap *parent, unsigned long asce,
112 int edat_level);
5b6c963b 113int gmap_shadow_valid(struct gmap *sg, unsigned long asce, int edat_level);
3218f709
DH
114int gmap_shadow_r2t(struct gmap *sg, unsigned long saddr, unsigned long r2t,
115 int fake);
116int gmap_shadow_r3t(struct gmap *sg, unsigned long saddr, unsigned long r3t,
117 int fake);
18b89809
DH
118int gmap_shadow_sgt(struct gmap *sg, unsigned long saddr, unsigned long sgt,
119 int fake);
fd8d4e3a
DH
120int gmap_shadow_pgt(struct gmap *sg, unsigned long saddr, unsigned long pgt,
121 int fake);
4be130a0 122int gmap_shadow_pgt_lookup(struct gmap *sg, unsigned long saddr,
fd8d4e3a 123 unsigned long *pgt, int *dat_protection, int *fake);
a9d23e71 124int gmap_shadow_page(struct gmap *sg, unsigned long saddr, pte_t pte);
4be130a0 125
b2d73b2a
MS
126void gmap_register_pte_notifier(struct gmap_notifier *);
127void gmap_unregister_pte_notifier(struct gmap_notifier *);
4be130a0
MS
128void gmap_pte_notify(struct mm_struct *, unsigned long addr, pte_t *,
129 unsigned long bits);
b2d73b2a
MS
130
131int gmap_mprotect_notify(struct gmap *, unsigned long start,
132 unsigned long len, int prot);
1e133ab2
MS
133
134#endif /* _ASM_S390_GMAP_H */
This page took 0.060936 seconds and 5 git commands to generate.