[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/36] memory: assert on out of scope notification
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 06/36] memory: assert on out of scope notification |
Date: |
Tue, 20 Aug 2019 08:59:25 +0200 |
From: Yan Zhao <address@hidden>
It is wrong for an entry to have parts out of scope of notifier's range.
assert this condition.
Out of scope mapping/unmapping would cause problem, as in below case:
1. initially there are two notifiers with ranges
0-0xfedfffff, 0xfef00000-0xffffffffffffffff,
IOVAs from 0x3c000000 - 0x3c1fffff is in shadow page table.
2. in vfio, memory_region_register_iommu_notifier() is followed by
memory_region_iommu_replay(), which will first call address space
unmap,
and walk and add back all entries in vtd shadow page table. e.g.
(1) for notifier 0-0xfedfffff,
IOVAs from 0 - 0xffffffff get unmapped,
and IOVAs from 0x3c000000 - 0x3c1fffff get mapped
(2) for notifier 0xfef00000-0xffffffffffffffff
IOVAs from 0 - 0x7fffffffff get unmapped,
but IOVAs from 0x3c000000 - 0x3c1fffff cannot get mapped back.
Cc: Eric Auger <address@hidden>
Signed-off-by: Yan Zhao <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
memory.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/memory.c b/memory.c
index 5d8c9a9..e42d63a 100644
--- a/memory.c
+++ b/memory.c
@@ -1942,16 +1942,18 @@ void memory_region_notify_one(IOMMUNotifier *notifier,
IOMMUTLBEntry *entry)
{
IOMMUNotifierFlag request_flags;
+ hwaddr entry_end = entry->iova + entry->addr_mask;
/*
* Skip the notification if the notification does not overlap
* with registered range.
*/
- if (notifier->start > entry->iova + entry->addr_mask ||
- notifier->end < entry->iova) {
+ if (notifier->start > entry_end || notifier->end < entry->iova) {
return;
}
+ assert(entry->iova >= notifier->start && entry_end <= notifier->end);
+
if (entry->perm & IOMMU_RW) {
request_flags = IOMMU_NOTIFIER_MAP;
} else {
--
1.8.3.1
- [Qemu-devel] [PULL 00/36] QEMU patches for 2018-08-20, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 01/36] kvm: i386: halt poll control MSR support, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 02/36] target-i386: adds PV_SCHED_YIELD CPUID feature bit, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 03/36] loader: Handle memory-mapped ELFs, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 04/36] elf-ops.h: Map into memory the ELF to load, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 05/36] hw/i386/pc: Map into memory the initrd, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 07/36] configure: Define target access alignment in configure, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 06/36] memory: assert on out of scope notification,
Paolo Bonzini <=
- [Qemu-devel] [PULL 08/36] block: fix NetBSD qemu-iotests failure, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 10/36] target-i386: kvm: 'kvm_get_supported_msrs' cleanup, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 11/36] test-throttle: Fix uninitialized use of burst_length, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 09/36] 9p: simplify source file selection, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 13/36] i386/kvm: initialize struct at full before ioctl call, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 21/36] replay: add missing fix for internal function, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 24/36] replay: fix replay shutdown, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 22/36] replay: document development rules, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 30/36] cpus-common: assert BQL nesting within cpu-exclusive sections, Paolo Bonzini, 2019/08/20
- [Qemu-devel] [PULL 31/36] kvm: vmxcap: Enhance with latest features, Paolo Bonzini, 2019/08/20