xref: /openbmc/linux/include/xen/xen-ops.h (revision 78700c0a)
1 #ifndef INCLUDE_XEN_OPS_H
2 #define INCLUDE_XEN_OPS_H
3 
4 #include <linux/percpu.h>
5 #include <linux/notifier.h>
6 #include <linux/efi.h>
7 #include <asm/xen/interface.h>
8 #include <xen/interface/vcpu.h>
9 
10 DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu);
11 
12 void xen_arch_pre_suspend(void);
13 void xen_arch_post_suspend(int suspend_cancelled);
14 
15 void xen_timer_resume(void);
16 void xen_arch_resume(void);
17 void xen_arch_suspend(void);
18 
19 void xen_resume_notifier_register(struct notifier_block *nb);
20 void xen_resume_notifier_unregister(struct notifier_block *nb);
21 
22 bool xen_vcpu_stolen(int vcpu);
23 void xen_setup_runstate_info(int cpu);
24 void xen_get_runstate_snapshot(struct vcpu_runstate_info *res);
25 
26 int xen_setup_shutdown_event(void);
27 
28 extern unsigned long *xen_contiguous_bitmap;
29 int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
30 				unsigned int address_bits,
31 				dma_addr_t *dma_handle);
32 
33 void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order);
34 
35 struct vm_area_struct;
36 
37 /*
38  * xen_remap_domain_gfn_array() - map an array of foreign frames
39  * @vma:     VMA to map the pages into
40  * @addr:    Address at which to map the pages
41  * @gfn:     Array of GFNs to map
42  * @nr:      Number entries in the GFN array
43  * @err_ptr: Returns per-GFN error status.
44  * @prot:    page protection mask
45  * @domid:   Domain owning the pages
46  * @pages:   Array of pages if this domain has an auto-translated physmap
47  *
48  * @gfn and @err_ptr may point to the same buffer, the GFNs will be
49  * overwritten by the error codes after they are mapped.
50  *
51  * Returns the number of successfully mapped frames, or a -ve error
52  * code.
53  */
54 int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
55 			       unsigned long addr,
56 			       xen_pfn_t *gfn, int nr,
57 			       int *err_ptr, pgprot_t prot,
58 			       unsigned domid,
59 			       struct page **pages);
60 
61 /* xen_remap_domain_gfn_range() - map a range of foreign frames
62  * @vma:     VMA to map the pages into
63  * @addr:    Address at which to map the pages
64  * @gfn:     First GFN to map.
65  * @nr:      Number frames to map
66  * @prot:    page protection mask
67  * @domid:   Domain owning the pages
68  * @pages:   Array of pages if this domain has an auto-translated physmap
69  *
70  * Returns the number of successfully mapped frames, or a -ve error
71  * code.
72  */
73 int xen_remap_domain_gfn_range(struct vm_area_struct *vma,
74 			       unsigned long addr,
75 			       xen_pfn_t gfn, int nr,
76 			       pgprot_t prot, unsigned domid,
77 			       struct page **pages);
78 int xen_unmap_domain_gfn_range(struct vm_area_struct *vma,
79 			       int numpgs, struct page **pages);
80 int xen_xlate_remap_gfn_array(struct vm_area_struct *vma,
81 			      unsigned long addr,
82 			      xen_pfn_t *gfn, int nr,
83 			      int *err_ptr, pgprot_t prot,
84 			      unsigned domid,
85 			      struct page **pages);
86 int xen_xlate_unmap_gfn_range(struct vm_area_struct *vma,
87 			      int nr, struct page **pages);
88 
89 bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
90 
91 #ifdef CONFIG_XEN_EFI
92 extern efi_system_table_t *xen_efi_probe(void);
93 #else
94 static inline efi_system_table_t __init *xen_efi_probe(void)
95 {
96 	return NULL;
97 }
98 #endif
99 
100 #ifdef CONFIG_PREEMPT
101 
102 static inline void xen_preemptible_hcall_begin(void)
103 {
104 }
105 
106 static inline void xen_preemptible_hcall_end(void)
107 {
108 }
109 
110 #else
111 
112 DECLARE_PER_CPU(bool, xen_in_preemptible_hcall);
113 
114 static inline void xen_preemptible_hcall_begin(void)
115 {
116 	__this_cpu_write(xen_in_preemptible_hcall, true);
117 }
118 
119 static inline void xen_preemptible_hcall_end(void)
120 {
121 	__this_cpu_write(xen_in_preemptible_hcall, false);
122 }
123 
124 #endif /* CONFIG_PREEMPT */
125 
126 #endif /* INCLUDE_XEN_OPS_H */
127