[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/63] hw/virtio/vhost-vdpa: Use target-agnostic qemu_target_page_
From: |
Michael S. Tsirkin |
Subject: |
[PULL 05/63] hw/virtio/vhost-vdpa: Use target-agnostic qemu_target_page_mask() |
Date: |
Wed, 4 Oct 2023 04:43:24 -0400 |
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Similarly to commit e414ed2c47 ("virtio-iommu: Use
target-agnostic qemu_target_page_mask"), Replace the
target-specific TARGET_PAGE_SIZE and TARGET_PAGE_MASK
definitions by a call to the runtime qemu_target_page_size()
helper which is target agnostic.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230710094931.84402-5-philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/vhost-vdpa.c | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 0e0ed6d7ac..50b932a930 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -14,6 +14,7 @@
#include <linux/vfio.h>
#include <sys/eventfd.h>
#include <sys/ioctl.h>
+#include "exec/target_page.h"
#include "hw/virtio/vhost.h"
#include "hw/virtio/vhost-backend.h"
#include "hw/virtio/virtio-net.h"
@@ -23,7 +24,6 @@
#include "migration/blocker.h"
#include "qemu/cutils.h"
#include "qemu/main-loop.h"
-#include "cpu.h"
#include "trace.h"
#include "qapi/error.h"
@@ -313,9 +313,11 @@ static void vhost_vdpa_listener_region_add(MemoryListener
*listener,
Int128 llend, llsize;
void *vaddr;
int ret;
+ int page_size = qemu_target_page_size();
+ int page_mask = -page_size;
if (vhost_vdpa_listener_skipped_section(section, v->iova_range.first,
- v->iova_range.last,
TARGET_PAGE_MASK)) {
+ v->iova_range.last, page_mask)) {
return;
}
if (memory_region_is_iommu(section->mr)) {
@@ -323,16 +325,16 @@ static void vhost_vdpa_listener_region_add(MemoryListener
*listener,
return;
}
- if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK) !=
- (section->offset_within_region & ~TARGET_PAGE_MASK))) {
+ if (unlikely((section->offset_within_address_space & ~page_mask) !=
+ (section->offset_within_region & ~page_mask))) {
trace_vhost_vdpa_listener_region_add_unaligned(v, section->mr->name,
- section->offset_within_address_space &
~TARGET_PAGE_MASK,
- section->offset_within_region & ~TARGET_PAGE_MASK);
+ section->offset_within_address_space & ~page_mask,
+ section->offset_within_region & ~page_mask);
return;
}
- iova = ROUND_UP(section->offset_within_address_space, TARGET_PAGE_SIZE);
- llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK);
+ iova = ROUND_UP(section->offset_within_address_space, page_size);
+ llend = vhost_vdpa_section_end(section, page_mask);
if (int128_ge(int128_make64(iova), llend)) {
return;
}
@@ -398,25 +400,27 @@ static void vhost_vdpa_listener_region_del(MemoryListener
*listener,
hwaddr iova;
Int128 llend, llsize;
int ret;
+ int page_size = qemu_target_page_size();
+ int page_mask = -page_size;
if (vhost_vdpa_listener_skipped_section(section, v->iova_range.first,
- v->iova_range.last,
TARGET_PAGE_MASK)) {
+ v->iova_range.last, page_mask)) {
return;
}
if (memory_region_is_iommu(section->mr)) {
vhost_vdpa_iommu_region_del(listener, section);
}
- if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK) !=
- (section->offset_within_region & ~TARGET_PAGE_MASK))) {
+ if (unlikely((section->offset_within_address_space & ~page_mask) !=
+ (section->offset_within_region & ~page_mask))) {
trace_vhost_vdpa_listener_region_del_unaligned(v, section->mr->name,
- section->offset_within_address_space &
~TARGET_PAGE_MASK,
- section->offset_within_region & ~TARGET_PAGE_MASK);
+ section->offset_within_address_space & ~page_mask,
+ section->offset_within_region & ~page_mask);
return;
}
- iova = ROUND_UP(section->offset_within_address_space, TARGET_PAGE_SIZE);
- llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK);
+ iova = ROUND_UP(section->offset_within_address_space, page_size);
+ llend = vhost_vdpa_section_end(section, page_mask);
trace_vhost_vdpa_listener_region_del(v, iova,
int128_get64(int128_sub(llend, int128_one())));
--
MST
- [PULL 00/63] virtio,pci: features, cleanups, Michael S. Tsirkin, 2023/10/04
- [PULL 04/63] hw/virtio/vhost-vdpa: Inline TARGET_PAGE_ALIGN() macro, Michael S. Tsirkin, 2023/10/04
- [PULL 03/63] hw/virtio: Propagate page_mask to vhost_vdpa_section_end(), Michael S. Tsirkin, 2023/10/04
- [PULL 02/63] hw/virtio: Propagate page_mask to vhost_vdpa_listener_skipped_section(), Michael S. Tsirkin, 2023/10/04
- [PULL 06/63] hw/virtio: Build vhost-vdpa.o once, Michael S. Tsirkin, 2023/10/04
- [PULL 01/63] pci: SLT must be RO, Michael S. Tsirkin, 2023/10/04
- [PULL 05/63] hw/virtio/vhost-vdpa: Use target-agnostic qemu_target_page_mask(),
Michael S. Tsirkin <=
- [PULL 07/63] hw/virtio/meson: Rename softmmu_virtio_ss[] -> system_virtio_ss[], Michael S. Tsirkin, 2023/10/04
- [PULL 11/63] virtio-net: Expose MAX_VLAN, Michael S. Tsirkin, 2023/10/04
- [PULL 09/63] hw/virtio: add config support to vhost-user-device, Michael S. Tsirkin, 2023/10/04
- [PULL 08/63] virtio: add vhost-user-base and a generic vhost-user-device, Michael S. Tsirkin, 2023/10/04
- [PULL 14/63] virtio: don't zero out memory region cache for indirect descriptors, Michael S. Tsirkin, 2023/10/04
- [PULL 13/63] vdpa: Allow VIRTIO_NET_F_CTRL_VLAN in SVQ, Michael S. Tsirkin, 2023/10/04
- [PULL 10/63] virtio-net: do not reset vlan filtering at set_features, Michael S. Tsirkin, 2023/10/04
- [PULL 15/63] vdpa: use first queue SVQ state for CVQ default, Michael S. Tsirkin, 2023/10/04
- [PULL 17/63] vdpa: rename vhost_vdpa_net_load to vhost_vdpa_net_cvq_load, Michael S. Tsirkin, 2023/10/04
- [PULL 19/63] vdpa: remove net cvq migration blocker, Michael S. Tsirkin, 2023/10/04