mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 17:23:56 -06:00
vfio queue:
* Fixed newly added potential issues in vfio-pci * Added support to report vfio-ap configuration changes * Added prerequisite support for vfio-user * Added first part for VFIO live update support -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmhJm00ACgkQUaNDx8/7 7KHBehAAlbSt+QCPwdNJ/5QPGGPWIQ86acIHaI/sE/lpcJx9FideQhtKTtt0gTOE ZNGbzfeCnewCM+VLMgkrYZC9DWd9OpEO68tDy6ev577F6ijSR8wzXRtDl2j5Revm R9gBuOm/cQ6Mafiv8SNPNSGW2tQ0M9Bd4GJRa5K3VBf8kFwPpWEZC/yDWbvSVvwc 99TFXziIbWJEYGRzG4h7hoEEd/GapZOwTRIPRoRGHznbOPMsxShjIhExn8ZGTlU9 woaNBPZXS5xjjy5tKyURexu+eyxbR6WsZFyeAA03+HzWEfRzhFc/rhAC6mBbpq7v 03a/4ewkKZ0fYUf9G2H5YpXTXl6io+qk+irKi99/4GT0oSBMrm+/NcY7u9Hv2MwA 50h3iXUhLQYzL2G2bSSoBTKOGxV84Xtto9j7dM7fy8e0nYv9rucvKl+V3Ox1Qwv4 8+bQsxP5tjmHlXE/n6ckfcrWtSHuWmb3JJ8yxdBttdo3Cz/+KxJ3UjtP9U81RXxY gepxCRXZmcTfnv1dV6FyjOE6QOhB3WIT5rHmgoQIvHGhtBsLpT2mDlSsMVEQIXvm ixQnRguwQv9fgEZeYB/ck/ezluOxewBlOv5Q3CPpHQBd2Ykh4N/8xsWpXlKI1KWr Tj7Nh/2ObqNXbKdmb9nNiuo6eQDkPOm4mr1cs2ncMr7/cRGeKeA= =KOf3 -----END PGP SIGNATURE----- Merge tag 'pull-vfio-20250611' of https://github.com/legoater/qemu into staging vfio queue: * Fixed newly added potential issues in vfio-pci * Added support to report vfio-ap configuration changes * Added prerequisite support for vfio-user * Added first part for VFIO live update support # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmhJm00ACgkQUaNDx8/7 # 7KHBehAAlbSt+QCPwdNJ/5QPGGPWIQ86acIHaI/sE/lpcJx9FideQhtKTtt0gTOE # ZNGbzfeCnewCM+VLMgkrYZC9DWd9OpEO68tDy6ev577F6ijSR8wzXRtDl2j5Revm # R9gBuOm/cQ6Mafiv8SNPNSGW2tQ0M9Bd4GJRa5K3VBf8kFwPpWEZC/yDWbvSVvwc # 99TFXziIbWJEYGRzG4h7hoEEd/GapZOwTRIPRoRGHznbOPMsxShjIhExn8ZGTlU9 # woaNBPZXS5xjjy5tKyURexu+eyxbR6WsZFyeAA03+HzWEfRzhFc/rhAC6mBbpq7v # 03a/4ewkKZ0fYUf9G2H5YpXTXl6io+qk+irKi99/4GT0oSBMrm+/NcY7u9Hv2MwA # 50h3iXUhLQYzL2G2bSSoBTKOGxV84Xtto9j7dM7fy8e0nYv9rucvKl+V3Ox1Qwv4 # 8+bQsxP5tjmHlXE/n6ckfcrWtSHuWmb3JJ8yxdBttdo3Cz/+KxJ3UjtP9U81RXxY # gepxCRXZmcTfnv1dV6FyjOE6QOhB3WIT5rHmgoQIvHGhtBsLpT2mDlSsMVEQIXvm # ixQnRguwQv9fgEZeYB/ck/ezluOxewBlOv5Q3CPpHQBd2Ykh4N/8xsWpXlKI1KWr # Tj7Nh/2ObqNXbKdmb9nNiuo6eQDkPOm4mr1cs2ncMr7/cRGeKeA= # =KOf3 # -----END PGP SIGNATURE----- # gpg: Signature made Wed 11 Jun 2025 11:05:49 EDT # gpg: using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1 # gpg: Good signature from "Cédric Le Goater <clg@redhat.com>" [full] # gpg: aka "Cédric Le Goater <clg@kaod.org>" [full] # Primary key fingerprint: A0F6 6548 F048 95EB FE6B 0B60 51A3 43C7 CFFB ECA1 * tag 'pull-vfio-20250611' of https://github.com/legoater/qemu: (27 commits) vfio: improve VFIODeviceIOOps docs vfio/pci: export MSI functions vfio/pci: vfio_notifier_cleanup vfio/pci: vfio_notifier_init cpr parameters vfio/pci: pass vector to virq functions vfio/pci: vfio_notifier_init vfio/pci: vfio_pci_vector_init vfio-pci: skip reset during cpr pci: skip reset during cpr pci: export msix_is_pending vfio/container: recover from unmap-all-vaddr failure vfio/container: mdev cpr blocker vfio/container: restore DMA vaddr vfio/container: discard old DMA vaddr vfio/container: preserve descriptors vfio/container: register container for cpr migration: lower handler priority migration: cpr helpers vfio: mark posted writes in region write callbacks vfio: add per-region fd support ... Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
commit
d9ce74873a
29 changed files with 914 additions and 128 deletions
|
@ -32,6 +32,7 @@ int msix_present(PCIDevice *dev);
|
|||
bool msix_is_masked(PCIDevice *dev, unsigned vector);
|
||||
void msix_set_pending(PCIDevice *dev, unsigned vector);
|
||||
void msix_clr_pending(PCIDevice *dev, int vector);
|
||||
int msix_is_pending(PCIDevice *dev, unsigned vector);
|
||||
|
||||
void msix_vector_use(PCIDevice *dev, unsigned vector);
|
||||
void msix_vector_unuse(PCIDevice *dev, unsigned vector);
|
||||
|
|
|
@ -222,6 +222,8 @@ enum {
|
|||
QEMU_PCIE_EXT_TAG = (1 << QEMU_PCIE_EXT_TAG_BITNR),
|
||||
#define QEMU_PCI_CAP_PM_BITNR 14
|
||||
QEMU_PCI_CAP_PM = (1 << QEMU_PCI_CAP_PM_BITNR),
|
||||
#define QEMU_PCI_SKIP_RESET_ON_CPR_BITNR 15
|
||||
QEMU_PCI_SKIP_RESET_ON_CPR = (1 << QEMU_PCI_SKIP_RESET_ON_CPR_BITNR),
|
||||
};
|
||||
|
||||
typedef struct PCIINTxRoute {
|
||||
|
|
|
@ -16,4 +16,43 @@
|
|||
|
||||
void s390_init_ap(void);
|
||||
|
||||
typedef struct ChscSeiNt0Res {
|
||||
uint16_t length;
|
||||
uint16_t code;
|
||||
uint8_t reserved1;
|
||||
uint16_t reserved2;
|
||||
uint8_t nt;
|
||||
#define PENDING_EVENT_INFO_BITMASK 0x80;
|
||||
uint8_t flags;
|
||||
uint8_t reserved3;
|
||||
uint8_t rs;
|
||||
uint8_t cc;
|
||||
} QEMU_PACKED ChscSeiNt0Res;
|
||||
|
||||
#define NT0_RES_RESPONSE_CODE 1
|
||||
#define NT0_RES_NT_DEFAULT 0
|
||||
#define NT0_RES_RS_AP_CHANGE 5
|
||||
#define NT0_RES_CC_AP_CHANGE 3
|
||||
|
||||
#define EVENT_INFORMATION_NOT_STORED 1
|
||||
#define EVENT_INFORMATION_STORED 0
|
||||
|
||||
/**
|
||||
* ap_chsc_sei_nt0_get_event - Retrieve the next pending AP config
|
||||
* change event
|
||||
* @res: Pointer to a ChscSeiNt0Res struct to be filled with event
|
||||
* data
|
||||
*
|
||||
* This function checks for any pending AP config change events and,
|
||||
* if present, populates the provided response structure with the
|
||||
* appropriate SEI NT0 fields.
|
||||
*
|
||||
* Return:
|
||||
* EVENT_INFORMATION_STORED - An event was available and written to @res
|
||||
* EVENT_INFORMATION_NOT_STORED - No event was available
|
||||
*/
|
||||
int ap_chsc_sei_nt0_get_event(void *res);
|
||||
|
||||
bool ap_chsc_sei_nt0_have_event(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -256,4 +256,7 @@ struct VFIOIOMMUClass {
|
|||
VFIORamDiscardListener *vfio_find_ram_discard_listener(
|
||||
VFIOContainerBase *bcontainer, MemoryRegionSection *section);
|
||||
|
||||
void vfio_container_region_add(VFIOContainerBase *bcontainer,
|
||||
MemoryRegionSection *section, bool cpr_remap);
|
||||
|
||||
#endif /* HW_VFIO_VFIO_CONTAINER_BASE_H */
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define HW_VFIO_CONTAINER_H
|
||||
|
||||
#include "hw/vfio/vfio-container-base.h"
|
||||
#include "hw/vfio/vfio-cpr.h"
|
||||
|
||||
typedef struct VFIOContainer VFIOContainer;
|
||||
typedef struct VFIODevice VFIODevice;
|
||||
|
@ -29,6 +30,7 @@ typedef struct VFIOContainer {
|
|||
int fd; /* /dev/vfio/vfio, empowered by the attached groups */
|
||||
unsigned iommu_type;
|
||||
QLIST_HEAD(, VFIOGroup) group_list;
|
||||
VFIOContainerCPR cpr;
|
||||
} VFIOContainer;
|
||||
|
||||
OBJECT_DECLARE_SIMPLE_TYPE(VFIOContainer, VFIO_IOMMU_LEGACY);
|
||||
|
|
|
@ -9,10 +9,49 @@
|
|||
#ifndef HW_VFIO_VFIO_CPR_H
|
||||
#define HW_VFIO_VFIO_CPR_H
|
||||
|
||||
#include "migration/misc.h"
|
||||
#include "system/memory.h"
|
||||
|
||||
struct VFIOContainer;
|
||||
struct VFIOContainerBase;
|
||||
struct VFIOGroup;
|
||||
|
||||
typedef struct VFIOContainerCPR {
|
||||
Error *blocker;
|
||||
bool vaddr_unmapped;
|
||||
NotifierWithReturn transfer_notifier;
|
||||
MemoryListener remap_listener;
|
||||
int (*saved_dma_map)(const struct VFIOContainerBase *bcontainer,
|
||||
hwaddr iova, ram_addr_t size,
|
||||
void *vaddr, bool readonly, MemoryRegion *mr);
|
||||
} VFIOContainerCPR;
|
||||
|
||||
typedef struct VFIODeviceCPR {
|
||||
Error *mdev_blocker;
|
||||
} VFIODeviceCPR;
|
||||
|
||||
bool vfio_legacy_cpr_register_container(struct VFIOContainer *container,
|
||||
Error **errp);
|
||||
void vfio_legacy_cpr_unregister_container(struct VFIOContainer *container);
|
||||
|
||||
int vfio_cpr_reboot_notifier(NotifierWithReturn *notifier, MigrationEvent *e,
|
||||
Error **errp);
|
||||
|
||||
bool vfio_cpr_register_container(struct VFIOContainerBase *bcontainer,
|
||||
Error **errp);
|
||||
void vfio_cpr_unregister_container(struct VFIOContainerBase *bcontainer);
|
||||
|
||||
int vfio_cpr_group_get_device_fd(int d, const char *name);
|
||||
|
||||
bool vfio_cpr_container_match(struct VFIOContainer *container,
|
||||
struct VFIOGroup *group, int fd);
|
||||
|
||||
void vfio_cpr_giommu_remap(struct VFIOContainerBase *bcontainer,
|
||||
MemoryRegionSection *section);
|
||||
|
||||
bool vfio_cpr_ram_discard_register_listener(
|
||||
struct VFIOContainerBase *bcontainer, MemoryRegionSection *section);
|
||||
|
||||
extern const VMStateDescription vfio_cpr_pci_vmstate;
|
||||
|
||||
#endif /* HW_VFIO_VFIO_CPR_H */
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#endif
|
||||
#include "system/system.h"
|
||||
#include "hw/vfio/vfio-container-base.h"
|
||||
#include "hw/vfio/vfio-cpr.h"
|
||||
#include "system/host_iommu_device.h"
|
||||
#include "system/iommufd.h"
|
||||
|
||||
|
@ -66,6 +67,7 @@ typedef struct VFIODevice {
|
|||
OnOffAuto enable_migration;
|
||||
OnOffAuto migration_multifd_transfer;
|
||||
bool migration_events;
|
||||
bool use_region_fds;
|
||||
VFIODeviceOps *ops;
|
||||
VFIODeviceIOOps *io_ops;
|
||||
unsigned int num_irqs;
|
||||
|
@ -84,6 +86,8 @@ typedef struct VFIODevice {
|
|||
VFIOIOASHwpt *hwpt;
|
||||
QLIST_ENTRY(VFIODevice) hwpt_next;
|
||||
struct vfio_region_info **reginfo;
|
||||
int *region_fds;
|
||||
VFIODeviceCPR cpr;
|
||||
} VFIODevice;
|
||||
|
||||
struct VFIODeviceOps {
|
||||
|
@ -164,36 +168,64 @@ struct VFIODeviceIOOps {
|
|||
* @device_feature
|
||||
*
|
||||
* Fill in feature info for the given device.
|
||||
*
|
||||
* @vdev: #VFIODevice to use
|
||||
* @feat: feature information to fill in
|
||||
*
|
||||
* Returns 0 on success or -errno.
|
||||
*/
|
||||
int (*device_feature)(VFIODevice *vdev, struct vfio_device_feature *);
|
||||
int (*device_feature)(VFIODevice *vdev, struct vfio_device_feature *feat);
|
||||
|
||||
/**
|
||||
* @get_region_info
|
||||
*
|
||||
* Fill in @info with information on the region given by @info->index.
|
||||
* Get the information for a given region on the device.
|
||||
*
|
||||
* @vdev: #VFIODevice to use
|
||||
* @info: set @info->index to the region index to look up; the rest of the
|
||||
* struct will be filled in on success
|
||||
* @fd: pointer to the fd for the region; will be -1 if not found
|
||||
*
|
||||
* Returns 0 on success or -errno.
|
||||
*/
|
||||
int (*get_region_info)(VFIODevice *vdev,
|
||||
struct vfio_region_info *info);
|
||||
struct vfio_region_info *info, int *fd);
|
||||
|
||||
/**
|
||||
* @get_irq_info
|
||||
*
|
||||
* Fill in @irq with information on the IRQ given by @info->index.
|
||||
* @vdev: #VFIODevice to use
|
||||
* @irq: set @irq->index to the IRQ index to look up; the rest of the struct
|
||||
* will be filled in on success
|
||||
*
|
||||
* Returns 0 on success or -errno.
|
||||
*/
|
||||
int (*get_irq_info)(VFIODevice *vdev, struct vfio_irq_info *irq);
|
||||
|
||||
/**
|
||||
* @set_irqs
|
||||
*
|
||||
* Configure IRQs as defined by @irqs.
|
||||
* Configure IRQs.
|
||||
*
|
||||
* @vdev: #VFIODevice to use
|
||||
* @irqs: IRQ configuration as defined by VFIO docs.
|
||||
*
|
||||
* Returns 0 on success or -errno.
|
||||
*/
|
||||
int (*set_irqs)(VFIODevice *vdev, struct vfio_irq_set *irqs);
|
||||
|
||||
/**
|
||||
* @region_read
|
||||
*
|
||||
* Read @size bytes from the region @nr at offset @off into the buffer
|
||||
* @data.
|
||||
* Read part of a region.
|
||||
*
|
||||
* @vdev: #VFIODevice to use
|
||||
* @nr: region index
|
||||
* @off: offset within the region
|
||||
* @size: size in bytes to read
|
||||
* @data: buffer to read into
|
||||
*
|
||||
* Returns number of bytes read on success or -errno.
|
||||
*/
|
||||
int (*region_read)(VFIODevice *vdev, uint8_t nr, off_t off, uint32_t size,
|
||||
void *data);
|
||||
|
@ -201,11 +233,18 @@ struct VFIODeviceIOOps {
|
|||
/**
|
||||
* @region_write
|
||||
*
|
||||
* Write @size bytes to the region @nr at offset @off from the buffer
|
||||
* @data.
|
||||
* Write part of a region.
|
||||
*
|
||||
* @vdev: #VFIODevice to use
|
||||
* @nr: region index
|
||||
* @off: offset within the region
|
||||
* @size: size in bytes to write
|
||||
* @data: buffer to write from
|
||||
*
|
||||
* Returns number of bytes write on success or -errno.
|
||||
*/
|
||||
int (*region_write)(VFIODevice *vdev, uint8_t nr, off_t off, uint32_t size,
|
||||
void *data);
|
||||
void *data, bool post);
|
||||
};
|
||||
|
||||
void vfio_device_prepare(VFIODevice *vbasedev, VFIOContainerBase *bcontainer,
|
||||
|
|
|
@ -29,6 +29,7 @@ typedef struct VFIORegion {
|
|||
uint32_t nr_mmaps;
|
||||
VFIOMmap *mmaps;
|
||||
uint8_t nr; /* cache the region number for debug */
|
||||
bool post_wr; /* writes can be posted */
|
||||
} VFIORegion;
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue