Final bits for 9.1-rc0 (docker, plugins, gdbstub, semihosting)
Subsystems (2)
cover Final bits for 9.1-rc0 (docker, plugins, gdbstub, semihosting)
I'm just flushing my various maintainer queues for the up-coming 9.1 soft freeze. Mostly this is a collection of fixes and tweaks although there is a new plugin in contrib. We've also bumped the libvirt-ci for the BSD python updates.
The following still need review:
tests/plugins: use qemu_plugin_outs for inline stats
testing: bump to latest libvirt-ci
Alex Bennée (3):
testing: bump to latest libvirt-ci
gdbstub: Re-factor gdb command extensions tests/plugins: use qemu_plugin_outs for inline stats
Frédéric Pétrot (1):
plugins/execlog.c: correct dump of registers values
Philippe Mathieu-Daudé (8):
semihosting: Include missing 'gdbstub/syscalls.h' header target/m68k: Add semihosting stub
target/mips: Add semihosting stub
target/m68k: Restrict semihosting to TCG target/mips: Restrict semihosting to TCG target/riscv: Restrict semihosting to TCG target/xtensa: Restrict semihosting to TCG
semihosting: Restrict to TCG
Pierrick Bouvier (1):
plugins: fix mem callback array size
Simon Hamelin (1):
plugins/stoptrigger: TCG plugin to stop execution under conditions
Thomas Huth (1):
tests/avocado: Remove non-working sparc leon3 test
MAINTAINERS | 1 - docs/devel/tcg-plugins.rst | 22 ++++ include/gdbstub/commands.h | 19 ++- include/semihosting/syscalls.h | 2 + target/arm/internals.h | 4 +- accel/tcg/plugin-gen.c | 3 +- contrib/plugins/execlog.c | 2 +- contrib/plugins/stoptrigger.c | 151 ++++++++++++++++++++++ gdbstub/gdbstub.c | 142 +++++++++++--------- target/arm/gdbstub.c | 16 +-- target/arm/gdbstub64.c | 11 +- target/m68k/semihosting-stub.c | 15 +++ target/mips/tcg/sysemu/semihosting-stub.c | 15 +++ tests/plugin/inline.c | 58 +++++---- .gitlab-ci.d/cirrus/freebsd-13.vars | 2 +- contrib/plugins/Makefile | 1 + semihosting/Kconfig | 1 + target/m68k/Kconfig | 2 +- target/m68k/meson.build | 5 +- target/mips/Kconfig | 2 +- target/mips/tcg/sysemu/meson.build | 6 +- target/riscv/Kconfig | 4 +- target/xtensa/Kconfig | 2 +- tests/avocado/machine_sparc_leon3.py | 37 ------ tests/lcitool/libvirt-ci | 2 +- tests/vm/generated/freebsd.json | 14 +- 26 files changed, 370 insertions(+), 169 deletions(-) create mode 100644 contrib/plugins/stoptrigger.c create mode 100644 target/m68k/semihosting-stub.c create mode 100644 target/mips/tcg/sysemu/semihosting-stub.c delete mode 100644 tests/avocado/machine_sparc_leon3.py
Signature · 1 line
2.39.2
PATCH 1/15 testing: bump to latest libvirt-ci
This brings in the latest python mappings for the BSD updates.
--- .gitlab-ci.d/cirrus/freebsd-13.vars | 2 +- tests/lcitool/libvirt-ci | 2 +- tests/vm/generated/freebsd.json | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-)
.gitlab-ci.d/cirrus/freebsd-13.vars +1 -1
@@ -11,6 +11,6 @@ MAKE='/usr/local/bin/gmake' NINJA='/usr/local/bin/ninja' PACKAGING_COMMAND='pkg' PIP3='/usr/local/bin/pip-3.8' -PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache cmocka ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson mtools ncurses nettle ninja opencv pixman pkgconf png py39-numpy py39-pillow py39-pip py39-sphinx py39-sphinx_rtd_theme py39-tomli py39-yaml python3 rpm2cpio sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir virglrenderer vte3 xorriso zstd' +PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache cmocka ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson mtools ncurses nettle ninja opencv pixman pkgconf png py311-numpy py311-pillow py311-pip py311-sphinx py311-sphinx_rtd_theme py311-tomli py311-yaml python3 rpm2cpio sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir virglrenderer vte3 xorriso zstd' PYPI_PKGS='' PYTHON='/usr/local/bin/python3'
tests/lcitool/libvirt-ci +1 -1
@@ -1 +1 @@ -Subproject commit 0e9490cebc726ef772b6c9e27dac32e7ae99f9b2 +Subproject commit 789b4601bce4e01f43fdb6ad4ce5ab4e46674440
tests/vm/generated/freebsd.json +7 -7
@@ -51,13 +51,13 @@ "pixman", "pkgconf", "png", - "py39-numpy", - "py39-pillow", - "py39-pip", - "py39-sphinx", - "py39-sphinx_rtd_theme", - "py39-tomli", - "py39-yaml", + "py311-numpy", + "py311-pillow", + "py311-pip", + "py311-sphinx", + "py311-sphinx_rtd_theme", + "py311-tomli", + "py311-yaml", "python3", "rpm2cpio", "sdl2",
Signature · 1 line
2.39.2
Re: [PATCH 01/15] testing: bump to latest libvirt-ci
Quoted 8 lines · Alex Bennée
This brings in the latest python mappings for the BSD updates.
Signed-off-by Alex Bennée <[email protected]>--- .gitlab-ci.d/cirrus/freebsd-13.vars | 2 +- tests/lcitool/libvirt-ci | 2 +- tests/vm/generated/freebsd.json | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-)
PATCH 2/15 tests/avocado: Remove non-working sparc leon3 test
In reply to Alex BennéeFrom: Thomas Huth <[email protected]>
The test has been marked as broken more than 4 years ago, and so far nobody ever cared to fix it. Thus let's simply remove it now ... if somebody ever needs it again, they can restore the file from an older version of QEMU.
Message-Id: <[email protected]>
--- MAINTAINERS | 1 - tests/avocado/machine_sparc_leon3.py | 37 ---------------------------- 2 files changed, 38 deletions(-) delete mode 100644 tests/avocado/machine_sparc_leon3.py
MAINTAINERS +0 -1
@@ -1727,7 +1727,6 @@ S: Maintained F: hw/sparc/leon3.c F: hw/*/grlib* F: include/hw/*/grlib* -F: tests/avocado/machine_sparc_leon3.py S390 Machines -------------
tests/avocado/machine_sparc_leon3.py deleted +0 -37
@@ -1,37 +0,0 @@ -# Functional test that boots a Leon3 machine and checks its serial console. -# -# Copyright (c) Philippe Mathieu-Daudé <[email protected]> -# -# This work is licensed under the terms of the GNU GPL, version 2 or -# later. See the COPYING file in the top-level directory. - -from avocado_qemu import QemuSystemTest -from avocado_qemu import wait_for_console_pattern -from avocado import skip - - -class Leon3Machine(QemuSystemTest): - - timeout = 60 - - @skip("Test currently broken") - # A Window Underflow exception occurs before booting the kernel, - # and QEMU exit calling cpu_abort(), which makes this test to fail. - def test_leon3_helenos_uimage(self): - """ - :avocado: tags=arch:sparc - :avocado: tags=machine:leon3_generic - :avocado: tags=binfmt:uimage - """ - kernel_url = ('http://www.helenos.org/releases/' - 'HelenOS-0.6.0-sparc32-leon3.bin') - kernel_hash = 'a88c9cfdb8430c66650e5290a08765f9bf049a30' - kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) - - self.vm.set_console() - self.vm.add_args('-kernel', kernel_path) - - self.vm.launch() - - wait_for_console_pattern(self, 'Copyright (c) 2001-2014 HelenOS project') - wait_for_console_pattern(self, 'Booting the kernel ...')
Signature · 1 line
2.39.2
PATCH 3/15 gdbstub: Re-factor gdb command extensions
In reply to Alex BennéeCoverity reported a memory leak (CID 1549757) in this code and its admittedly rather clumsy handling of extending the command table. Instead of handing over a full array of the commands lets use the lighter weight GPtrArray and simply test for the presence of each entry as we go. This avoids complications of transferring ownership of arrays and keeps the final command entries as static entries in the target code.
---
v2
- don't use strrstr, instead maintain a strv array
- process the array later when building the query response
- shorten names to hit line length limit
--- include/gdbstub/commands.h | 19 +++-- target/arm/internals.h | 4 +- gdbstub/gdbstub.c | 142 +++++++++++++++++++++---------------- target/arm/gdbstub.c | 16 ++--- target/arm/gdbstub64.c | 11 ++- 5 files changed, 106 insertions(+), 86 deletions(-)
include/gdbstub/commands.h +12 -7
@@ -74,23 +74,28 @@ int gdb_put_packet(const char *buf);/** * gdb_extend_query_table() - Extend query table. -* @table: The table with the additional query packet handlers. -* @size: The number of handlers to be added. +* @table: GPtrArray of GdbCmdParseEntry entries. +* +* The caller should free @table afterwards */ -void gdb_extend_query_table (GdbCmdParseEntry *table,int size); +void gdb_extend_query_table (GPtrArray *table);/** * gdb_extend_set_table() - Extend set table. -* @table: The table with the additional set packet handlers. -* @size: The number of handlers to be added. +* @table: GPtrArray of GdbCmdParseEntry entries. +* +* The caller should free @table afterwards */ -void gdb_extend_set_table (GdbCmdParseEntry *table,int size); +void gdb_extend_set_table (GPtrArray *table);/** * gdb_extend_qsupported_features() - Extend the qSupported features string. * @qsupported_features: The additional qSupported feature(s) string. The string * should start with a semicolon and, if there are more than one feature, the -* features should be separate by a semiocolon. +* features should be separate by a semicolon. +* +* The caller should free @qsupported_features afterwards if +* dynamically allocated. */ void gdb_extend_qsupported_features (char *qsupported_features);
target/arm/internals.h +2 -2
@@ -359,8 +359,8 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu);void arm_translate_init (void );void arm_cpu_register_gdb_commands (ARMCPU *cpu); -void aarch64_cpu_register_gdb_commands (ARMCPU *cpu,GString *,GArray *, -GArray *); +void aarch64_cpu_register_gdb_commands (ARMCPU *cpu,GString *, +GPtrArray *,GPtrArray *); void arm_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb,
gdbstub/gdbstub.c +82 -60
219 lines not on this page · raw message
target/arm/gdbstub.c +5 -11
@@ -477,11 +477,9 @@ static GDBFeature *arm_gen_dynamic_m_secextreg_feature(CPUState *cs,void arm_cpu_register_gdb_commands (ARMCPU *cpu) { -GArray *query_table = -g_array_new (FALSE, FALSE,sizeof (GdbCmdParseEntry)); -GArray *set_table = -g_array_new (FALSE, FALSE,sizeof (GdbCmdParseEntry)); -GString *qsupported_features =g_string_new (NULL ); +g_autoptr (GPtrArray) query_table =g_ptr_array_new (); +g_autoptr (GPtrArray) set_table =g_ptr_array_new (); +g_autoptr (GString) qsupported_features =g_string_new (NULL );if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {#ifdef TARGET_AARCH64
@@ -492,16 +490,12 @@ void arm_cpu_register_gdb_commands(ARMCPU *cpu)/* Set arch-specific handlers for 'q' commands. */ if (query_table->len) { -gdb_extend_query_table (&g_array_index (query_table, - GdbCmdParseEntry,0 ), - query_table->len); +gdb_extend_query_table (query_table); }/* Set arch-specific handlers for 'Q' commands. */ if (set_table->len) { -gdb_extend_set_table (&g_array_index (set_table, - GdbCmdParseEntry,0 ), - set_table->len); +gdb_extend_set_table (set_table); }/* Set arch-specific qSupported feature. */
target/arm/gdbstub64.c +5 -6
@@ -564,7 +564,7 @@ enum Command {NUM_CMDS }; -static GdbCmdParseEntry cmd_handler_table[NUM_CMDS ] = { +static const GdbCmdParseEntry cmd_handler_table[NUM_CMDS ] = { [qMemTags] = { .handler = handle_q_memtag, .cmd_startswith = true,
@@ -590,17 +590,16 @@ static GdbCmdParseEntry cmd_handler_table[NUM_CMDS] = {#endif /* CONFIG_USER_ONLY */ void aarch64_cpu_register_gdb_commands (ARMCPU *cpu,GString *qsupported, -GArray *qtable,GArray *stable) +GPtrArray *qtable,GPtrArray *stable) {#ifdef CONFIG_USER_ONLY /* MTE */ if (cpu_isar_feature (aa64_mte, cpu)) {g_string_append (qsupported,";memory-tagging+" ); -g_array_append_val (qtable, cmd_handler_table[qMemTags]); -g_array_append_val (qtable, cmd_handler_table[qIsAddressTagged]); - -g_array_append_val (stable, cmd_handler_table[QMemTags]); +g_ptr_array_add (qtable, (gpointer) &cmd_handler_table[qMemTags]); +g_ptr_array_add (qtable, (gpointer) &cmd_handler_table[qIsAddressTagged]); +g_ptr_array_add (stable, (gpointer) &cmd_handler_table[QMemTags]); }#endif }
Signature · 1 line
2.39.2
PATCH 4/15 plugins/stoptrigger: TCG plugin to stop execution under conditions
In reply to Alex BennéeFrom: Simon Hamelin <[email protected]>
This new plugin allows to stop emulation using conditions on the emulation state. By setting this plugin arguments, it is possible to set an instruction count limit and/or trigger address(es) to stop at. The code returned at emulation exit can be customized.
This plugin demonstrates how someone could stop QEMU execution. It could be used for research purposes to launch some code and deterministically stop it and understand where its execution flow went.
Message-Id: <[email protected]>
--- docs/devel/tcg-plugins.rst | 22 +++++ contrib/plugins/stoptrigger.c | 151 ++++++++++++++++++++++++++++++++++ contrib/plugins/Makefile | 1 + 3 files changed, 174 insertions(+) create mode 100644 contrib/plugins/stoptrigger.c
docs/devel/tcg-plugins.rst +22 -0
@@ -642,6 +642,28 @@ The plugin has a number of arguments, all of them are optional: configuration arguments implies ``l2=on``. (default: N = 2097152 (2MB), B = 64, A = 16) +- contrib/plugins/stoptrigger.c + +The stoptrigger plugin allows to setup triggers to stop emulation. +It can be used for research purposes to launch some code and precisely stop it +and understand where its execution flow went. + +Two types of triggers can be configured: a count of instructions to stop at, +or an address to stop at. Multiple triggers can be set at once. + +By default, QEMU will exit with return code 0. A custom return code can be +configured for each trigger using ``:CODE`` syntax. + +For example, to stop at the 20-th instruction with return code 41, at address +0xd4 with return code 0 or at address 0xd8 with return code 42:: + + $ qemu-system-aarch64 $(QEMU_ARGS) \ + -plugin ./contrib/plugins/libstoptrigger.so,icount=20:41,addr=0xd4,addr=0xd8:42 -d plugin + +The plugin will log the reason of exit, for example:: + + 0xd4 reached, exiting + Plugin API ==========
contrib/plugins/stoptrigger.c new file +151 -0
151 lines not on this page · raw message
contrib/plugins/Makefile +1 -0
@@ -28,6 +28,7 @@ NAMES += hwprofile NAMES += cache NAMES += drcov NAMES += ips +NAMES += stoptrigger ifeq ($(CONFIG_WIN32),y) SO_SUFFIX := .dll
Signature · 1 line
2.39.2
PATCH 5/15 plugins: fix mem callback array size
In reply to Alex BennéeFrom: Pierrick Bouvier <[email protected]>
data was correctly copied, but size of array was not set (g_array_sized_new only reserves memory, but does not set size).
As a result, callbacks were not called for code path relying on plugin_register_vcpu_mem_cb().
Found when trying to trigger mem access callbacks for atomic instructions.
Message-Id: <[email protected]>
--- accel/tcg/plugin-gen.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
accel/tcg/plugin-gen.c +1 -2
@@ -85,8 +85,7 @@ static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, len = insn->mem_cbs->len; arr =g_array_sized_new (false, false,sizeof (struct qemu_plugin_dyn_cb ), len); -memcpy (arr->data, insn->mem_cbs->data, - len *sizeof (struct qemu_plugin_dyn_cb )); +g_array_append_vals (arr, insn->mem_cbs->data, len);qemu_plugin_add_dyn_cb_arr (arr); tcg_gen_st_ptr(tcg_constant_ptr((intptr_t)arr), tcg_env,
Signature · 1 line
2.39.2
PATCH 6/15 tests/plugins: use qemu_plugin_outs for inline stats
In reply to Alex BennéeUsing bare printf's in plugins is perfectly acceptable but they do rather mess up the output of "make check-tcg". Convert the printfs to use g_string and then output with the plugin output helper which will already be captured to .pout files by the test harness.
--- tests/plugin/inline.c | 58 ++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 25 deletions(-)
tests/plugin/inline.c +33 -25
@@ -71,10 +71,12 @@ static void stats_insn(void)const uint64_t cond_track_left =qemu_plugin_u64_sum (insn_cond_track_count);const uint64_t conditional = cond_num_trigger * cond_trigger_limit + cond_track_left; -printf ("insn: %" PRIu64"\n" , expected); -printf ("insn: %" PRIu64" (per vcpu)\n" , per_vcpu); -printf ("insn: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); -printf ("insn: %" PRIu64" (cond cb)\n" , conditional); +g_autoptr (GString) stats =g_string_new ("" ); +g_string_append_printf (stats,"insn: %" PRIu64"\n" , expected); +g_string_append_printf (stats,"insn: %" PRIu64" (per vcpu)\n" , per_vcpu); +g_string_append_printf (stats,"insn: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); +g_string_append_printf (stats,"insn: %" PRIu64" (cond cb)\n" , conditional); +qemu_plugin_outs (stats->str);g_assert (expected >0 );g_assert (per_vcpu == expected);g_assert (inl_per_vcpu == expected);
@@ -91,10 +93,12 @@ static void stats_tb(void)const uint64_t cond_track_left =qemu_plugin_u64_sum (tb_cond_track_count);const uint64_t conditional = cond_num_trigger * cond_trigger_limit + cond_track_left; -printf ("tb: %" PRIu64"\n" , expected); -printf ("tb: %" PRIu64" (per vcpu)\n" , per_vcpu); -printf ("tb: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); -printf ("tb: %" PRIu64" (conditional cb)\n" , conditional); +g_autoptr (GString) stats =g_string_new ("" ); +g_string_append_printf (stats,"tb: %" PRIu64"\n" , expected); +g_string_append_printf (stats,"tb: %" PRIu64" (per vcpu)\n" , per_vcpu); +g_string_append_printf (stats,"tb: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); +g_string_append_printf (stats,"tb: %" PRIu64" (conditional cb)\n" , conditional); +qemu_plugin_outs (stats->str);g_assert (expected >0 );g_assert (per_vcpu == expected);g_assert (inl_per_vcpu == expected);
@@ -107,9 +111,11 @@ static void stats_mem(void)const uint64_t per_vcpu =qemu_plugin_u64_sum (count_mem);const uint64_t inl_per_vcpu =qemu_plugin_u64_sum (count_mem_inline); -printf ("mem: %" PRIu64"\n" , expected); -printf ("mem: %" PRIu64" (per vcpu)\n" , per_vcpu); -printf ("mem: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); +g_autoptr (GString) stats =g_string_new ("" ); +g_string_append_printf (stats,"mem: %" PRIu64"\n" , expected); +g_string_append_printf (stats,"mem: %" PRIu64" (per vcpu)\n" , per_vcpu); +g_string_append_printf (stats,"mem: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); +qemu_plugin_outs (stats->str);g_assert (expected >0 );g_assert (per_vcpu == expected);g_assert (inl_per_vcpu == expected);
@@ -118,6 +124,7 @@ static void stats_mem(void)static void plugin_exit (qemu_plugin_id_t id,void *udata) {const unsigned int num_cpus =qemu_plugin_num_vcpus (); +g_autoptr (GString) stats =g_string_new ("" );g_assert (num_cpus == max_cpu_index +1 );for (int i =0 ; i < num_cpus ; ++i) {
@@ -135,20 +142,21 @@ static void plugin_exit(qemu_plugin_id_t id, void *udata)qemu_plugin_u64_get (insn_cond_num_trigger, i);const uint64_t insn_cond_left =qemu_plugin_u64_get (insn_cond_track_count, i); -printf ("cpu %d: tb (%" PRIu64", %" PRIu64 -", %" PRIu64" * %" PRIu64" + %" PRIu64 -") | " -"insn (%" PRIu64", %" PRIu64 -", %" PRIu64" * %" PRIu64" + %" PRIu64 -") | " -"mem (%" PRIu64", %" PRIu64")" -"\n" , - i, - tb, tb_inline, - tb_cond_trigger, cond_trigger_limit, tb_cond_left, - insn, insn_inline, - insn_cond_trigger, cond_trigger_limit, insn_cond_left, - mem, mem_inline); +g_string_printf (stats,"cpu %d: tb (%" PRIu64", %" PRIu64 +", %" PRIu64" * %" PRIu64" + %" PRIu64 +") | " +"insn (%" PRIu64", %" PRIu64 +", %" PRIu64" * %" PRIu64" + %" PRIu64 +") | " +"mem (%" PRIu64", %" PRIu64")" +"\n" , + i, + tb, tb_inline, + tb_cond_trigger, cond_trigger_limit, tb_cond_left, + insn, insn_inline, + insn_cond_trigger, cond_trigger_limit, insn_cond_left, + mem, mem_inline); +qemu_plugin_outs (stats->str);g_assert (tb == tb_inline);g_assert (insn == insn_inline);g_assert (mem == mem_inline);
Signature · 1 line
2.39.2
Re: [PATCH 06/15] tests/plugins: use qemu_plugin_outs for inline stats
Quoted 9 lines · Alex Bennée
Using bare printf's in plugins is perfectly acceptable but they do rather mess up the output of "make check-tcg". Convert the printfs to use
g_stringand then output with the plugin output helper which will already be captured to .pout files by the test harness.Signed-off-by Alex Bennée <[email protected]>--- tests/plugin/inline.c | 58 ++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 25 deletions(-)
Re: [PATCH 06/15] tests/plugins: use qemu_plugin_outs for inline stats
In reply to Alex BennéeQuoted 97 lines · Alex Bennée
Using bare printf's in plugins is perfectly acceptable but they do rather mess up the output of "make check-tcg". Convert the printfs to use
g_stringand then output with the plugin output helper which will already be captured to .pout files by the test harness.Signed-off-by Alex Bennée <[email protected]>--- tests/plugin/inline.c | 58 ++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 25 deletions(-)tests/plugin/inline.c +26
-25@@ -71,10 +71,12 @@ static void stats_insn(void)const uint64_t cond_track_left =qemu_plugin_u64_sum (insn_cond_track_count);const uint64_t conditional = cond_num_trigger * cond_trigger_limit + cond_track_left; -printf ("insn: %" PRIu64"\n" , expected); -printf ("insn: %" PRIu64" (per vcpu)\n" , per_vcpu); -printf ("insn: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); -printf ("insn: %" PRIu64" (cond cb)\n" , conditional); +g_autoptr (GString) stats =g_string_new ("" ); +g_string_append_printf (stats,"insn: %" PRIu64"\n" , expected); +g_string_append_printf (stats,"insn: %" PRIu64" (per vcpu)\n" , per_vcpu); +g_string_append_printf (stats,"insn: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); +g_string_append_printf (stats,"insn: %" PRIu64" (cond cb)\n" , conditional); +qemu_plugin_outs (stats->str);g_assert (expected >0 );g_assert (per_vcpu == expected);g_assert (inl_per_vcpu == expected);@@ -91,10 +93,12 @@ static void stats_tb(void)const uint64_t cond_track_left =qemu_plugin_u64_sum (tb_cond_track_count);const uint64_t conditional = cond_num_trigger * cond_trigger_limit + cond_track_left; -printf ("tb: %" PRIu64"\n" , expected); -printf ("tb: %" PRIu64" (per vcpu)\n" , per_vcpu); -printf ("tb: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); -printf ("tb: %" PRIu64" (conditional cb)\n" , conditional); +g_autoptr (GString) stats =g_string_new ("" ); +g_string_append_printf (stats,"tb: %" PRIu64"\n" , expected); +g_string_append_printf (stats,"tb: %" PRIu64" (per vcpu)\n" , per_vcpu); +g_string_append_printf (stats,"tb: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); +g_string_append_printf (stats,"tb: %" PRIu64" (conditional cb)\n" , conditional); +qemu_plugin_outs (stats->str);g_assert (expected >0 );g_assert (per_vcpu == expected);g_assert (inl_per_vcpu == expected);@@ -107,9 +111,11 @@ static void stats_mem(void)const uint64_t per_vcpu =qemu_plugin_u64_sum (count_mem);const uint64_t inl_per_vcpu =qemu_plugin_u64_sum (count_mem_inline); -printf ("mem: %" PRIu64"\n" , expected); -printf ("mem: %" PRIu64" (per vcpu)\n" , per_vcpu); -printf ("mem: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); +g_autoptr (GString) stats =g_string_new ("" ); +g_string_append_printf (stats,"mem: %" PRIu64"\n" , expected); +g_string_append_printf (stats,"mem: %" PRIu64" (per vcpu)\n" , per_vcpu); +g_string_append_printf (stats,"mem: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); +qemu_plugin_outs (stats->str);g_assert (expected >0 );g_assert (per_vcpu == expected);g_assert (inl_per_vcpu == expected);@@ -118,6 +124,7 @@ static void stats_mem(void)static void plugin_exit (qemu_plugin_id_t id,void *udata) {const unsigned int num_cpus =qemu_plugin_num_vcpus (); +g_autoptr (GString) stats =g_string_new ("" );g_assert (num_cpus == max_cpu_index +1 );for (int i =0 ; i < num_cpus ; ++i) {@@ -135,20 +142,21 @@ static void plugin_exit(qemu_plugin_id_t id, void *udata)qemu_plugin_u64_get (insn_cond_num_trigger, i);const uint64_t insn_cond_left =qemu_plugin_u64_get (insn_cond_track_count, i); -printf ("cpu %d: tb (%" PRIu64", %" PRIu64 -", %" PRIu64" * %" PRIu64" + %" PRIu64 -") | " -"insn (%" PRIu64", %" PRIu64 -", %" PRIu64" * %" PRIu64" + %" PRIu64 -") | " -"mem (%" PRIu64", %" PRIu64")" -"\n" , - i, - tb, tb_inline, - tb_cond_trigger, cond_trigger_limit, tb_cond_left, - insn, insn_inline, - insn_cond_trigger, cond_trigger_limit, insn_cond_left, - mem, mem_inline); + g_string_printf(stats, "cpu %d: tb (%" PRIu64 ", %" PRIu64 + ", %" PRIu64 " * %" PRIu64 " + %" PRIu64 + ") | " + "insn (%" PRIu64 ", %" PRIu64 + ", %" PRIu64 " * %" PRIu64 " + %" PRIu64 + ") | " + "mem (%" PRIu64 ", %" PRIu64 ")" + "\n",
tests/plugin/inline.c static void plugin_exit(qemu_plugin_id_t id, void *udata) · line 162
Quoted 10 lines
tests/plugin/inline.c +7
-0+ i, + tb, tb_inline, + tb_cond_trigger, cond_trigger_limit, tb_cond_left, + insn, insn_inline, + insn_cond_trigger, cond_trigger_limit, insn_cond_left, + mem, mem_inline); +qemu_plugin_outs (stats->str);g_assert (tb == tb_inline);g_assert (insn == insn_inline);g_assert (mem == mem_inline);
PATCH 7/15 plugins/execlog.c: correct dump of registers values
In reply to Alex BennéeFrom: Frédéric Pétrot <[email protected]>
Register values are dumped as 'sz' chunks of two nibbles in the execlog plugin, sz was 1 too big.
Message-Id: <[email protected]>
--- contrib/plugins/execlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/plugins/execlog.c +1 -1
@@ -101,7 +101,7 @@ static void insn_check_regs(CPU *cpu)GByteArray *temp = reg->last;g_string_append_printf (cpu->last_exec,", %s -> 0x" , reg->name);/* TODO: handle BE properly */ -for (int i = sz; i >=0 ; i--) { +for (int i = sz -1 ; i >=0 ; i--) {g_string_append_printf (cpu->last_exec,"%02x" , reg->new->data[i]); }
Signature · 1 line
2.39.2
PATCH 8/15 semihosting: Include missing 'gdbstub/syscalls.h' header
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
"semihosting/syscalls.h" requires definitions from "gdbstub/syscalls.h", include it in order to avoid:
include/semihosting/syscalls.h:23:38: error: unknown type name 'gdb_syscall_complete_cb' void semihost_sys_open(CPUState *cs, gdb_syscall_complete_cb complete,
^
Message-Id: <[email protected]>
--- include/semihosting/syscalls.h | 2 ++ 1 file changed, 2 insertions(+)
include/semihosting/syscalls.h +2 -0
@@ -9,6 +9,8 @@#ifndef SEMIHOSTING_SYSCALLS_H #define SEMIHOSTING_SYSCALLS_H +#include "gdbstub/syscalls.h" +/* * Argument loading from the guest is performed by the caller; * results are returned via the 'complete' callback.
Signature · 1 line
2.39.2
PATCH 9/15 target/m68k: Add semihosting stub
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
Since the SEMIHOSTING feature is optional, we need a stub to link when it is disabled.
Message-Id: <[email protected]>
--- target/m68k/semihosting-stub.c | 15 +++++++++++++++ target/m68k/meson.build | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 target/m68k/semihosting-stub.c
target/m68k/semihosting-stub.c new file +15 -0
@@ -0,0 +1,15 @@ +/* +* m68k/ColdFire semihosting stub +* +* SPDX-FileContributor: Philippe Mathieu-Daudé <[email protected]> +* SPDX-FileCopyrightText: 2024 Linaro Ltd. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "cpu.h" + +void do_m68k_semihosting (CPUM68KState *env,int nr) +{ +g_assert_not_reached (); +}
target/m68k/meson.build +4 -1
@@ -11,9 +11,12 @@ m68k_ss.add(files( m68k_system_ss = ss.source_set() m68k_system_ss.add(files( - 'm68k-semi.c', 'monitor.c' )) +m68k_system_ss.add(when: ['CONFIG_SEMIHOSTING'], + if_true: files('m68k-semi.c'), + if_false: files('semihosting-stub.c') +) target_arch += {'m68k': m68k_ss} target_system_arch += {'m68k': m68k_system_ss}
Signature · 1 line
2.39.2
PATCH 10/15 target/mips: Add semihosting stub
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
Since the SEMIHOSTING feature is optional, we need a stub to link when it is disabled.
Message-Id: <[email protected]>
--- target/mips/tcg/sysemu/semihosting-stub.c | 15 +++++++++++++++ target/mips/tcg/sysemu/meson.build | 6 ++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 target/mips/tcg/sysemu/semihosting-stub.c
target/mips/tcg/sysemu/semihosting-stub.c new file +15 -0
@@ -0,0 +1,15 @@ +/* +* MIPS semihosting stub +* +* SPDX-FileContributor: Philippe Mathieu-Daudé <[email protected]> +* SPDX-FileCopyrightText: 2024 Linaro Ltd. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "internal.h" + +void mips_semihosting (CPUMIPSState *env) +{ +g_assert_not_reached (); +}
target/mips/tcg/sysemu/meson.build +4 -2
@@ -1,10 +1,12 @@ mips_system_ss.add(files( 'cp0_helper.c', - 'mips-semi.c', 'special_helper.c', 'tlb_helper.c', )) - +mips_system_ss.add(when: ['CONFIG_SEMIHOSTING'], + if_true: files('mips-semi.c'), + if_false: files('semihosting-stub.c') +) mips_system_ss.add(when: 'TARGET_MIPS64', if_true: files( 'lcsr_helper.c', ))
Signature · 1 line
2.39.2
PATCH 11/15 target/m68k: Restrict semihosting to TCG
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
The semihosting feature depends on TCG (due to the probe_access API access). Although TCG is the single accelerator currently available for the m68k target, use the Kconfig "imply" directive which is more correct (if we were to support a different accel).
Message-Id: <[email protected]>
--- target/m68k/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/m68k/Kconfig +1 -1
@@ -1,3 +1,3 @@ config M68K bool - select SEMIHOSTING + imply SEMIHOSTING if TCG
Signature · 1 line
2.39.2
PATCH 12/15 target/mips: Restrict semihosting to TCG
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
Semihosting currently uses the TCG probe_access API. To prepare for encoding the TCG dependency in Kconfig, do not enable it unless TCG is available.
Message-Id: <[email protected]>
--- target/mips/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/Kconfig +1 -1
@@ -1,6 +1,6 @@ config MIPS bool - select SEMIHOSTING + imply SEMIHOSTING if TCG config MIPS64 bool
Signature · 1 line
2.39.2
PATCH 13/15 target/riscv: Restrict semihosting to TCG
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
Semihosting currently uses the TCG probe_access API. To prepare for encoding the TCG dependency in Kconfig, do not enable it unless TCG is available.
Message-Id: <[email protected]>
--- target/riscv/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/riscv/Kconfig +2 -2
@@ -1,9 +1,9 @@ config RISCV32 bool - select ARM_COMPATIBLE_SEMIHOSTING # for do_common_semihosting() + imply ARM_COMPATIBLE_SEMIHOSTING if TCG select DEVICE_TREE # needed by boot.c config RISCV64 bool - select ARM_COMPATIBLE_SEMIHOSTING # for do_common_semihosting() + imply ARM_COMPATIBLE_SEMIHOSTING if TCG select DEVICE_TREE # needed by boot.c
Signature · 1 line
2.39.2
PATCH 14/15 target/xtensa: Restrict semihosting to TCG
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
The semihosting feature depends on TCG (due to the probe_access API access). Although TCG is the single accelerator currently available for the xtensa target, use the Kconfig "imply" directive which is more correct (if we were to support a different accel).
Message-Id: <[email protected]>
--- target/xtensa/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/xtensa/Kconfig +1 -1
@@ -1,3 +1,3 @@ config XTENSA bool - select SEMIHOSTING + imply SEMIHOSTING if TCG
Signature · 1 line
2.39.2
PATCH 15/15 semihosting: Restrict to TCG
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
Semihosting currently uses the TCG probe_access API. It is pointless to have it in the binary when TCG isn't.
Message-Id: <[email protected]>
--- semihosting/Kconfig | 1 + 1 file changed, 1 insertion(+)
semihosting/Kconfig +1 -0
@@ -1,6 +1,7 @@ config SEMIHOSTING bool + depends on TCG config ARM_COMPATIBLE_SEMIHOSTING bool
Signature · 1 line
2.39.2