blob: 86abe07b20ec71459e7d5d0613b92886f2655980 [file] [log] [blame]
Isaku Yamahatae04d0d02008-04-02 10:53:55 -07001#ifndef INCLUDE_XEN_OPS_H
2#define INCLUDE_XEN_OPS_H
3
4#include <linux/percpu.h>
Stanislaw Gruszkacd979882014-02-26 11:30:30 +01005#include <linux/notifier.h>
Daniel Kiperbe81c8a2014-06-30 19:53:02 +02006#include <linux/efi.h>
Ian Campbell7892f692012-10-16 17:19:15 +01007#include <asm/xen/interface.h>
Stefano Stabellini4ccefbe2015-11-05 15:15:07 +00008#include <xen/interface/vcpu.h>
Isaku Yamahatae04d0d02008-04-02 10:53:55 -07009
10DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu);
11
Ian Campbell03c81422011-02-17 11:04:20 +000012void xen_arch_pre_suspend(void);
13void xen_arch_post_suspend(int suspend_cancelled);
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +010014
Isaku Yamahataad55db92008-07-08 15:06:32 -070015void xen_timer_resume(void);
16void xen_arch_resume(void);
Boris Ostrovsky2b953a52015-04-28 18:46:20 -040017void xen_arch_suspend(void);
Isaku Yamahataad55db92008-07-08 15:06:32 -070018
Stanislaw Gruszkacd979882014-02-26 11:30:30 +010019void xen_resume_notifier_register(struct notifier_block *nb);
20void xen_resume_notifier_unregister(struct notifier_block *nb);
21
Stefano Stabellini4ccefbe2015-11-05 15:15:07 +000022bool xen_vcpu_stolen(int vcpu);
23void xen_setup_runstate_info(int cpu);
24void xen_get_runstate_snapshot(struct vcpu_runstate_info *res);
25
Stefano Stabellini016b6f52010-05-14 12:45:07 +010026int xen_setup_shutdown_event(void);
27
Alex Nixon08bbc9d2009-02-09 12:05:46 -080028extern unsigned long *xen_contiguous_bitmap;
Stefano Stabellini1b65c4e2013-10-10 13:41:10 +000029int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
Stefano Stabellini69908902013-10-09 16:56:32 +000030 unsigned int address_bits,
31 dma_addr_t *dma_handle);
Alex Nixon08bbc9d2009-02-09 12:05:46 -080032
Stefano Stabellini1b65c4e2013-10-10 13:41:10 +000033void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order);
Alex Nixon08bbc9d2009-02-09 12:05:46 -080034
David Howellsc140d872012-03-28 18:30:02 +010035struct vm_area_struct;
David Vrabel4e8c0c82015-03-11 14:49:57 +000036
37/*
Julien Gralla13d7202015-08-07 17:34:41 +010038 * xen_remap_domain_gfn_array() - map an array of foreign frames
David Vrabel4e8c0c82015-03-11 14:49:57 +000039 * @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 */
Julien Gralla13d7202015-08-07 17:34:41 +010054int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
David Vrabel4e8c0c82015-03-11 14:49:57 +000055 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
Julien Gralla13d7202015-08-07 17:34:41 +010061/* xen_remap_domain_gfn_range() - map a range of foreign frames
David Vrabel4e8c0c82015-03-11 14:49:57 +000062 * @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 */
Julien Gralla13d7202015-08-07 17:34:41 +010073int xen_remap_domain_gfn_range(struct vm_area_struct *vma,
Ian Campbellde1ef202009-05-21 10:09:46 +010074 unsigned long addr,
David Vrabel4e8c0c82015-03-11 14:49:57 +000075 xen_pfn_t gfn, int nr,
Ian Campbell9a032e32012-10-17 13:37:49 -070076 pgprot_t prot, unsigned domid,
77 struct page **pages);
Julien Gralla13d7202015-08-07 17:34:41 +010078int xen_unmap_domain_gfn_range(struct vm_area_struct *vma,
Ian Campbell9a032e32012-10-17 13:37:49 -070079 int numpgs, struct page **pages);
David Vrabel4e8c0c82015-03-11 14:49:57 +000080int xen_xlate_remap_gfn_array(struct vm_area_struct *vma,
David Vrabel628c28e2015-03-11 14:49:56 +000081 unsigned long addr,
David Vrabel4e8c0c82015-03-11 14:49:57 +000082 xen_pfn_t *gfn, int nr,
83 int *err_ptr, pgprot_t prot,
David Vrabel628c28e2015-03-11 14:49:56 +000084 unsigned domid,
85 struct page **pages);
86int xen_xlate_unmap_gfn_range(struct vm_area_struct *vma,
87 int nr, struct page **pages);
Ian Campbellde1ef202009-05-21 10:09:46 +010088
Konrad Rzeszutek Wilk394b40f2012-11-27 11:39:40 -050089bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
Daniel Kiperbe81c8a2014-06-30 19:53:02 +020090
91#ifdef CONFIG_XEN_EFI
92extern efi_system_table_t *xen_efi_probe(void);
93#else
Daniel Kiper57f71382014-07-12 23:09:47 +020094static inline efi_system_table_t __init *xen_efi_probe(void)
Daniel Kiperbe81c8a2014-06-30 19:53:02 +020095{
96 return NULL;
97}
98#endif
99
David Vrabelfdfd8112015-02-19 15:23:17 +0000100#ifdef CONFIG_PREEMPT
101
102static inline void xen_preemptible_hcall_begin(void)
103{
104}
105
106static inline void xen_preemptible_hcall_end(void)
107{
108}
109
110#else
111
112DECLARE_PER_CPU(bool, xen_in_preemptible_hcall);
113
114static inline void xen_preemptible_hcall_begin(void)
115{
116 __this_cpu_write(xen_in_preemptible_hcall, true);
117}
118
119static inline void xen_preemptible_hcall_end(void)
120{
121 __this_cpu_write(xen_in_preemptible_hcall, false);
122}
123
124#endif /* CONFIG_PREEMPT */
125
Isaku Yamahatae04d0d02008-04-02 10:53:55 -0700126#endif /* INCLUDE_XEN_OPS_H */