1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21ccbf534SJeremy Fitzhardinge #ifndef _XEN_XEN_H 31ccbf534SJeremy Fitzhardinge #define _XEN_XEN_H 41ccbf534SJeremy Fitzhardinge 51ccbf534SJeremy Fitzhardinge enum xen_domain_type { 61ccbf534SJeremy Fitzhardinge XEN_NATIVE, /* running on bare hardware */ 71ccbf534SJeremy Fitzhardinge XEN_PV_DOMAIN, /* running in a PV domain */ 81ccbf534SJeremy Fitzhardinge XEN_HVM_DOMAIN, /* running in a Xen hvm domain */ 91ccbf534SJeremy Fitzhardinge }; 101ccbf534SJeremy Fitzhardinge 111ccbf534SJeremy Fitzhardinge #ifdef CONFIG_XEN 121ccbf534SJeremy Fitzhardinge extern enum xen_domain_type xen_domain_type; 131ccbf534SJeremy Fitzhardinge #else 141ccbf534SJeremy Fitzhardinge #define xen_domain_type XEN_NATIVE 151ccbf534SJeremy Fitzhardinge #endif 161ccbf534SJeremy Fitzhardinge 17b4feaeb0SJuergen Gross #ifdef CONFIG_XEN_PVH 18b4feaeb0SJuergen Gross extern bool xen_pvh; 19b4feaeb0SJuergen Gross #else 20b4feaeb0SJuergen Gross #define xen_pvh 0 21b4feaeb0SJuergen Gross #endif 22b4feaeb0SJuergen Gross 231ccbf534SJeremy Fitzhardinge #define xen_domain() (xen_domain_type != XEN_NATIVE) 24b4feaeb0SJuergen Gross #define xen_pv_domain() (xen_domain_type == XEN_PV_DOMAIN) 25b4feaeb0SJuergen Gross #define xen_hvm_domain() (xen_domain_type == XEN_HVM_DOMAIN) 26b4feaeb0SJuergen Gross #define xen_pvh_domain() (xen_pvh) 271ccbf534SJeremy Fitzhardinge 281fe83888SRoger Pau Monne #include <linux/types.h> 291fe83888SRoger Pau Monne 301fe83888SRoger Pau Monne extern uint32_t xen_start_flags; 311fe83888SRoger Pau Monne 328cee3974SMaran Wilson #include <xen/interface/hvm/start_info.h> 338cee3974SMaran Wilson extern struct hvm_start_info pvh_start_info; 348cee3974SMaran Wilson 351ccbf534SJeremy Fitzhardinge #ifdef CONFIG_XEN_DOM0 361ccbf534SJeremy Fitzhardinge #include <xen/interface/xen.h> 371ccbf534SJeremy Fitzhardinge #include <asm/xen/hypervisor.h> 381ccbf534SJeremy Fitzhardinge 394c071ee5SStefano Stabellini #define xen_initial_domain() (xen_domain() && \ 401fe83888SRoger Pau Monne (xen_start_flags & SIF_INITDOMAIN)) 411ccbf534SJeremy Fitzhardinge #else /* !CONFIG_XEN_DOM0 */ 421ccbf534SJeremy Fitzhardinge #define xen_initial_domain() (0) 431ccbf534SJeremy Fitzhardinge #endif /* CONFIG_XEN_DOM0 */ 441ccbf534SJeremy Fitzhardinge 4520e32676SChristoph Hellwig struct bio_vec; 460383ad43SMing Lei struct page; 470383ad43SMing Lei 4820e32676SChristoph Hellwig bool xen_biovec_phys_mergeable(const struct bio_vec *vec1, 490383ad43SMing Lei const struct page *page); 5020e32676SChristoph Hellwig 511d988ed4SJuergen Gross #if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_XEN_BALLOON) 521d988ed4SJuergen Gross extern u64 xen_saved_max_mem_size; 531d988ed4SJuergen Gross #endif 541d988ed4SJuergen Gross 559dd060afSOleksandr Tyshchenko #ifdef CONFIG_XEN_UNPOPULATED_ALLOC 569e2369c0SRoger Pau Monne int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages); 579e2369c0SRoger Pau Monne void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages); 58*d1a928eaSOleksandr Tyshchenko #include <linux/ioport.h> 59*d1a928eaSOleksandr Tyshchenko int arch_xen_unpopulated_init(struct resource **res); 609dd060afSOleksandr Tyshchenko #else 619dd060afSOleksandr Tyshchenko #include <xen/balloon.h> 629dd060afSOleksandr Tyshchenko static inline int xen_alloc_unpopulated_pages(unsigned int nr_pages, 639dd060afSOleksandr Tyshchenko struct page **pages) 649dd060afSOleksandr Tyshchenko { 659dd060afSOleksandr Tyshchenko return xen_alloc_ballooned_pages(nr_pages, pages); 669dd060afSOleksandr Tyshchenko } 679dd060afSOleksandr Tyshchenko static inline void xen_free_unpopulated_pages(unsigned int nr_pages, 689dd060afSOleksandr Tyshchenko struct page **pages) 699dd060afSOleksandr Tyshchenko { 709dd060afSOleksandr Tyshchenko xen_free_ballooned_pages(nr_pages, pages); 719dd060afSOleksandr Tyshchenko } 729dd060afSOleksandr Tyshchenko #endif 739e2369c0SRoger Pau Monne 741ccbf534SJeremy Fitzhardinge #endif /* _XEN_XEN_H */ 75