s390/mm: add reference counter to gmap structure
[deliverable/linux.git] / arch / s390 / include / asm / gmap.h
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
13 * @crst_list: list of all crst tables used in the guest address space
14 * @mm: pointer to the parent mm_struct
15 * @guest_to_host: radix tree with guest to host address translation
16 * @host_to_guest: radix tree with pointer to segment table entries
17 * @guest_table_lock: spinlock to protect all entries in the guest page table
18 * @ref_count: reference counter for the gmap structure
19 * @table: pointer to the page directory
20 * @asce: address space control element for gmap page table
21 * @pfault_enabled: defines if pfaults are applicable for the guest
22 */
23 struct gmap {
24 struct list_head list;
25 struct list_head crst_list;
26 struct mm_struct *mm;
27 struct radix_tree_root guest_to_host;
28 struct radix_tree_root host_to_guest;
29 spinlock_t guest_table_lock;
30 atomic_t ref_count;
31 unsigned long *table;
32 unsigned long asce;
33 unsigned long asce_end;
34 void *private;
35 bool pfault_enabled;
36 };
37
38 /**
39 * struct gmap_notifier - notify function block for page invalidation
40 * @notifier_call: address of callback function
41 */
42 struct gmap_notifier {
43 struct list_head list;
44 struct rcu_head rcu;
45 void (*notifier_call)(struct gmap *gmap, unsigned long start,
46 unsigned long end);
47 };
48
49 struct gmap *gmap_create(struct mm_struct *mm, unsigned long limit);
50 void gmap_remove(struct gmap *gmap);
51 struct gmap *gmap_get(struct gmap *gmap);
52 void gmap_put(struct gmap *gmap);
53
54 void gmap_enable(struct gmap *gmap);
55 void gmap_disable(struct gmap *gmap);
56 int gmap_map_segment(struct gmap *gmap, unsigned long from,
57 unsigned long to, unsigned long len);
58 int gmap_unmap_segment(struct gmap *gmap, unsigned long to, unsigned long len);
59 unsigned long __gmap_translate(struct gmap *, unsigned long gaddr);
60 unsigned long gmap_translate(struct gmap *, unsigned long gaddr);
61 int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr);
62 int gmap_fault(struct gmap *, unsigned long gaddr, unsigned int fault_flags);
63 void gmap_discard(struct gmap *, unsigned long from, unsigned long to);
64 void __gmap_zap(struct gmap *, unsigned long gaddr);
65 void gmap_unlink(struct mm_struct *, unsigned long *table, unsigned long vmaddr);
66
67 void gmap_register_pte_notifier(struct gmap_notifier *);
68 void gmap_unregister_pte_notifier(struct gmap_notifier *);
69 void gmap_pte_notify(struct mm_struct *, unsigned long addr, pte_t *);
70
71 int gmap_mprotect_notify(struct gmap *, unsigned long start,
72 unsigned long len, int prot);
73
74 #endif /* _ASM_S390_GMAP_H */
This page took 0.033866 seconds and 6 git commands to generate.