Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/contrib/xen/hvm/hvm_op.h
48253 views
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
uint16_t pad;
36
uint32_t index; /* IN */
37
uint64_t value; /* IN/OUT */
38
};
39
typedef struct xen_hvm_param xen_hvm_param_t;
40
DEFINE_XEN_GUEST_HANDLE(xen_hvm_param_t);
41
42
struct xen_hvm_altp2m_suppress_ve {
43
uint16_t view;
44
uint8_t suppress_ve; /* Boolean type. */
45
uint8_t pad1;
46
uint32_t pad2;
47
uint64_t gfn;
48
};
49
50
struct xen_hvm_altp2m_suppress_ve_multi {
51
uint16_t view;
52
uint8_t suppress_ve; /* Boolean type. */
53
uint8_t pad1;
54
int32_t first_error; /* Should be set to 0. */
55
uint64_t first_gfn; /* Value may be updated. */
56
uint64_t last_gfn;
57
uint64_t first_error_gfn; /* Gfn of the first error. */
58
};
59
60
#if __XEN_INTERFACE_VERSION__ < 0x00040900
61
62
/* Set the logical level of one of a domain's PCI INTx wires. */
63
#define HVMOP_set_pci_intx_level 2
64
struct xen_hvm_set_pci_intx_level {
65
/* Domain to be updated. */
66
domid_t domid;
67
/* PCI INTx identification in PCI topology (domain:bus:device:intx). */
68
uint8_t domain, bus, device, intx;
69
/* Assertion level (0 = unasserted, 1 = asserted). */
70
uint8_t level;
71
};
72
typedef struct xen_hvm_set_pci_intx_level xen_hvm_set_pci_intx_level_t;
73
DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_intx_level_t);
74
75
/* Set the logical level of one of a domain's ISA IRQ wires. */
76
#define HVMOP_set_isa_irq_level 3
77
struct xen_hvm_set_isa_irq_level {
78
/* Domain to be updated. */
79
domid_t domid;
80
/* ISA device identification, by ISA IRQ (0-15). */
81
uint8_t isa_irq;
82
/* Assertion level (0 = unasserted, 1 = asserted). */
83
uint8_t level;
84
};
85
typedef struct xen_hvm_set_isa_irq_level xen_hvm_set_isa_irq_level_t;
86
DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_isa_irq_level_t);
87
88
#define HVMOP_set_pci_link_route 4
89
struct xen_hvm_set_pci_link_route {
90
/* Domain to be updated. */
91
domid_t domid;
92
/* PCI link identifier (0-3). */
93
uint8_t link;
94
/* ISA IRQ (1-15), or 0 (disable link). */
95
uint8_t isa_irq;
96
};
97
typedef struct xen_hvm_set_pci_link_route xen_hvm_set_pci_link_route_t;
98
DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_link_route_t);
99
100
#endif /* __XEN_INTERFACE_VERSION__ < 0x00040900 */
101
102
/* Flushes all VCPU TLBs: @arg must be NULL. */
103
#define HVMOP_flush_tlbs 5
104
105
/*
106
* hvmmem_type_t should not be defined when generating the corresponding
107
* compat header. This will ensure that the improperly named HVMMEM_(*)
108
* values are defined only once.
109
*/
110
#ifndef XEN_GENERATING_COMPAT_HEADERS
111
112
typedef enum {
113
HVMMEM_ram_rw, /* Normal read/write guest RAM */
114
HVMMEM_ram_ro, /* Read-only; writes are discarded */
115
HVMMEM_mmio_dm, /* Reads and write go to the device model */
116
#if __XEN_INTERFACE_VERSION__ < 0x00040700
117
HVMMEM_mmio_write_dm, /* Read-only; writes go to the device model */
118
#else
119
HVMMEM_unused, /* Placeholder; setting memory to this type
120
will fail for code after 4.7.0 */
121
#endif
122
HVMMEM_ioreq_server /* Memory type claimed by an ioreq server; type
123
changes to this value are only allowed after
124
an ioreq server has claimed its ownership.
125
Only pages with HVMMEM_ram_rw are allowed to
126
change to this type; conversely, pages with
127
this type are only allowed to be changed back
128
to HVMMEM_ram_rw. */
129
} hvmmem_type_t;
130
131
#endif /* XEN_GENERATING_COMPAT_HEADERS */
132
133
/* Hint from PV drivers for pagetable destruction. */
134
#define HVMOP_pagetable_dying 9
135
struct xen_hvm_pagetable_dying {
136
/* Domain with a pagetable about to be destroyed. */
137
domid_t domid;
138
uint16_t pad[3]; /* align next field on 8-byte boundary */
139
/* guest physical address of the toplevel pagetable dying */
140
uint64_t gpa;
141
};
142
typedef struct xen_hvm_pagetable_dying xen_hvm_pagetable_dying_t;
143
DEFINE_XEN_GUEST_HANDLE(xen_hvm_pagetable_dying_t);
144
145
/* Get the current Xen time, in nanoseconds since system boot. */
146
#define HVMOP_get_time 10
147
struct xen_hvm_get_time {
148
uint64_t now; /* OUT */
149
};
150
typedef struct xen_hvm_get_time xen_hvm_get_time_t;
151
DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_time_t);
152
153
#define HVMOP_xentrace 11
154
struct xen_hvm_xentrace {
155
uint16_t event, extra_bytes;
156
uint8_t extra[TRACE_EXTRA_MAX * sizeof(uint32_t)];
157
};
158
typedef struct xen_hvm_xentrace xen_hvm_xentrace_t;
159
DEFINE_XEN_GUEST_HANDLE(xen_hvm_xentrace_t);
160
161
/* Following tools-only interfaces may change in future. */
162
#if defined(__XEN__) || defined(__XEN_TOOLS__)
163
164
/* Deprecated by XENMEM_access_op_set_access */
165
#define HVMOP_set_mem_access 12
166
167
/* Deprecated by XENMEM_access_op_get_access */
168
#define HVMOP_get_mem_access 13
169
170
#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
171
172
#define HVMOP_get_mem_type 15
173
/* Return hvmmem_type_t for the specified pfn. */
174
struct xen_hvm_get_mem_type {
175
/* Domain to be queried. */
176
domid_t domid;
177
/* OUT variable. */
178
uint16_t mem_type;
179
uint16_t pad[2]; /* align next field on 8-byte boundary */
180
/* IN variable. */
181
uint64_t pfn;
182
};
183
typedef struct xen_hvm_get_mem_type xen_hvm_get_mem_type_t;
184
DEFINE_XEN_GUEST_HANDLE(xen_hvm_get_mem_type_t);
185
186
/* Following tools-only interfaces may change in future. */
187
#if defined(__XEN__) || defined(__XEN_TOOLS__)
188
189
/*
190
* Definitions relating to DMOP_create_ioreq_server. (Defined here for
191
* backwards compatibility).
192
*/
193
194
#define HVM_IOREQSRV_BUFIOREQ_OFF 0
195
#define HVM_IOREQSRV_BUFIOREQ_LEGACY 1
196
/*
197
* Use this when read_pointer gets updated atomically and
198
* the pointer pair gets read atomically:
199
*/
200
#define HVM_IOREQSRV_BUFIOREQ_ATOMIC 2
201
202
#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
203
204
#if defined(__i386__) || defined(__x86_64__)
205
206
/*
207
* HVMOP_set_evtchn_upcall_vector: Set a <vector> that should be used for event
208
* channel upcalls on the specified <vcpu>. If set,
209
* this vector will be used in preference to the
210
* domain global callback via (see
211
* HVM_PARAM_CALLBACK_IRQ).
212
*/
213
#define HVMOP_set_evtchn_upcall_vector 23
214
struct xen_hvm_evtchn_upcall_vector {
215
uint32_t vcpu;
216
uint8_t vector;
217
};
218
typedef struct xen_hvm_evtchn_upcall_vector xen_hvm_evtchn_upcall_vector_t;
219
DEFINE_XEN_GUEST_HANDLE(xen_hvm_evtchn_upcall_vector_t);
220
221
#endif /* defined(__i386__) || defined(__x86_64__) */
222
223
#define HVMOP_guest_request_vm_event 24
224
225
/* HVMOP_altp2m: perform altp2m state operations */
226
#define HVMOP_altp2m 25
227
228
#define HVMOP_ALTP2M_INTERFACE_VERSION 0x00000001
229
230
struct xen_hvm_altp2m_domain_state {
231
/* IN or OUT variable on/off */
232
uint8_t state;
233
};
234
typedef struct xen_hvm_altp2m_domain_state xen_hvm_altp2m_domain_state_t;
235
DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_domain_state_t);
236
237
struct xen_hvm_altp2m_vcpu_enable_notify {
238
uint32_t vcpu_id;
239
uint32_t pad;
240
/* #VE info area gfn */
241
uint64_t gfn;
242
};
243
typedef struct xen_hvm_altp2m_vcpu_enable_notify xen_hvm_altp2m_vcpu_enable_notify_t;
244
DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_vcpu_enable_notify_t);
245
246
struct xen_hvm_altp2m_vcpu_disable_notify {
247
uint32_t vcpu_id;
248
};
249
typedef struct xen_hvm_altp2m_vcpu_disable_notify xen_hvm_altp2m_vcpu_disable_notify_t;
250
DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_vcpu_disable_notify_t);
251
252
struct xen_hvm_altp2m_view {
253
/* IN/OUT variable */
254
uint16_t view;
255
uint16_t hvmmem_default_access; /* xenmem_access_t */
256
};
257
typedef struct xen_hvm_altp2m_view xen_hvm_altp2m_view_t;
258
DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_view_t);
259
260
#if __XEN_INTERFACE_VERSION__ < 0x00040a00
261
struct xen_hvm_altp2m_set_mem_access {
262
/* view */
263
uint16_t view;
264
/* Memory type */
265
uint16_t access; /* xenmem_access_t */
266
uint32_t pad;
267
/* gfn */
268
uint64_t gfn;
269
};
270
typedef struct xen_hvm_altp2m_set_mem_access xen_hvm_altp2m_set_mem_access_t;
271
DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_set_mem_access_t);
272
#endif /* __XEN_INTERFACE_VERSION__ < 0x00040a00 */
273
274
struct xen_hvm_altp2m_mem_access {
275
/* view */
276
uint16_t view;
277
/* Memory type */
278
uint16_t access; /* xenmem_access_t */
279
uint32_t pad;
280
/* gfn */
281
uint64_t gfn;
282
};
283
typedef struct xen_hvm_altp2m_mem_access xen_hvm_altp2m_mem_access_t;
284
DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_mem_access_t);
285
286
struct xen_hvm_altp2m_set_mem_access_multi {
287
/* view */
288
uint16_t view;
289
uint16_t pad;
290
/* Number of pages */
291
uint32_t nr;
292
/*
293
* Used for continuation purposes.
294
* Must be set to zero upon initial invocation.
295
*/
296
uint64_t opaque;
297
/* List of pfns to set access for */
298
XEN_GUEST_HANDLE(const_uint64) pfn_list;
299
/* Corresponding list of access settings for pfn_list */
300
XEN_GUEST_HANDLE(const_uint8) access_list;
301
};
302
303
struct xen_hvm_altp2m_change_gfn {
304
/* view */
305
uint16_t view;
306
uint16_t pad1;
307
uint32_t pad2;
308
/* old gfn */
309
uint64_t old_gfn;
310
/* new gfn, INVALID_GFN (~0UL) means revert */
311
uint64_t new_gfn;
312
};
313
typedef struct xen_hvm_altp2m_change_gfn xen_hvm_altp2m_change_gfn_t;
314
DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_change_gfn_t);
315
316
struct xen_hvm_altp2m_get_vcpu_p2m_idx {
317
uint32_t vcpu_id;
318
uint16_t altp2m_idx;
319
};
320
321
struct xen_hvm_altp2m_set_visibility {
322
uint16_t altp2m_idx;
323
uint8_t visible;
324
uint8_t pad;
325
};
326
327
struct xen_hvm_altp2m_op {
328
uint32_t version; /* HVMOP_ALTP2M_INTERFACE_VERSION */
329
uint32_t cmd;
330
/* Get/set the altp2m state for a domain */
331
#define HVMOP_altp2m_get_domain_state 1
332
#define HVMOP_altp2m_set_domain_state 2
333
/* Set a given VCPU to receive altp2m event notifications */
334
#define HVMOP_altp2m_vcpu_enable_notify 3
335
/* Create a new view */
336
#define HVMOP_altp2m_create_p2m 4
337
/* Destroy a view */
338
#define HVMOP_altp2m_destroy_p2m 5
339
/* Switch view for an entire domain */
340
#define HVMOP_altp2m_switch_p2m 6
341
/* Notify that a page of memory is to have specific access types */
342
#define HVMOP_altp2m_set_mem_access 7
343
/* Change a p2m entry to have a different gfn->mfn mapping */
344
#define HVMOP_altp2m_change_gfn 8
345
/* Set access for an array of pages */
346
#define HVMOP_altp2m_set_mem_access_multi 9
347
/* Set the "Suppress #VE" bit on a page */
348
#define HVMOP_altp2m_set_suppress_ve 10
349
/* Get the "Suppress #VE" bit of a page */
350
#define HVMOP_altp2m_get_suppress_ve 11
351
/* Get the access of a page of memory from a certain view */
352
#define HVMOP_altp2m_get_mem_access 12
353
/* Disable altp2m event notifications for a given VCPU */
354
#define HVMOP_altp2m_vcpu_disable_notify 13
355
/* Get the active vcpu p2m index */
356
#define HVMOP_altp2m_get_p2m_idx 14
357
/* Set the "Supress #VE" bit for a range of pages */
358
#define HVMOP_altp2m_set_suppress_ve_multi 15
359
/* Set visibility for a given altp2m view */
360
#define HVMOP_altp2m_set_visibility 16
361
domid_t domain;
362
uint16_t pad1;
363
uint32_t pad2;
364
union {
365
struct xen_hvm_altp2m_domain_state domain_state;
366
struct xen_hvm_altp2m_vcpu_enable_notify enable_notify;
367
struct xen_hvm_altp2m_view view;
368
#if __XEN_INTERFACE_VERSION__ < 0x00040a00
369
struct xen_hvm_altp2m_set_mem_access set_mem_access;
370
#endif /* __XEN_INTERFACE_VERSION__ < 0x00040a00 */
371
struct xen_hvm_altp2m_mem_access mem_access;
372
struct xen_hvm_altp2m_change_gfn change_gfn;
373
struct xen_hvm_altp2m_set_mem_access_multi set_mem_access_multi;
374
struct xen_hvm_altp2m_suppress_ve suppress_ve;
375
struct xen_hvm_altp2m_suppress_ve_multi suppress_ve_multi;
376
struct xen_hvm_altp2m_vcpu_disable_notify disable_notify;
377
struct xen_hvm_altp2m_get_vcpu_p2m_idx get_vcpu_p2m_idx;
378
struct xen_hvm_altp2m_set_visibility set_visibility;
379
uint8_t pad[64];
380
} u;
381
};
382
typedef struct xen_hvm_altp2m_op xen_hvm_altp2m_op_t;
383
DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_op_t);
384
385
#endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */
386
387
/*
388
* Local variables:
389
* mode: C
390
* c-file-style: "BSD"
391
* c-basic-offset: 4
392
* tab-width: 4
393
* indent-tabs-mode: nil
394
* End:
395
*/
396
397