* [PATCH v6 1/4] accel/tcg: Make use of qemu_target_page_mask() in perf.c
2024-01-25 5:46 [PATCH v6 0/4] accel/tcg: Move perf and debuginfo support to tcg Philippe Mathieu-Daudé
@ 2024-01-25 5:46 ` Philippe Mathieu-Daudé
2024-01-25 5:46 ` [PATCH v6 2/4] tcg: Make tb_cflags() usable from target-agnostic code Philippe Mathieu-Daudé
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-25 5:46 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Richard Henderson,
Ilya Leoshkevich, Alex Bennée, Philippe Mathieu-Daudé
From: Ilya Leoshkevich <iii@linux.ibm.com>
Stop using TARGET_PAGE_MASK in order to make perf.c more
target-agnostic.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231212003837.64090-2-iii@linux.ibm.com>
---
accel/tcg/perf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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;
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v6 2/4] tcg: Make tb_cflags() usable from target-agnostic code
2024-01-25 5:46 [PATCH v6 0/4] accel/tcg: Move perf and debuginfo support to tcg Philippe Mathieu-Daudé
2024-01-25 5:46 ` [PATCH v6 1/4] accel/tcg: Make use of qemu_target_page_mask() in perf.c Philippe Mathieu-Daudé
@ 2024-01-25 5:46 ` Philippe Mathieu-Daudé
2024-01-25 5:46 ` [PATCH v6 3/4] accel/tcg: Remove #ifdef TARGET_I386 from perf.c Philippe Mathieu-Daudé
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-25 5:46 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Richard Henderson,
Ilya Leoshkevich, Philippe Mathieu-Daudé
From: Ilya Leoshkevich <iii@linux.ibm.com>
Currently tb_cflags() is defined in exec-all.h, which is not usable
from target-agnostic code. Move it to translation-block.h, which is.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20231212003837.64090-3-iii@linux.ibm.com>
---
include/exec/exec-all.h | 6 ------
include/exec/translation-block.h | 6 ++++++
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index df3d93a2e2..ce36bb10d4 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -459,12 +459,6 @@ int probe_access_full_mmu(CPUArchState *env, vaddr addr, int size,
#endif
-/* Hide the qatomic_read to make code a little easier on the eyes */
-static inline uint32_t tb_cflags(const TranslationBlock *tb)
-{
- return qatomic_read(&tb->cflags);
-}
-
static inline tb_page_addr_t tb_page_addr0(const TranslationBlock *tb)
{
#ifdef CONFIG_USER_ONLY
diff --git a/include/exec/translation-block.h b/include/exec/translation-block.h
index e2b26e16da..48211c890a 100644
--- a/include/exec/translation-block.h
+++ b/include/exec/translation-block.h
@@ -145,4 +145,10 @@ struct TranslationBlock {
/* The alignment given to TranslationBlock during allocation. */
#define CODE_GEN_ALIGN 16
+/* Hide the qatomic_read to make code a little easier on the eyes */
+static inline uint32_t tb_cflags(const TranslationBlock *tb)
+{
+ return qatomic_read(&tb->cflags);
+}
+
#endif /* EXEC_TRANSLATION_BLOCK_H */
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v6 3/4] accel/tcg: Remove #ifdef TARGET_I386 from perf.c
2024-01-25 5:46 [PATCH v6 0/4] accel/tcg: Move perf and debuginfo support to tcg Philippe Mathieu-Daudé
2024-01-25 5:46 ` [PATCH v6 1/4] accel/tcg: Make use of qemu_target_page_mask() in perf.c Philippe Mathieu-Daudé
2024-01-25 5:46 ` [PATCH v6 2/4] tcg: Make tb_cflags() usable from target-agnostic code Philippe Mathieu-Daudé
@ 2024-01-25 5:46 ` Philippe Mathieu-Daudé
2024-01-25 5:46 ` [PATCH v6 4/4] accel/tcg: Move perf and debuginfo support to tcg/ Philippe Mathieu-Daudé
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-25 5:46 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Richard Henderson,
Ilya Leoshkevich, Alex Bennée
From: Ilya Leoshkevich <iii@linux.ibm.com>
Preparation for moving perf.c to tcg/.
This affects only profiling guest code, which has code in a non-0 based
segment, e.g., 16-bit code, which is not particularly important.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20231212003837.64090-4-iii@linux.ibm.com>
---
accel/tcg/perf.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/accel/tcg/perf.c b/accel/tcg/perf.c
index ba75c1bbe4..68a46b1b52 100644
--- a/accel/tcg/perf.c
+++ b/accel/tcg/perf.c
@@ -337,10 +337,6 @@ void perf_report_code(uint64_t guest_pc, TranslationBlock *tb,
q[insn].address = gen_insn_data[insn * start_words + 0];
if (tb_cflags(tb) & CF_PCREL) {
q[insn].address |= (guest_pc & qemu_target_page_mask());
- } else {
-#if defined(TARGET_I386)
- q[insn].address -= tb->cs_base;
-#endif
}
q[insn].flags = DEBUGINFO_SYMBOL | (jitdump ? DEBUGINFO_LINE : 0);
}
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v6 4/4] accel/tcg: Move perf and debuginfo support to tcg/
2024-01-25 5:46 [PATCH v6 0/4] accel/tcg: Move perf and debuginfo support to tcg Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2024-01-25 5:46 ` [PATCH v6 3/4] accel/tcg: Remove #ifdef TARGET_I386 from perf.c Philippe Mathieu-Daudé
@ 2024-01-25 5:46 ` Philippe Mathieu-Daudé
2024-01-27 2:53 ` [PATCH v6 0/4] accel/tcg: Move perf and debuginfo support to tcg Richard Henderson
2024-01-28 1:59 ` Richard Henderson
5 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-25 5:46 UTC (permalink / raw)
To: qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Richard Henderson,
Ilya Leoshkevich, Philippe Mathieu-Daudé
From: Ilya Leoshkevich <iii@linux.ibm.com>
tcg/ should not depend on accel/tcg/, but perf and debuginfo
support provided by the latter are being used by tcg/tcg.c.
Since that's the only user, move both to tcg/.
Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20231212003837.64090-5-iii@linux.ibm.com>
---
{accel => include}/tcg/debuginfo.h | 4 ++--
{accel => include}/tcg/perf.h | 4 ++--
accel/tcg/translate-all.c | 2 +-
hw/core/loader.c | 2 +-
linux-user/elfload.c | 2 +-
linux-user/exit.c | 2 +-
linux-user/main.c | 2 +-
system/vl.c | 2 +-
{accel/tcg => tcg}/debuginfo.c | 3 +--
{accel/tcg => tcg}/perf.c | 7 +++----
tcg/tcg.c | 2 +-
accel/tcg/meson.build | 4 ----
tcg/meson.build | 5 +++++
13 files changed, 20 insertions(+), 21 deletions(-)
rename {accel => include}/tcg/debuginfo.h (96%)
rename {accel => include}/tcg/perf.h (95%)
rename {accel/tcg => tcg}/debuginfo.c (98%)
rename {accel/tcg => tcg}/perf.c (99%)
diff --git a/accel/tcg/debuginfo.h b/include/tcg/debuginfo.h
similarity index 96%
rename from accel/tcg/debuginfo.h
rename to include/tcg/debuginfo.h
index f064e1c144..858535b5da 100644
--- a/accel/tcg/debuginfo.h
+++ b/include/tcg/debuginfo.h
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
-#ifndef ACCEL_TCG_DEBUGINFO_H
-#define ACCEL_TCG_DEBUGINFO_H
+#ifndef TCG_DEBUGINFO_H
+#define TCG_DEBUGINFO_H
#include "qemu/bitops.h"
diff --git a/accel/tcg/perf.h b/include/tcg/perf.h
similarity index 95%
rename from accel/tcg/perf.h
rename to include/tcg/perf.h
index f92dd52c69..c96b5920a3 100644
--- a/accel/tcg/perf.h
+++ b/include/tcg/perf.h
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
-#ifndef ACCEL_TCG_PERF_H
-#define ACCEL_TCG_PERF_H
+#ifndef TCG_PERF_H
+#define TCG_PERF_H
#if defined(CONFIG_TCG) && defined(CONFIG_LINUX)
/* Start writing perf-<pid>.map. */
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 1737bb3da5..1c695efe02 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -63,7 +63,7 @@
#include "tb-context.h"
#include "internal-common.h"
#include "internal-target.h"
-#include "perf.h"
+#include "tcg/perf.h"
#include "tcg/insn-start-words.h"
TBContext tb_ctx;
diff --git a/hw/core/loader.c b/hw/core/loader.c
index e7a9b3775b..b8e52f3fb0 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -62,7 +62,7 @@
#include "hw/boards.h"
#include "qemu/cutils.h"
#include "sysemu/runstate.h"
-#include "accel/tcg/debuginfo.h"
+#include "tcg/debuginfo.h"
#include <zlib.h>
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index cf9e74468b..62120c7615 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -21,7 +21,7 @@
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "target_signal.h"
-#include "accel/tcg/debuginfo.h"
+#include "tcg/debuginfo.h"
#ifdef TARGET_ARM
#include "target/arm/cpu-features.h"
diff --git a/linux-user/exit.c b/linux-user/exit.c
index 50266314e0..1ff8fe4f07 100644
--- a/linux-user/exit.c
+++ b/linux-user/exit.c
@@ -17,7 +17,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
-#include "accel/tcg/perf.h"
+#include "tcg/perf.h"
#include "gdbstub/syscalls.h"
#include "qemu.h"
#include "user-internals.h"
diff --git a/linux-user/main.c b/linux-user/main.c
index c9470eeccf..74b2fbb393 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -54,7 +54,7 @@
#include "signal-common.h"
#include "loader.h"
#include "user-mmap.h"
-#include "accel/tcg/perf.h"
+#include "tcg/perf.h"
#ifdef CONFIG_SEMIHOSTING
#include "semihosting/semihost.h"
diff --git a/system/vl.c b/system/vl.c
index 788d88ea03..60fd1e56b6 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -96,7 +96,7 @@
#endif
#include "sysemu/qtest.h"
#ifdef CONFIG_TCG
-#include "accel/tcg/perf.h"
+#include "tcg/perf.h"
#endif
#include "disas/disas.h"
diff --git a/accel/tcg/debuginfo.c b/tcg/debuginfo.c
similarity index 98%
rename from accel/tcg/debuginfo.c
rename to tcg/debuginfo.c
index 71c66d04d1..3753f7ef67 100644
--- a/accel/tcg/debuginfo.c
+++ b/tcg/debuginfo.c
@@ -6,11 +6,10 @@
#include "qemu/osdep.h"
#include "qemu/lockable.h"
+#include "tcg/debuginfo.h"
#include <elfutils/libdwfl.h>
-#include "debuginfo.h"
-
static QemuMutex lock;
static Dwfl *dwfl;
static const Dwfl_Callbacks dwfl_callbacks = {
diff --git a/accel/tcg/perf.c b/tcg/perf.c
similarity index 99%
rename from accel/tcg/perf.c
rename to tcg/perf.c
index 68a46b1b52..412a987d95 100644
--- a/accel/tcg/perf.c
+++ b/tcg/perf.c
@@ -11,13 +11,12 @@
#include "qemu/osdep.h"
#include "elf.h"
#include "exec/target_page.h"
-#include "exec/exec-all.h"
+#include "exec/translation-block.h"
#include "qemu/timer.h"
+#include "tcg/debuginfo.h"
+#include "tcg/perf.h"
#include "tcg/tcg.h"
-#include "debuginfo.h"
-#include "perf.h"
-
static FILE *safe_fopen_w(const char *path)
{
int saved_errno;
diff --git a/tcg/tcg.c b/tcg/tcg.c
index e2c38f6d11..eeff4c1d51 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -55,7 +55,7 @@
#include "tcg/tcg-ldst.h"
#include "tcg/tcg-temp-internal.h"
#include "tcg-internal.h"
-#include "accel/tcg/perf.h"
+#include "tcg/perf.h"
#ifdef CONFIG_USER_ONLY
#include "exec/user/guest-base.h"
#endif
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index c15ac9ac8f..46f7d53eeb 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -16,10 +16,6 @@ tcg_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_false: files('user-exec-stub.c'))
if get_option('plugins')
tcg_ss.add(files('plugin-gen.c'))
endif
-tcg_ss.add(when: libdw, if_true: files('debuginfo.c'))
-if host_os == 'linux'
- tcg_ss.add(files('perf.c'))
-endif
specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss)
specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files(
diff --git a/tcg/meson.build b/tcg/meson.build
index 5afdec1e1a..8251589fd4 100644
--- a/tcg/meson.build
+++ b/tcg/meson.build
@@ -22,6 +22,11 @@ if get_option('tcg_interpreter')
tcg_ss.add(files('tci.c'))
endif
+tcg_ss.add(when: libdw, if_true: files('debuginfo.c'))
+if host_os == 'linux'
+ tcg_ss.add(files('perf.c'))
+endif
+
tcg_ss = tcg_ss.apply({})
libtcg_user = static_library('tcg_user',
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v6 0/4] accel/tcg: Move perf and debuginfo support to tcg
2024-01-25 5:46 [PATCH v6 0/4] accel/tcg: Move perf and debuginfo support to tcg Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2024-01-25 5:46 ` [PATCH v6 4/4] accel/tcg: Move perf and debuginfo support to tcg/ Philippe Mathieu-Daudé
@ 2024-01-27 2:53 ` Richard Henderson
2024-01-28 1:59 ` Richard Henderson
5 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2024-01-27 2:53 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Ilya Leoshkevich
On 1/25/24 15:46, Philippe Mathieu-Daudé wrote:
> Since v5:
> - Use v4 instead of v3...
> - Rebased on commit 53e8868d69
> ("meson: remove OS definitions from config_targetos")
>
> Ilya Leoshkevich (4):
> accel/tcg: Make use of qemu_target_page_mask() in perf.c
> tcg: Make tb_cflags() usable from target-agnostic code
> accel/tcg: Remove #ifdef TARGET_I386 from perf.c
> accel/tcg: Move perf and debuginfo support to tcg/
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v6 0/4] accel/tcg: Move perf and debuginfo support to tcg
2024-01-25 5:46 [PATCH v6 0/4] accel/tcg: Move perf and debuginfo support to tcg Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2024-01-27 2:53 ` [PATCH v6 0/4] accel/tcg: Move perf and debuginfo support to tcg Richard Henderson
@ 2024-01-28 1:59 ` Richard Henderson
5 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2024-01-28 1:59 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Laurent Vivier, Paolo Bonzini, Ilya Leoshkevich
On 1/25/24 15:46, Philippe Mathieu-Daudé wrote:
> Since v5:
> - Use v4 instead of v3...
> - Rebased on commit 53e8868d69
> ("meson: remove OS definitions from config_targetos")
>
> Ilya Leoshkevich (4):
> accel/tcg: Make use of qemu_target_page_mask() in perf.c
> tcg: Make tb_cflags() usable from target-agnostic code
> accel/tcg: Remove #ifdef TARGET_I386 from perf.c
> accel/tcg: Move perf and debuginfo support to tcg/
>
> include/exec/exec-all.h | 6 ------
> include/exec/translation-block.h | 6 ++++++
> {accel => include}/tcg/debuginfo.h | 4 ++--
> {accel => include}/tcg/perf.h | 4 ++--
> accel/tcg/translate-all.c | 2 +-
> hw/core/loader.c | 2 +-
> linux-user/elfload.c | 2 +-
> linux-user/exit.c | 2 +-
> linux-user/main.c | 2 +-
> system/vl.c | 2 +-
> {accel/tcg => tcg}/debuginfo.c | 3 +--
> {accel/tcg => tcg}/perf.c | 14 +++++---------
> tcg/tcg.c | 2 +-
> accel/tcg/meson.build | 4 ----
> tcg/meson.build | 5 +++++
> 15 files changed, 28 insertions(+), 32 deletions(-)
> rename {accel => include}/tcg/debuginfo.h (96%)
> rename {accel => include}/tcg/perf.h (95%)
> rename {accel/tcg => tcg}/debuginfo.c (98%)
> rename {accel/tcg => tcg}/perf.c (97%)
>
Queued, thanks.
r~
^ permalink raw reply [flat|nested] 7+ messages in thread