3745768918
Now we have switched to PCIIOMMUOps to convey host IOMMU information, the host reserved regions are transmitted when the PCIe topology is built. This happens way before the virtio-iommu driver calls the probe request. So let's remove the probe_done flag that allowed to check the probe was not done before the IOMMU MR got enabled. Besides this probe_done flag had a flaw wrt migration since it was not saved/restored. The only case at risk is if 2 devices were plugged to a PCIe to PCI bridge and thus aliased. First of all we discovered in the past this case was not properly supported for neither SMMU nor virtio-iommu on guest kernel side: see [RFC] virtio-iommu: Take into account possible aliasing in virtio_iommu_mr() https://lore.kernel.org/all/20230116124709.793084-1-eric.auger@redhat.com/ If this were supported by the guest kernel, it is unclear what the call sequence would be from a virtio-iommu driver point of view. Signed-off-by: Eric Auger <eric.auger@redhat.com> Message-Id: <20240716094619.1713905-3-eric.auger@redhat.com> Tested-by: Cédric Le Goater <clg@redhat.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
76 lines
2.2 KiB
C
76 lines
2.2 KiB
C
/*
|
|
* virtio-iommu device
|
|
*
|
|
* Copyright (c) 2020 Red Hat, Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2 or later, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along with
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
#ifndef QEMU_VIRTIO_IOMMU_H
|
|
#define QEMU_VIRTIO_IOMMU_H
|
|
|
|
#include "standard-headers/linux/virtio_iommu.h"
|
|
#include "hw/virtio/virtio.h"
|
|
#include "hw/pci/pci.h"
|
|
#include "qom/object.h"
|
|
#include "qapi/qapi-types-virtio.h"
|
|
#include "sysemu/host_iommu_device.h"
|
|
|
|
#define TYPE_VIRTIO_IOMMU "virtio-iommu-device"
|
|
#define TYPE_VIRTIO_IOMMU_PCI "virtio-iommu-pci"
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VirtIOIOMMU, VIRTIO_IOMMU)
|
|
|
|
#define TYPE_VIRTIO_IOMMU_MEMORY_REGION "virtio-iommu-memory-region"
|
|
|
|
typedef struct IOMMUDevice {
|
|
void *viommu;
|
|
PCIBus *bus;
|
|
int devfn;
|
|
IOMMUMemoryRegion iommu_mr;
|
|
AddressSpace as;
|
|
MemoryRegion root; /* The root container of the device */
|
|
MemoryRegion bypass_mr; /* The alias of shared memory MR */
|
|
GList *resv_regions;
|
|
GList *host_resv_ranges;
|
|
} IOMMUDevice;
|
|
|
|
typedef struct IOMMUPciBus {
|
|
PCIBus *bus;
|
|
IOMMUDevice *pbdev[]; /* Parent array is sparse, so dynamically alloc */
|
|
} IOMMUPciBus;
|
|
|
|
struct VirtIOIOMMU {
|
|
VirtIODevice parent_obj;
|
|
VirtQueue *req_vq;
|
|
VirtQueue *event_vq;
|
|
struct virtio_iommu_config config;
|
|
uint64_t features;
|
|
GHashTable *as_by_busptr;
|
|
GHashTable *host_iommu_devices;
|
|
IOMMUPciBus *iommu_pcibus_by_bus_num[PCI_BUS_MAX];
|
|
PCIBus *primary_bus;
|
|
ReservedRegion *prop_resv_regions;
|
|
uint32_t nr_prop_resv_regions;
|
|
GTree *domains;
|
|
QemuRecMutex mutex;
|
|
GTree *endpoints;
|
|
bool boot_bypass;
|
|
Notifier machine_done;
|
|
bool granule_frozen;
|
|
GranuleMode granule_mode;
|
|
uint8_t aw_bits;
|
|
};
|
|
|
|
#endif
|