Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
dm_op.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: MIT */
2/*
3 * Copyright (c) 2016, Citrix Systems Inc
4 *
5 */
6
7#ifndef __XEN_PUBLIC_HVM_DM_OP_H__
8#define __XEN_PUBLIC_HVM_DM_OP_H__
9
10#include "../xen.h"
11#include "../event_channel.h"
12
13#ifndef uint64_aligned_t
14#define uint64_aligned_t uint64_t
15#endif
16
17/*
18 * IOREQ Servers
19 *
20 * The interface between an I/O emulator an Xen is called an IOREQ Server.
21 * A domain supports a single 'legacy' IOREQ Server which is instantiated if
22 * parameter...
23 *
24 * HVM_PARAM_IOREQ_PFN is read (to get the gfn containing the synchronous
25 * ioreq structures), or...
26 * HVM_PARAM_BUFIOREQ_PFN is read (to get the gfn containing the buffered
27 * ioreq ring), or...
28 * HVM_PARAM_BUFIOREQ_EVTCHN is read (to get the event channel that Xen uses
29 * to request buffered I/O emulation).
30 *
31 * The following hypercalls facilitate the creation of IOREQ Servers for
32 * 'secondary' emulators which are invoked to implement port I/O, memory, or
33 * PCI config space ranges which they explicitly register.
34 */
35
37
38/*
39 * XEN_DMOP_create_ioreq_server: Instantiate a new IOREQ Server for a
40 * secondary emulator.
41 *
42 * The <id> handed back is unique for target domain. The valur of
43 * <handle_bufioreq> should be one of HVM_IOREQSRV_BUFIOREQ_* defined in
44 * hvm_op.h. If the value is HVM_IOREQSRV_BUFIOREQ_OFF then the buffered
45 * ioreq ring will not be allocated and hence all emulation requests to
46 * this server will be synchronous.
47 */
48#define XEN_DMOP_create_ioreq_server 1
49
51 /* IN - should server handle buffered ioreqs */
54 /* OUT - server id */
56};
58
59/*
60 * XEN_DMOP_get_ioreq_server_info: Get all the information necessary to
61 * access IOREQ Server <id>.
62 *
63 * If the IOREQ Server is handling buffered emulation requests, the
64 * emulator needs to bind to event channel <bufioreq_port> to listen for
65 * them. (The event channels used for synchronous emulation requests are
66 * specified in the per-CPU ioreq structures).
67 * In addition, if the XENMEM_acquire_resource memory op cannot be used,
68 * the emulator will need to map the synchronous ioreq structures and
69 * buffered ioreq ring (if it exists) from guest memory. If <flags> does
70 * not contain XEN_DMOP_no_gfns then these pages will be made available and
71 * the frame numbers passed back in gfns <ioreq_gfn> and <bufioreq_gfn>
72 * respectively. (If the IOREQ Server is not handling buffered emulation
73 * only <ioreq_gfn> will be valid).
74 *
75 * NOTE: To access the synchronous ioreq structures and buffered ioreq
76 * ring, it is preferable to use the XENMEM_acquire_resource memory
77 * op specifying resource type XENMEM_resource_ioreq_server.
78 */
79#define XEN_DMOP_get_ioreq_server_info 2
80
82 /* IN - server id */
84 /* IN - flags */
86
87#define _XEN_DMOP_no_gfns 0
88#define XEN_DMOP_no_gfns (1u << _XEN_DMOP_no_gfns)
89
90 /* OUT - buffered ioreq port */
92 /* OUT - sync ioreq gfn (see block comment above) */
94 /* OUT - buffered ioreq gfn (see block comment above)*/
96};
98
99/*
100 * XEN_DMOP_map_io_range_to_ioreq_server: Register an I/O range for
101 * emulation by the client of
102 * IOREQ Server <id>.
103 * XEN_DMOP_unmap_io_range_from_ioreq_server: Deregister an I/O range
104 * previously registered for
105 * emulation by the client of
106 * IOREQ Server <id>.
107 *
108 * There are three types of I/O that can be emulated: port I/O, memory
109 * accesses and PCI config space accesses. The <type> field denotes which
110 * type of range* the <start> and <end> (inclusive) fields are specifying.
111 * PCI config space ranges are specified by segment/bus/device/function
112 * values which should be encoded using the DMOP_PCI_SBDF helper macro
113 * below.
114 *
115 * NOTE: unless an emulation request falls entirely within a range mapped
116 * by a secondary emulator, it will not be passed to that emulator.
117 */
118#define XEN_DMOP_map_io_range_to_ioreq_server 3
119#define XEN_DMOP_unmap_io_range_from_ioreq_server 4
120
122 /* IN - server id */
125 /* IN - type of range */
127#define XEN_DMOP_IO_RANGE_PORT 0 /* I/O port range */
128#define XEN_DMOP_IO_RANGE_MEMORY 1 /* MMIO range */
129#define XEN_DMOP_IO_RANGE_PCI 2 /* PCI segment/bus/dev/func range */
130 /* IN - inclusive start and end of range */
132};
134
135#define XEN_DMOP_PCI_SBDF(s, b, d, f) \
136 ((((s) & 0xffff) << 16) | (((b) & 0xff) << 8) | (((d) & 0x1f) << 3) | ((f) & 0x07))
137
138/*
139 * XEN_DMOP_set_ioreq_server_state: Enable or disable the IOREQ Server <id>
140 *
141 * The IOREQ Server will not be passed any emulation requests until it is
142 * in the enabled state.
143 * Note that the contents of the ioreq_gfn and bufioreq_gfn (see
144 * XEN_DMOP_get_ioreq_server_info) are not meaningful until the IOREQ Server
145 * is in the enabled state.
146 */
147#define XEN_DMOP_set_ioreq_server_state 5
148
150 /* IN - server id */
152 /* IN - enabled? */
155};
157
158/*
159 * XEN_DMOP_destroy_ioreq_server: Destroy the IOREQ Server <id>.
160 *
161 * Any registered I/O ranges will be automatically deregistered.
162 */
163#define XEN_DMOP_destroy_ioreq_server 6
164
166 /* IN - server id */
169};
171
172/*
173 * XEN_DMOP_track_dirty_vram: Track modifications to the specified pfn
174 * range.
175 *
176 * NOTE: The bitmap passed back to the caller is passed in a
177 * secondary buffer.
178 */
179#define XEN_DMOP_track_dirty_vram 7
180
182 /* IN - number of pages to be tracked */
185 /* IN - first pfn to track */
187};
189
190/*
191 * XEN_DMOP_set_pci_intx_level: Set the logical level of one of a domain's
192 * PCI INTx pins.
193 */
194#define XEN_DMOP_set_pci_intx_level 8
195
197 /* IN - PCI INTx identification (domain:bus:device:intx) */
200 /* IN - Level: 0 -> deasserted, 1 -> asserted */
202};
204
205/*
206 * XEN_DMOP_set_isa_irq_level: Set the logical level of a one of a domain's
207 * ISA IRQ lines.
208 */
209#define XEN_DMOP_set_isa_irq_level 9
210
212 /* IN - ISA IRQ (0-15) */
214 /* IN - Level: 0 -> deasserted, 1 -> asserted */
216};
218
219/*
220 * XEN_DMOP_set_pci_link_route: Map a PCI INTx line to an IRQ line.
221 */
222#define XEN_DMOP_set_pci_link_route 10
223
225 /* PCI INTx line (0-3) */
227 /* ISA IRQ (1-15) or 0 -> disable link */
229};
231
232/*
233 * XEN_DMOP_modified_memory: Notify that a set of pages were modified by
234 * an emulator.
235 *
236 * DMOP buf 1 contains an array of xen_dm_op_modified_memory_extent with
237 * @nr_extents entries.
238 *
239 * On error, @nr_extents will contain the index+1 of the extent that
240 * had the error. It is not defined if or which pages may have been
241 * marked as dirty, in this event.
242 */
243#define XEN_DMOP_modified_memory 11
244
246 /*
247 * IN - Number of extents to be processed
248 * OUT -returns n+1 for failing extent
249 */
251 /* IN/OUT - Must be set to 0 */
253};
255
257 /* IN - number of contiguous pages modified */
260 /* IN - first pfn modified */
262};
263
264/*
265 * XEN_DMOP_set_mem_type: Notify that a region of memory is to be treated
266 * in a specific way. (See definition of
267 * hvmmem_type_t).
268 *
269 * NOTE: In the event of a continuation (return code -ERESTART), the
270 * @first_pfn is set to the value of the pfn of the remaining
271 * region and @nr reduced to the size of the remaining region.
272 */
273#define XEN_DMOP_set_mem_type 12
274
276 /* IN - number of contiguous pages */
278 /* IN - new hvmmem_type_t of region */
281 /* IN - first pfn in region */
283};
285
286/*
287 * XEN_DMOP_inject_event: Inject an event into a VCPU, which will
288 * get taken up when it is next scheduled.
289 *
290 * Note that the caller should know enough of the state of the CPU before
291 * injecting, to know what the effect of injecting the event will be.
292 */
293#define XEN_DMOP_inject_event 13
294
296 /* IN - index of vCPU */
298 /* IN - interrupt vector */
300 /* IN - event type (DMOP_EVENT_* ) */
302/* NB. This enumeration precisely matches hvm.h:X86_EVENTTYPE_* */
303#define XEN_DMOP_EVENT_ext_int 0 /* external interrupt */
304#define XEN_DMOP_EVENT_nmi 2 /* nmi */
305#define XEN_DMOP_EVENT_hw_exc 3 /* hardware exception */
306#define XEN_DMOP_EVENT_sw_int 4 /* software interrupt (CD nn) */
307#define XEN_DMOP_EVENT_pri_sw_exc 5 /* ICEBP (F1) */
308#define XEN_DMOP_EVENT_sw_exc 6 /* INT3 (CC), INTO (CE) */
309 /* IN - instruction length */
312 /* IN - error code (or ~0 to skip) */
315 /* IN - type-specific extra data (%cr2 for #PF, pending_dbg for #DB) */
317};
319
320/*
321 * XEN_DMOP_inject_msi: Inject an MSI for an emulated device.
322 */
323#define XEN_DMOP_inject_msi 14
324
326 /* IN - MSI data (lower 32 bits) */
329 /* IN - MSI address (0xfeexxxxx) */
331};
333
334/*
335 * XEN_DMOP_map_mem_type_to_ioreq_server : map or unmap the IOREQ Server <id>
336 * to specific memory type <type>
337 * for specific accesses <flags>
338 *
339 * For now, flags only accept the value of XEN_DMOP_IOREQ_MEM_ACCESS_WRITE,
340 * which means only write operations are to be forwarded to an ioreq server.
341 * Support for the emulation of read operations can be added when an ioreq
342 * server has such requirement in future.
343 */
344#define XEN_DMOP_map_mem_type_to_ioreq_server 15
345
347 ioservid_t id; /* IN - ioreq server id */
348 uint16_t type; /* IN - memory type */
349 uint32_t flags; /* IN - types of accesses to be forwarded to the */
350 /* ioreq server. flags with 0 means to unmap the */
351 /* ioreq server */
352
353#define XEN_DMOP_IOREQ_MEM_ACCESS_READ (1u << 0)
354#define XEN_DMOP_IOREQ_MEM_ACCESS_WRITE (1u << 1)
355
356 uint64_t opaque; /* IN/OUT - only used for hypercall continuation, */
357 /* has to be set to zero by the caller */
358};
360
361/*
362 * XEN_DMOP_remote_shutdown : Declare a shutdown for another domain
363 * Identical to SCHEDOP_remote_shutdown
364 */
365#define XEN_DMOP_remote_shutdown 16
366
368 uint32_t reason; /* SHUTDOWN_* => enum sched_shutdown_reason */
369 /* (Other reason values are not blocked) */
370};
372
373/*
374 * XEN_DMOP_relocate_memory : Relocate GFNs for the specified guest.
375 * Identical to XENMEM_add_to_physmap with
376 * space == XENMAPSPACE_gmfn_range.
377 */
378#define XEN_DMOP_relocate_memory 17
379
381 /* All fields are IN/OUT, with their OUT state undefined. */
382 /* Number of GFNs to process. */
385 /* Starting GFN to relocate. */
387 /* Starting GFN where GFNs should be relocated. */
389};
391
392/*
393 * XEN_DMOP_pin_memory_cacheattr : Pin caching type of RAM space.
394 * Identical to XEN_DOMCTL_pin_mem_cacheattr.
395 */
396#define XEN_DMOP_pin_memory_cacheattr 18
397
399 uint64_aligned_t start; /* Start gfn. */
400 uint64_aligned_t end; /* End gfn. */
401/* Caching types: these happen to be the same as x86 MTRR/PAT type codes. */
402#define XEN_DMOP_MEM_CACHEATTR_UC 0
403#define XEN_DMOP_MEM_CACHEATTR_WC 1
404#define XEN_DMOP_MEM_CACHEATTR_WT 4
405#define XEN_DMOP_MEM_CACHEATTR_WP 5
406#define XEN_DMOP_MEM_CACHEATTR_WB 6
407#define XEN_DMOP_MEM_CACHEATTR_UCM 7
408#define XEN_DMOP_DELETE_MEM_CACHEATTR (~(uint32_t)0)
409 uint32_t type; /* XEN_DMOP_MEM_CACHEATTR_* */
411};
413
414/*
415 * XEN_DMOP_set_irq_level: Set the logical level of a one of a domain's
416 * IRQ lines (currently Arm only).
417 * Only SPIs are supported.
418 */
419#define XEN_DMOP_set_irq_level 19
420
423 /* IN - Level: 0 -> deasserted, 1 -> asserted */
426};
428
429/*
430 * XEN_DMOP_nr_vcpus: Query the number of vCPUs a domain has.
431 *
432 * This is the number of vcpu objects allocated in Xen for the domain, and is
433 * fixed from creation time. This bound is applicable to e.g. the vcpuid
434 * parameter of XEN_DMOP_inject_event, or number of struct ioreq objects
435 * mapped via XENMEM_acquire_resource.
436 */
437#define XEN_DMOP_nr_vcpus 20
438
440 uint32_t vcpus; /* OUT */
441};
443
470
477
478/* ` enum neg_errnoval
479 * ` HYPERVISOR_dm_op(domid_t domid,
480 * ` unsigned int nr_bufs,
481 * ` xen_dm_op_buf_t bufs[])
482 * `
483 *
484 * @domid is the domain the hypercall operates on.
485 * @nr_bufs is the number of buffers in the @bufs array.
486 * @bufs points to an array of buffers where @bufs[0] contains a struct
487 * xen_dm_op, describing the specific device model operation and its
488 * parameters.
489 * @bufs[1..] may be referenced in the parameters for the purposes of
490 * passing extra information to or from the domain.
491 */
492
493#endif /* __XEN_PUBLIC_HVM_DM_OP_H__ */
494
495/*
496 * Local variables:
497 * mode: C
498 * c-file-style: "BSD"
499 * c-basic-offset: 4
500 * tab-width: 4
501 * indent-tabs-mode: nil
502 * End:
503 */
uint64_t xen_ulong_t
Definition arch-arm.h:214
#define uint64_aligned_t
Definition arch-arm.h:173
#define DEFINE_XEN_GUEST_HANDLE(name)
Definition arch-arm.h:192
struct xen_dm_op_remote_shutdown xen_dm_op_remote_shutdown_t
Definition dm_op.h:371
struct xen_dm_op_inject_msi xen_dm_op_inject_msi_t
Definition dm_op.h:332
struct xen_dm_op_set_ioreq_server_state xen_dm_op_set_ioreq_server_state_t
Definition dm_op.h:156
struct xen_dm_op_set_pci_intx_level xen_dm_op_set_pci_intx_level_t
Definition dm_op.h:203
struct xen_dm_op_set_irq_level xen_dm_op_set_irq_level_t
Definition dm_op.h:427
uint16_t ioservid_t
Definition dm_op.h:36
struct xen_dm_op_set_isa_irq_level xen_dm_op_set_isa_irq_level_t
Definition dm_op.h:217
struct xen_dm_op_modified_memory xen_dm_op_modified_memory_t
Definition dm_op.h:254
struct xen_dm_op_create_ioreq_server xen_dm_op_create_ioreq_server_t
Definition dm_op.h:57
struct xen_dm_op_track_dirty_vram xen_dm_op_track_dirty_vram_t
Definition dm_op.h:188
struct xen_dm_op_pin_memory_cacheattr xen_dm_op_pin_memory_cacheattr_t
Definition dm_op.h:412
struct xen_dm_op_buf xen_dm_op_buf_t
Definition dm_op.h:475
struct xen_dm_op_ioreq_server_range xen_dm_op_ioreq_server_range_t
Definition dm_op.h:133
struct xen_dm_op_inject_event xen_dm_op_inject_event_t
Definition dm_op.h:318
struct xen_dm_op_map_mem_type_to_ioreq_server xen_dm_op_map_mem_type_to_ioreq_server_t
Definition dm_op.h:359
struct xen_dm_op_get_ioreq_server_info xen_dm_op_get_ioreq_server_info_t
Definition dm_op.h:97
struct xen_dm_op_relocate_memory xen_dm_op_relocate_memory_t
Definition dm_op.h:390
struct xen_dm_op_set_mem_type xen_dm_op_set_mem_type_t
Definition dm_op.h:284
struct xen_dm_op_set_pci_link_route xen_dm_op_set_pci_link_route_t
Definition dm_op.h:230
struct xen_dm_op_destroy_ioreq_server xen_dm_op_destroy_ioreq_server_t
Definition dm_op.h:170
struct xen_dm_op_nr_vcpus xen_dm_op_nr_vcpus_t
Definition dm_op.h:442
uint32_t evtchn_port_t
Definition event_channel.h:74
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Definition dm_op.h:471
XEN_GUEST_HANDLE(void) h
xen_ulong_t size
Definition dm_op.h:473
Definition dm_op.h:50
ioservid_t id
Definition dm_op.h:55
uint8_t handle_bufioreq
Definition dm_op.h:52
uint8_t pad[3]
Definition dm_op.h:53
Definition dm_op.h:165
ioservid_t id
Definition dm_op.h:167
uint16_t pad
Definition dm_op.h:168
Definition dm_op.h:81
uint64_t bufioreq_gfn
Definition dm_op.h:95
ioservid_t id
Definition dm_op.h:83
evtchn_port_t bufioreq_port
Definition dm_op.h:91
uint64_t ioreq_gfn
Definition dm_op.h:93
uint16_t flags
Definition dm_op.h:85
Definition dm_op.h:295
uint8_t type
Definition dm_op.h:301
uint8_t pad0
Definition dm_op.h:311
uint8_t vector
Definition dm_op.h:299
uint32_t vcpuid
Definition dm_op.h:297
uint64_t cr2
Definition dm_op.h:316
uint8_t insn_len
Definition dm_op.h:310
uint32_t error_code
Definition dm_op.h:313
uint32_t pad1
Definition dm_op.h:314
Definition dm_op.h:325
uint32_t data
Definition dm_op.h:327
uint32_t pad
Definition dm_op.h:328
uint64_t addr
Definition dm_op.h:330
Definition dm_op.h:121
uint16_t pad
Definition dm_op.h:124
uint32_t type
Definition dm_op.h:126
uint64_t end
Definition dm_op.h:131
uint64_t start
Definition dm_op.h:131
ioservid_t id
Definition dm_op.h:123
ioservid_t id
Definition dm_op.h:347
uint16_t type
Definition dm_op.h:348
uint64_t opaque
Definition dm_op.h:356
uint32_t flags
Definition dm_op.h:349
Definition dm_op.h:256
uint32_t nr
Definition dm_op.h:258
uint64_t first_pfn
Definition dm_op.h:261
uint32_t pad
Definition dm_op.h:259
Definition dm_op.h:245
uint32_t opaque
Definition dm_op.h:252
uint32_t nr_extents
Definition dm_op.h:250
Definition dm_op.h:439
uint32_t vcpus
Definition dm_op.h:440
Definition dm_op.h:398
uint64_t start
Definition dm_op.h:399
uint64_t end
Definition dm_op.h:400
uint32_t type
Definition dm_op.h:409
uint32_t pad
Definition dm_op.h:410
Definition dm_op.h:380
uint32_t pad
Definition dm_op.h:384
uint64_t dst_gfn
Definition dm_op.h:388
uint32_t size
Definition dm_op.h:383
uint64_t src_gfn
Definition dm_op.h:386
Definition dm_op.h:367
uint32_t reason
Definition dm_op.h:368
Definition dm_op.h:149
uint8_t pad
Definition dm_op.h:154
uint8_t enabled
Definition dm_op.h:153
ioservid_t id
Definition dm_op.h:151
Definition dm_op.h:421
uint8_t pad[3]
Definition dm_op.h:425
uint8_t level
Definition dm_op.h:424
uint32_t irq
Definition dm_op.h:422
Definition dm_op.h:211
uint8_t isa_irq
Definition dm_op.h:213
uint8_t level
Definition dm_op.h:215
Definition dm_op.h:275
uint16_t mem_type
Definition dm_op.h:279
uint16_t pad
Definition dm_op.h:280
uint64_t first_pfn
Definition dm_op.h:282
uint32_t nr
Definition dm_op.h:277
Definition dm_op.h:196
uint8_t bus
Definition dm_op.h:199
uint8_t device
Definition dm_op.h:199
uint16_t domain
Definition dm_op.h:198
uint8_t intx
Definition dm_op.h:199
uint8_t level
Definition dm_op.h:201
Definition dm_op.h:181
uint32_t pad
Definition dm_op.h:184
uint64_t first_pfn
Definition dm_op.h:186
uint32_t nr
Definition dm_op.h:183
Definition dm_op.h:444
xen_dm_op_set_pci_link_route_t set_pci_link_route
Definition dm_op.h:458
union xen_dm_op::@051264064221276027152201126237270154335365102132 u
xen_dm_op_set_irq_level_t set_irq_level
Definition dm_op.h:457
xen_dm_op_set_ioreq_server_state_t set_ioreq_server_state
Definition dm_op.h:452
xen_dm_op_inject_event_t inject_event
Definition dm_op.h:461
xen_dm_op_get_ioreq_server_info_t get_ioreq_server_info
Definition dm_op.h:449
uint32_t op
Definition dm_op.h:445
xen_dm_op_track_dirty_vram_t track_dirty_vram
Definition dm_op.h:454
xen_dm_op_remote_shutdown_t remote_shutdown
Definition dm_op.h:464
xen_dm_op_inject_msi_t inject_msi
Definition dm_op.h:462
xen_dm_op_ioreq_server_range_t unmap_io_range_from_ioreq_server
Definition dm_op.h:451
xen_dm_op_nr_vcpus_t nr_vcpus
Definition dm_op.h:467
xen_dm_op_set_mem_type_t set_mem_type
Definition dm_op.h:460
xen_dm_op_modified_memory_t modified_memory
Definition dm_op.h:459
xen_dm_op_create_ioreq_server_t create_ioreq_server
Definition dm_op.h:448
xen_dm_op_map_mem_type_to_ioreq_server_t map_mem_type_to_ioreq_server
Definition dm_op.h:463
xen_dm_op_set_isa_irq_level_t set_isa_irq_level
Definition dm_op.h:456
xen_dm_op_relocate_memory_t relocate_memory
Definition dm_op.h:465
xen_dm_op_ioreq_server_range_t map_io_range_to_ioreq_server
Definition dm_op.h:450
xen_dm_op_destroy_ioreq_server_t destroy_ioreq_server
Definition dm_op.h:453
xen_dm_op_set_pci_intx_level_t set_pci_intx_level
Definition dm_op.h:455
uint32_t pad
Definition dm_op.h:446
xen_dm_op_pin_memory_cacheattr_t pin_memory_cacheattr
Definition dm_op.h:466