blob: 2cf49624af994438ec94ce75b214e6d0f2c257be [file] [log] [blame]
Martin Schwidefsky1e133ab2016-03-08 11:49:57 +01001/*
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 * @table: pointer to the page directory
19 * @asce: address space control element for gmap page table
20 * @pfault_enabled: defines if pfaults are applicable for the guest
21 */
22struct gmap {
23 struct list_head list;
24 struct list_head crst_list;
25 struct mm_struct *mm;
26 struct radix_tree_root guest_to_host;
27 struct radix_tree_root host_to_guest;
28 spinlock_t guest_table_lock;
29 unsigned long *table;
30 unsigned long asce;
31 unsigned long asce_end;
32 void *private;
33 bool pfault_enabled;
34};
35
36/**
37 * struct gmap_notifier - notify function block for page invalidation
38 * @notifier_call: address of callback function
39 */
40struct gmap_notifier {
41 struct list_head list;
Martin Schwidefsky8ecb1a52016-03-08 11:54:14 +010042 struct rcu_head rcu;
Martin Schwidefsky414d3b02016-03-08 11:52:54 +010043 void (*notifier_call)(struct gmap *gmap, unsigned long start,
44 unsigned long end);
Martin Schwidefsky1e133ab2016-03-08 11:49:57 +010045};
46
47struct gmap *gmap_alloc(struct mm_struct *mm, unsigned long limit);
48void gmap_free(struct gmap *gmap);
49void gmap_enable(struct gmap *gmap);
50void gmap_disable(struct gmap *gmap);
51int gmap_map_segment(struct gmap *gmap, unsigned long from,
52 unsigned long to, unsigned long len);
53int gmap_unmap_segment(struct gmap *gmap, unsigned long to, unsigned long len);
54unsigned long __gmap_translate(struct gmap *, unsigned long gaddr);
55unsigned long gmap_translate(struct gmap *, unsigned long gaddr);
56int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr);
57int gmap_fault(struct gmap *, unsigned long gaddr, unsigned int fault_flags);
58void gmap_discard(struct gmap *, unsigned long from, unsigned long to);
59void __gmap_zap(struct gmap *, unsigned long gaddr);
60void gmap_unlink(struct mm_struct *, unsigned long *table, unsigned long vmaddr);
61
62void gmap_register_ipte_notifier(struct gmap_notifier *);
63void gmap_unregister_ipte_notifier(struct gmap_notifier *);
64int gmap_ipte_notify(struct gmap *, unsigned long start, unsigned long len);
65
66#endif /* _ASM_S390_GMAP_H */