diff mbox series

[01/11] softmmu: Introduce qemu_target_page_mask/qemu_target_page_align helpers

Message ID 20230523163600.83391-2-philmd@linaro.org (mailing list archive)
State New, archived
Headers show
Series hw/virtio: Build various target-agnostic objects just once | expand

Commit Message

Philippe Mathieu-Daudé May 23, 2023, 4:35 p.m. UTC
Since TARGET_PAGE_MASK and TARGET_PAGE_ALIGN are poisoned in
target-agnostic code, introduce the qemu_target_page_mask()
and qemu_target_page_align() helpers to get these values from
target-agnostic code at runtime.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/exec/target_page.h |  2 ++
 softmmu/physmem.c          | 10 ++++++++++
 2 files changed, 12 insertions(+)

Comments

Thomas Huth May 23, 2023, 6:17 p.m. UTC | #1
On 23/05/2023 18.35, Philippe Mathieu-Daudé wrote:
> Since TARGET_PAGE_MASK and TARGET_PAGE_ALIGN are poisoned in
> target-agnostic code, introduce the qemu_target_page_mask()
> and qemu_target_page_align() helpers to get these values from
> target-agnostic code at runtime.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/exec/target_page.h |  2 ++
>   softmmu/physmem.c          | 10 ++++++++++
>   2 files changed, 12 insertions(+)

Reviewed-by: Thomas Huth <thuth@redhat.com>
Richard Henderson May 23, 2023, 11:08 p.m. UTC | #2
On 5/23/23 09:35, Philippe Mathieu-Daudé wrote:
> +unsigned qemu_target_page_mask(void);

Should be signed int, so that it sign-extends to whatever needed width.

r~
diff mbox series

Patch

diff --git a/include/exec/target_page.h b/include/exec/target_page.h
index bbf37aea17..660416920b 100644
--- a/include/exec/target_page.h
+++ b/include/exec/target_page.h
@@ -15,6 +15,8 @@ 
 #define EXEC_TARGET_PAGE_H
 
 size_t qemu_target_page_size(void);
+unsigned qemu_target_page_mask(void);
+uint64_t qemu_target_page_align(uint64_t value);
 int qemu_target_page_bits(void);
 int qemu_target_page_bits_min(void);
 
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index efaed36773..14fcba4fb2 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -3347,6 +3347,16 @@  size_t qemu_target_page_size(void)
     return TARGET_PAGE_SIZE;
 }
 
+unsigned qemu_target_page_mask(void)
+{
+    return TARGET_PAGE_MASK;
+}
+
+uint64_t qemu_target_page_align(uint64_t value)
+{
+    return TARGET_PAGE_ALIGN(value);
+}
+
 int qemu_target_page_bits(void)
 {
     return TARGET_PAGE_BITS;