[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 17/44] vdpa: Add vhost_vdpa_section_end
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 17/44] vdpa: Add vhost_vdpa_section_end |
Date: |
Wed, 20 Oct 2021 06:19:59 -0400 |
From: Eugenio Pérez <eperezma@redhat.com>
Abstract this operation, that will be reused when validating the region
against the iova range that the device supports.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20211014141236.923287-3-eperezma@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
---
hw/virtio/vhost-vdpa.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index ea1aa71ad8..be7c63b4ba 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -24,6 +24,19 @@
#include "trace.h"
#include "qemu-common.h"
+/*
+ * Return one past the end of the end of section. Be careful with uint64_t
+ * conversions!
+ */
+static Int128 vhost_vdpa_section_end(const MemoryRegionSection *section)
+{
+ Int128 llend = int128_make64(section->offset_within_address_space);
+ llend = int128_add(llend, section->size);
+ llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK));
+
+ return llend;
+}
+
static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section)
{
return (!memory_region_is_ram(section->mr) &&
@@ -160,10 +173,7 @@ static void vhost_vdpa_listener_region_add(MemoryListener
*listener,
}
iova = TARGET_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 = vhost_vdpa_section_end(section);
if (int128_ge(int128_make64(iova), llend)) {
return;
}
@@ -221,9 +231,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener
*listener,
}
iova = TARGET_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 = vhost_vdpa_section_end(section);
trace_vhost_vdpa_listener_region_del(v, iova, int128_get64(llend));
--
MST
- [PULL v2 07/44] tests: acpi: add testcase for intel_iommu (DMAR table), (continued)
- [PULL v2 07/44] tests: acpi: add testcase for intel_iommu (DMAR table), Michael S. Tsirkin, 2021/10/20
- [PULL v2 08/44] tests: acpi: add expected blob for DMAR table, Michael S. Tsirkin, 2021/10/20
- [PULL v2 09/44] tests: acpi: whitelist expected blobs for new acpi/q35/ivrs testcase, Michael S. Tsirkin, 2021/10/20
- [PULL v2 10/44] tests: acpi: add testcase for amd-iommu (IVRS table), Michael S. Tsirkin, 2021/10/20
- [PULL v2 11/44] tests: acpi: update expected blobs, Michael S. Tsirkin, 2021/10/20
- [PULL v2 12/44] tests: acpi: arm/virt: drop redundant test_acpi_one() in test_acpi_virt_tcg(), Michael S. Tsirkin, 2021/10/20
- [PULL v2 15/44] tests: bios-tables-test: use qtest_has_accel() API to register TCG only tests, Michael S. Tsirkin, 2021/10/20
- [PULL v2 16/44] vdpa: Skip protected ram IOMMU mappings, Michael S. Tsirkin, 2021/10/20
- [PULL v2 14/44] tests: migration-test: use qtest_has_accel() API, Michael S. Tsirkin, 2021/10/20
- [PULL v2 13/44] tests: arm-cpu-features: use qtest_has_kvm() API, Michael S. Tsirkin, 2021/10/20
- [PULL v2 17/44] vdpa: Add vhost_vdpa_section_end,
Michael S. Tsirkin <=
- [PULL v2 19/44] virtio-iommu: Remove the non transitional name, Michael S. Tsirkin, 2021/10/20
- [PULL v2 20/44] virtio-iommu: Drop base_name and change generic_name, Michael S. Tsirkin, 2021/10/20
- [PULL v2 23/44] vhost-user-rng-pci: Add vhost-user-rng-pci implementation, Michael S. Tsirkin, 2021/10/20
- [PULL v2 21/44] libvhost-user: fix VHOST_USER_REM_MEM_REG skipping mmap_addr, Michael S. Tsirkin, 2021/10/20
- [PULL v2 18/44] vdpa: Check for iova range at mappings changes, Michael S. Tsirkin, 2021/10/20
- [PULL v2 24/44] docs: Add documentation for vhost based RNG implementation, Michael S. Tsirkin, 2021/10/20
- [PULL v2 26/44] failover: fix a regression introduced by JSON'ification of -device, Michael S. Tsirkin, 2021/10/20
- [PULL v2 27/44] vhost-user-blk-test: pass vhost-user socket fds to QSD, Michael S. Tsirkin, 2021/10/20
- [PULL v2 25/44] vhost-user: fix duplicated notifier MR init, Michael S. Tsirkin, 2021/10/20
- [PULL v2 22/44] vhost-user-rng: Add vhost-user-rng implementation, Michael S. Tsirkin, 2021/10/20