master
h 71 lines 2.16 KB
Raw
1 /*
2 * vfio generic region quirks (mostly backdoors to PCI config space)
3 *
4 * Copyright Red Hat, Inc. 2012-2015
5 *
6 * Authors:
7 * Alex Williamson <alex.williamson@redhat.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 */
12 #ifndef HW_VFIO_VFIO_PCI_QUIRKS_H
13 #define HW_VFIO_VFIO_PCI_QUIRKS_H
14
15 #include "exec/memop.h"
16
17 /*
18 * The generic window quirks operate on an address and data register,
19 * vfio_generic_window_address_quirk handles the address register and
20 * vfio_generic_window_data_quirk handles the data register. These ops
21 * pass reads and writes through to hardware until a value matching the
22 * stored address match/mask is written. When this occurs, the data
23 * register access emulated PCI config space for the device rather than
24 * passing through accesses. This enables devices where PCI config space
25 * is accessible behind a window register to maintain the virtualization
26 * provided through vfio.
27 */
28 typedef struct VFIOConfigWindowMatch {
29 uint32_t match;
30 uint32_t mask;
31 } VFIOConfigWindowMatch;
32
33 typedef struct VFIOConfigWindowQuirk {
34 struct VFIOPCIDevice *vdev;
35
36 uint32_t address_val;
37
38 uint32_t address_offset;
39 uint32_t data_offset;
40
41 bool window_enabled;
42 uint8_t bar;
43
44 MemoryRegion *addr_mem;
45 MemoryRegion *data_mem;
46
47 uint32_t nr_matches;
48 VFIOConfigWindowMatch matches[];
49 } VFIOConfigWindowQuirk;
50
51 extern const MemoryRegionOps vfio_generic_window_address_quirk;
52 extern const MemoryRegionOps vfio_generic_window_data_quirk;
53
54 /*
55 * The generic mirror quirk handles devices which expose PCI config space
56 * through a region within a BAR. When enabled, reads and writes are
57 * redirected through to emulated PCI config space. XXX if PCI config space
58 * used memory regions, this could just be an alias.
59 */
60 typedef struct VFIOConfigMirrorQuirk {
61 struct VFIOPCIDevice *vdev;
62 uint32_t offset; /* Offset in BAR */
63 uint32_t config_offset; /* Offset in PCI config space */
64 uint8_t bar;
65 MemoryRegion *mem;
66 uint8_t data[];
67 } VFIOConfigMirrorQuirk;
68
69 extern const MemoryRegionOps vfio_generic_mirror_quirk;
70
71 #endif /* HW_VFIO_VFIO_PCI_QUIRKS_H */