From 01187ec9bce1eaf00d990c4ae6fa9af1a497a75d Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Tue, 7 Sep 2021 15:14:12 +0800 Subject: [PATCH 1/3] vfio/common: Fix incorrect address alignment in vfio_dma_map_ram_section The 'iova' will be passed to host kernel for mapping with the HPA. It is related to the host page size. So TARGET_PAGE_ALIGN should be replaced by REAL_HOST_PAGE_ALIGN. In the case of large granularity (64K), it may return early when map MMIO RAM section. And because of the inconsistency with vfio_dma_unmap_ram_section, it may cause 'assert(qrange)' in vfio_dma_unmap. Signed-off-by: Kunkun Jiang Signed-off-by: Zenghui Yu --- ...incorrect-address-alignment-in-vfio_.patch | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 vfio-common-Fix-incorrect-address-alignment-in-vfio_.patch diff --git a/vfio-common-Fix-incorrect-address-alignment-in-vfio_.patch b/vfio-common-Fix-incorrect-address-alignment-in-vfio_.patch new file mode 100644 index 00000000..e1b96e6d --- /dev/null +++ b/vfio-common-Fix-incorrect-address-alignment-in-vfio_.patch @@ -0,0 +1,40 @@ +From 7438519f5cfb0e07dd54f242901761da87f1156c Mon Sep 17 00:00:00 2001 +From: Kunkun Jiang +Date: Tue, 7 Sep 2021 15:14:12 +0800 +Subject: [PATCH] vfio/common: Fix incorrect address alignment in + vfio_dma_map_ram_section + +The 'iova' will be passed to host kernel for mapping with the +HPA. It is related to the host page size. So TARGET_PAGE_ALIGN +should be replaced by REAL_HOST_PAGE_ALIGN. In the case of +large granularity (64K), it may return early when map MMIO RAM +section. And because of the inconsistency with +vfio_dma_unmap_ram_section, it may cause 'assert(qrange)' +in vfio_dma_unmap. + +Signed-off-by: Kunkun Jiang +Signed-off-by: Zenghui Yu +--- + hw/vfio/common.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/hw/vfio/common.c b/hw/vfio/common.c +index fb7ca63748..de166dd5f9 100644 +--- a/hw/vfio/common.c ++++ b/hw/vfio/common.c +@@ -846,10 +846,10 @@ static int vfio_dma_map_ram_section(VFIOContainer *container, + + assert(memory_region_is_ram(section->mr)); + +- iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); ++ iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space); + llend = int128_make64(section->offset_within_address_space); + llend = int128_add(llend, section->size); +- llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK)); ++ llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask)); + end = int128_get64(int128_sub(llend, int128_one())); + + vaddr = memory_region_get_ram_ptr(section->mr) + +-- +2.27.0 + -- Gitee From 5f67e5fb45f3cb2bd7b8935805e138bdf33aed23 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Wed, 8 Sep 2021 11:27:53 +0800 Subject: [PATCH 2/3] spec: Update patch and changelog with !192 vfio/common: Fix incorrect address alignment in vfio_dma_map_ram_section !192 vfio/common: Fix incorrect address alignment in vfio_dma_map_ram_section Signed-off-by: Chen Qun --- qemu.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu.spec b/qemu.spec index 10d2efc9..be664e60 100644 --- a/qemu.spec +++ b/qemu.spec @@ -556,6 +556,7 @@ Patch0543: vfio-Add-vfio_prereg_listener_log_clear-to-re-enable.patch Patch0544: vfio-Add-vfio_prereg_listener_global_log_start-stop-.patch Patch0545: hw-arm-smmuv3-Post-load-stage-1-configurations-to-th.patch Patch0546: usbredir-fix-free-call.patch +Patch0547: vfio-common-Fix-incorrect-address-alignment-in-vfio_.patch BuildRequires: flex BuildRequires: gcc @@ -960,6 +961,9 @@ getent passwd qemu >/dev/null || \ %endif %changelog +* Wed Sep 08 2021 Chen Qun +- vfio/common: Fix incorrect address alignment in vfio_dma_map_ram_section + * Mon Aug 30 2021 Zhongrui Tang - qemu.spec: Specify the package version of zstd and zstd-devel that qemu depends on. -- Gitee From 333296b1316e2ee571800dcbf81893da007630a9 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Wed, 8 Sep 2021 11:27:55 +0800 Subject: [PATCH 3/3] spec: Update release version with !192 increase release verison by one Signed-off-by: Chen Qun --- qemu.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu.spec b/qemu.spec index be664e60..db21cd49 100644 --- a/qemu.spec +++ b/qemu.spec @@ -1,6 +1,6 @@ Name: qemu Version: 4.1.0 -Release: 79 +Release: 80 Epoch: 2 Summary: QEMU is a generic and open source machine emulator and virtualizer License: GPLv2 and BSD and MIT and CC-BY-SA-4.0 -- Gitee