- i386/cpuid: Move leaf 7 to correct group - i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F - i386/cpu: Mask with XCR0/XSS mask for FEAT_XSAVE_XCR0_HI and FEAT_XSAVE_XSS_HI leafs - i386/cpu: Clear FEAT_XSAVE_XSS_LO/HI leafs when CPUID_EXT_XSAVE is not available - target/i386: Change wrong XFRM value in SGX CPUID leaf - target/i386: Enable support for XSAVES based features - target/i386: Add kvm_get_one_msr helper - hw/block/hd-geometry: Do not override specified bios-chs-trans mainline inclusion commit fd8a68ad6823d33bedeba20a22857867a1c3890e category: bugfix - linux-user/riscv: Align signal frame to 16 bytes mainline inclusion commit 1eaa63429a9944265c92efdb94c02fabb231f564 category: bugfix - ipmi:smbus: Add a check around a memcpy mainline inclusion commit 3fde641e7286f9b968bdb3b4b922c6465f2a9abc category: bugfix - tests/tcg/linux-test: Fix random hangs in test_socket mainline inclusion commit b9e6074fc5b429b1e956e9c60db7e284a91e0f3d category: bugfix - qemu-options.hx: Don't claim "-serial" has limit of 4 serial ports Before v2.12, the implementation of serial ports was limited to a value of MAX_SERIAL_PORTS = 4. We now dynamically allocate the data structures for serial ports, so this limit is no longer present, but the documentation for the -serial options still reads: - target/ppc: Modify the uncorrect value irq to n_IRQ - block-migration: Ensure we don't crash during migration cleanup - target/s390x: fix handling of zeroes in vfmin/vfmax mainline inclusion commit 13c59eb09bd6d1fbc13f08b708226421f14a232b category: bugfix - hw/virtio/virtio-iommu: Enforce power-of-two notify for both MAP and UNMAP mainline inclusion commit 0522be9a0c0094088ccef7aab352c57f483ca250 category: bugfix - configure: Add missing POSIX-required space mainline inclusion commit 35a7a6fc5624b1df828d82f2dfa74d0e4188b3b2 category: bugfix - vga: fix incorrect line height in 640x200x2 mode mainline inclusion commit 37e7b86766244b62a406747bb78e049390d0b528 category: bugfix - hw/ide/core: set ERR_STAT in unsupported command completion - linux-user/flatload.c: Fix setting of image_info::end_code mainline inclusion commit 734a659ad264ac080457167e845ffabbaaa66d0e category: bugfix - load_elf: fix iterator's type for elf file processing - hw/misc/mps2-scc: Free MPS2SCC::oscclk[] array on finalize() - hw/nvram/xlnx-efuse: Free XlnxEFuse::ro_bits[] array on finalize() - hw/nvram/xlnx-efuse-ctrl: Free XlnxVersalEFuseCtrl[] "pg0-lock" array - chardev/char.c: fix "abstract device type" error message - block/rbd: fix handling of holes in .bdrv_co_block_status - qga: treat get-guest-fsinfo as "best effort" mainline inclusion commit bbb0151cf2e82489120a15df5e2eb9653312b0ec category: bugfix - usb/hcd-xhci: check slotid in xhci_wakeup_endpoint() mainline inclusion commit 84218892f05515d20347fde4506e1944eb11cb25 category: bugfix - hw/display/bcm2835_fb: Fix framebuffer allocation address mainline inclusion commit 5865d99fe88d8c8fa437c18c6b63fb2a8165634f category: bugfix - block/parallels: Fix buffer-based write call mainline inclusion commit eba088f91d21d9e42a81bef847173da30c5da961 category: bugfix - vl: Improve error message for conflicting -incoming and -loadvm - hw/smbios: Fix OEM strings table option validation Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com> (cherry picked from commit 5d1a5160936dce1757c09050d97d12f42642794b)
114 lines
4.2 KiB
Diff
114 lines
4.2 KiB
Diff
From 89376545e23d5fa3b6e3f9d404edf0382c6f5ad3 Mon Sep 17 00:00:00 2001
|
|
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
Date: Wed, 13 Mar 2024 03:28:06 +0000
|
|
Subject: [PATCH] hw/virtio/virtio-iommu: Enforce power-of-two notify for both
|
|
MAP and UNMAP mainline inclusion commit
|
|
0522be9a0c0094088ccef7aab352c57f483ca250 category: bugfix
|
|
|
|
---------------------------------------------------------------
|
|
|
|
Currently we only enforce power-of-two mappings (required by the QEMU
|
|
notifier) for UNMAP requests. A MAP request not aligned on a
|
|
power-of-two may be successfully handled by VFIO, and then the
|
|
corresponding UNMAP notify will fail because it will attempt to split
|
|
that mapping. Ensure MAP and UNMAP notifications are consistent.
|
|
|
|
Fixes: dde3f08b5cab ("virtio-iommu: Handle non power of 2 range invalidations")
|
|
Reported-by: Tina Zhang <tina.zhang@intel.com>
|
|
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
|
|
Message-Id: <20220718135636.338264-1-jean-philippe@linaro.org>
|
|
Tested-by: Tina Zhang <tina.zhang@intel.com>
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
|
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
---
|
|
hw/virtio/virtio-iommu.c | 47 ++++++++++++++++++++++++----------------
|
|
1 file changed, 28 insertions(+), 19 deletions(-)
|
|
|
|
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
|
|
index ae33d93b11..190ec2579a 100644
|
|
--- a/hw/virtio/virtio-iommu.c
|
|
+++ b/hw/virtio/virtio-iommu.c
|
|
@@ -125,6 +125,32 @@ static gint interval_cmp(gconstpointer a, gconstpointer b, gpointer user_data)
|
|
}
|
|
}
|
|
|
|
+static void virtio_iommu_notify_map_unmap(IOMMUMemoryRegion *mr,
|
|
+ IOMMUTLBEvent *event,
|
|
+ hwaddr virt_start, hwaddr virt_end)
|
|
+{
|
|
+ uint64_t delta = virt_end - virt_start;
|
|
+
|
|
+ event->entry.iova = virt_start;
|
|
+ event->entry.addr_mask = delta;
|
|
+
|
|
+ if (delta == UINT64_MAX) {
|
|
+ memory_region_notify_iommu(mr, 0, *event);
|
|
+ }
|
|
+
|
|
+ while (virt_start != virt_end + 1) {
|
|
+ uint64_t mask = dma_aligned_pow2_mask(virt_start, virt_end, 64);
|
|
+
|
|
+ event->entry.addr_mask = mask;
|
|
+ event->entry.iova = virt_start;
|
|
+ memory_region_notify_iommu(mr, 0, *event);
|
|
+ virt_start += mask + 1;
|
|
+ if (event->entry.perm != IOMMU_NONE) {
|
|
+ event->entry.translated_addr += mask + 1;
|
|
+ }
|
|
+ }
|
|
+}
|
|
+
|
|
static void virtio_iommu_notify_map(IOMMUMemoryRegion *mr, hwaddr virt_start,
|
|
hwaddr virt_end, hwaddr paddr,
|
|
uint32_t flags)
|
|
@@ -143,19 +169,16 @@ static void virtio_iommu_notify_map(IOMMUMemoryRegion *mr, hwaddr virt_start,
|
|
|
|
event.type = IOMMU_NOTIFIER_MAP;
|
|
event.entry.target_as = &address_space_memory;
|
|
- event.entry.addr_mask = virt_end - virt_start;
|
|
- event.entry.iova = virt_start;
|
|
event.entry.perm = perm;
|
|
event.entry.translated_addr = paddr;
|
|
|
|
- memory_region_notify_iommu(mr, 0, event);
|
|
+ virtio_iommu_notify_map_unmap(mr, &event, virt_start, virt_end);
|
|
}
|
|
|
|
static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start,
|
|
hwaddr virt_end)
|
|
{
|
|
IOMMUTLBEvent event;
|
|
- uint64_t delta = virt_end - virt_start;
|
|
|
|
if (!(mr->iommu_notify_flags & IOMMU_NOTIFIER_UNMAP)) {
|
|
return;
|
|
@@ -167,22 +190,8 @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start,
|
|
event.entry.target_as = &address_space_memory;
|
|
event.entry.perm = IOMMU_NONE;
|
|
event.entry.translated_addr = 0;
|
|
- event.entry.addr_mask = delta;
|
|
- event.entry.iova = virt_start;
|
|
-
|
|
- if (delta == UINT64_MAX) {
|
|
- memory_region_notify_iommu(mr, 0, event);
|
|
- }
|
|
|
|
-
|
|
- while (virt_start != virt_end + 1) {
|
|
- uint64_t mask = dma_aligned_pow2_mask(virt_start, virt_end, 64);
|
|
-
|
|
- event.entry.addr_mask = mask;
|
|
- event.entry.iova = virt_start;
|
|
- memory_region_notify_iommu(mr, 0, event);
|
|
- virt_start += mask + 1;
|
|
- }
|
|
+ virtio_iommu_notify_map_unmap(mr, &event, virt_start, virt_end);
|
|
}
|
|
|
|
static gboolean virtio_iommu_notify_unmap_cb(gpointer key, gpointer value,
|
|
--
|
|
2.27.0
|
|
|