diff mbox series

[v5,1/4] target: Make qemu_target_page_mask() available for *-user

Message ID 20240124075609.14756-2-philmd@linaro.org
State New
Headers show
Series accel/tcg: Move perf and debuginfo support to tcg | expand

Commit Message

Philippe Mathieu-Daudé Jan. 24, 2024, 7:56 a.m. UTC
From: Ilya Leoshkevich <iii@linux.ibm.com>

Currently qemu_target_page_mask() is usable only from the softmmu
code. Make it possible to use it from the *-user code as well.

Make use of it in perf.c.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-ID: <20231208003754.3688038-2-iii@linux.ibm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/perf.c       |  3 ++-
 system/physmem.c       |  5 -----
 target/target-common.c | 10 ++++++++++
 target/meson.build     |  2 ++
 4 files changed, 14 insertions(+), 6 deletions(-)
 create mode 100644 target/target-common.c

Comments

Richard Henderson Jan. 24, 2024, 9:06 p.m. UTC | #1
On 1/24/24 17:56, Philippe Mathieu-Daudé wrote:
> From: Ilya Leoshkevich<iii@linux.ibm.com>
> 
> Currently qemu_target_page_mask() is usable only from the softmmu
> code. Make it possible to use it from the *-user code as well.
> 
> Make use of it in perf.c.
> 
> Signed-off-by: Ilya Leoshkevich<iii@linux.ibm.com>
> Message-ID:<20231208003754.3688038-2-iii@linux.ibm.com>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   accel/tcg/perf.c       |  3 ++-
>   system/physmem.c       |  5 -----
>   target/target-common.c | 10 ++++++++++
>   target/meson.build     |  2 ++
>   4 files changed, 14 insertions(+), 6 deletions(-)
>   create mode 100644 target/target-common.c

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

r~
diff mbox series

Patch

diff --git a/accel/tcg/perf.c b/accel/tcg/perf.c
index cd1aa99a7e..ba75c1bbe4 100644
--- a/accel/tcg/perf.c
+++ b/accel/tcg/perf.c
@@ -10,6 +10,7 @@ 
 
 #include "qemu/osdep.h"
 #include "elf.h"
+#include "exec/target_page.h"
 #include "exec/exec-all.h"
 #include "qemu/timer.h"
 #include "tcg/tcg.h"
@@ -335,7 +336,7 @@  void perf_report_code(uint64_t guest_pc, TranslationBlock *tb,
         /* FIXME: This replicates the restore_state_to_opc() logic. */
         q[insn].address = gen_insn_data[insn * start_words + 0];
         if (tb_cflags(tb) & CF_PCREL) {
-            q[insn].address |= (guest_pc & TARGET_PAGE_MASK);
+            q[insn].address |= (guest_pc & qemu_target_page_mask());
         } else {
 #if defined(TARGET_I386)
             q[insn].address -= tb->cs_base;
diff --git a/system/physmem.c b/system/physmem.c
index cc68a79763..5e66d9ae36 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3431,11 +3431,6 @@  size_t qemu_target_page_size(void)
     return TARGET_PAGE_SIZE;
 }
 
-int qemu_target_page_mask(void)
-{
-    return TARGET_PAGE_MASK;
-}
-
 int qemu_target_page_bits(void)
 {
     return TARGET_PAGE_BITS;
diff --git a/target/target-common.c b/target/target-common.c
new file mode 100644
index 0000000000..903b10cfe4
--- /dev/null
+++ b/target/target-common.c
@@ -0,0 +1,10 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#include "qemu/osdep.h"
+
+#include "cpu.h"
+#include "exec/target_page.h"
+
+int qemu_target_page_mask(void)
+{
+    return TARGET_PAGE_MASK;
+}
diff --git a/target/meson.build b/target/meson.build
index a53a60486f..dee2ac47e0 100644
--- a/target/meson.build
+++ b/target/meson.build
@@ -19,3 +19,5 @@  subdir('sh4')
 subdir('sparc')
 subdir('tricore')
 subdir('xtensa')
+
+specific_ss.add(files('target-common.c'))