aboutsummaryrefslogtreecommitdiff
path: root/softmmu/memory.c
diff options
context:
space:
mode:
authorEugenio Pérez <eperezma@redhat.com>2020-11-16 17:55:06 +0100
committerMichael S. Tsirkin <mst@redhat.com>2020-12-08 13:48:57 -0500
commit1804857f19f612f6907832e35599cdb51d4ec764 (patch)
tree4b80e0ee166a494ca13864827c14f0e48435e733 /softmmu/memory.c
parentf7701e2c7983b680790af47117577b285b6a1aed (diff)
downloadqemu-1804857f19f612f6907832e35599cdb51d4ec764.zip
qemu-1804857f19f612f6907832e35599cdb51d4ec764.tar.gz
qemu-1804857f19f612f6907832e35599cdb51d4ec764.tar.bz2
memory: Skip bad range assertion if notifier is DEVIOTLB_UNMAP type
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>
Diffstat (limited to 'softmmu/memory.c')
-rw-r--r--softmmu/memory.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 6ca87e8..22bacbb 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);
}
}