From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
Thomas Huth <thuth@redhat.com>
Subject: Re: [PATCH v3 4/6] hw/virtio/vhost-vdpa: Use target-agnostic qemu_target_page_mask()
Date: Fri, 18 Aug 2023 13:00:53 +0200 [thread overview]
Message-ID: <e24e67e0-fd01-6374-3bb7-1a73a35b48da@linaro.org> (raw)
In-Reply-To: <20230710094931.84402-5-philmd@linaro.org>
ping?
On 10/7/23 11:49, Philippe Mathieu-Daudé wrote:
> 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>
> ---
> hw/virtio/vhost-vdpa.c | 26 +++++++++++++++-----------
> 1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> index a3dd7c712a..2717edf51d 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,14 +325,14 @@ 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))) {
> error_report("%s received unaligned region", __func__);
> 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;
> }
> @@ -396,23 +398,25 @@ 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))) {
> error_report("%s received unaligned region", __func__);
> 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())));
next prev parent reply other threads:[~2023-08-18 14:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-10 9:49 [PATCH v3 0/6] hw/virtio: Build vhost-vdpa.o once for all targets Philippe Mathieu-Daudé
2023-07-10 9:49 ` [PATCH v3 1/6] hw/virtio: Propagate page_mask to vhost_vdpa_listener_skipped_section() Philippe Mathieu-Daudé
2023-07-10 9:49 ` [PATCH v3 2/6] hw/virtio: Propagate page_mask to vhost_vdpa_section_end() Philippe Mathieu-Daudé
2023-07-10 9:49 ` [PATCH v3 3/6] hw/virtio/vhost-vdpa: Inline TARGET_PAGE_ALIGN() macro Philippe Mathieu-Daudé
2023-07-10 9:49 ` [PATCH v3 4/6] hw/virtio/vhost-vdpa: Use target-agnostic qemu_target_page_mask() Philippe Mathieu-Daudé
2023-08-18 11:00 ` Philippe Mathieu-Daudé [this message]
2023-08-25 8:11 ` Philippe Mathieu-Daudé
2023-08-29 16:50 ` Richard Henderson
2023-07-10 10:04 ` [PATCH v3 5/6] hw/virtio: Build vhost-vdpa.o once Philippe Mathieu-Daudé
2023-07-10 10:05 ` [PATCH v3 6/6] hw/virtio/meson: Rename softmmu_virtio_ss[] -> system_virtio_ss[] Philippe Mathieu-Daudé
2023-08-30 13:35 ` [PATCH v3 0/6] hw/virtio: Build vhost-vdpa.o once for all targets Philippe Mathieu-Daudé
2023-09-06 6:31 ` Philippe Mathieu-Daudé
2023-09-18 10:42 ` Philippe Mathieu-Daudé
2023-09-25 22:00 ` Michael S. Tsirkin
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=e24e67e0-fd01-6374-3bb7-1a73a35b48da@linaro.org \
--to=philmd@linaro.org \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--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).