1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /* Test programs for various Xen versions that QEMU supports. */
4 #if CONFIG_XEN_CTRL_INTERFACE_VERSION == 41100
5 #undef XC_WANT_COMPAT_DEVICEMODEL_API
7 #include <xendevicemodel.h>
8 #include <xenforeignmemory.h>
10 xendevicemodel_handle
*xd
;
11 xenforeignmemory_handle
*xfmem
;
13 xd
= xendevicemodel_open(0, 0);
14 xendevicemodel_pin_memory_cacheattr(xd
, 0, 0, 0, 0);
16 xfmem
= xenforeignmemory_open(0, 0);
17 xenforeignmemory_map_resource(xfmem
, 0, 0, 0, 0, 0, NULL
, 0, 0);
22 #elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 41000
23 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
24 #include <xenforeignmemory.h>
25 #include <xentoolcore.h>
27 xenforeignmemory_handle
*xfmem
;
29 xfmem
= xenforeignmemory_open(0, 0);
30 xenforeignmemory_map2(xfmem
, 0, 0, 0, 0, 0, 0, 0);
31 xentoolcore_restrict_all(0);
36 #elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40900
37 #undef XC_WANT_COMPAT_DEVICEMODEL_API
39 #include <xendevicemodel.h>
41 xendevicemodel_handle
*xd
;
43 xd
= xendevicemodel_open(0, 0);
44 xendevicemodel_close(xd
);
49 #elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40800
51 * If we have stable libs the we don't want the libxc compat
52 * layers, regardless of what CFLAGS we may have been given.
54 * Also, check if xengnttab_grant_copy_segment_t is defined and
55 * grant copy operation is implemented.
57 #undef XC_WANT_COMPAT_EVTCHN_API
58 #undef XC_WANT_COMPAT_GNTTAB_API
59 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
62 #include <xenevtchn.h>
63 #include <xengnttab.h>
64 #include <xenforeignmemory.h>
66 #include <xen/hvm/hvm_info_table.h>
67 #if !defined(HVM_MAX_VCPUS)
68 # error HVM_MAX_VCPUS not defined
71 xc_interface
*xc
= NULL
;
72 xenforeignmemory_handle
*xfmem
;
75 xengnttab_grant_copy_segment_t
* seg
= NULL
;
79 xc
= xc_interface_open(0, 0, 0);
80 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro
, 0, 0);
81 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn
, 0, 0);
82 xc_hvm_inject_msi(xc
, 0, 0xf0000000, 0x00000000);
83 xc_hvm_create_ioreq_server(xc
, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC
, NULL
);
85 xfmem
= xenforeignmemory_open(0, 0);
86 xenforeignmemory_map(xfmem
, 0, 0, 0, 0, 0);
88 xe
= xenevtchn_open(0, 0);
91 xg
= xengnttab_open(0, 0);
92 xengnttab_grant_copy(xg
, 0, seg
);
97 #elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40701
99 * If we have stable libs the we don't want the libxc compat
100 * layers, regardless of what CFLAGS we may have been given.
102 #undef XC_WANT_COMPAT_EVTCHN_API
103 #undef XC_WANT_COMPAT_GNTTAB_API
104 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
106 #include <xenstore.h>
107 #include <xenevtchn.h>
108 #include <xengnttab.h>
109 #include <xenforeignmemory.h>
111 #include <xen/hvm/hvm_info_table.h>
112 #if !defined(HVM_MAX_VCPUS)
113 # error HVM_MAX_VCPUS not defined
116 xc_interface
*xc
= NULL
;
117 xenforeignmemory_handle
*xfmem
;
118 xenevtchn_handle
*xe
;
119 xengnttab_handle
*xg
;
123 xc
= xc_interface_open(0, 0, 0);
124 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro
, 0, 0);
125 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn
, 0, 0);
126 xc_hvm_inject_msi(xc
, 0, 0xf0000000, 0x00000000);
127 xc_hvm_create_ioreq_server(xc
, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC
, NULL
);
129 xfmem
= xenforeignmemory_open(0, 0);
130 xenforeignmemory_map(xfmem
, 0, 0, 0, 0, 0);
132 xe
= xenevtchn_open(0, 0);
135 xg
= xengnttab_open(0, 0);
136 xengnttab_map_grant_ref(xg
, 0, 0, 0);
141 #elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40600
143 #include <xenstore.h>
145 #include <xen/hvm/hvm_info_table.h>
146 #if !defined(HVM_MAX_VCPUS)
147 # error HVM_MAX_VCPUS not defined
152 xc
= xc_interface_open(0, 0, 0);
153 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro
, 0, 0);
154 xc_gnttab_open(NULL
, 0);
155 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn
, 0, 0);
156 xc_hvm_inject_msi(xc
, 0, 0xf0000000, 0x00000000);
157 xc_hvm_create_ioreq_server(xc
, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC
, NULL
);
158 xc_reserved_device_memory_map(xc
, 0, 0, 0, 0, NULL
, 0);
162 #elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40500
164 #include <xenstore.h>
166 #include <xen/hvm/hvm_info_table.h>
167 #if !defined(HVM_MAX_VCPUS)
168 # error HVM_MAX_VCPUS not defined
173 xc
= xc_interface_open(0, 0, 0);
174 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro
, 0, 0);
175 xc_gnttab_open(NULL
, 0);
176 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn
, 0, 0);
177 xc_hvm_inject_msi(xc
, 0, 0xf0000000, 0x00000000);
178 xc_hvm_create_ioreq_server(xc
, 0, 0, NULL
);
182 #elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40200
184 #include <xenstore.h>
186 #include <xen/hvm/hvm_info_table.h>
187 #if !defined(HVM_MAX_VCPUS)
188 # error HVM_MAX_VCPUS not defined
193 xc
= xc_interface_open(0, 0, 0);
194 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro
, 0, 0);
195 xc_gnttab_open(NULL
, 0);
196 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn
, 0, 0);
197 xc_hvm_inject_msi(xc
, 0, 0xf0000000, 0x00000000);
202 #error invalid CONFIG_XEN_CTRL_INTERFACE_VERSION