[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 06/65] memory: Skip bad range assertion if notifier is DEVIOTLB
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 06/65] memory: Skip bad range assertion if notifier is DEVIOTLB_UNMAP type |
Date: |
Wed, 9 Dec 2020 13:07:03 -0500 |
From: Eugenio Pérez <eperezma@redhat.com>
Device IOTLB invalidations can unmap arbitrary ranges, eiter outside of
the memory region or even [0, ~0ULL] for all the space. The assertion
could be hit by a guest, and rhel7 guest effectively hit it.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20201116165506.31315-6-eperezma@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
softmmu/memory.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 6ca87e8d73..22bacbbc78 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -1947,6 +1947,7 @@ void memory_region_notify_iommu_one(IOMMUNotifier
*notifier,
{
IOMMUTLBEntry *entry = &event->entry;
hwaddr entry_end = entry->iova + entry->addr_mask;
+ IOMMUTLBEntry tmp = *entry;
if (event->type == IOMMU_NOTIFIER_UNMAP) {
assert(entry->perm == IOMMU_NONE);
@@ -1960,10 +1961,16 @@ void memory_region_notify_iommu_one(IOMMUNotifier
*notifier,
return;
}
- assert(entry->iova >= notifier->start && entry_end <= notifier->end);
+ if (notifier->notifier_flags & IOMMU_NOTIFIER_DEVIOTLB_UNMAP) {
+ /* Crop (iova, addr_mask) to range */
+ tmp.iova = MAX(tmp.iova, notifier->start);
+ tmp.addr_mask = MIN(entry_end, notifier->end) - tmp.iova;
+ } else {
+ assert(entry->iova >= notifier->start && entry_end <= notifier->end);
+ }
if (event->type & notifier->notifier_flags) {
- notifier->notify(notifier, entry);
+ notifier->notify(notifier, &tmp);
}
}
--
MST
- [PULL v2 00/65] pc,pci,virtio: fixes, cleanups, Michael S. Tsirkin, 2020/12/09
- [PULL v2 01/65] vhost-user-scsi: Fix memleaks in vus_proc_req(), Michael S. Tsirkin, 2020/12/09
- [PULL v2 02/65] memory: Rename memory_region_notify_one to memory_region_notify_iommu_one, Michael S. Tsirkin, 2020/12/09
- [PULL v2 03/65] memory: Add IOMMUTLBEvent, Michael S. Tsirkin, 2020/12/09
- [PULL v2 04/65] memory: Add IOMMU_NOTIFIER_DEVIOTLB_UNMAP IOMMUTLBNotificationType, Michael S. Tsirkin, 2020/12/09
- [PULL v2 05/65] intel_iommu: Skip page walking on device iotlb invalidations, Michael S. Tsirkin, 2020/12/09
- [PULL v2 06/65] memory: Skip bad range assertion if notifier is DEVIOTLB_UNMAP type,
Michael S. Tsirkin <=
- [PULL v2 07/65] virtio: reset device on bad guest index in virtio_load(), Michael S. Tsirkin, 2020/12/09
- [PULL v2 08/65] acpi/gpex: Extract two APIs from acpi_dsdt_add_pci, Michael S. Tsirkin, 2020/12/09
- [PULL v2 09/65] fw_cfg: Refactor extra pci roots addition, Michael S. Tsirkin, 2020/12/09
- [PULL v2 10/65] hw/arm/virt: Write extra pci roots into fw_cfg, Michael S. Tsirkin, 2020/12/09
- [PULL v2 12/65] acpi/gpex: Build tables for pxb, Michael S. Tsirkin, 2020/12/09
- [PULL v2 11/65] acpi: Extract crs build form acpi_build.c, Michael S. Tsirkin, 2020/12/09
- [PULL v2 13/65] acpi: Align the size to 128k, Michael S. Tsirkin, 2020/12/09
- [PULL v2 14/65] unit-test: The files changed., Michael S. Tsirkin, 2020/12/09
- [PULL v2 16/65] unit-test: Add the binary file and clear diff.h, Michael S. Tsirkin, 2020/12/09
- [PULL v2 17/65] failover: fix indentantion, Michael S. Tsirkin, 2020/12/09