blob: a99bab8175234eb9117dddcd36702083d0896c3c [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Jeremy Fitzhardinge1ccbf532009-10-06 15:11:14 -07002#ifndef _XEN_XEN_H
3#define _XEN_XEN_H
4
5enum xen_domain_type {
6 XEN_NATIVE, /* running on bare hardware */
7 XEN_PV_DOMAIN, /* running in a PV domain */
8 XEN_HVM_DOMAIN, /* running in a Xen hvm domain */
9};
10
11#ifdef CONFIG_XEN
12extern enum xen_domain_type xen_domain_type;
13#else
14#define xen_domain_type XEN_NATIVE
15#endif
16
Juergen Grossb4feaeb2017-07-27 17:11:58 +020017#ifdef CONFIG_XEN_PVH
18extern bool xen_pvh;
19#else
20#define xen_pvh 0
21#endif
22
Jeremy Fitzhardinge1ccbf532009-10-06 15:11:14 -070023#define xen_domain() (xen_domain_type != XEN_NATIVE)
Juergen Grossb4feaeb2017-07-27 17:11:58 +020024#define xen_pv_domain() (xen_domain_type == XEN_PV_DOMAIN)
25#define xen_hvm_domain() (xen_domain_type == XEN_HVM_DOMAIN)
26#define xen_pvh_domain() (xen_pvh)
Jeremy Fitzhardinge1ccbf532009-10-06 15:11:14 -070027
Roger Pau Monne1fe83882018-06-08 10:40:38 +020028#include <linux/types.h>
29
30extern uint32_t xen_start_flags;
31
Maran Wilson8cee3972018-12-10 11:08:45 -080032#include <xen/interface/hvm/start_info.h>
33extern struct hvm_start_info pvh_start_info;
34
Jeremy Fitzhardinge1ccbf532009-10-06 15:11:14 -070035#ifdef CONFIG_XEN_DOM0
36#include <xen/interface/xen.h>
37#include <asm/xen/hypervisor.h>
38
Stefano Stabellini4c071ee2012-09-14 13:53:39 +000039#define xen_initial_domain() (xen_domain() && \
Roger Pau Monne1fe83882018-06-08 10:40:38 +020040 (xen_start_flags & SIF_INITDOMAIN))
Jeremy Fitzhardinge1ccbf532009-10-06 15:11:14 -070041#else /* !CONFIG_XEN_DOM0 */
42#define xen_initial_domain() (0)
43#endif /* CONFIG_XEN_DOM0 */
44
Christoph Hellwig20e32672018-09-25 13:30:07 -070045struct bio_vec;
Ming Lei0383ad42019-03-29 15:07:54 +080046struct page;
47
Christoph Hellwig20e32672018-09-25 13:30:07 -070048bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
Ming Lei0383ad42019-03-29 15:07:54 +080049 const struct page *page);
Christoph Hellwig20e32672018-09-25 13:30:07 -070050
Juergen Gross1d988ed2019-02-14 11:42:40 +010051#if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_XEN_BALLOON)
52extern u64 xen_saved_max_mem_size;
53#endif
54
Oleksandr Tyshchenko9dd060a2021-12-09 22:05:33 +020055#ifdef CONFIG_XEN_UNPOPULATED_ALLOC
Roger Pau Monne9e2369c2020-09-01 10:33:26 +020056int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages);
57void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages);
Oleksandr Tyshchenkod1a928e2021-12-09 22:05:34 +020058#include <linux/ioport.h>
59int arch_xen_unpopulated_init(struct resource **res);
Oleksandr Tyshchenko9dd060a2021-12-09 22:05:33 +020060#else
61#include <xen/balloon.h>
62static inline int xen_alloc_unpopulated_pages(unsigned int nr_pages,
63 struct page **pages)
64{
65 return xen_alloc_ballooned_pages(nr_pages, pages);
66}
67static inline void xen_free_unpopulated_pages(unsigned int nr_pages,
68 struct page **pages)
69{
70 xen_free_ballooned_pages(nr_pages, pages);
71}
72#endif
Roger Pau Monne9e2369c2020-09-01 10:33:26 +020073
Jeremy Fitzhardinge1ccbf532009-10-06 15:11:14 -070074#endif /* _XEN_XEN_H */