diff mbox series

[RFC,02/18] hw/vfio/common: Get target page size using runtime helpers

Message ID 20250305153929.43687-3-philmd@linaro.org
State New
Headers show
Series hw/microblaze: Quick single binary proof of concept | expand

Commit Message

Philippe Mathieu-Daudé March 5, 2025, 3:39 p.m. UTC
Prefer runtime helpers to get target page size.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/vfio/common.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Richard Henderson March 6, 2025, 1:37 a.m. UTC | #1
On 3/5/25 07:39, Philippe Mathieu-Daudé wrote:
> Prefer runtime helpers to get target page size.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/vfio/common.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 7a4010ef4ee..d4c9e59173d 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -30,6 +30,7 @@
>   #include "exec/address-spaces.h"
>   #include "exec/memory.h"
>   #include "exec/ram_addr.h"
> +#include "exec/target_page.h"
>   #include "hw/hw.h"
>   #include "qemu/error-report.h"
>   #include "qemu/main-loop.h"
> @@ -395,10 +396,12 @@ static void vfio_register_ram_discard_listener(VFIOContainerBase *bcontainer,
>       VFIORamDiscardListener *vrdl;
>   
>       /* Ignore some corner cases not relevant in practice. */
> -    g_assert(QEMU_IS_ALIGNED(section->offset_within_region, TARGET_PAGE_SIZE));
> +    g_assert(QEMU_IS_ALIGNED(section->offset_within_region,
> +                             qemu_target_page_size()));
>       g_assert(QEMU_IS_ALIGNED(section->offset_within_address_space,
> -                             TARGET_PAGE_SIZE));
> -    g_assert(QEMU_IS_ALIGNED(int128_get64(section->size), TARGET_PAGE_SIZE));
> +                             qemu_target_page_size()));
> +    g_assert(QEMU_IS_ALIGNED(int128_get64(section->size),
> +                             qemu_target_page_size()));

It would be worth storing this in a local variable, I think.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
diff mbox series

Patch

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 7a4010ef4ee..d4c9e59173d 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -30,6 +30,7 @@ 
 #include "exec/address-spaces.h"
 #include "exec/memory.h"
 #include "exec/ram_addr.h"
+#include "exec/target_page.h"
 #include "hw/hw.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
@@ -395,10 +396,12 @@  static void vfio_register_ram_discard_listener(VFIOContainerBase *bcontainer,
     VFIORamDiscardListener *vrdl;
 
     /* Ignore some corner cases not relevant in practice. */
-    g_assert(QEMU_IS_ALIGNED(section->offset_within_region, TARGET_PAGE_SIZE));
+    g_assert(QEMU_IS_ALIGNED(section->offset_within_region,
+                             qemu_target_page_size()));
     g_assert(QEMU_IS_ALIGNED(section->offset_within_address_space,
-                             TARGET_PAGE_SIZE));
-    g_assert(QEMU_IS_ALIGNED(int128_get64(section->size), TARGET_PAGE_SIZE));
+                             qemu_target_page_size()));
+    g_assert(QEMU_IS_ALIGNED(int128_get64(section->size),
+                             qemu_target_page_size()));
 
     vrdl = g_new0(VFIORamDiscardListener, 1);
     vrdl->bcontainer = bcontainer;