pci-quirks.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #include "qemu/osdep.h"
  15. #include "exec/memop.h"
  16. /*
  17. * The generic window quirks operate on an address and data register,
  18. * vfio_generic_window_address_quirk handles the address register and
  19. * vfio_generic_window_data_quirk handles the data register. These ops
  20. * pass reads and writes through to hardware until a value matching the
  21. * stored address match/mask is written. When this occurs, the data
  22. * register access emulated PCI config space for the device rather than
  23. * passing through accesses. This enables devices where PCI config space
  24. * is accessible behind a window register to maintain the virtualization
  25. * provided through vfio.
  26. */
  27. typedef struct VFIOConfigWindowMatch {
  28. uint32_t match;
  29. uint32_t mask;
  30. } VFIOConfigWindowMatch;
  31. typedef struct VFIOConfigWindowQuirk {
  32. struct VFIOPCIDevice *vdev;
  33. uint32_t address_val;
  34. uint32_t address_offset;
  35. uint32_t data_offset;
  36. bool window_enabled;
  37. uint8_t bar;
  38. MemoryRegion *addr_mem;
  39. MemoryRegion *data_mem;
  40. uint32_t nr_matches;
  41. VFIOConfigWindowMatch matches[];
  42. } VFIOConfigWindowQuirk;
  43. extern const MemoryRegionOps vfio_generic_window_address_quirk;
  44. extern const MemoryRegionOps vfio_generic_window_data_quirk;
  45. /*
  46. * The generic mirror quirk handles devices which expose PCI config space
  47. * through a region within a BAR. When enabled, reads and writes are
  48. * redirected through to emulated PCI config space. XXX if PCI config space
  49. * used memory regions, this could just be an alias.
  50. */
  51. typedef struct VFIOConfigMirrorQuirk {
  52. struct VFIOPCIDevice *vdev;
  53. uint32_t offset; /* Offset in BAR */
  54. uint32_t config_offset; /* Offset in PCI config space */
  55. uint8_t bar;
  56. MemoryRegion *mem;
  57. uint8_t data[];
  58. } VFIOConfigMirrorQuirk;
  59. extern const MemoryRegionOps vfio_generic_mirror_quirk;
  60. #endif /* HW_VFIO_VFIO_PCI_QUIRKS_H */