qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Raphael Norwitz" <raphael.norwitz@nutanix.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	qemu-block@nongnu.org, "Eric Farman" <farman@linux.ibm.com>,
	"Fam Zheng" <fam@euphon.net>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Eric Auger" <eric.auger@redhat.com>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>,
	qemu-s390x@nongnu.org
Subject: [RFC PATCH 11/11] hw/virtio: Make vhost-vdpa.c target-agnostic to build it once
Date: Tue, 23 May 2023 18:36:00 +0200	[thread overview]
Message-ID: <20230523163600.83391-12-philmd@linaro.org> (raw)
In-Reply-To: <20230523163600.83391-1-philmd@linaro.org>

Replace TARGET_PAGE_MASK -> qemu_target_page_mask() and
TARGET_PAGE_ALIGN() -> qemu_target_page_align() so we don't
need the target-specific "cpu.h" header.

These macros are used in the MemoryListener add/del handlers
(vhost_vdpa_listener_skipped_section is only called by
vhost_vdpa_listener_region_add) which are not hot-path.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/virtio/vhost-vdpa.c | 16 ++++++++--------
 hw/virtio/meson.build  |  3 ++-
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 3c575a9a6e..a51497aaf1 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"
 
@@ -35,7 +35,7 @@ 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));
+    llend = int128_and(llend, int128_exts64(qemu_target_page_mask()));
 
     return llend;
 }
@@ -321,13 +321,13 @@ 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 & ~qemu_target_page_mask()) !=
+                 (section->offset_within_region & ~qemu_target_page_mask()))) {
         error_report("%s received unaligned region", __func__);
         return;
     }
 
-    iova = TARGET_PAGE_ALIGN(section->offset_within_address_space);
+    iova = qemu_target_page_align(section->offset_within_address_space);
     llend = vhost_vdpa_section_end(section);
     if (int128_ge(int128_make64(iova), llend)) {
         return;
@@ -403,13 +403,13 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
         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 & ~qemu_target_page_mask()) !=
+                 (section->offset_within_region & ~qemu_target_page_mask()))) {
         error_report("%s received unaligned region", __func__);
         return;
     }
 
-    iova = TARGET_PAGE_ALIGN(section->offset_within_address_space);
+    iova = qemu_target_page_align(section->offset_within_address_space);
     llend = vhost_vdpa_section_end(section);
 
     trace_vhost_vdpa_listener_region_del(v, iova,
diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
index 16e64e1cf1..c29be98ab0 100644
--- a/hw/virtio/meson.build
+++ b/hw/virtio/meson.build
@@ -18,7 +18,8 @@ if have_vhost
     specific_virtio_ss.add(files('vhost-user.c'))
   endif
   if have_vhost_vdpa
-    specific_virtio_ss.add(files('vhost-vdpa.c', 'vhost-shadow-virtqueue.c'))
+    softmmu_virtio_ss.add(files('vhost-vdpa.c'))
+    specific_virtio_ss.add(files('vhost-shadow-virtqueue.c'))
   endif
 else
   softmmu_virtio_ss.add(files('vhost-stub.c'))
-- 
2.38.1



  parent reply	other threads:[~2023-05-23 16:37 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23 16:35 [PATCH 00/11] hw/virtio: Build various target-agnostic objects just once Philippe Mathieu-Daudé
2023-05-23 16:35 ` [PATCH 01/11] softmmu: Introduce qemu_target_page_mask/qemu_target_page_align helpers Philippe Mathieu-Daudé
2023-05-23 18:17   ` Thomas Huth
2023-05-23 23:08   ` Richard Henderson
2023-05-23 16:35 ` [PATCH 02/11] hw/scsi: Introduce VHOST_SCSI_COMMON symbol in Kconfig Philippe Mathieu-Daudé
2023-05-23 18:18   ` Thomas Huth
2023-05-23 23:13   ` Richard Henderson
2023-05-23 16:35 ` [PATCH 03/11] hw/scsi: Rearrange meson.build Philippe Mathieu-Daudé
2023-05-23 23:14   ` Richard Henderson
2023-05-24  7:14   ` Thomas Huth
2023-05-24  9:33     ` Philippe Mathieu-Daudé
2023-05-23 16:35 ` [PATCH 04/11] hw/scsi: Rename target-specific source set as 'specific_virtio_scsi_ss' Philippe Mathieu-Daudé
2023-05-23 23:15   ` Richard Henderson
2023-05-23 16:35 ` [PATCH 05/11] hw/virtio: Introduce VHOST_VSOCK_COMMON symbol in Kconfig Philippe Mathieu-Daudé
2023-05-23 23:23   ` Richard Henderson
2023-05-24  7:15   ` Thomas Huth
2023-05-23 16:35 ` [PATCH 06/11] hw/virtio/virtio-mem: Use qemu_ram_get_fd() helper Philippe Mathieu-Daudé
2023-05-23 17:28   ` David Hildenbrand
2023-05-23 23:24   ` Richard Henderson
2023-05-23 16:35 ` [PATCH 07/11] hw/virtio/vhost-vsock: Include missing 'virtio/virtio-bus.h' header Philippe Mathieu-Daudé
2023-05-23 23:24   ` Richard Henderson
2023-05-24  7:17   ` Thomas Huth
2023-05-23 16:35 ` [PATCH 08/11] hw/virtio/virtio-iommu: Use target-agnostic qemu_target_page_mask() Philippe Mathieu-Daudé
2023-05-23 23:28   ` Richard Henderson
2023-05-24  9:27     ` Philippe Mathieu-Daudé
2023-05-24  7:18   ` Thomas Huth
2023-05-24  7:35   ` Eric Auger
2023-05-23 16:35 ` [PATCH 09/11] hw/virtio: Remove unnecessary 'virtio-access.h' header Philippe Mathieu-Daudé
2023-05-23 23:29   ` Richard Henderson
2023-05-24  7:29   ` Thomas Huth
2023-05-24  7:38     ` Philippe Mathieu-Daudé
2023-05-23 16:35 ` [PATCH 10/11] hw/virtio: Build various target-agnostic objects just once Philippe Mathieu-Daudé
2023-05-23 23:31   ` Richard Henderson
2023-05-24  7:32   ` Thomas Huth
2023-05-23 16:36 ` Philippe Mathieu-Daudé [this message]
2023-05-23 23:43   ` [RFC PATCH 11/11] hw/virtio: Make vhost-vdpa.c target-agnostic to build it once Richard Henderson
2023-05-24  7:34   ` Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230523163600.83391-12-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=arei.gonglei@huawei.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=fam@euphon.net \
    --cc=farman@linux.ibm.com \
    --cc=hreitz@redhat.com \
    --cc=iii@linux.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=raphael.norwitz@nutanix.com \
    --cc=richard.henderson@linaro.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).