1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _XEN_XEN_H 3 #define _XEN_XEN_H 4 5 #include <linux/types.h> 6 7 enum xen_domain_type { 8 XEN_NATIVE, /* running on bare hardware */ 9 XEN_PV_DOMAIN, /* running in a PV domain */ 10 XEN_HVM_DOMAIN, /* running in a Xen hvm domain */ 11 }; 12 13 #ifdef CONFIG_XEN 14 extern enum xen_domain_type xen_domain_type; 15 #else 16 #define xen_domain_type XEN_NATIVE 17 #endif 18 19 #ifdef CONFIG_XEN_PVH 20 extern bool xen_pvh; 21 #else 22 #define xen_pvh 0 23 #endif 24 25 #define xen_domain() (xen_domain_type != XEN_NATIVE) 26 #define xen_pv_domain() (xen_domain_type == XEN_PV_DOMAIN) 27 #define xen_hvm_domain() (xen_domain_type == XEN_HVM_DOMAIN) 28 #define xen_pvh_domain() (xen_pvh) 29 30 extern uint32_t xen_start_flags; 31 32 #include <xen/interface/hvm/start_info.h> 33 extern struct hvm_start_info pvh_start_info; 34 void xen_prepare_pvh(void); 35 struct pt_regs; 36 void xen_pv_evtchn_do_upcall(struct pt_regs *regs); 37 38 #ifdef CONFIG_XEN_DOM0 39 #include <xen/interface/xen.h> 40 #include <asm/xen/hypervisor.h> 41 42 #define xen_initial_domain() (xen_domain() && \ 43 (xen_start_flags & SIF_INITDOMAIN)) 44 #else /* !CONFIG_XEN_DOM0 */ 45 #define xen_initial_domain() (0) 46 #endif /* CONFIG_XEN_DOM0 */ 47 48 struct bio_vec; 49 struct page; 50 51 bool xen_biovec_phys_mergeable(const struct bio_vec *vec1, 52 const struct page *page); 53 54 #if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_XEN_BALLOON) 55 extern u64 xen_saved_max_mem_size; 56 #endif 57 58 #ifdef CONFIG_XEN_UNPOPULATED_ALLOC 59 int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages); 60 void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages); 61 #include <linux/ioport.h> 62 int arch_xen_unpopulated_init(struct resource **res); 63 #else 64 #include <xen/balloon.h> 65 static inline int xen_alloc_unpopulated_pages(unsigned int nr_pages, 66 struct page **pages) 67 { 68 return xen_alloc_ballooned_pages(nr_pages, pages); 69 } 70 static inline void xen_free_unpopulated_pages(unsigned int nr_pages, 71 struct page **pages) 72 { 73 xen_free_ballooned_pages(nr_pages, pages); 74 } 75 #endif 76 77 #if defined(CONFIG_XEN_DOM0) && defined(CONFIG_ACPI) && defined(CONFIG_X86) 78 bool __init xen_processor_present(uint32_t acpi_id); 79 #else 80 #include <linux/bug.h> 81 static inline bool xen_processor_present(uint32_t acpi_id) 82 { 83 BUG(); 84 return false; 85 } 86 #endif 87 88 #endif /* _XEN_XEN_H */ 89