accel/tcg: Move perf and debuginfo support to tcg
v5 cover accel/tcg: Move perf and debuginfo support to tcg
Since v5:
- Rebased on commit 53e8868d69
("meson: remove OS definitions from config_targetos")
Ilya Leoshkevich (4):
target: Make qemu_target_page_mask() available for *-user
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/tcg => tcg}/debuginfo.h | 4 ++--
{accel/tcg => 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/physmem.c | 5 -----
system/vl.c | 2 +-
target/target-common.c | 10 ++++++++++
{accel/tcg => tcg}/debuginfo.c | 0
{accel/tcg => tcg}/perf.c | 9 +++------
tcg/tcg.c | 2 +-
accel/tcg/meson.build | 4 ----
target/meson.build | 2 ++
tcg/meson.build | 5 +++++
18 files changed, 37 insertions(+), 32 deletions(-)
rename {accel/tcg => tcg}/debuginfo.h (96%)
rename {accel/tcg => tcg}/perf.h (95%)
create mode 100644 target/target-common.c
rename {accel/tcg => tcg}/debuginfo.c (100%)
rename {accel/tcg => tcg}/perf.c (98%)Signature · 1 line
2.41.0
PATCH v5 1/4 target: Make qemu_target_page_mask() available for *-user
From: Ilya Leoshkevich <[email protected]>
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.
Message-ID: <[email protected]>
--- 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
accel/tcg/perf.c +2 -1
@@ -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;
system/physmem.c +0 -5
@@ -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 ;
target/target-common.c new file +10 -0
@@ -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 ; +}
target/meson.build +2 -0
@@ -19,3 +19,5 @@ subdir('sh4') subdir('sparc') subdir('tricore') subdir('xtensa') + +specific_ss.add(files('target-common.c'))
Signature · 1 line
2.41.0
Re: [PATCH v5 1/4] target: Make qemu_target_page_mask() available for *-user
Quoted 9 lines · Philippe Mathieu-Daudé
From: Ilya Leoshkevich<[email protected]>
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<[email protected]>Message-ID:<[email protected]>
Quoted 8 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- 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
r~
PATCH v5 2/4 tcg: Make tb_cflags() usable from target-agnostic code
In reply to Philippe Mathieu-DaudéFrom: Ilya Leoshkevich <[email protected]>
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.
Message-ID: <[email protected]>
--- include/exec/exec-all.h | 6 ------ include/exec/translation-block.h | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-)
include/exec/exec-all.h +0 -6
@@ -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
include/exec/translation-block.h +6 -0
@@ -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 */
Signature · 1 line
2.41.0
Re: [PATCH v5 2/4] tcg: Make tb_cflags() usable from target-agnostic code
Quoted 5 lines · Philippe Mathieu-Daudé
From: Ilya Leoshkevich<[email protected]>
Currently
tb_cflags()is defined inexec-all.h, which is not usable from target-agnostic code. Move it totranslation-block.h, which is.
Quoted 8 lines
Reviewed-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Ilya Leoshkevich<[email protected]>Message-ID:<[email protected]>
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/exec/exec-all.h | 6 ------ include/exec/translation-block.h | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-)
r~
PATCH v5 3/4 accel/tcg: Remove #ifdef TARGET_I386 from perf.c
In reply to Philippe Mathieu-DaudéFrom: Ilya Leoshkevich <[email protected]>
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.
Message-ID: <[email protected]>
--- accel/tcg/perf.c | 4 ---- 1 file changed, 4 deletions(-)
accel/tcg/perf.c +0 -4
@@ -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 ); }
Signature · 1 line
2.41.0
Re: [PATCH v5 3/4] accel/tcg: Remove #ifdef TARGET_I386 from perf.c
Quoted 7 lines · Philippe Mathieu-Daudé
From: Ilya Leoshkevich<[email protected]>
Preparation for moving
perf.cto 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.
Quoted 8 lines
Suggested-by Richard Henderson<[email protected]>Signed-off-by Ilya Leoshkevich<[email protected]>Reviewed-by Alex Bennée<[email protected]>Message-ID:<[email protected]>
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- accel/tcg/perf.c | 4 ---- 1 file changed, 4 deletions(-)
r~
PATCH v5 4/4 accel/tcg: Move perf and debuginfo support to tcg
In reply to Philippe Mathieu-DaudéFrom: Ilya Leoshkevich <[email protected]>
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/.
Message-ID: <[email protected]>
---
{accel/tcg => tcg}/debuginfo.h | 4 ++--
{accel/tcg => 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 | 0
{accel/tcg => tcg}/perf.c | 2 +-
tcg/tcg.c | 2 +-
accel/tcg/meson.build | 4 ----
tcg/meson.build | 5 +++++
13 files changed, 17 insertions(+), 16 deletions(-)
rename {accel/tcg => tcg}/debuginfo.h (96%)
rename {accel/tcg => tcg}/perf.h (95%)
rename {accel/tcg => tcg}/debuginfo.c (100%)
rename {accel/tcg => tcg}/perf.c (99%)tcg/debuginfo.h renamed from accel/tcg/debuginfo.h +2 -2
@@ -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"
tcg/perf.h renamed from accel/tcg/perf.h +2 -2
@@ -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. */
accel/tcg/translate-all.c +1 -1
@@ -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;
hw/core/loader.c +1 -1
@@ -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>
linux-user/elfload.c +1 -1
@@ -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"
linux-user/exit.c +1 -1
@@ -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"
linux-user/main.c +1 -1
@@ -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"
system/vl.c +1 -1
@@ -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"
tcg/debuginfo.c renamed from accel/tcg/debuginfo.c +0 -0
tcg/perf.c renamed from accel/tcg/perf.c +1 -1
@@ -11,7 +11,7 @@#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/tcg.h"
tcg/tcg.c +1 -1
@@ -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
accel/tcg/meson.build +0 -4
@@ -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(
tcg/meson.build +5 -0
@@ -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',
Signature · 1 line
2.41.0
Quoted 7 lines · Philippe Mathieu-Daudé
From: Ilya Leoshkevich <[email protected]>
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/.
Quoted 8 lines
Suggested-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Ilya Leoshkevich <[email protected]>Message-ID: <[email protected]>
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- {accel/tcg => tcg}/debuginfo.h | 4 ++-- {accel/tcg => tcg}/perf.h | 4 ++--
Headers should be in include/tcg/.
accel/tcg/translate-all.c line 66
Quoted 8 lines
accel/tcg/translate-all.c +1
-1@@ -63,7 +63,7 @@#include "tb-context.h" #include "internal-common.h" #include "internal-target.h" -#include "perf.h" +#include "tcg/perf.h"
Since it is used from accel/tcg/,
hw/core/loader.c line 65
Quoted 13 lines
accel/tcg/translate-all.c +0
-0#include "tcg/insn-start-words.h" TBContext tb_ctx;hw/core/loader.c +1
-1@@ -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"
... and hw/core/.
Otherwise,
r~
Quoted 46 lines · Richard Henderson
Quoted 7 lines · Philippe Mathieu-Daudé
From: Ilya Leoshkevich <[email protected]>
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/.
Quoted 8 lines
Suggested-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Ilya Leoshkevich <[email protected]>Message-ID: <[email protected]>
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
{accel/tcg =>tcg}/debuginfo.h| 4 ++--
{accel/tcg => tcg}/perf.h | 4 ++--Headers should be in
include/tcg/.accel/tcg/translate-all.c line 66
Quoted 8 lines
accel/tcg/translate-all.c +1
-1@@ -63,7 +63,7 @@ #include "tb-context.h" #include "internal-common.h" #include "internal-target.h" -#include "perf.h" +#include "tcg/perf.h" Since it is used from accel/tcg/,
hw/core/loader.c line 65
Quoted 13 lines
accel/tcg/translate-all.c +0
-0#include "tcg/insn-start-words.h"
TBContexttb_ctx;hw/core/loader.c +1
-1@@ -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" ... and hw/core/.
Quoted 4 lines
Otherwise,
Reviewed-by Richard Henderson <[email protected]>r~
Can it be that this is the rebased v3?
v4 seems to have these issues fixed:
Quoted 50 lines · Ilya Leoshkevich
Quoted 49 lines · Richard Henderson
Quoted 7 lines · Philippe Mathieu-Daudé
From: Ilya Leoshkevich <[email protected]>
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/.
Quoted 8 lines
Suggested-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Ilya Leoshkevich <[email protected]>Message-ID: <[email protected]>
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- {accel/tcg => tcg}/debuginfo.h | 4 ++-- {accel/tcg => tcg}/perf.h | 4 ++--Headers should be in
include/tcg/.accel/tcg/translate-all.c line 66
Quoted 8 lines
accel/tcg/translate-all.c +1
-1@@ -63,7 +63,7 @@ #include "tb-context.h" #include "internal-common.h" #include "internal-target.h" -#include "perf.h" +#include "tcg/perf.h" Since it is used from accel/tcg/,
hw/core/loader.c line 65
Quoted 13 lines
accel/tcg/translate-all.c +0
-0#include "tcg/insn-start-words.h" TBContext tb_ctx;hw/core/loader.c +1
-1@@ -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" ... and hw/core/.
Otherwise,
Reviewed-by Richard Henderson <[email protected]>
Quoted 6 lines
Quoted 1 line
r~
Can it be that this is the rebased v3?
v4 seems to have these issues fixed:
Indeed 🤦♂️ v6 on the way...