Debian Codegraph @

include/xen/hvm/hvm_op.h

raw
1 /*
2 * Permission is hereby granted, free of charge, to any person obtaining a copy
3 * of this software and associated documentation files (the "Software"), to
4 * deal in the Software without restriction, including without limitation the
5 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6 * sell copies of the Software, and to permit persons to whom the Software is
7 * furnished to do so, subject to the following conditions:
8 *
9 * The above copyright notice and this permission notice shall be included in
10 * all copies or substantial portions of the Software.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 * DEALINGS IN THE SOFTWARE.
19 *
20 * Copyright (c) 2007, Keir Fraser
21 */
22
23 #ifndef __XEN_PUBLIC_HVM_HVM_OP_H__
24 #define __XEN_PUBLIC_HVM_HVM_OP_H__
25
26 #include "../xen.h"
27 #include "../trace.h"
28 #include "../event_channel.h"
29
30 /* Get/set subcommands: extra argument == pointer to xen_hvm_param struct. */
31 #define HVMOP_set_param 0
32 #define HVMOP_get_param 1
33 struct xen_hvm_param {
34 domid_t domid; /* IN */
35 uint32_t index; /* IN */
36 uint64_t value; /* IN/OUT */
37 };
38 typedef struct xen_hvm_param xen_hvm_param_t;
39 DEFINE_XEN_GUEST_HANDLE(xen_hvm_param_t);
40
41 #if __XEN_INTERFACE_VERSION__ < 0x00040900
42
43 /* Set the logical level of one of a domain's PCI INTx wires. */
44 #define HVMOP_set_pci_intx_level 2
45 struct xen_hvm_set_pci_intx_level {
46 /* Domain to be updated. */
47 domid_t domid;
48 /* PCI INTx identification in PCI topology (domain:bus:device:intx). */
49 uint8_t domain, bus, device, intx;
50 /* Assertion level (0 = unasserted, 1 = asserted). */
51 uint8_t level;
52 };
53 typedef struct xen_hvm_set_pci_intx_level xen_hvm_set_pci_intx_level_t;
54 DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_intx_level_t);
55
56 /* Set the logical level of one of a domain's ISA IRQ wires. */
57 #define HVMOP_set_isa_irq_level 3
58 struct xen_hvm_set_isa_irq_level {
59 /* Domain to be updated. */
60 domid_t domid;
61 /* ISA device identification, by ISA IRQ (0-15). */
62 uint8_t isa_irq;
63 /* Assertion level (0 = unasserted, 1 = asserted). */
64 uint8_t level;
65 };
66 typedef struct xen_hvm_set_isa_irq_level xen_hvm_set_isa_irq_level_t;
67 DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_isa_irq_level_t);
68
69 #define HVMOP_set_pci_link_route 4
70 struct xen_hvm_set_pci_link_route {
71 /* Domain to be updated. */
72 domid_t domid;
73 /* PCI link identifier (0-3). */
74 uint8_t link;
75 /* ISA IRQ (1-15), or 0 (disable link). */
76 uint8_t isa_irq;
77 };
78 typedef struct xen_hvm_set_pci_link_route xen_hvm_set_pci_link_route_t;
79 DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_link_route_t);
80
81 #endif /* __XEN_INTERFACE_VERSION__ < 0x00040900 */
82
83 /* Flushes all VCPU TLBs: @arg must be NULL. */
84 #define HVMOP_flush_tlbs 5
85
86 typedef enum {
87 HVMMEM_ram_rw, /* Normal read/write guest RAM */
88 HVMMEM_ram_ro, /* Read-only; writes are discarded */
89 HVMMEM_mmio_dm, /* Reads and write go to the device model */
90 #if __XEN_INTERFACE_VERSION__ < 0x00040700
91 HVMMEM_mmio_write_dm, /* Read-only; writes go to the device model */
92 #else
93 HVMMEM_unused, /* Placeholder; setting memory to this type
94 will fail for code after 4.7.0 */
95 #endif
96 HVMMEM_ioreq_server /* Memory type claimed by an ioreq server; type
97 changes to this value are only allowed after
98 an ioreq server has claimed its ownership.
99 Only pages with HVMMEM_ram_rw are allowed to
100 change to this type; conversely, pages with
101 this type are only allowed to be changed back
102 to HVMMEM_ram_rw. */
103 } hvmmem_type_t;
104
105 /* Hint from PV drivers for pagetable destruction. */
106 #define HVMOP_pagetable_dying 9
107 struct xen_hvm_pagetable_dying {
108 /* Domain with a pagetable about to be destroyed. */
109 domid_t domid;
110 uint16_t pad[3]; /* align next field on 8-byte boundary */
111 /* guest physical address of the toplevel pagetable dying */
112 uint64_t gpa;
113 };
114 typedef struct xen_hvm_pagetable_dying xen_hvm_pagetable_dying_t;
115 DEFINE_XEN_GUEST_HANDLE(xen_hvm_pagetable_dying_t);
116
117 /* Get the current Xen time, in nanoseconds since system boot. */
118 #define HVMOP_get_time 10
119 struct xen_hvm_get_time {
120 uint64_t now; /* OUT */
121 };
122 typedef struct xen_hvm_get_time xen_hvm_get_time_t;
123 DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_time_t);
124
125 #define HVMOP_xentrace 11
126 struct xen_hvm_xentrace {
127 uint16_t event, extra_bytes;
128 uint8_t extra[TRACE_EXTRA_MAX * sizeof(uint32_t)];
129 };
130 typedef struct xen_hvm_xentrace xen_hvm_xentrace_t;
131 DEFINE_XEN_GUEST_HANDLE(xen_hvm_xentrace_t);
132
133 /* Following tools-only interfaces may change in future. */
134 #if defined(__XEN__) || defined(__XEN_TOOLS__)
135
136 /* Deprecated by XENMEM_access_op_set_access */
137 #define HVMOP_set_mem_access 12
138
139 /* Deprecated by XENMEM_access_op_get_access */
140 #define HVMOP_get_mem_access 13
141
142 #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
143
144 #define HVMOP_get_mem_type 15
145 /* Return hvmmem_type_t for the specified pfn. */
146 struct xen_hvm_get_mem_type {
147 /* Domain to be queried. */
148 domid_t domid;
149 /* OUT variable. */
150 uint16_t mem_type;
151 uint16_t pad[2]; /* align next field on 8-byte boundary */
152 /* IN variable. */
153 uint64_t pfn;
154 };
155 typedef struct xen_hvm_get_mem_type xen_hvm_get_mem_type_t;
156 DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_mem_type_t);
157
158 /* Following tools-only interfaces may change in future. */
159 #if defined(__XEN__) || defined(__XEN_TOOLS__)
160
161 /*
162 * Definitions relating to DMOP_create_ioreq_server. (Defined here for
163 * backwards compatibility).
164 */
165
166 #define HVM_IOREQSRV_BUFIOREQ_OFF 0
167 #define HVM_IOREQSRV_BUFIOREQ_LEGACY 1
168 /*
169 * Use this when read_pointer gets updated atomically and
170 * the pointer pair gets read atomically:
171 */
172 #define HVM_IOREQSRV_BUFIOREQ_ATOMIC 2
173
174 #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
175
176 #if defined(__i386__) || defined(__x86_64__)
177
178 /*
179 * HVMOP_set_evtchn_upcall_vector: Set a <vector> that should be used for event
180 * channel upcalls on the specified <vcpu>. If set,
181 * this vector will be used in preference to the
182 * domain global callback via (see
183 * HVM_PARAM_CALLBACK_IRQ).
184 */
185 #define HVMOP_set_evtchn_upcall_vector 23
186 struct xen_hvm_evtchn_upcall_vector {
187 uint32_t vcpu;
188 uint8_t vector;
189 };
190 typedef struct xen_hvm_evtchn_upcall_vector xen_hvm_evtchn_upcall_vector_t;
191 DEFINE_XEN_GUEST_HANDLE(xen_hvm_evtchn_upcall_vector_t);
192
193 #endif /* defined(__i386__) || defined(__x86_64__) */
194
195 #define HVMOP_guest_request_vm_event 24
196
197 /* HVMOP_altp2m: perform altp2m state operations */
198 #define HVMOP_altp2m 25
199
200 #define HVMOP_ALTP2M_INTERFACE_VERSION 0x00000001
201
202 struct xen_hvm_altp2m_domain_state {
203 /* IN or OUT variable on/off */
204 uint8_t state;
205 };
206 typedef struct xen_hvm_altp2m_domain_state xen_hvm_altp2m_domain_state_t;
207 DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_domain_state_t);
208
209 struct xen_hvm_altp2m_vcpu_enable_notify {
210 uint32_t vcpu_id;
211 uint32_t pad;
212 /* #VE info area gfn */
213 uint64_t gfn;
214 };
215 typedef struct xen_hvm_altp2m_vcpu_enable_notify xen_hvm_altp2m_vcpu_enable_notify_t;
216 DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_vcpu_enable_notify_t);
217
218 struct xen_hvm_altp2m_view {
219 /* IN/OUT variable */
220 uint16_t view;
221 /* Create view only: default access type
222 * NOTE: currently ignored */
223 uint16_t hvmmem_default_access; /* xenmem_access_t */
224 };
225 typedef struct xen_hvm_altp2m_view xen_hvm_altp2m_view_t;
226 DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_view_t);
227
228 struct xen_hvm_altp2m_set_mem_access {
229 /* view */
230 uint16_t view;
231 /* Memory type */
232 uint16_t hvmmem_access; /* xenmem_access_t */
233 uint32_t pad;
234 /* gfn */
235 uint64_t gfn;
236 };
237 typedef struct xen_hvm_altp2m_set_mem_access xen_hvm_altp2m_set_mem_access_t;
238 DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_set_mem_access_t);
239
240 struct xen_hvm_altp2m_change_gfn {
241 /* view */
242 uint16_t view;
243 uint16_t pad1;
244 uint32_t pad2;
245 /* old gfn */
246 uint64_t old_gfn;
247 /* new gfn, INVALID_GFN (~0UL) means revert */
248 uint64_t new_gfn;
249 };
250 typedef struct xen_hvm_altp2m_change_gfn xen_hvm_altp2m_change_gfn_t;
251 DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_change_gfn_t);
252
253 struct xen_hvm_altp2m_op {
254 uint32_t version; /* HVMOP_ALTP2M_INTERFACE_VERSION */
255 uint32_t cmd;
256 /* Get/set the altp2m state for a domain */
257 #define HVMOP_altp2m_get_domain_state 1
258 #define HVMOP_altp2m_set_domain_state 2
259 /* Set the current VCPU to receive altp2m event notifications */
260 #define HVMOP_altp2m_vcpu_enable_notify 3
261 /* Create a new view */
262 #define HVMOP_altp2m_create_p2m 4
263 /* Destroy a view */
264 #define HVMOP_altp2m_destroy_p2m 5
265 /* Switch view for an entire domain */
266 #define HVMOP_altp2m_switch_p2m 6
267 /* Notify that a page of memory is to have specific access types */
268 #define HVMOP_altp2m_set_mem_access 7
269 /* Change a p2m entry to have a different gfn->mfn mapping */
270 #define HVMOP_altp2m_change_gfn 8
271 domid_t domain;
272 uint16_t pad1;
273 uint32_t pad2;
274 union {
275 struct xen_hvm_altp2m_domain_state domain_state;
276 struct xen_hvm_altp2m_vcpu_enable_notify enable_notify;
277 struct xen_hvm_altp2m_view view;
278 struct xen_hvm_altp2m_set_mem_access set_mem_access;
279 struct xen_hvm_altp2m_change_gfn change_gfn;
280 uint8_t pad[64];
281 } u;
282 };
283 typedef struct xen_hvm_altp2m_op xen_hvm_altp2m_op_t;
284 DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_op_t);
285
286 #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */
287
288 /*
289 * Local variables:
290 * mode: C
291 * c-file-style: "BSD"
292 * c-basic-offset: 4
293 * tab-width: 4
294 * indent-tabs-mode: nil
295 * End:
296 */