maintainer updates (tests, gdbstub, plugins)
Subsystems (2)
The following changes since commit db596ae19040574e41d086e78469014191d7d7fc:
Merge tag 'pull-target-arm-20240305' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2024-03-05 13:54:54 +0000)
are available in the Git repository at:
https://gitlab.com/stsquad/qemu.git tags/pull-maintainer-updates-060324-1
for you to fetch changes up to db7e8b1f75662cf957f6bfad938ed112488518ed:
target/riscv: honour show_opcodes when disassembling (2024-03-06 12:35:51 +0000)
----------------------------------------------------------------
maintainer updates (tests, gdbstub, plugins):
- expand QOS_PATH_MAX_ELEMENT_SIZE to avoid LTO issues
- support fork-follow-mode in gdbstub
- new thread-safe scoreboard API for TCG plugins
- suppress showing opcodes in plugin disassembly
----------------------------------------------------------------
Alex Bennée (5):
tests: bump QOS_PATH_MAX_ELEMENT_SIZE again
disas: introduce show_opcodes
disas/hppa: honour show_opcodes target/loongarch: honour show_opcodes when disassembling target/riscv: honour show_opcodes when disassembling
Ilya Leoshkevich (12):
gdbstub: Support disablement in a multi-threaded process {linux,bsd}-user: Introduce get_task_state() {linux,bsd}-user: Update ts_tid after fork()
gdbstub: Introduce gdbserver_fork_start() {linux,bsd}-user: Pass pid to fork_end() {linux,bsd}-user: Pass pid to gdbserver_fork()
gdbstub: Call gdbserver_fork() both in parent and in child
gdbstub: Introduce gdb_handle_query_supported_user()
gdbstub: Introduce gdb_handle_set_thread_user()
gdbstub: Introduce gdb_handle_detach_user()
gdbstub: Implement follow-fork-mode child tests/tcg: Add two follow-fork-mode tests
Pierrick Bouvier (12):
plugins: scoreboard API
plugins: define qemu_plugin_u64
plugins: implement inline operation relative to cpu_index
plugins: add inline operation per vcpu tests/plugin: add test plugin for inline operations tests/plugin/mem: migrate to new per_vcpu API tests/plugin/insn: migrate to new per_vcpu API tests/plugin/bb: migrate to new per_vcpu API contrib/plugins/hotblocks: migrate to new per_vcpu API contrib/plugins/howvec: migrate to new per_vcpu API
plugins: remove non per_vcpu inline operation from API
plugins: cleanup codepath for previous inline operation
bsd-user/bsd-file.h | 2 +- bsd-user/freebsd/os-proc.h | 6 +- bsd-user/qemu.h | 7 +- gdbstub/internals.h | 3 + include/disas/dis-asm.h | 8 + include/gdbstub/user.h | 10 +- include/qemu/plugin.h | 7 + include/qemu/qemu-plugin.h | 142 +++++++++--- include/user/safe-syscall.h | 2 +- linux-user/m68k/target_cpu.h | 2 +- linux-user/qemu.h | 5 + linux-user/signal-common.h | 2 +- linux-user/user-internals.h | 2 +- plugins/plugin.h | 17 +- tests/qtest/libqos/qgraph.h | 2 +- accel/tcg/plugin-gen.c | 69 +++++- bsd-user/main.c | 9 +- bsd-user/signal.c | 20 +- contrib/plugins/hotblocks.c | 50 +++-- contrib/plugins/howvec.c | 53 +++-- disas/disas.c | 1 + disas/hppa.c | 8 +- disas/riscv.c | 28 +-- gdbstub/gdbstub.c | 29 ++- gdbstub/user-target.c | 4 +- gdbstub/user.c | 244 ++++++++++++++++++++- linux-user/aarch64/cpu_loop.c | 2 +- linux-user/arm/cpu_loop.c | 4 +- linux-user/arm/signal.c | 2 +- linux-user/cris/cpu_loop.c | 2 +- linux-user/elfload.c | 2 +- linux-user/hppa/signal.c | 2 +- linux-user/linuxload.c | 2 +- linux-user/m68k/cpu_loop.c | 2 +- linux-user/main.c | 8 +- linux-user/mips/cpu_loop.c | 2 +- linux-user/ppc/signal.c | 4 +- linux-user/riscv/cpu_loop.c | 2 +- linux-user/signal.c | 30 +-- linux-user/syscall.c | 32 +-- linux-user/vm86.c | 18 +- linux-user/xtensa/signal.c | 2 +- plugins/api.c | 100 +++++++-- plugins/core.c | 79 ++++++- semihosting/arm-compat-semi.c | 8 +- target/loongarch/disas.c | 13 +- tests/plugin/bb.c | 63 +++--- tests/plugin/inline.c | 186 ++++++++++++++++ tests/plugin/insn.c | 106 +++++---- tests/plugin/mem.c | 46 ++-- tests/tcg/multiarch/follow-fork-mode.c | 56 +++++ plugins/qemu-plugins.symbols | 13 +- tests/plugin/meson.build | 2 +- tests/tcg/Makefile.target | 2 +- tests/tcg/multiarch/Makefile.target | 17 +- .../multiarch/gdbstub/follow-fork-mode-child.py | 40 ++++ .../multiarch/gdbstub/follow-fork-mode-parent.py | 16 ++ 57 files changed, 1257 insertions(+), 338 deletions(-) create mode 100644 tests/plugin/inline.c create mode 100644 tests/tcg/multiarch/follow-fork-mode.c create mode 100644 tests/tcg/multiarch/gdbstub/follow-fork-mode-child.py create mode 100644 tests/tcg/multiarch/gdbstub/follow-fork-mode-parent.py
Signature · 1 line
2.39.2
[PULL 05/29] gdbstub: Introduce gdbserver_fork_start()
From: Ilya Leoshkevich <[email protected]>
The upcoming follow-fork-mode child support requires knowing when fork() is about to happen in order to initialize its state. Add a hook for that.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
include/gdbstub/user.h +5 -0
@@ -45,6 +45,11 @@ static inline int gdb_handlesig(CPUState *cpu, int sig)*/ void gdb_signalled (CPUArchState *as,int sig); +/** +* gdbserver_fork_start() - inform gdb of the upcoming fork() +*/ +void gdbserver_fork_start (void ); +/** * gdbserver_fork() - disable gdb stub for child processes. * @cs: CPU
bsd-user/main.c +1 -0
@@ -113,6 +113,7 @@ void fork_start(void)start_exclusive ();cpu_list_lock ();mmap_fork_start (); +gdbserver_fork_start (); }void fork_end (int child)
gdbstub/user.c +4 -0
@@ -356,6 +356,10 @@ int gdbserver_start(const char *port_or_path)return -1 ; } +void gdbserver_fork_start (void ) +{ +} +static void disable_gdbstub (CPUState *thread_cpu) {CPUState *cpu;
linux-user/main.c +1 -0
@@ -145,6 +145,7 @@ void fork_start(void)mmap_fork_start ();cpu_list_lock ();qemu_plugin_user_prefork_lock (); +gdbserver_fork_start (); }void fork_end (int child)
Signature · 1 line
2.39.2
[PULL 01/29] tests: bump QOS_PATH_MAX_ELEMENT_SIZE again
In reply to Alex BennéeWe "fixed" a bug with LTO builds with 100c459f194 (tests/qtest: bump up QOS_PATH_MAX_ELEMENT_SIZE) but it seems it has triggered again.
The array is sized according to the maximum anticipated length of a path on the graph. However, the worst case for a depth-first search is to push all nodes on the graph. So it's not really LTO, it depends on the ordering of the constructors.
Lets be more assertive raising QOS_PATH_MAX_ELEMENT_SIZE to make it go away again.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1186 (again)
Message-Id: <[email protected]>
tests/qtest/libqos/qgraph.h +1 -1
@@ -24,7 +24,7 @@#include "libqos-malloc.h" /* maximum path length */ -#define QOS_PATH_MAX_ELEMENT_SIZE 64 +#define QOS_PATH_MAX_ELEMENT_SIZE 128typedef struct QOSGraphObject QOSGraphObject ;typedef struct QOSGraphNode QOSGraphNode ;
Signature · 1 line
2.39.2
[PULL 13/29] tests/tcg: Add two follow-fork-mode tests
In reply to Alex BennéeFrom: Ilya Leoshkevich <[email protected]>
Add follow-fork-mode child and and follow-fork-mode parent tests. Check for the obvious pitfalls, such as lingering breakpoints, catchpoints, and single-step mode.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
tests/tcg/multiarch/follow-fork-mode.c new file +56 -0
@@ -0,0 +1,56 @@ +/* +* Test GDB's follow-fork-mode. +* +* fork() a chain of processes. +* Parents sends one byte to their children, and children return their +* position in the chain, in order to prove that they survived GDB's fork() +* handling. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#include <assert.h> +#include <stdlib.h> +#include <sys/wait.h> +#include <unistd.h> + +void break_after_fork (void ) +{ +} + +int main (void ) +{ +int depth =42 , err, i, fd[2 ], status; +pid_t child, pid; +ssize_t n; +char b; + +for (i =0 ; i < depth; i++) { + err =pipe (fd); +assert (err ==0 ); + child =fork (); +break_after_fork (); +assert (child !=-1 ); +if (child ==0 ) { +close (fd[1 ]); + + n =read (fd[0 ], &b,1 ); +close (fd[0 ]); +assert (n ==1 ); +assert (b == (char )i); + }else { +close (fd[0 ]); + + b = (char )i; + n =write (fd[1 ], &b,1 ); +close (fd[1 ]); +assert (n ==1 ); + + pid =waitpid (child, &status,0 ); +assert (pid == child); +assert (WIFEXITED (status)); +return WEXITSTATUS (status) -1 ; + } + } + +return depth; +}
tests/tcg/multiarch/Makefile.target +16 -1
@@ -106,6 +106,20 @@ run-gdbstub-catch-syscalls: catch-syscalls --bin $< --test $(MULTIARCH_SRC)/gdbstub/catch-syscalls.py, \ hitting a syscall catchpoint) +run-gdbstub-follow-fork-mode-child: follow-fork-mode + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/follow-fork-mode-child.py, \ + following children on fork) + +run-gdbstub-follow-fork-mode-parent: follow-fork-mode + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/follow-fork-mode-parent.py, \ + following parents on fork) + else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb with $(patsubst -%,,$(TARGET_NAME)) support")
@@ -113,7 +127,8 @@ endif EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \ run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \ run-gdbstub-registers run-gdbstub-prot-none \ - run-gdbstub-catch-syscalls + run-gdbstub-catch-syscalls run-gdbstub-follow-fork-mode-child \ + run-gdbstub-follow-fork-mode-parent # ARM Compatible Semi Hosting Tests #
tests/tcg/multiarch/gdbstub/follow-fork-mode-child.py new file +40 -0
@@ -0,0 +1,40 @@ +"""Test GDB's follow-fork-mode child. + +SPDX-License-Identifier: GPL-2.0-or-later +""" +from test_gdbstub import main, report + + +def run_test(): + """Run through the tests one by one""" + gdb.execute("set follow-fork-mode child") + # Check that the parent breakpoints are unset. + gdb.execute("break break_after_fork") + # Check that the parent syscall catchpoints are unset. + # Skip this check on the architectures that don't have them. + have_fork_syscall = False + for fork_syscall in ("fork", "clone", "clone2", "clone3"): + try: + gdb.execute("catch syscall {}".format(fork_syscall)) + except gdb.error: + pass + else: + have_fork_syscall = True + gdb.execute("continue") + for i in range(42): + if have_fork_syscall: + # syscall entry. + if i % 2 == 0: + # Check that the parent single-stepping is turned off. + gdb.execute("si") + else: + gdb.execute("continue") + # syscall exit. + gdb.execute("continue") + # break_after_fork() + gdb.execute("continue") + exitcode = int(gdb.parse_and_eval("$_exitcode")) + report(exitcode == 42, "{} == 42".format(exitcode)) + + +main(run_test)
tests/tcg/multiarch/gdbstub/follow-fork-mode-parent.py new file +16 -0
@@ -0,0 +1,16 @@ +"""Test GDB's follow-fork-mode parent. + +SPDX-License-Identifier: GPL-2.0-or-later +""" +from test_gdbstub import main, report + + +def run_test(): + """Run through the tests one by one""" + gdb.execute("set follow-fork-mode parent") + gdb.execute("continue") + exitcode = int(gdb.parse_and_eval("$_exitcode")) + report(exitcode == 0, "{} == 0".format(exitcode)) + + +main(run_test)
Signature · 1 line
2.39.2
[PULL 11/29] gdbstub: Introduce gdb_handle_detach_user()
In reply to Alex BennéeFrom: Ilya Leoshkevich <[email protected]>
The upcoming follow-fork-mode child support needs to perform certain actions when GDB detaches from the stopped parent or the stopped child. Introduce a user-specific hook for this.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
gdbstub/internals.h +1 -0
@@ -198,6 +198,7 @@ void gdb_handle_query_xfer_exec_file(GArray *params, void *user_ctx); /* user */void gdb_handle_set_catch_syscalls (GArray *params,void *user_ctx);/* user */ void gdb_handle_query_supported_user (const char *gdb_supported);/* user */ bool gdb_handle_set_thread_user (uint32_t pid,uint32_t tid);/* user */ +bool gdb_handle_detach_user (uint32_t pid);/* user */ void gdb_handle_query_attached (GArray *params,void *user_ctx);/* both */
gdbstub/gdbstub.c +6 -0
@@ -1024,6 +1024,12 @@ static void handle_detach(GArray *params, void *user_ctx) pid =get_param (params,0 )->val_ul; } +#ifdef CONFIG_USER_ONLY +if (gdb_handle_detach_user (pid)) { +return ; + } +#endif + process =gdb_get_process (pid);gdb_process_breakpoint_remove_all (process); process->attached = false;
gdbstub/user.c +5 -0
@@ -391,6 +391,11 @@ bool gdb_handle_set_thread_user(uint32_t pid, uint32_t tid)return false; } +bool gdb_handle_detach_user (uint32_t pid) +{ +return false; +} +/* * Execution state helpers */
Signature · 1 line
2.39.2
[PULL 16/29] plugins: implement inline operation relative to cpu_index
In reply to Alex BennéeFrom: Pierrick Bouvier <[email protected]>
Instead of working on a fixed memory location, allow to address it based on cpu_index, an element size and a given offset.
Result address: ptr + offset + cpu_index * element_size.
With this, we can target a member in a struct array from a base pointer.
Current semantic is not modified, thus inline operation still targets always the same memory location.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
plugins/plugin.h +1 -1
@@ -99,7 +99,7 @@ void plugin_register_vcpu_mem_cb(GArray **arr,enum qemu_plugin_mem_rw rw, void *udata); -void exec_inline_op (struct qemu_plugin_dyn_cb *cb); +void exec_inline_op (struct qemu_plugin_dyn_cb *cb,int cpu_index);int plugin_num_vcpus (void );
accel/tcg/plugin-gen.c +56 -13
108 lines not on this page · raw message
plugins/api.c +2 -1
@@ -106,7 +106,8 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, void *ptr, uint64_t imm) {if (!tb->mem_only) { -plugin_register_inline_op (&tb->cbs[PLUGIN_CB_INLINE ],0 , op, ptr, imm); +plugin_register_inline_op (&tb->cbs[PLUGIN_CB_INLINE ], +0 , op, ptr, imm); } }
plugins/core.c +8 -4
@@ -318,7 +318,8 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GArray **arr)void plugin_register_inline_op (GArray **arr,enum qemu_plugin_mem_rw rw, -enum qemu_plugin_op op,void *ptr, +enum qemu_plugin_op op, +void *ptr,uint64_t imm) {struct qemu_plugin_dyn_cb *dyn_cb;
@@ -474,9 +475,12 @@ void qemu_plugin_flush_cb(void)plugin_cb__simple (QEMU_PLUGIN_EV_FLUSH ); } -void exec_inline_op (struct qemu_plugin_dyn_cb *cb) +void exec_inline_op (struct qemu_plugin_dyn_cb *cb,int cpu_index) { -uint64_t *val = cb->userp; +char *ptr = cb->userp; +size_t elem_size =0 ; +size_t offset =0 ; +uint64_t *val = (uint64_t *)(ptr + offset + cpu_index * elem_size);switch (cb->inline_insn.op) {case QEMU_PLUGIN_INLINE_ADD_U64 :
@@ -509,7 +513,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, vaddr, cb->userp);break ;case PLUGIN_CB_INLINE : -exec_inline_op (cb); +exec_inline_op (cb, cpu->cpu_index);break ;default :g_assert_not_reached ();
Signature · 1 line
2.39.2
[PULL 19/29] tests/plugin/mem: migrate to new per_vcpu API
In reply to Alex BennéeFrom: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
Message-Id: <[email protected]>
tests/plugin/mem.c +31 -15
@@ -16,9 +16,14 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; -static uint64_t inline_mem_count; -static uint64_t cb_mem_count; -static uint64_t io_count; +typedef struct { +uint64_t mem_count; +uint64_t io_count; +}CPUCount ; + +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64 mem_count; +static qemu_plugin_u64 io_count;static bool do_inline, do_callback;static bool do_haddr;static enum qemu_plugin_mem_rw rw =QEMU_PLUGIN_MEM_RW ;
@@ -27,16 +32,16 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) {g_autoptr (GString) out =g_string_new ("" ); -if (do_inline) { -g_string_printf (out,"inline mem accesses: %" PRIu64"\n" , inline_mem_count); - } -if (do_callback) { -g_string_append_printf (out,"callback mem accesses: %" PRIu64"\n" , cb_mem_count); +if (do_inline || do_callback) { +g_string_printf (out,"mem accesses: %" PRIu64"\n" , +qemu_plugin_u64_sum (mem_count)); }if (do_haddr) { -g_string_append_printf (out,"io accesses: %" PRIu64"\n" , io_count); +g_string_append_printf (out,"io accesses: %" PRIu64"\n" , +qemu_plugin_u64_sum (io_count)); }qemu_plugin_outs (out->str); +qemu_plugin_scoreboard_free (counts); } static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo,
@@ -46,12 +51,12 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo,struct qemu_plugin_hwaddr *hwaddr; hwaddr =qemu_plugin_get_hwaddr (meminfo, vaddr);if (qemu_plugin_hwaddr_is_io (hwaddr)) { - io_count++; +qemu_plugin_u64_add (io_count, cpu_index,1 ); }else { - cb_mem_count++; +qemu_plugin_u64_add (mem_count, cpu_index,1 ); } }else { - cb_mem_count++; +qemu_plugin_u64_add (mem_count, cpu_index,1 ); } }
@@ -64,9 +69,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)struct qemu_plugin_insn *insn =qemu_plugin_tb_get_insn (tb, i);if (do_inline) { -qemu_plugin_register_vcpu_mem_inline (insn, rw, -QEMU_PLUGIN_INLINE_ADD_U64 , - &inline_mem_count,1 ); +qemu_plugin_register_vcpu_mem_inline_per_vcpu ( + insn, rw, +QEMU_PLUGIN_INLINE_ADD_U64 , + mem_count,1 ); }if (do_callback) { qemu_plugin_register_vcpu_mem_cb(insn, vcpu_mem,
@@ -117,6 +123,16 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, } } +if (do_inline && do_callback) { +fprintf (stderr, +"can't enable inline and callback counting at the same time\n" ); +return -1 ; + } + + counts =qemu_plugin_scoreboard_new (sizeof (CPUCount)); + mem_count =qemu_plugin_scoreboard_u64_in_struct ( + counts, CPUCount, mem_count); + io_count =qemu_plugin_scoreboard_u64_in_struct (counts, CPUCount, io_count);qemu_plugin_register_vcpu_tb_trans_cb (id, vcpu_tb_trans);qemu_plugin_register_atexit_cb (id, plugin_exit,NULL );return 0 ;
tests/tcg/Makefile.target +1 -1
@@ -168,7 +168,7 @@ RUN_TESTS+=$(EXTRA_RUNS) # Some plugins need additional arguments above the default to fully # exercise things. We can define them on a per-test basis here. -run-plugin-%-with-libmem.so: PLUGIN_ARGS=$(COMMA)inline=true$(COMMA)callback=true +run-plugin-%-with-libmem.so: PLUGIN_ARGS=$(COMMA)inline=true ifeq ($(filter %-softmmu, $(TARGET)),) run-%: %
Signature · 1 line
2.39.2
[PULL 23/29] contrib/plugins/howvec: migrate to new per_vcpu API
In reply to Alex BennéeFrom: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
Message-Id: <[email protected]>
contrib/plugins/howvec.c +38 -15
@@ -43,13 +43,13 @@ typedef struct {uint32_t mask;uint32_t pattern;CountType what; -uint64_t count; +qemu_plugin_u64 count; } InsnClassExecCount;typedef struct {char *insn;uint32_t opcode; -uint64_t count; +qemu_plugin_u64 count;InsnClassExecCount *class; }InsnExecCount ;
@@ -159,7 +159,9 @@ static gint cmp_exec_count(gconstpointer a, gconstpointer b) {InsnExecCount *ea = (InsnExecCount *) a;InsnExecCount *eb = (InsnExecCount *) b; -return ea->count > eb->count ?-1 :1 ; +uint64_t count_a =qemu_plugin_u64_sum (ea->count); +uint64_t count_b =qemu_plugin_u64_sum (eb->count); +return count_a > count_b ?-1 :1 ; }static void free_record (gpointer data)
@@ -167,12 +169,14 @@ static void free_record(gpointer data)InsnExecCount *rec = (InsnExecCount *) data;g_free (rec->insn);g_free (rec); +qemu_plugin_scoreboard_free (rec->count.score); }static void plugin_exit (qemu_plugin_id_t id,void *p) {g_autoptr (GString) report =g_string_new ("Instruction Classes:\n" );int i; +uint64_t total_count;GList *counts;InsnClassExecCount *class =NULL ;
@@ -180,11 +184,12 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) class = &class_table[i];switch (class->what) {case COUNT_CLASS : -if (class->count || verbose) { + total_count =qemu_plugin_u64_sum (class->count); +if (total_count || verbose) {g_string_append_printf (report,"Class: %-24s\t(%" PRId64" hits)\n" , class->class, - class->count); + total_count); }break ;case COUNT_INDIVIDUAL :
@@ -212,7 +217,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)"Instr: %-24s\t(%" PRId64" hits)" "\t(op=0x%08x/%s)\n" , rec->insn, - rec->count, +qemu_plugin_u64_sum (rec->count), rec->opcode, rec->class ? rec->class->class : "un-categorised");
@@ -221,6 +226,12 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) }g_hash_table_destroy (insns); +for (i =0 ; i <ARRAY_SIZE (class_tables); i++) { +for (int j =0 ; j < class_tables[i].table_sz; ++j) { +qemu_plugin_scoreboard_free (class_tables[i].table[j].count.score); + } + } +qemu_plugin_outs (report->str); }
@@ -232,11 +243,12 @@ static void plugin_init(void)static void vcpu_insn_exec_before (unsigned int cpu_index,void *udata) { -uint64_t *count = (uint64_t *) udata; - (*count)++; +struct qemu_plugin_scoreboard *score = udata; +qemu_plugin_u64_add (qemu_plugin_scoreboard_u64 (score), cpu_index,1 ); } -static uint64_t *find_counter (struct qemu_plugin_insn *insn) +static struct qemu_plugin_scoreboard *find_counter ( +struct qemu_plugin_insn *insn) {int i;uint64_t *cnt =NULL ;
@@ -265,7 +277,7 @@ static uint64_t *find_counter(struct qemu_plugin_insn *insn)case COUNT_NONE :return NULL ;case COUNT_CLASS : -return &class->count; +return class->count.score;case COUNT_INDIVIDUAL : {InsnExecCount *icount;
@@ -279,13 +291,16 @@ static uint64_t *find_counter(struct qemu_plugin_insn *insn) icount->opcode = opcode; icount->insn =qemu_plugin_insn_disas (insn); icount->class = class; +struct qemu_plugin_scoreboard *score = +qemu_plugin_scoreboard_new (sizeof (uint64_t )); + icount->count =qemu_plugin_scoreboard_u64 (score);g_hash_table_insert (insns,GUINT_TO_POINTER (opcode), (gpointer ) icount); }g_mutex_unlock (&lock); -return &icount->count; +return icount->count.score; }default :g_assert_not_reached ();
@@ -300,14 +315,14 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)size_t i;for (i =0 ; i < n; i++) { -uint64_t *cnt;struct qemu_plugin_insn *insn =qemu_plugin_tb_get_insn (tb, i); - cnt =find_counter (insn); +struct qemu_plugin_scoreboard *cnt =find_counter (insn);if (cnt) {if (do_inline) { -qemu_plugin_register_vcpu_insn_exec_inline ( - insn,QEMU_PLUGIN_INLINE_ADD_U64 , cnt,1 ); +qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu ( + insn,QEMU_PLUGIN_INLINE_ADD_U64 , +qemu_plugin_scoreboard_u64 (cnt),1 ); }else {qemu_plugin_register_vcpu_insn_exec_cb ( insn, vcpu_insn_exec_before,QEMU_PLUGIN_CB_NO_REGS , cnt);
@@ -322,6 +337,14 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, {int i; +for (i =0 ; i <ARRAY_SIZE (class_tables); i++) { +for (int j =0 ; j < class_tables[i].table_sz; ++j) { +struct qemu_plugin_scoreboard *score = +qemu_plugin_scoreboard_new (sizeof (uint64_t )); + class_tables[i].table[j].count =qemu_plugin_scoreboard_u64 (score); + } + } +/* Select a class table appropriate to the guest architecture */ for (i =0 ; i <ARRAY_SIZE (class_tables); i++) {ClassSelector *entry = &class_tables[i];
Signature · 1 line
2.39.2
[PULL 24/29] plugins: remove non per_vcpu inline operation from API
In reply to Alex BennéeFrom: Pierrick Bouvier <[email protected]>
Now we have a thread-safe equivalent of inline operation, and that all plugins were changed to use it, there is no point to keep the old API.
In more, it will help when we implement more functionality (conditional callbacks), as we can assume that we operate on a scoreboard.
API version bump was already done as part of this series.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
include/qemu/qemu-plugin.h +5 -53
@@ -52,7 +52,11 @@ typedef uint64_t qemu_plugin_id_t;* The plugins export the API they were built against by exposing the * symbol qemu_plugin_version which can be checked. * -* version 2: removed qemu_plugin_n_vcpus and qemu_plugin_n_max_vcpus +* version 2: +* - removed qemu_plugin_n_vcpus and qemu_plugin_n_max_vcpus +* - Remove qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline. +* Those functions are replaced by *_per_vcpu variants, which guarantee +* thread-safety for operations. */ extern QEMU_PLUGIN_EXPORT int qemu_plugin_version;
@@ -309,25 +313,6 @@ enum qemu_plugin_op { QEMU_PLUGIN_INLINE_ADD_U64, }; -/** -* qemu_plugin_register_vcpu_tb_exec_inline() - execution inline op -* @tb: the opaque qemu_plugin_tb handle for the translation -* @op: the type of qemu_plugin_op (e.g. ADD_U64) -* @ptr: the target memory location for the op -* @imm: the op data (e.g. 1) -* -* Insert an inline op to every time a translated unit executes. -* Useful if you just want to increment a single counter somewhere in -* memory. -* -* Note: ops are not atomic so in multi-threaded/multi-smp situations -* you will get inexact results. -*/ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, -enum qemu_plugin_op op, -void *ptr,uint64_t imm); -/** * qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu() - execution inline op * @tb: the opaque qemu_plugin_tb handle for the translation
@@ -359,21 +344,6 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn,enum qemu_plugin_cb_flags flags, void *userdata); -/** -* qemu_plugin_register_vcpu_insn_exec_inline() - insn execution inline op -* @insn: the opaque qemu_plugin_insn handle for an instruction -* @op: the type of qemu_plugin_op (e.g. ADD_U64) -* @ptr: the target memory location for the op -* @imm: the op data (e.g. 1) -* -* Insert an inline op to every time an instruction executes. Useful -* if you just want to increment a single counter somewhere in memory. -*/ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, -enum qemu_plugin_op op, -void *ptr,uint64_t imm); -/** * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inline op * @insn: the opaque qemu_plugin_insn handle for an instruction
@@ -597,24 +567,6 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn,enum qemu_plugin_mem_rw rw, void *userdata); -/** -* qemu_plugin_register_vcpu_mem_inline() - register an inline op to any memory access -* @insn: handle for instruction to instrument -* @rw: apply to reads, writes or both -* @op: the op, of type qemu_plugin_op -* @ptr: pointer memory for the op -* @imm: immediate data for @op -* -* This registers a inline op every memory access generated by the -* instruction. This provides for a lightweight but not thread-safe -* way of counting the number of operations done. -*/ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, -enum qemu_plugin_mem_rw rw, -enum qemu_plugin_op op,void *ptr, -uint64_t imm); -/** * qemu_plugin_register_vcpu_mem_inline_per_vcpu() - inline op for mem access * @insn: handle for instruction to instrument
plugins/api.c +0 -29
@@ -101,16 +101,6 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, } } -void qemu_plugin_register_vcpu_tb_exec_inline (struct qemu_plugin_tb *tb, -enum qemu_plugin_op op, -void *ptr,uint64_t imm) -{ -if (!tb->mem_only) { -plugin_register_inline_op (&tb->cbs[PLUGIN_CB_INLINE ], -0 , op, ptr, imm); - } -} - void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( struct qemu_plugin_tb *tb, enum qemu_plugin_op op,
@@ -138,16 +128,6 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, } } -void qemu_plugin_register_vcpu_insn_exec_inline (struct qemu_plugin_insn *insn, -enum qemu_plugin_op op, -void *ptr,uint64_t imm) -{ -if (!insn->mem_only) { -plugin_register_inline_op (&insn->cbs[PLUGIN_CB_INSN ][PLUGIN_CB_INLINE ], -0 , op, ptr, imm); - } -} - void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_op op,
@@ -175,15 +155,6 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, cb, flags, rw, udata); } -void qemu_plugin_register_vcpu_mem_inline (struct qemu_plugin_insn *insn, -enum qemu_plugin_mem_rw rw, -enum qemu_plugin_op op,void *ptr, -uint64_t imm) -{ -plugin_register_inline_op (&insn->cbs[PLUGIN_CB_MEM ][PLUGIN_CB_INLINE ], - rw, op, ptr, imm); -} - void qemu_plugin_register_vcpu_mem_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw,
plugins/qemu-plugins.symbols +0 -3
@@ -27,16 +27,13 @@ qemu_plugin_register_vcpu_idle_cb; qemu_plugin_register_vcpu_init_cb; qemu_plugin_register_vcpu_insn_exec_cb; - qemu_plugin_register_vcpu_insn_exec_inline; qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu; qemu_plugin_register_vcpu_mem_cb; - qemu_plugin_register_vcpu_mem_inline; qemu_plugin_register_vcpu_mem_inline_per_vcpu; qemu_plugin_register_vcpu_resume_cb; qemu_plugin_register_vcpu_syscall_cb; qemu_plugin_register_vcpu_syscall_ret_cb; qemu_plugin_register_vcpu_tb_exec_cb; - qemu_plugin_register_vcpu_tb_exec_inline; qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset;
Signature · 1 line
2.39.2
[PULL 02/29] gdbstub: Support disablement in a multi-threaded process
In reply to Alex BennéeFrom: Ilya Leoshkevich <[email protected]>
The upcoming follow-fork-mode child support will require disabling gdbstub in the parent process, which may have multiple threads (which are represented as CPUs).
Loop over all CPUs in order to remove breakpoints and disable single-step. Move the respective code into a separate function.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
gdbstub/user.c +15 -4
@@ -356,16 +356,27 @@ int gdbserver_start(const char *port_or_path)return -1 ; } +static void disable_gdbstub (CPUState *thread_cpu) +{ +CPUState *cpu; + +close (gdbserver_user_state.fd); + gdbserver_user_state.fd =-1 ; +CPU_FOREACH (cpu) { +cpu_breakpoint_remove_all (cpu,BP_GDB ); +/* no cpu_watchpoint_remove_all for user-mode */ +cpu_single_step (cpu,0 ); + } +tb_flush (thread_cpu); +} +/* Disable gdb stub for child processes. */ void gdbserver_fork (CPUState *cpu) {if (!gdbserver_state.init || gdbserver_user_state.fd <0 ) {return ; } -close (gdbserver_user_state.fd); - gdbserver_user_state.fd =-1 ; -cpu_breakpoint_remove_all (cpu,BP_GDB ); -/* no cpu_watchpoint_remove_all for user-mode */ +disable_gdbstub (cpu); }/*
Signature · 1 line
2.39.2
[PULL 12/29] gdbstub: Implement follow-fork-mode child
In reply to Alex BennéeFrom: Ilya Leoshkevich <[email protected]>
Currently it's not possible to use gdbstub for debugging linux-user code that runs in a forked child, which is normally done using the set follow-fork-mode child GDB command. Purely on the protocol level, the missing piece is the fork-events feature.
However, a deeper problem is supporting $Hg switching between different processes - right now it can do only threads. Implementing this for the general case would be quite complicated, but, fortunately, for the follow-fork-mode case there are a few factors that greatly simplify
things: fork() happens in the exclusive section, there are only two processes involved, and before one of them is resumed, the second one is detached.
This makes it possible to implement a simplified scheme: the parent and the child share the gdbserver socket, it's used only by one of them at any given time, which is coordinated through a separate socketpair. The processes can read from the gdbserver socket only one byte at a time, which is not great for performance, but, fortunately, the follow-fork-mode handling involves only a few messages.
Advertise the fork-events support, and remember whether GDB has it as well. Implement the state machine that is initialized on fork(), decides the current owner of the gdbserver socket, and is terminated when one of the two processes is detached. The logic for the parent and the child is the same, only the initial state is different.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
gdbstub/user.c +210 -2
@@ -25,6 +25,61 @@#define GDB_NR_SYSCALLS 1024typedef unsigned long GDBSyscallsMask [BITS_TO_LONGS (GDB_NR_SYSCALLS )]; +/* +* Forked child talks to its parent in order to let GDB enforce the +* follow-fork-mode. This happens inside a start_exclusive() section, so that +* the other threads, which may be forking too, do not interfere. The +* implementation relies on GDB not sending $vCont until it has detached +* either from the parent (follow-fork-mode child) or from the child +* (follow-fork-mode parent). +* +* The parent and the child share the GDB socket; at any given time only one +* of them is allowed to use it, as is reflected in the respective fork_state. +* This is negotiated via the fork_sockets pair as a reaction to $Hg. +* +* Below is a short summary of the possible state transitions: +* +* ENABLED : Terminal state. +* DISABLED : Terminal state. +* ACTIVE : Parent initial state. +* INACTIVE : Child initial state. +* ACTIVE -> DEACTIVATING: On $Hg. +* ACTIVE -> ENABLING : On $D. +* ACTIVE -> DISABLING : On $D. +* ACTIVE -> DISABLED : On communication error. +* DEACTIVATING -> INACTIVE : On gdb_read_byte() return. +* DEACTIVATING -> DISABLED : On communication error. +* INACTIVE -> ACTIVE : On $Hg in the peer. +* INACTIVE -> ENABLE : On $D in the peer. +* INACTIVE -> DISABLE : On $D in the peer. +* INACTIVE -> DISABLED : On communication error. +* ENABLING -> ENABLED : On gdb_read_byte() return. +* ENABLING -> DISABLED : On communication error. +* DISABLING -> DISABLED : On gdb_read_byte() return. +*/ +enum GDBForkState { +/* Fully owning the GDB socket. */ +GDB_FORK_ENABLED , +/* Working with the GDB socket; the peer is inactive. */ +GDB_FORK_ACTIVE , +/* Handing off the GDB socket to the peer. */ +GDB_FORK_DEACTIVATING , +/* The peer is working with the GDB socket. */ +GDB_FORK_INACTIVE , +/* Asking the peer to close its GDB socket fd. */ +GDB_FORK_ENABLING , +/* Asking the peer to take over, closing our GDB socket fd. */ +GDB_FORK_DISABLING , +/* The peer has taken over, our GDB socket fd is closed. */ +GDB_FORK_DISABLED , +}; + +enum GDBForkMessage { +GDB_FORK_ACTIVATE ='a' , +GDB_FORK_ENABLE ='e' , +GDB_FORK_DISABLE ='d' , +}; +/* User-mode specific state */ typedef struct { int fd;
@@ -36,6 +91,10 @@ typedef struct {*/ bool catch_all_syscalls;GDBSyscallsMask catch_syscalls_mask; +bool fork_events; +enum GDBForkState fork_state; +int fork_sockets[2 ]; +pid_t fork_peer_pid, fork_peer_tid; } GDBUserState;static GDBUserState gdbserver_user_state;
@@ -358,6 +417,18 @@ int gdbserver_start(const char *port_or_path)void gdbserver_fork_start (void ) { +if (!gdbserver_state.init || gdbserver_user_state.fd <0 ) { +return ; + } +if (!gdbserver_user_state.fork_events || +qemu_socketpair (AF_UNIX ,SOCK_STREAM ,0 , + gdbserver_user_state.fork_sockets) <0 ) { + gdbserver_user_state.fork_state =GDB_FORK_DISABLED ; +return ; + } + gdbserver_user_state.fork_state =GDB_FORK_INACTIVE ; + gdbserver_user_state.fork_peer_pid =getpid (); + gdbserver_user_state.fork_peer_tid =qemu_get_thread_id (); }static void disable_gdbstub (CPUState *thread_cpu)
@@ -376,23 +447,160 @@ static void disable_gdbstub(CPUState *thread_cpu)void gdbserver_fork_end (CPUState *cpu,pid_t pid) { -if (pid !=0 || !gdbserver_state.init || gdbserver_user_state.fd <0 ) { +char b; +int fd; + +if (!gdbserver_state.init || gdbserver_user_state.fd <0 ) {return ; } -disable_gdbstub (cpu); + +if (pid ==-1 ) { +if (gdbserver_user_state.fork_state !=GDB_FORK_DISABLED ) { +g_assert (gdbserver_user_state.fork_state ==GDB_FORK_INACTIVE ); +close (gdbserver_user_state.fork_sockets[0 ]); +close (gdbserver_user_state.fork_sockets[1 ]); + } +return ; + } + +if (gdbserver_user_state.fork_state ==GDB_FORK_DISABLED ) { +if (pid ==0 ) { +disable_gdbstub (cpu); + } +return ; + } + +if (pid ==0 ) { +close (gdbserver_user_state.fork_sockets[0 ]); + fd = gdbserver_user_state.fork_sockets[1 ]; +g_assert (gdbserver_state.process_num ==1 ); +g_assert (gdbserver_state.processes[0 ].pid == + gdbserver_user_state.fork_peer_pid); +g_assert (gdbserver_state.processes[0 ].attached); + gdbserver_state.processes[0 ].pid =getpid (); + }else { +close (gdbserver_user_state.fork_sockets[1 ]); + fd = gdbserver_user_state.fork_sockets[0 ]; + gdbserver_user_state.fork_state =GDB_FORK_ACTIVE ; + gdbserver_user_state.fork_peer_pid = pid; + gdbserver_user_state.fork_peer_tid = pid; + +if (!gdbserver_state.allow_stop_reply) { + goto fail; + } +g_string_printf (gdbserver_state.str_buf, +"T%02xfork:p%02x.%02x;thread:p%02x.%02x;" , +gdb_target_signal_to_gdb (gdb_target_sigtrap ()), + pid, pid, (int )getpid (),qemu_get_thread_id ()); +gdb_put_strbuf (); + } + + gdbserver_state.state =RS_IDLE ; + gdbserver_state.allow_stop_reply = false; + gdbserver_user_state.running_state =0 ; +for (;;) { +switch (gdbserver_user_state.fork_state) { +case GDB_FORK_ENABLED : +if (gdbserver_user_state.running_state) { +return ; + } +QEMU_FALLTHROUGH ; +case GDB_FORK_ACTIVE : +if (read (gdbserver_user_state.fd, &b,1 ) !=1 ) { + goto fail; + } +gdb_read_byte (b); +break ; +case GDB_FORK_DEACTIVATING : + b =GDB_FORK_ACTIVATE ; +if (write (fd, &b,1 ) !=1 ) { + goto fail; + } + gdbserver_user_state.fork_state =GDB_FORK_INACTIVE ; +break ; +case GDB_FORK_INACTIVE : +if (read (fd, &b,1 ) !=1 ) { + goto fail; + } +switch (b) { +case GDB_FORK_ACTIVATE : + gdbserver_user_state.fork_state =GDB_FORK_ACTIVE ; +break ; +case GDB_FORK_ENABLE : +close (fd); + gdbserver_user_state.fork_state =GDB_FORK_ENABLED ; +break ; +case GDB_FORK_DISABLE : + gdbserver_user_state.fork_state =GDB_FORK_DISABLED ; +break ; +default : +g_assert_not_reached (); + } +break ; +case GDB_FORK_ENABLING : + b =GDB_FORK_DISABLE ; +if (write (fd, &b,1 ) !=1 ) { + goto fail; + } +close (fd); + gdbserver_user_state.fork_state =GDB_FORK_ENABLED ; +break ; +case GDB_FORK_DISABLING : + b =GDB_FORK_ENABLE ; +if (write (fd, &b,1 ) !=1 ) { + goto fail; + } + gdbserver_user_state.fork_state =GDB_FORK_DISABLED ; +break ; +case GDB_FORK_DISABLED : +close (fd); +disable_gdbstub (cpu); +return ; +default : +g_assert_not_reached (); + } + } + +fail: +close (fd); +if (pid ==0 ) { +disable_gdbstub (cpu); + } }void gdb_handle_query_supported_user (const char *gdb_supported) { +if (strstr (gdb_supported,"fork-events+" )) { + gdbserver_user_state.fork_events = true; + } +g_string_append (gdbserver_state.str_buf,";fork-events+" ); }bool gdb_handle_set_thread_user (uint32_t pid,uint32_t tid) { +if (gdbserver_user_state.fork_state ==GDB_FORK_ACTIVE && + pid == gdbserver_user_state.fork_peer_pid && + tid == gdbserver_user_state.fork_peer_tid) { + gdbserver_user_state.fork_state =GDB_FORK_DEACTIVATING ; +gdb_put_packet ("OK" ); +return true; + }return false; }bool gdb_handle_detach_user (uint32_t pid) { +bool enable; + +if (gdbserver_user_state.fork_state ==GDB_FORK_ACTIVE ) { + enable = pid == gdbserver_user_state.fork_peer_pid; +if (enable || pid ==getpid ()) { + gdbserver_user_state.fork_state = enable ?GDB_FORK_ENABLING : +GDB_FORK_DISABLING ; +gdb_put_packet ("OK" ); +return true; + } + }return false; }
Signature · 1 line
2.39.2
Re: [PULL 12/29] gdbstub: Implement follow-fork-mode child
Quoted 29 lines · Alex Bennée
From: Ilya Leoshkevich <[email protected]>
Currently it's not possible to use gdbstub for debugging linux-user code that runs in a forked child, which is normally done using the
set follow-fork-mode childGDB command. Purely on the protocol level, the missing piece is the fork-events feature.However, a deeper problem is supporting $Hg switching between different processes - right now it can do only threads. Implementing this for the general case would be quite complicated, but, fortunately, for the follow-fork-mode case there are a few factors that greatly simplify
things:fork()happens in the exclusive section, there are only two processes involved, and before one of them is resumed, the second one is detached.This makes it possible to implement a simplified scheme: the parent and the child share the gdbserver socket, it's used only by one of them at any given time, which is coordinated through a separate socketpair. The processes can read from the gdbserver socket only one byte at a time, which is not great for performance, but, fortunately, the follow-fork-mode handling involves only a few messages.
Advertise the fork-events support, and remember whether GDB has it as well. Implement the state machine that is initialized on
fork(), decides the current owner of the gdbserver socket, and is terminated when one of the two processes is detached. The logic for the parent and the child is the same, only the initial state is different.
Quoted 5 lines
Signed-off-by Ilya Leoshkevich <[email protected]>Message-Id: <[email protected]>
Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
Hi; Coverity points out an issue with this code (CID 1539966):
Quoted 32 lines
gdbstub/user.c +25
-0@@ -376,23 +447,160 @@ static void disable_gdbstub(CPUState *thread_cpu)void gdbserver_fork_end (CPUState *cpu,pid_t pid) { + gdbserver_state.state =RS_IDLE ; + gdbserver_state.allow_stop_reply = false; + gdbserver_user_state.running_state =0 ; +for (;;) { +switch (gdbserver_user_state.fork_state) { +case GDB_FORK_ENABLED : +if (gdbserver_user_state.running_state) { +return ; + } +QEMU_FALLTHROUGH ; +case GDB_FORK_ACTIVE : +if (read (gdbserver_user_state.fd, &b,1 ) !=1 ) { + goto fail; + } +gdb_read_byte (b); +break ; +case GDB_FORK_DEACTIVATING : + b =GDB_FORK_ACTIVATE ; +if (write (fd, &b,1 ) !=1 ) { + goto fail; + } + gdbserver_user_state.fork_state =GDB_FORK_INACTIVE ; +break ; +case GDB_FORK_INACTIVE : +if (read (fd, &b,1 ) !=1 ) {
gdbstub/user.c static void disable_gdbstub(CPUState *thread_cpu) · line 487
Quoted 10 lines
gdbstub/user.c +10
-0+ goto fail; + } +switch (b) { +case GDB_FORK_ACTIVATE : + gdbserver_user_state.fork_state =GDB_FORK_ACTIVE ; +break ; +case GDB_FORK_ENABLE : +close (fd); + gdbserver_user_state.fork_state =GDB_FORK_ENABLED ; +break ;
In this branch of the switch we close(fd), and then break...
gdbstub/user.c static void disable_gdbstub(CPUState *thread_cpu) · line 539
Quoted 7 lines
gdbstub/user.c +7
-0+case GDB_FORK_DISABLE : + gdbserver_user_state.fork_state =GDB_FORK_DISABLED ; +break ; +default : +g_assert_not_reached (); + } +break ;
...and break again, so we leave the for() loop...
Quoted 13 lines
gdbstub/user.c +13
-0+case GDB_FORK_ENABLING : + b =GDB_FORK_DISABLE ; +if (write (fd, &b,1 ) !=1 ) { + goto fail; + } +close (fd); + gdbserver_user_state.fork_state =GDB_FORK_ENABLED ; +break ; +case GDB_FORK_DISABLING : + b =GDB_FORK_ENABLE ; +if (write (fd, &b,1 ) !=1 ) { + goto fail; + }
gdbstub/user.c static void disable_gdbstub(CPUState *thread_cpu) · line 562
Quoted 10 lines
gdbstub/user.c +10
-0+ gdbserver_user_state.fork_state =GDB_FORK_DISABLED ; +break ; +case GDB_FORK_DISABLED : +close (fd); +disable_gdbstub (cpu); +return ; +default : +g_assert_not_reached (); + } + }
...but at the end of the for loop we will fall into this code:
gdbstub/user.c static void disable_gdbstub(CPUState *thread_cpu) · line 565
Quoted 3 lines
gdbstub/user.c +3
-0+ +fail: +close (fd);
...which tries to close(fd) again, which isn't valid.
gdbstub/user.c static void disable_gdbstub(CPUState *thread_cpu) · line 569
Quoted 4 lines
gdbstub/user.c +3
-0+if (pid ==0 ) { +disable_gdbstub (cpu); + } }
thanks
-- PMM
[PULL 08/29] gdbstub: Call gdbserver_fork() both in parent and in child
In reply to Alex BennéeFrom: Ilya Leoshkevich <[email protected]>
The upcoming follow-fork-mode child support requires post-fork message exchange between the parent and the child. Prepare gdbserver_fork() for this purpose. Rename it to gdbserver_fork_end() to better reflect its purpose.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
include/gdbstub/user.h +3 -2
@@ -51,10 +51,11 @@ void gdb_signalled(CPUArchState *as, int sig);void gdbserver_fork_start (void );/** -* gdbserver_fork() - disable gdb stub for child processes. +* gdbserver_fork_end() - inform gdb of the completed fork() * @cs: CPU +* @pid: 0 if in child process, -1 if fork failed, child process pid otherwise */ -void gdbserver_fork (CPUState *cs,pid_t pid); +void gdbserver_fork_end (CPUState *cs,pid_t pid);/** * gdb_syscall_entry() - inform gdb of syscall entry and yield control to it
bsd-user/main.c +2 -1
@@ -138,10 +138,11 @@ void fork_end(pid_t pid)*/ qemu_init_cpu_list ();get_task_state (thread_cpu)->ts_tid =qemu_get_thread_id (); -gdbserver_fork (thread_cpu, pid); +gdbserver_fork_end (thread_cpu, pid); }else {mmap_fork_end (child);cpu_list_unlock (); +gdbserver_fork_end (thread_cpu, pid);end_exclusive (); } }
gdbstub/user.c +2 -3
@@ -374,10 +374,9 @@ static void disable_gdbstub(CPUState *thread_cpu)tb_flush (thread_cpu); } -/* Disable gdb stub for child processes. */ -void gdbserver_fork (CPUState *cpu,pid_t pid) +void gdbserver_fork_end (CPUState *cpu,pid_t pid) { -if (!gdbserver_state.init || gdbserver_user_state.fd <0 ) { +if (pid !=0 || !gdbserver_state.init || gdbserver_user_state.fd <0 ) {return ; }disable_gdbstub (cpu);
linux-user/main.c +1 -1
@@ -165,10 +165,10 @@ void fork_end(pid_t pid) }qemu_init_cpu_list ();get_task_state (thread_cpu)->ts_tid =qemu_get_thread_id (); -gdbserver_fork (thread_cpu, pid); }else {cpu_list_unlock (); } +gdbserver_fork_end (thread_cpu, pid);/* * qemu_init_cpu_list() reinitialized the child exclusive state, but we * also need to keep current_cpu consistent, so call end_exclusive() for
Signature · 1 line
2.39.2
[PULL 15/29] plugins: define qemu_plugin_u64
In reply to Alex BennéeFrom: Pierrick Bouvier <[email protected]>
Additionally to the scoreboard, we define a qemu_plugin_u64, which is a simple struct holding a pointer to a scoreboard, and a given offset. This allows to have a scoreboard containing structs, without having to bring offset to operate on a specific field.
Since most of the plugins are simply collecting a sum of per-cpu values, qemu_plugin_u64 directly support this operation as well.
All inline operations defined later will use a qemu_plugin_u64 as input.
New functions:
- qemu_plugin_u64_add
- qemu_plugin_u64_get
- qemu_plugin_u64_set
- qemu_plugin_u64_sum
New macros:
- qemu_plugin_scoreboard_u64
- qemu_plugin_scoreboard_u64_in_struct
Message-Id: <[email protected]>
Message-Id: <[email protected]>
include/qemu/qemu-plugin.h +52 -0
@@ -225,6 +225,17 @@ struct qemu_plugin_insn;/** struct qemu_plugin_scoreboard - Opaque handle for a scoreboard */ struct qemu_plugin_scoreboard ; +/** +* typedef qemu_plugin_u64 - uint64_t member of an entry in a scoreboard +* +* This field allows to access a specific uint64_t member in one given entry, +* located at a specified offset. Inline operations expect this as entry. +*/ +typedef struct { +struct qemu_plugin_scoreboard *score; +size_t offset; +}qemu_plugin_u64 ; +/** * enum qemu_plugin_cb_flags - type of callback *
@@ -784,4 +795,45 @@ QEMU_PLUGIN_APIvoid *qemu_plugin_scoreboard_find (struct qemu_plugin_scoreboard *score,unsigned int vcpu_index); +/* Macros to define a qemu_plugin_u64 */ +#define qemu_plugin_scoreboard_u64 (score) \ + (qemu_plugin_u64) {score, 0} +#define qemu_plugin_scoreboard_u64_in_struct (score, type, member) \ + (qemu_plugin_u64) {score, offsetof(type, member)} + +/** +* qemu_plugin_u64_add() - add a value to a qemu_plugin_u64 for a given vcpu +* @entry: entry to query +* @vcpu_index: entry index +* @added: value to add +*/ +QEMU_PLUGIN_API +void qemu_plugin_u64_add(qemu_plugin_u64 entry, unsigned int vcpu_index, +uint64_t added); + +/** +* qemu_plugin_u64_get() - get value of a qemu_plugin_u64 for a given vcpu +* @entry: entry to query +* @vcpu_index: entry index +*/ +QEMU_PLUGIN_API +uint64_t qemu_plugin_u64_get(qemu_plugin_u64 entry, unsigned int vcpu_index); + +/** +* qemu_plugin_u64_set() - set value of a qemu_plugin_u64 for a given vcpu +* @entry: entry to query +* @vcpu_index: entry index +* @val: new value +*/ +QEMU_PLUGIN_API +void qemu_plugin_u64_set(qemu_plugin_u64 entry, unsigned int vcpu_index, +uint64_t val); + +/** +* qemu_plugin_u64_sum() - return sum of all vcpu entries in a scoreboard +* @entry: entry to sum +*/ +QEMU_PLUGIN_API +uint64_t qemu_plugin_u64_sum(qemu_plugin_u64 entry); +#endif /* QEMU_QEMU_PLUGIN_H */
plugins/api.c +34 -0
@@ -484,3 +484,37 @@ void *qemu_plugin_scoreboard_find(struct qemu_plugin_scoreboard *score,char *base_ptr = score->data->data;return base_ptr + vcpu_index *g_array_get_element_size (score->data); } + +static uint64_t *plugin_u64_address (qemu_plugin_u64 entry, +unsigned int vcpu_index) +{ +char *ptr =qemu_plugin_scoreboard_find (entry.score, vcpu_index); +return (uint64_t *)(ptr + entry.offset); +} + +void qemu_plugin_u64_add (qemu_plugin_u64 entry,unsigned int vcpu_index, +uint64_t added) +{ + *plugin_u64_address (entry, vcpu_index) += added; +} + +uint64_t qemu_plugin_u64_get (qemu_plugin_u64 entry, +unsigned int vcpu_index) +{ +return *plugin_u64_address (entry, vcpu_index); +} + +void qemu_plugin_u64_set (qemu_plugin_u64 entry,unsigned int vcpu_index, +uint64_t val) +{ + *plugin_u64_address (entry, vcpu_index) = val; +} + +uint64_t qemu_plugin_u64_sum (qemu_plugin_u64 entry) +{ +uint64_t total =0 ; +for (int i =0 , n =qemu_plugin_num_vcpus (); i < n; ++i) { + total +=qemu_plugin_u64_get (entry, i); + } +return total; +}
plugins/qemu-plugins.symbols +4 -0
@@ -44,6 +44,10 @@ qemu_plugin_tb_get_insn; qemu_plugin_tb_n_insns; qemu_plugin_tb_vaddr; + qemu_plugin_u64_add; + qemu_plugin_u64_get; + qemu_plugin_u64_set; + qemu_plugin_u64_sum; qemu_plugin_uninstall; qemu_plugin_vcpu_for_each; };
Signature · 1 line
2.39.2
[PULL 18/29] tests/plugin: add test plugin for inline operations
In reply to Alex BennéeFrom: Pierrick Bouvier <[email protected]>
For now, it simply performs instruction, bb and mem count, and ensure that inline vs callback versions have the same result. Later, we'll extend it when new inline operations are added.
Use existing plugins to test everything works is a bit cumbersome, as different events are treated in different plugins. Thus, this new one.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
tests/plugin/inline.c new file +186 -0
@@ -0,0 +1,186 @@ +/* +* Copyright (C) 2023, Pierrick Bouvier <[email protected]> +* +* Demonstrates and tests usage of inline ops. +* +* License: GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include <glib.h> +#include <stdint.h> +#include <stdio.h> + +#include <qemu-plugin.h> + +typedef struct { +uint64_t count_tb; +uint64_t count_tb_inline; +uint64_t count_insn; +uint64_t count_insn_inline; +uint64_t count_mem; +uint64_t count_mem_inline; +}CPUCount ; + +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64 count_tb; +static qemu_plugin_u64 count_tb_inline; +static qemu_plugin_u64 count_insn; +static qemu_plugin_u64 count_insn_inline; +static qemu_plugin_u64 count_mem; +static qemu_plugin_u64 count_mem_inline; + +static uint64_t global_count_tb; +static uint64_t global_count_insn; +static uint64_t global_count_mem; +static unsigned int max_cpu_index; +static GMutex tb_lock; +static GMutex insn_lock; +static GMutex mem_lock; + +QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; + +static void stats_insn (void ) +{ +const uint64_t expected = global_count_insn; +const uint64_t per_vcpu =qemu_plugin_u64_sum (count_insn); +const uint64_t inl_per_vcpu = +qemu_plugin_u64_sum (count_insn_inline); +printf ("insn: %" PRIu64"\n" , expected); +printf ("insn: %" PRIu64" (per vcpu)\n" , per_vcpu); +printf ("insn: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); +g_assert (expected >0 ); +g_assert (per_vcpu == expected); +g_assert (inl_per_vcpu == expected); +} + +static void stats_tb (void ) +{ +const uint64_t expected = global_count_tb; +const uint64_t per_vcpu =qemu_plugin_u64_sum (count_tb); +const uint64_t inl_per_vcpu = +qemu_plugin_u64_sum (count_tb_inline); +printf ("tb: %" PRIu64"\n" , expected); +printf ("tb: %" PRIu64" (per vcpu)\n" , per_vcpu); +printf ("tb: %" PRIu64" (per vcpu inline)\n" , inl_per_vcpu); +g_assert (expected >0 ); +g_assert (per_vcpu == expected); +g_assert (inl_per_vcpu == expected); +} + +static void stats_mem (void ) +{ +const uint64_t expected = global_count_mem; +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_assert (expected >0 ); +g_assert (per_vcpu == expected); +g_assert (inl_per_vcpu == expected); +} + +static void plugin_exit (qemu_plugin_id_t id,void *udata) +{ +const unsigned int num_cpus =qemu_plugin_num_vcpus (); +g_assert (num_cpus == max_cpu_index +1 ); + +for (int i =0 ; i < num_cpus ; ++i) { +const uint64_t tb =qemu_plugin_u64_get (count_tb, i); +const uint64_t tb_inline =qemu_plugin_u64_get (count_tb_inline, i); +const uint64_t insn =qemu_plugin_u64_get (count_insn, i); +const uint64_t insn_inline =qemu_plugin_u64_get (count_insn_inline, i); +const uint64_t mem =qemu_plugin_u64_get (count_mem, i); +const uint64_t mem_inline =qemu_plugin_u64_get (count_mem_inline, i); +printf ("cpu %d: tb (%" PRIu64", %" PRIu64") | " +"insn (%" PRIu64", %" PRIu64") | " +"mem (%" PRIu64", %" PRIu64")" +"\n" , + i, tb, tb_inline, insn, insn_inline, mem, mem_inline); +g_assert (tb == tb_inline); +g_assert (insn == insn_inline); +g_assert (mem == mem_inline); + } + +stats_tb (); +stats_insn (); +stats_mem (); + +qemu_plugin_scoreboard_free (counts); +} + +static void vcpu_tb_exec (unsigned int cpu_index,void *udata) +{ +qemu_plugin_u64_add (count_tb, cpu_index,1 ); +g_mutex_lock (&tb_lock); + max_cpu_index =MAX (max_cpu_index, cpu_index); + global_count_tb++; +g_mutex_unlock (&tb_lock); +} + +static void vcpu_insn_exec (unsigned int cpu_index,void *udata) +{ +qemu_plugin_u64_add (count_insn, cpu_index,1 ); +g_mutex_lock (&insn_lock); + global_count_insn++; +g_mutex_unlock (&insn_lock); +} + +static void vcpu_mem_access (unsigned int cpu_index, +qemu_plugin_meminfo_t info, +uint64_t vaddr, +void *userdata) +{ +qemu_plugin_u64_add (count_mem, cpu_index,1 ); +g_mutex_lock (&mem_lock); + global_count_mem++; +g_mutex_unlock (&mem_lock); +} + +static void vcpu_tb_trans (qemu_plugin_id_t id,struct qemu_plugin_tb *tb) +{ +qemu_plugin_register_vcpu_tb_exec_cb ( + tb, vcpu_tb_exec,QEMU_PLUGIN_CB_NO_REGS ,0 ); +qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu ( + tb,QEMU_PLUGIN_INLINE_ADD_U64 , count_tb_inline,1 ); + +for (int idx =0 ; idx <qemu_plugin_tb_n_insns (tb); ++idx) { +struct qemu_plugin_insn *insn =qemu_plugin_tb_get_insn (tb, idx); +qemu_plugin_register_vcpu_insn_exec_cb ( + insn, vcpu_insn_exec,QEMU_PLUGIN_CB_NO_REGS ,0 ); +qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu ( + insn,QEMU_PLUGIN_INLINE_ADD_U64 , count_insn_inline,1 ); +qemu_plugin_register_vcpu_mem_cb (insn, &vcpu_mem_access, +QEMU_PLUGIN_CB_NO_REGS , +QEMU_PLUGIN_MEM_RW ,0 ); +qemu_plugin_register_vcpu_mem_inline_per_vcpu ( + insn,QEMU_PLUGIN_MEM_RW , +QEMU_PLUGIN_INLINE_ADD_U64 , + count_mem_inline,1 ); + } +} + +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, +int argc,char **argv) +{ + counts =qemu_plugin_scoreboard_new (sizeof (CPUCount)); + count_tb =qemu_plugin_scoreboard_u64_in_struct ( + counts, CPUCount, count_tb); + count_insn =qemu_plugin_scoreboard_u64_in_struct ( + counts, CPUCount, count_insn); + count_mem =qemu_plugin_scoreboard_u64_in_struct ( + counts, CPUCount, count_mem); + count_tb_inline =qemu_plugin_scoreboard_u64_in_struct ( + counts, CPUCount, count_tb_inline); + count_insn_inline =qemu_plugin_scoreboard_u64_in_struct ( + counts, CPUCount, count_insn_inline); + count_mem_inline =qemu_plugin_scoreboard_u64_in_struct ( + counts, CPUCount, count_mem_inline); +qemu_plugin_register_vcpu_tb_trans_cb (id, vcpu_tb_trans); +qemu_plugin_register_atexit_cb (id, plugin_exit,NULL ); + +return 0 ; +}
tests/plugin/meson.build +1 -1
@@ -1,6 +1,6 @@ t = [] if get_option('plugins') - foreach i : ['bb', 'empty', 'insn', 'mem', 'syscall'] + foreach i : ['bb', 'empty', 'inline', 'insn', 'mem', 'syscall'] if host_os == 'windows' t += shared_module(i, files(i + '.c') + '../../contrib/plugins/win32_linker.c', include_directories: '../../include/qemu',
Signature · 1 line
2.39.2
[PULL 09/29] gdbstub: Introduce gdb_handle_query_supported_user()
In reply to Alex BennéeFrom: Ilya Leoshkevich <[email protected]>
The upcoming follow-fork-mode child support requires advertising the fork-events feature, which is user-specific. Introduce a user-specific hook for this.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
gdbstub/internals.h +1 -0
@@ -196,6 +196,7 @@ void gdb_handle_v_file_pread(GArray *params, void *user_ctx); /* user */void gdb_handle_v_file_readlink (GArray *params,void *user_ctx);/* user */ void gdb_handle_query_xfer_exec_file (GArray *params,void *user_ctx);/* user */ void gdb_handle_set_catch_syscalls (GArray *params,void *user_ctx);/* user */ +void gdb_handle_query_supported_user (const char *gdb_supported);/* user */ void gdb_handle_query_attached (GArray *params,void *user_ctx);/* both */
gdbstub/gdbstub.c +9 -3
@@ -1655,9 +1655,15 @@ static void handle_query_supported(GArray *params, void *user_ctx)g_string_append (gdbserver_state.str_buf,";qXfer:exec-file:read+" );#endif -if (params->len && -strstr (get_param (params,0 )->data,"multiprocess+" )) { - gdbserver_state.multiprocess = true; +if (params->len) { +const char *gdb_supported =get_param (params,0 )->data; + +if (strstr (gdb_supported,"multiprocess+" )) { + gdbserver_state.multiprocess = true; + } +#if defined(CONFIG_USER_ONLY ) +gdb_handle_query_supported_user (gdb_supported); +#endif }g_string_append (gdbserver_state.str_buf,";vContSupported+;multiprocess+" );
gdbstub/user.c +4 -0
@@ -382,6 +382,10 @@ void gdbserver_fork_end(CPUState *cpu, pid_t pid)disable_gdbstub (cpu); } +void gdb_handle_query_supported_user (const char *gdb_supported) +{ +} +/* * Execution state helpers */
Signature · 1 line
2.39.2
[PULL 04/29] {linux,bsd}-user: Update ts_tid after fork()
In reply to Alex BennéeFrom: Ilya Leoshkevich <[email protected]>
Currently ts_tid contains the parent tid after fork(), which is not correct. So far it has not affected anything, but the upcoming follow-fork-mode child support relies on the correct value, so fix it.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
bsd-user/main.c +1 -0
@@ -134,6 +134,7 @@ void fork_end(int child)* state, so we don't need to end_exclusive() here. */ qemu_init_cpu_list (); +get_task_state (thread_cpu)->ts_tid =qemu_get_thread_id ();gdbserver_fork (thread_cpu); }else {mmap_fork_end (child);
linux-user/main.c +1 -0
@@ -161,6 +161,7 @@ void fork_end(int child) } }qemu_init_cpu_list (); +get_task_state (thread_cpu)->ts_tid =qemu_get_thread_id ();gdbserver_fork (thread_cpu); }else {cpu_list_unlock ();
Signature · 1 line
2.39.2
[PULL 06/29] {linux,bsd}-user: Pass pid to fork_end()
In reply to Alex BennéeFrom: Ilya Leoshkevich <[email protected]>
The upcoming follow-fork-mode child support requires knowing the child pid. Pass it down.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
bsd-user/freebsd/os-proc.h +3 -3
@@ -208,7 +208,7 @@ static inline abi_long do_freebsd_fork(void *cpu_env)*/ set_second_rval (cpu_env, child_flag); -fork_end (child_flag); +fork_end (ret);return ret; }
@@ -252,7 +252,7 @@ static inline abi_long do_freebsd_rfork(void *cpu_env, abi_long flags)* value: 0 for parent process, 1 for child process. */ set_second_rval (cpu_env, child_flag); -fork_end (child_flag); +fork_end (ret);return ret;
@@ -285,7 +285,7 @@ static inline abi_long do_freebsd_pdfork(void *cpu_env, abi_ulong target_fdp,* value: 0 for parent process, 1 for child process. */ set_second_rval (cpu_env, child_flag); -fork_end (child_flag); +fork_end (ret);return ret; }
bsd-user/qemu.h +1 -1
@@ -192,7 +192,7 @@ void cpu_loop(CPUArchState *env);char *target_strerror (int err);int get_osversion (void );void fork_start (void ); -void fork_end (int child); +void fork_end (pid_t pid);#include "qemu/log.h"
linux-user/user-internals.h +1 -1
@@ -71,7 +71,7 @@ const char *target_strerror(int err);int get_osversion (void );void init_qemu_uname_release (void );void fork_start (void ); -void fork_end (int child); +void fork_end (pid_t pid);/** * probe_guest_base:
bsd-user/main.c +3 -1
@@ -116,8 +116,10 @@ void fork_start(void)gdbserver_fork_start (); } -void fork_end (int child) +void fork_end (pid_t pid) { +bool child = pid ==0 ; +if (child) {CPUState *cpu, *next_cpu;/*
linux-user/main.c +3 -1
@@ -148,8 +148,10 @@ void fork_start(void)gdbserver_fork_start (); } -void fork_end (int child) +void fork_end (pid_t pid) { +bool child = pid ==0 ; +qemu_plugin_user_postfork (child);mmap_fork_end (child);if (child) {
linux-user/syscall.c +3 -3
@@ -6669,7 +6669,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,if (ret ==0 ) {/* Child Process. */ cpu_clone_regs_child (env, newsp, flags); -fork_end (1 ); +fork_end (ret);/* There is a race condition here. The parent process could theoretically read the TID in the child process before the child tid is set. This would require using either ptrace
@@ -6700,8 +6700,8 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, }#endif put_user_u32 (pid_fd, parent_tidptr); - } -fork_end (0 ); + } +fork_end (ret); }g_assert (!cpu_in_exclusive_context (cpu)); }
Signature · 1 line
2.39.2
[PULL 07/29] {linux,bsd}-user: Pass pid to gdbserver_fork()
In reply to Alex BennéeFrom: Ilya Leoshkevich <[email protected]>
The upcoming follow-fork-mode child support requires knowing the child pid. Pass it down.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
include/gdbstub/user.h +1 -1
@@ -54,7 +54,7 @@ void gdbserver_fork_start(void);* gdbserver_fork() - disable gdb stub for child processes. * @cs: CPU */ -void gdbserver_fork (CPUState *cs); +void gdbserver_fork (CPUState *cs,pid_t pid);/** * gdb_syscall_entry() - inform gdb of syscall entry and yield control to it
bsd-user/main.c +1 -1
@@ -138,7 +138,7 @@ void fork_end(pid_t pid)*/ qemu_init_cpu_list ();get_task_state (thread_cpu)->ts_tid =qemu_get_thread_id (); -gdbserver_fork (thread_cpu); +gdbserver_fork (thread_cpu, pid); }else {mmap_fork_end (child);cpu_list_unlock ();
gdbstub/user.c +1 -1
@@ -375,7 +375,7 @@ static void disable_gdbstub(CPUState *thread_cpu) }/* Disable gdb stub for child processes. */ -void gdbserver_fork (CPUState *cpu) +void gdbserver_fork (CPUState *cpu,pid_t pid) {if (!gdbserver_state.init || gdbserver_user_state.fd <0 ) {return ;
linux-user/main.c +1 -1
@@ -165,7 +165,7 @@ void fork_end(pid_t pid) }qemu_init_cpu_list ();get_task_state (thread_cpu)->ts_tid =qemu_get_thread_id (); -gdbserver_fork (thread_cpu); +gdbserver_fork (thread_cpu, pid); }else {cpu_list_unlock (); }
Signature · 1 line
2.39.2
[PULL 03/29] {linux,bsd}-user: Introduce get_task_state()
In reply to Alex BennéeFrom: Ilya Leoshkevich <[email protected]>
A CPU's TaskState is stored in the CPUState's void *opaque field, accessing which is somewhat awkward due to having to use a cast. Introduce a wrapper and use it everywhere.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
bsd-user/bsd-file.h +1 -1
@@ -641,7 +641,7 @@ static abi_long do_bsd_readlink(CPUArchState *env, abi_long arg1, }if (strcmp (p1,"/proc/curproc/file" ) ==0 ) {CPUState *cpu =env_cpu (env); -TaskState *ts = (TaskState *)cpu->opaque; +TaskState *ts =get_task_state (cpu);strncpy (p2, ts->bprm->fullpath, arg3); ret =MIN ((abi_long )strlen (ts->bprm->fullpath), arg3); }else {
bsd-user/qemu.h +5 -0
@@ -117,6 +117,11 @@ typedef struct TaskState {struct target_sigaltstack sigaltstack_used; } __attribute__((aligned(16))) TaskState; +static inline TaskState *get_task_state (CPUState *cs) +{ +return cs->opaque; +} +void stop_all_tasks (void );extern const char *interp_prefix;extern const char *qemu_uname_release;
include/user/safe-syscall.h +1 -1
@@ -134,7 +134,7 @@ extern char safe_syscall_start[];extern char safe_syscall_end[];#define safe_syscall (...) \ - safe_syscall_base(&((TaskState *)thread_cpu->opaque)->signal_pending, \ + safe_syscall_base(&get_task_state(thread_cpu)->signal_pending, \ __VA_ARGS__)#endif
linux-user/m68k/target_cpu.h +1 -1
@@ -37,7 +37,7 @@ static inline void cpu_clone_regs_parent(CPUM68KState *env, unsigned flags)static inline void cpu_set_tls (CPUM68KState *env,target_ulong newtls) {CPUState *cs =env_cpu (env); -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs); ts->tp_value = newtls; }
linux-user/qemu.h +5 -0
@@ -162,6 +162,11 @@ typedef struct TaskState {uint64_t start_boottime; } TaskState; +static inline TaskState *get_task_state (CPUState *cs) +{ +return cs->opaque; +} +abi_long do_brk (abi_ulong new_brk);int do_guest_openat (CPUArchState *cpu_env,int dirfd,const char *pathname,int flags,mode_t mode,bool safe);
linux-user/signal-common.h +1 -1
@@ -113,7 +113,7 @@ int process_sigsuspend_mask(sigset_t **pset, target_ulong sigset,static inline void finish_sigsuspend_mask (int ret) {if (ret != -QEMU_ERESTARTSYS ) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu); ts->in_sigsuspend =1 ; } }
bsd-user/signal.c +10 -10
@@ -319,7 +319,7 @@ void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info)int block_signals (void ) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);sigset_t set;/*
@@ -359,7 +359,7 @@ void dump_core_and_abort(int target_sig) {CPUState *cpu = thread_cpu;CPUArchState *env =cpu_env (cpu); -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);int core_dumped =0 ;int host_sig;struct sigaction act;
@@ -421,7 +421,7 @@ void queue_signal(CPUArchState *env, int sig, int si_type, target_siginfo_t *info) {CPUState *cpu =env_cpu (env); -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);trace_user_queue_signal (env, sig);
@@ -476,7 +476,7 @@ void force_sig_fault(int sig, int code, abi_ulong addr)static void host_signal_handler (int host_sig,siginfo_t *info,void *puc) {CPUState *cpu = thread_cpu; -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);target_siginfo_t tinfo;ucontext_t *uc = puc;struct emulated_sigtable *k;
@@ -585,7 +585,7 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc)/* compare to kern/kern_sig.c sys_sigaltstack() and kern_sigaltstack() */ abi_long do_sigaltstack (abi_ulong uss_addr,abi_ulong uoss_addr,abi_ulong sp) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);int ret;target_stack_t oss;
@@ -714,7 +714,7 @@ int do_sigaction(int sig, const struct target_sigaction *act,static inline abi_ulong get_sigframe (struct target_sigaction *ka,CPUArchState *env,size_t frame_size) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);abi_ulong sp;/* Use default user stack */
@@ -789,7 +789,7 @@ static int reset_signal_mask(target_ucontext_t *ucontext)int i;sigset_t blocked;target_sigset_t target_set; -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);for (i =0 ; i <TARGET_NSIG_WORDS ; i++) {__get_user (target_set.__bits[i], &ucontext->uc_sigmask.__bits[i]);
@@ -839,7 +839,7 @@ badframe:void signal_init (void ) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);struct sigaction act;struct sigaction oact;int i;
@@ -878,7 +878,7 @@ static void handle_pending_signal(CPUArchState *env, int sig, struct emulated_sigtable *k) {CPUState *cpu =env_cpu (env); -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);struct target_sigaction *sa;int code;sigset_t set;
@@ -967,7 +967,7 @@ void process_pending_signals(CPUArchState *env)int sig;sigset_t *blocked_set, set;struct emulated_sigtable *k; -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);while (qatomic_read (&ts->signal_pending)) {sigfillset (&set);
gdbstub/user-target.c +2 -2
@@ -204,7 +204,7 @@ int gdb_target_signal_to_gdb(int sig)int gdb_get_cpu_index (CPUState *cpu) { -TaskState *ts = (TaskState *) cpu->opaque; +TaskState *ts =get_task_state (cpu);return ts ? ts->ts_tid :-1 ; }
@@ -399,7 +399,7 @@ void gdb_handle_query_xfer_exec_file(GArray *params, void *user_ctx)return ; } -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);if (!ts || !ts->bprm || !ts->bprm->filename) {gdb_put_packet ("E00" );return ;
linux-user/aarch64/cpu_loop.c +1 -1
@@ -189,7 +189,7 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) {ARMCPU *cpu =env_archcpu (env);CPUState *cs =env_cpu (env); -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs);struct image_info *info = ts->info;int i;
linux-user/arm/cpu_loop.c +2 -2
@@ -263,7 +263,7 @@ static bool insn_is_linux_bkpt(uint32_t opcode, bool is_thumb)static bool emulate_arm_fpa11 (CPUARMState *env,uint32_t opcode) { -TaskState *ts =env_cpu (env)->opaque; +TaskState *ts =get_task_state (env_cpu (env));int rc =EmulateAll (opcode, &ts->fpa, env);int raise, enabled;
@@ -514,7 +514,7 @@ void cpu_loop(CPUARMState *env)void target_cpu_copy_regs (CPUArchState *env,struct target_pt_regs *regs) {CPUState *cpu =env_cpu (env); -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);struct image_info *info = ts->info;int i;
linux-user/arm/signal.c +1 -1
@@ -177,7 +177,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, int usig,abi_ulong handler =0 ;abi_ulong handler_fdpic_GOT =0 ;abi_ulong retcode; -bool is_fdpic =info_is_fdpic (((TaskState *)thread_cpu->opaque)->info); +bool is_fdpic =info_is_fdpic (get_task_state (thread_cpu)->info);bool is_rt = ka->sa_flags &TARGET_SA_SIGINFO ;bool thumb;
linux-user/cris/cpu_loop.c +1 -1
@@ -72,7 +72,7 @@ void cpu_loop(CPUCRISState *env)void target_cpu_copy_regs (CPUArchState *env,struct target_pt_regs *regs) {CPUState *cpu =env_cpu (env); -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);struct image_info *info = ts->info; env->regs[0 ] = regs->r0;
linux-user/elfload.c +1 -1
@@ -4404,7 +4404,7 @@ static int wmr_write_region(void *opaque, target_ulong start,static int elf_core_dump (int signr,const CPUArchState *env) {const CPUState *cpu =env_cpu ((CPUArchState *)env); -const TaskState *ts = (const TaskState *)cpu->opaque; +const TaskState *ts = (const TaskState *)get_task_state ((CPUState *)cpu);struct rlimit dumpsize;CountAndSizeRegions css;off_t offset, note_offset, data_offset;
linux-user/hppa/signal.c +1 -1
@@ -112,7 +112,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,abi_ulong frame_addr, sp, haddr;struct target_rt_sigframe *frame;int i; -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu); sp =get_sp_from_cpustate (env);if ((ka->sa_flags &TARGET_SA_ONSTACK ) && !sas_ss_flags (sp)) {
linux-user/linuxload.c +1 -1
@@ -89,7 +89,7 @@ static int prepare_binprm(struct linux_binprm *bprm)abi_ulong loader_build_argptr (int envc,int argc,abi_ulong sp,abi_ulong stringp,int push_ptr) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);int n =sizeof (abi_ulong);abi_ulong envp;abi_ulong argv;
linux-user/m68k/cpu_loop.c +1 -1
@@ -95,7 +95,7 @@ void cpu_loop(CPUM68KState *env)void target_cpu_copy_regs (CPUArchState *env,struct target_pt_regs *regs) {CPUState *cpu =env_cpu (env); -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);struct image_info *info = ts->info; env->pc = regs->pc;
linux-user/mips/cpu_loop.c +1 -1
@@ -214,7 +214,7 @@ done_syscall:void target_cpu_copy_regs (CPUArchState *env,struct target_pt_regs *regs) {CPUState *cpu =env_cpu (env); -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);struct image_info *info = ts->info;int i;
linux-user/ppc/signal.c +2 -2
@@ -486,7 +486,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,int i, err =0 ;#if defined(TARGET_PPC64 )struct target_sigcontext *sc =0 ; -struct image_info *image = ((TaskState *)thread_cpu->opaque)->info; +struct image_info *image =get_task_state (thread_cpu)->info;#endif rt_sf_addr =get_sigframe (ka, env,sizeof (*rt_sf));
@@ -673,7 +673,7 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx, }if (uold_ctx) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);if (!lock_user_struct (VERIFY_WRITE , uctx, uold_ctx,1 )) {return -TARGET_EFAULT ;
linux-user/riscv/cpu_loop.c +1 -1
@@ -97,7 +97,7 @@ void cpu_loop(CPURISCVState *env)void target_cpu_copy_regs (CPUArchState *env,struct target_pt_regs *regs) {CPUState *cpu =env_cpu (env); -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);struct image_info *info = ts->info; env->pc = regs->sepc;
linux-user/signal.c +15 -15
@@ -172,7 +172,7 @@ void target_to_host_old_sigset(sigset_t *sigset,int block_signals (void ) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);sigset_t set;/* It's OK to block everything including SIGSEGV, because we won't
@@ -194,7 +194,7 @@ int block_signals(void)*/ int do_sigprocmask (int how,const sigset_t *set,sigset_t *oldset) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);if (oldset) { *oldset = ts->signal_mask;
@@ -237,7 +237,7 @@ int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset)*/ void set_sigmask (const sigset_t *set) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu); ts->signal_mask = *set; }
@@ -246,7 +246,7 @@ void set_sigmask(const sigset_t *set)int on_sig_stack (unsigned long sp) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);return (sp - ts->sigaltstack_used.ss_sp < ts->sigaltstack_used.ss_size);
@@ -254,7 +254,7 @@ int on_sig_stack(unsigned long sp)int sas_ss_flags (unsigned long sp) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);return (ts->sigaltstack_used.ss_size ==0 ?SS_DISABLE :on_sig_stack (sp) ?SS_ONSTACK :0 );
@@ -265,7 +265,7 @@ abi_ulong target_sigsp(abi_ulong sp, struct target_sigaction *ka)/* * This is the X/Open sanctioned signal stack switching. */ -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);if ((ka->sa_flags &TARGET_SA_ONSTACK ) && !sas_ss_flags (sp)) {return ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size;
@@ -275,7 +275,7 @@ abi_ulong target_sigsp(abi_ulong sp, struct target_sigaction *ka)void target_save_altstack (target_stack_t *uss,CPUArchState *env) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);__put_user (ts->sigaltstack_used.ss_sp, &uss->ss_sp);__put_user (sas_ss_flags (get_sp_from_cpustate (env)), &uss->ss_flags);
@@ -284,7 +284,7 @@ void target_save_altstack(target_stack_t *uss, CPUArchState *env)abi_long target_restore_altstack (target_stack_t *uss,CPUArchState *env) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);size_t minstacksize =TARGET_MINSIGSTKSZ ;target_stack_t ss;
@@ -571,7 +571,7 @@ static void signal_table_init(void)void signal_init (void ) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);struct sigaction act, oact;/* initialize signal conversion tables */
@@ -730,7 +730,7 @@ static G_NORETURNvoid dump_core_and_abort (CPUArchState *env,int target_sig) {CPUState *cpu =env_cpu (env); -TaskState *ts = (TaskState *)cpu->opaque; +TaskState *ts =get_task_state (cpu);int host_sig, core_dumped =0 ;/* On exit, undo the remapping of SIGABRT. */
@@ -769,7 +769,7 @@ void queue_signal(CPUArchState *env, int sig, int si_type, target_siginfo_t *info) {CPUState *cpu =env_cpu (env); -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);trace_user_queue_signal (env, sig);
@@ -954,7 +954,7 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) {CPUState *cpu = thread_cpu;CPUArchState *env =cpu_env (cpu); -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);target_siginfo_t tinfo;host_sigcontext *uc = puc;struct emulated_sigtable *k;
@@ -1174,7 +1174,7 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig,sigset_t set;target_sigset_t target_old_set;struct target_sigaction *sa; -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);trace_user_handle_signal (cpu_env, sig);/* dequeue signal */
@@ -1256,7 +1256,7 @@ void process_pending_signals(CPUArchState *cpu_env) {CPUState *cpu =env_cpu (cpu_env);int sig; -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);sigset_t set;sigset_t *blocked_set;
@@ -1316,7 +1316,7 @@ void process_pending_signals(CPUArchState *cpu_env)int process_sigsuspend_mask (sigset_t **pset,target_ulong sigset,target_ulong sigsize) { -TaskState *ts = (TaskState *)thread_cpu->opaque; +TaskState *ts =get_task_state (thread_cpu);sigset_t *host_set = &ts->sigsuspend_mask;target_sigset_t *target_sigset;
linux-user/syscall.c +13 -13
@@ -6515,7 +6515,7 @@ static void *clone_func(void *arg) env = info->env; cpu =env_cpu (env); thread_cpu = cpu; - ts = (TaskState *)cpu->opaque; + ts =get_task_state (cpu); info->tid =sys_gettid ();task_settid (ts);if (info->child_tidptr)
@@ -6557,7 +6557,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, flags &= ~(CLONE_VFORK |CLONE_VM );if (flags &CLONE_VM ) { -TaskState *parent_ts = (TaskState *)cpu->opaque; +TaskState *parent_ts =get_task_state (cpu);new_thread_info info;pthread_attr_t attr;
@@ -6680,7 +6680,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,put_user_u32 (sys_gettid (), child_tidptr);if (flags &CLONE_PARENT_SETTID )put_user_u32 (sys_gettid (), parent_tidptr); - ts = (TaskState *)cpu->opaque; + ts =get_task_state (cpu);if (flags &CLONE_SETTLS )cpu_set_tls (env, newtls);if (flags &CLONE_CHILD_CLEARTID )
@@ -7946,7 +7946,7 @@ int host_to_target_waitstatus(int status)static int open_self_cmdline (CPUArchState *cpu_env,int fd) {CPUState *cpu =env_cpu (cpu_env); -struct linux_binprm *bprm = ((TaskState *)cpu->opaque)->bprm; +struct linux_binprm *bprm =get_task_state (cpu)->bprm;int i;for (i =0 ; i < bprm->argc; i++) {
@@ -8146,7 +8146,7 @@ static int open_self_smaps(CPUArchState *cpu_env, int fd)static int open_self_stat (CPUArchState *cpu_env,int fd) {CPUState *cpu =env_cpu (cpu_env); -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);g_autoptr (GString) buf =g_string_new (NULL );int i;
@@ -8187,7 +8187,7 @@ static int open_self_stat(CPUArchState *cpu_env, int fd)static int open_self_auxv (CPUArchState *cpu_env,int fd) {CPUState *cpu =env_cpu (cpu_env); -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);abi_ulong auxv = ts->info->saved_auxv;abi_ulong len = ts->info->auxv_len;char *ptr;
@@ -9012,7 +9012,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,pthread_mutex_lock (&clone_lock);if (CPU_NEXT (first_cpu)) { -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);if (ts->child_tidptr) {put_user_u32 (0 , ts->child_tidptr);
@@ -9439,7 +9439,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_pause/* not on alpha */ case TARGET_NR_pause:if (!block_signals ()) { -sigsuspend (&((TaskState *)cpu->opaque)->signal_mask); +sigsuspend (&get_task_state (cpu)->signal_mask); }return -TARGET_EINTR ;#endif
@@ -10005,7 +10005,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,sigset_t *set;#if defined(TARGET_ALPHA ) -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);/* target_to_host_old_sigset will bswap back */ abi_ulong mask =tswapal (arg1); set = &ts->sigsuspend_mask;
@@ -10406,7 +10406,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,case TARGET_NR_mprotect: arg1 =cpu_untagged_addr (cpu, arg1); { -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);/* Special hack to detect libc making the stack executable. */ if ((arg3 &PROT_GROWSDOWN ) && arg1 >= ts->info->stack_limit
@@ -12537,7 +12537,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,return do_set_thread_area (cpu_env, arg1);#elif defined(TARGET_M68K ) { -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu); ts->tp_value = arg1;return 0 ; }
@@ -12551,7 +12551,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,return do_get_thread_area (cpu_env, arg1);#elif defined(TARGET_M68K ) { -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu);return ts->tp_value; }#else
@@ -12676,7 +12676,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_set_tid_address)case TARGET_NR_set_tid_address: { -TaskState *ts = cpu->opaque; +TaskState *ts =get_task_state (cpu); ts->child_tidptr = arg1;/* do not call host set_tid_address() syscall, instead return tid() */ return get_errno (sys_gettid ());
linux-user/vm86.c +9 -9
@@ -74,7 +74,7 @@ static inline unsigned int vm_getl(CPUX86State *env,void save_v86_state (CPUX86State *env) {CPUState *cs =env_cpu (env); -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs);struct target_vm86plus_struct * target_v86;if (!lock_user_struct (VERIFY_WRITE , target_v86, ts->target_v86,0 ))
@@ -134,7 +134,7 @@ static inline void return_to_32bit(CPUX86State *env, int retval)static inline int set_IF (CPUX86State *env) {CPUState *cs =env_cpu (env); -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs); ts->v86flags |=VIF_MASK ;if (ts->v86flags &VIP_MASK ) {
@@ -147,7 +147,7 @@ static inline int set_IF(CPUX86State *env)static inline void clear_IF (CPUX86State *env) {CPUState *cs =env_cpu (env); -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs); ts->v86flags &= ~VIF_MASK ; }
@@ -165,7 +165,7 @@ static inline void clear_AC(CPUX86State *env)static inline int set_vflags_long (unsigned long eflags,CPUX86State *env) {CPUState *cs =env_cpu (env); -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs);set_flags (ts->v86flags, eflags, ts->v86mask);set_flags (env->eflags, eflags,SAFE_MASK );
@@ -179,7 +179,7 @@ static inline int set_vflags_long(unsigned long eflags, CPUX86State *env)static inline int set_vflags_short (unsigned short flags,CPUX86State *env) {CPUState *cs =env_cpu (env); -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs);set_flags (ts->v86flags, flags, ts->v86mask &0xffff );set_flags (env->eflags, flags,SAFE_MASK );
@@ -193,7 +193,7 @@ static inline int set_vflags_short(unsigned short flags, CPUX86State *env)static inline unsigned int get_vflags (CPUX86State *env) {CPUState *cs =env_cpu (env); -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs);unsigned int flags; flags = env->eflags &RETURN_MASK ;
@@ -210,7 +210,7 @@ static inline unsigned int get_vflags(CPUX86State *env)static void do_int (CPUX86State *env,int intno) {CPUState *cs =env_cpu (env); -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs);uint32_t int_addr, segoffs, ssp;unsigned int sp;
@@ -269,7 +269,7 @@ void handle_vm86_trap(CPUX86State *env, int trapno)void handle_vm86_fault (CPUX86State *env) {CPUState *cs =env_cpu (env); -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs);uint32_t csp, ssp;unsigned int ip, sp, newflags, newip, newcs, opcode, intno;int data32, pref_done;
@@ -394,7 +394,7 @@ void handle_vm86_fault(CPUX86State *env)int do_vm86 (CPUX86State *env,long subfunction,abi_ulong vm86_addr) {CPUState *cs =env_cpu (env); -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs);struct target_vm86plus_struct * target_v86;int ret;
linux-user/xtensa/signal.c +1 -1
@@ -157,7 +157,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, {abi_ulong frame_addr;struct target_rt_sigframe *frame; -int is_fdpic =info_is_fdpic (((TaskState *)thread_cpu->opaque)->info); +int is_fdpic =info_is_fdpic (get_task_state (thread_cpu)->info);abi_ulong handler =0 ;abi_ulong handler_fdpic_GOT =0 ;uint32_t ra;
plugins/api.c +4 -4
@@ -378,7 +378,7 @@ const char *qemu_plugin_path_to_binary(void) {char *path =NULL ;#ifdef CONFIG_USER_ONLY -TaskState *ts = (TaskState *) current_cpu->opaque; +TaskState *ts =get_task_state (current_cpu); path =g_strdup (ts->bprm->filename);#endif return path;
@@ -388,7 +388,7 @@ uint64_t qemu_plugin_start_code(void) {uint64_t start =0 ;#ifdef CONFIG_USER_ONLY -TaskState *ts = (TaskState *) current_cpu->opaque; +TaskState *ts =get_task_state (current_cpu); start = ts->info->start_code;#endif return start;
@@ -398,7 +398,7 @@ uint64_t qemu_plugin_end_code(void) {uint64_t end =0 ;#ifdef CONFIG_USER_ONLY -TaskState *ts = (TaskState *) current_cpu->opaque; +TaskState *ts =get_task_state (current_cpu); end = ts->info->end_code;#endif return end;
@@ -408,7 +408,7 @@ uint64_t qemu_plugin_entry_code(void) {uint64_t entry =0 ;#ifdef CONFIG_USER_ONLY -TaskState *ts = (TaskState *) current_cpu->opaque; +TaskState *ts =get_task_state (current_cpu); entry = ts->info->entry;#endif return entry;
semihosting/arm-compat-semi.c +4 -4
@@ -214,7 +214,7 @@ static target_ulong syscall_err;static inline uint32_t get_swi_errno (CPUState *cs) {#ifdef CONFIG_USER_ONLY -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs);return ts->swi_errno;#else
@@ -226,7 +226,7 @@ static void common_semi_cb(CPUState *cs, uint64_t ret, int err) {if (err) {#ifdef CONFIG_USER_ONLY -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs); ts->swi_errno = err;#else syscall_err = err;
@@ -586,7 +586,7 @@ void do_common_semihosting(CPUState *cs)#if !defined(CONFIG_USER_ONLY )const char *cmdline;#else -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs);#endif GET_ARG (0 );GET_ARG (1 );
@@ -664,7 +664,7 @@ void do_common_semihosting(CPUState *cs)target_ulong retvals[4 ];int i;#ifdef CONFIG_USER_ONLY -TaskState *ts = cs->opaque; +TaskState *ts =get_task_state (cs);target_ulong limit;#else LayoutInfo info =common_semi_find_bases (cs);
Signature · 1 line
2.39.2
[PULL 14/29] plugins: scoreboard API
In reply to Alex BennéeFrom: Pierrick Bouvier <[email protected]>
We introduce a cpu local storage, automatically managed (and extended) by QEMU itself. Plugin allocate a scoreboard, and don't have to deal with how many cpus are launched.
This API will be used by new inline functions but callbacks can benefit from this as well. This way, they can operate without a global lock for simple operations.
At any point during execution, any scoreboard will be dimensioned with at least qemu_plugin_num_vcpus entries.
New functions:
- qemu_plugin_scoreboard_find
- qemu_plugin_scoreboard_free
- qemu_plugin_scoreboard_new
Message-Id: <[email protected]>
Message-Id: <[email protected]>
include/qemu/plugin.h +6 -0
@@ -112,6 +112,12 @@ struct qemu_plugin_insn {bool mem_only; }; +/* A scoreboard is an array of values, indexed by vcpu_index */ +struct qemu_plugin_scoreboard { +GArray *data; +QLIST_ENTRY (qemu_plugin_scoreboard) entry; +}; +/* * qemu_plugin_insn allocate and cleanup functions. We don't expect to * cleanup many of these structures. They are reused for each fresh
include/qemu/qemu-plugin.h +31 -0
@@ -222,6 +222,8 @@ void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id,struct qemu_plugin_tb ;/** struct qemu_plugin_insn - Opaque handle for a translated instruction */ struct qemu_plugin_insn ; +/** struct qemu_plugin_scoreboard - Opaque handle for a scoreboard */ +struct qemu_plugin_scoreboard ;/** * enum qemu_plugin_cb_flags - type of callback
@@ -752,5 +754,34 @@ QEMU_PLUGIN_APIint qemu_plugin_read_register (struct qemu_plugin_register *handle,GByteArray *buf); +/** +* qemu_plugin_scoreboard_new() - alloc a new scoreboard +* +* @element_size: size (in bytes) for one entry +* +* Returns a pointer to a new scoreboard. It must be freed using +* qemu_plugin_scoreboard_free. +*/ +QEMU_PLUGIN_API +struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_size); + +/** +* qemu_plugin_scoreboard_free() - free a scoreboard +* @score: scoreboard to free +*/ +QEMU_PLUGIN_API +void qemu_plugin_scoreboard_free(struct qemu_plugin_scoreboard *score); + +/** +* qemu_plugin_scoreboard_find() - get pointer to an entry of a scoreboard +* @score: scoreboard to query +* @vcpu_index: entry index +* +* Returns address of entry of a scoreboard matching a given vcpu_index. This +* address can be modified later if scoreboard is resized. +*/ +QEMU_PLUGIN_API +void *qemu_plugin_scoreboard_find(struct qemu_plugin_scoreboard *score, +unsigned int vcpu_index);#endif /* QEMU_QEMU_PLUGIN_H */
plugins/plugin.h +6 -0
@@ -31,6 +31,8 @@ struct qemu_plugin_state {* but with the HT we avoid adding a field to CPUState. */ GHashTable *cpu_ht; + QLIST_HEAD(, qemu_plugin_scoreboard) scoreboards; +size_t scoreboard_alloc_size;DECLARE_BITMAP (mask,QEMU_PLUGIN_EV_MAX );/* * @lock protects the struct as well as ctx->uninstalling.
@@ -101,4 +103,8 @@ void exec_inline_op(struct qemu_plugin_dyn_cb *cb);int plugin_num_vcpus (void ); +struct qemu_plugin_scoreboard *plugin_scoreboard_new (size_t element_size); + +void plugin_scoreboard_free (struct qemu_plugin_scoreboard *score); +#endif /* PLUGIN_H */
plugins/api.c +19 -0
@@ -465,3 +465,22 @@ int qemu_plugin_read_register(struct qemu_plugin_register *reg, GByteArray *buf)return gdb_read_register (current_cpu, buf,GPOINTER_TO_INT (reg)); } + +struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new (size_t element_size) +{ +return plugin_scoreboard_new (element_size); +} + +void qemu_plugin_scoreboard_free (struct qemu_plugin_scoreboard *score) +{ +plugin_scoreboard_free (score); +} + +void *qemu_plugin_scoreboard_find (struct qemu_plugin_scoreboard *score, +unsigned int vcpu_index) +{ +g_assert (vcpu_index <qemu_plugin_num_vcpus ()); +/* we can't use g_array_index since entry size is not statically known */ +char *base_ptr = score->data->data; +return base_ptr + vcpu_index *g_array_get_element_size (score->data); +}
plugins/core.c +57 -0
84 lines not on this page · raw message
plugins/qemu-plugins.symbols +3 -0
@@ -37,6 +37,9 @@ qemu_plugin_register_vcpu_tb_exec_inline; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; + qemu_plugin_scoreboard_free; + qemu_plugin_scoreboard_find; + qemu_plugin_scoreboard_new; qemu_plugin_start_code; qemu_plugin_tb_get_insn; qemu_plugin_tb_n_insns;
Signature · 1 line
2.39.2
[PULL 10/29] gdbstub: Introduce gdb_handle_set_thread_user()
In reply to Alex BennéeFrom: Ilya Leoshkevich <[email protected]>
The upcoming follow-fork-mode child support needs to perform certain actions when GDB switches between the stopped parent and the stopped child. Introduce a user-specific hook for this.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
gdbstub/internals.h +1 -0
@@ -197,6 +197,7 @@ void gdb_handle_v_file_readlink(GArray *params, void *user_ctx); /* user */void gdb_handle_query_xfer_exec_file (GArray *params,void *user_ctx);/* user */ void gdb_handle_set_catch_syscalls (GArray *params,void *user_ctx);/* user */ void gdb_handle_query_supported_user (const char *gdb_supported);/* user */ +bool gdb_handle_set_thread_user (uint32_t pid,uint32_t tid);/* user */ void gdb_handle_query_attached (GArray *params,void *user_ctx);/* both */
gdbstub/gdbstub.c +9 -2
@@ -1099,6 +1099,7 @@ static void handle_cont_with_sig(GArray *params, void *user_ctx)static void handle_set_thread (GArray *params,void *user_ctx) { +uint32_t pid, tid;CPUState *cpu;if (params->len !=2 ) {
@@ -1116,8 +1117,14 @@ static void handle_set_thread(GArray *params, void *user_ctx)return ; } - cpu =gdb_get_cpu (get_param (params,1 )->thread_id.pid, -get_param (params,1 )->thread_id.tid); + pid =get_param (params,1 )->thread_id.pid; + tid =get_param (params,1 )->thread_id.tid; +#ifdef CONFIG_USER_ONLY +if (gdb_handle_set_thread_user (pid, tid)) { +return ; + } +#endif + cpu =gdb_get_cpu (pid, tid);if (!cpu) {gdb_put_packet ("E22" );return ;
gdbstub/user.c +5 -0
@@ -386,6 +386,11 @@ void gdb_handle_query_supported_user(const char *gdb_supported) { } +bool gdb_handle_set_thread_user (uint32_t pid,uint32_t tid) +{ +return false; +} +/* * Execution state helpers */
Signature · 1 line
2.39.2
[PULL 17/29] plugins: add inline operation per vcpu
In reply to Alex BennéeFrom: Pierrick Bouvier <[email protected]>
Extends API with three new functions:
qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline_per_vcpu().
Those functions takes a qemu_plugin_u64 as input.
This allows to have a thread-safe and type-safe version of inline operations.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
include/qemu/plugin.h +1 -0
@@ -92,6 +92,7 @@ struct qemu_plugin_dyn_cb {/* fields specific to each dyn_cb type go here */ union {struct { +qemu_plugin_u64 entry;enum qemu_plugin_op op;uint64_t imm; } inline_insn;
include/qemu/qemu-plugin.h +50 -1
69 lines not on this page · raw message
plugins/plugin.h +6 -0
@@ -73,6 +73,12 @@ void plugin_register_inline_op(GArray **arr, enum qemu_plugin_op op, void *ptr, uint64_t imm); +void plugin_register_inline_op_on_entry (GArray **arr, +enum qemu_plugin_mem_rw rw, +enum qemu_plugin_op op, +qemu_plugin_u64 entry, +uint64_t imm); +void plugin_reset_uninstall (qemu_plugin_id_t id,qemu_plugin_simple_cb_t cb,bool reset);
accel/tcg/plugin-gen.c +7 -0
@@ -443,6 +443,13 @@ static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb,char *ptr = cb->userp;size_t elem_size =0 ;size_t offset =0 ; +if (!ptr) { +/* use inline entry */ + ptr = cb->inline_insn.entry.score->data->data; + elem_size =g_array_get_element_size (cb->inline_insn.entry.score->data); + offset = cb->inline_insn.entry.offset; + } + op =copy_ld_i32 (&begin_op, op); op =copy_mul_i32 (&begin_op, op, elem_size); op =copy_ext_i32_ptr (&begin_op, op);
plugins/api.c +36 -1
@@ -111,6 +111,18 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, } } +void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu ( +struct qemu_plugin_tb *tb, +enum qemu_plugin_op op, +qemu_plugin_u64 entry, +uint64_t imm) +{ +if (!tb->mem_only) { +plugin_register_inline_op_on_entry ( + &tb->cbs[PLUGIN_CB_INLINE ],0 , op, entry, imm); + } +} + void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flags,
@@ -136,6 +148,18 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, } } +void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu ( +struct qemu_plugin_insn *insn, +enum qemu_plugin_op op, +qemu_plugin_u64 entry, +uint64_t imm) +{ +if (!insn->mem_only) { +plugin_register_inline_op_on_entry ( + &insn->cbs[PLUGIN_CB_INSN ][PLUGIN_CB_INLINE ],0 , op, entry, imm); + } +} +/* * We always plant memory instrumentation because they don't finalise until
@@ -148,7 +172,7 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, void *udata) {plugin_register_vcpu_mem_cb (&insn->cbs[PLUGIN_CB_MEM ][PLUGIN_CB_REGULAR ], - cb, flags, rw, udata); + cb, flags, rw, udata); } void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn,
@@ -160,6 +184,17 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, rw, op, ptr, imm); } +void qemu_plugin_register_vcpu_mem_inline_per_vcpu ( +struct qemu_plugin_insn *insn, +enum qemu_plugin_mem_rw rw, +enum qemu_plugin_op op, +qemu_plugin_u64 entry, +uint64_t imm) +{ +plugin_register_inline_op_on_entry ( + &insn->cbs[PLUGIN_CB_MEM ][PLUGIN_CB_INLINE ], rw, op, entry, imm); +} +void qemu_plugin_register_vcpu_tb_trans_cb (qemu_plugin_id_t id,qemu_plugin_vcpu_tb_trans_cb_t cb) {
plugins/core.c +23 -0
@@ -332,6 +332,23 @@ void plugin_register_inline_op(GArray **arr, dyn_cb->inline_insn.imm = imm; } +void plugin_register_inline_op_on_entry (GArray **arr, +enum qemu_plugin_mem_rw rw, +enum qemu_plugin_op op, +qemu_plugin_u64 entry, +uint64_t imm) +{ +struct qemu_plugin_dyn_cb *dyn_cb; + + dyn_cb =plugin_get_dyn_cb (arr); + dyn_cb->userp =NULL ; + dyn_cb->type =PLUGIN_CB_INLINE ; + dyn_cb->rw = rw; + dyn_cb->inline_insn.entry = entry; + dyn_cb->inline_insn.op = op; + dyn_cb->inline_insn.imm = imm; +} + void plugin_register_dyn_cb__udata(GArray **arr, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flags,
@@ -480,6 +497,12 @@ void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index)char *ptr = cb->userp;size_t elem_size =0 ;size_t offset =0 ; +if (!ptr) { +/* use inline entry */ + ptr = cb->inline_insn.entry.score->data->data; + elem_size =g_array_get_element_size (cb->inline_insn.entry.score->data); + offset = cb->inline_insn.entry.offset; + }uint64_t *val = (uint64_t *)(ptr + offset + cpu_index * elem_size);switch (cb->inline_insn.op) {
plugins/qemu-plugins.symbols +3 -0
@@ -28,13 +28,16 @@ qemu_plugin_register_vcpu_init_cb; qemu_plugin_register_vcpu_insn_exec_cb; qemu_plugin_register_vcpu_insn_exec_inline; + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu; qemu_plugin_register_vcpu_mem_cb; qemu_plugin_register_vcpu_mem_inline; + qemu_plugin_register_vcpu_mem_inline_per_vcpu; qemu_plugin_register_vcpu_resume_cb; qemu_plugin_register_vcpu_syscall_cb; qemu_plugin_register_vcpu_syscall_ret_cb; qemu_plugin_register_vcpu_tb_exec_cb; qemu_plugin_register_vcpu_tb_exec_inline; + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; qemu_plugin_scoreboard_free;
Signature · 1 line
2.39.2
[PULL 25/29] plugins: cleanup codepath for previous inline operation
In reply to Alex BennéeFrom: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
Message-Id: <[email protected]>
plugins/plugin.h +0 -5
@@ -68,11 +68,6 @@ struct qemu_plugin_ctx {struct qemu_plugin_ctx *plugin_id_to_ctx_locked (qemu_plugin_id_t id); -void plugin_register_inline_op (GArray **arr, -enum qemu_plugin_mem_rw rw, -enum qemu_plugin_op op,void *ptr, -uint64_t imm); - void plugin_register_inline_op_on_entry(GArray **arr, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op,
accel/tcg/plugin-gen.c +4 -9
@@ -440,15 +440,10 @@ static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) { -char *ptr = cb->userp; -size_t elem_size =0 ; -size_t offset =0 ; -if (!ptr) { -/* use inline entry */ - ptr = cb->inline_insn.entry.score->data->data; - elem_size =g_array_get_element_size (cb->inline_insn.entry.score->data); - offset = cb->inline_insn.entry.offset; - } +char *ptr = cb->inline_insn.entry.score->data->data; +size_t elem_size =g_array_get_element_size ( + cb->inline_insn.entry.score->data); +size_t offset = cb->inline_insn.entry.offset; op =copy_ld_i32 (&begin_op, op); op =copy_mul_i32 (&begin_op, op, elem_size);
plugins/core.c +4 -25
@@ -316,22 +316,6 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GArray **arr) return &g_array_index(cbs, struct qemu_plugin_dyn_cb, cbs->len - 1); } -void plugin_register_inline_op (GArray **arr, -enum qemu_plugin_mem_rw rw, -enum qemu_plugin_op op, -void *ptr, -uint64_t imm) -{ -struct qemu_plugin_dyn_cb *dyn_cb; - - dyn_cb =plugin_get_dyn_cb (arr); - dyn_cb->userp = ptr; - dyn_cb->type =PLUGIN_CB_INLINE ; - dyn_cb->rw = rw; - dyn_cb->inline_insn.op = op; - dyn_cb->inline_insn.imm = imm; -} - void plugin_register_inline_op_on_entry(GArray **arr, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op,
@@ -494,15 +478,10 @@ void qemu_plugin_flush_cb(void)void exec_inline_op (struct qemu_plugin_dyn_cb *cb,int cpu_index) { -char *ptr = cb->userp; -size_t elem_size =0 ; -size_t offset =0 ; -if (!ptr) { -/* use inline entry */ - ptr = cb->inline_insn.entry.score->data->data; - elem_size =g_array_get_element_size (cb->inline_insn.entry.score->data); - offset = cb->inline_insn.entry.offset; - } +char *ptr = cb->inline_insn.entry.score->data->data; +size_t elem_size =g_array_get_element_size ( + cb->inline_insn.entry.score->data); +size_t offset = cb->inline_insn.entry.offset;uint64_t *val = (uint64_t *)(ptr + offset + cpu_index * elem_size);switch (cb->inline_insn.op) {
Signature · 1 line
2.39.2
[PULL 29/29] target/riscv: honour show_opcodes when disassembling
In reply to Alex BennéeThis makes the output suitable when used for plugins.
Message-Id: <[email protected]>
disas/riscv.c +15 -13
@@ -5192,19 +5192,21 @@ print_insn_riscv(bfd_vma memaddr, struct disassemble_info *info, rv_isa isa) } } -switch (len) { -case 2 : - (*info->fprintf_func)(info->stream,INST_FMT_2 , inst); -break ; -case 4 : - (*info->fprintf_func)(info->stream,INST_FMT_4 , inst); -break ; -case 6 : - (*info->fprintf_func)(info->stream,INST_FMT_6 , inst); -break ; -default : - (*info->fprintf_func)(info->stream,INST_FMT_8 , inst); -break ; +if (info->show_opcodes) { +switch (len) { +case 2 : + (*info->fprintf_func)(info->stream,INST_FMT_2 , inst); +break ; +case 4 : + (*info->fprintf_func)(info->stream,INST_FMT_4 , inst); +break ; +case 6 : + (*info->fprintf_func)(info->stream,INST_FMT_6 , inst); +break ; +default : + (*info->fprintf_func)(info->stream,INST_FMT_8 , inst); +break ; + } } disasm_inst(buf, sizeof(buf), isa, memaddr, inst,
Signature · 1 line
2.39.2
[PULL 22/29] contrib/plugins/hotblocks: migrate to new per_vcpu API
In reply to Alex BennéeFrom: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
Message-Id: <[email protected]>
contrib/plugins/hotblocks.c +30 -20
@@ -34,8 +34,8 @@ static guint64 limit = 20;*/ typedef struct {uint64_t start_addr; -uint64_t exec_count; -int trans_count; +struct qemu_plugin_scoreboard *exec_count; +int trans_count;unsigned long insns; }ExecCount ;
@@ -43,7 +43,17 @@ static gint cmp_exec_count(gconstpointer a, gconstpointer b) {ExecCount *ea = (ExecCount *) a;ExecCount *eb = (ExecCount *) b; -return ea->exec_count > eb->exec_count ?-1 :1 ; +uint64_t count_a = +qemu_plugin_u64_sum (qemu_plugin_scoreboard_u64 (ea->exec_count)); +uint64_t count_b = +qemu_plugin_u64_sum (qemu_plugin_scoreboard_u64 (eb->exec_count)); +return count_a > count_b ?-1 :1 ; +} + +static void exec_count_free (gpointer key,gpointer value,gpointer user_data) +{ +ExecCount *cnt = value; +qemu_plugin_scoreboard_free (cnt->exec_count); }static void plugin_exit (qemu_plugin_id_t id,void *p)
@@ -52,7 +62,6 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)GList *counts, *it;int i; -g_mutex_lock (&lock);g_string_append_printf (report,"%d entries in the hash table\n" ,g_hash_table_size (hotblocks)); counts =g_hash_table_get_values (hotblocks);
@@ -63,16 +72,21 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)for (i =0 ; i < limit && it->next; i++, it = it->next) {ExecCount *rec = (ExecCount *) it->data; -g_string_append_printf (report,"0x%016" PRIx64", %d, %ld, %" PRId64"\n" , - rec->start_addr, rec->trans_count, - rec->insns, rec->exec_count); +g_string_append_printf ( + report,"0x%016" PRIx64", %d, %ld, %" PRId64"\n" , + rec->start_addr, rec->trans_count, + rec->insns, +qemu_plugin_u64_sum ( +qemu_plugin_scoreboard_u64 (rec->exec_count))); }g_list_free (it); } -g_mutex_unlock (&lock);qemu_plugin_outs (report->str); + +g_hash_table_foreach (hotblocks, exec_count_free,NULL ); +g_hash_table_destroy (hotblocks); }static void plugin_init (void )
@@ -82,15 +96,9 @@ static void plugin_init(void)static void vcpu_tb_exec (unsigned int cpu_index,void *udata) { -ExecCount *cnt; -uint64_t hash = (uint64_t ) udata; - -g_mutex_lock (&lock); - cnt = (ExecCount *)g_hash_table_lookup (hotblocks, (gconstpointer ) hash); -/* should always succeed */ -g_assert (cnt); - cnt->exec_count++; -g_mutex_unlock (&lock); +ExecCount *cnt = (ExecCount *)udata; +qemu_plugin_u64_add (qemu_plugin_scoreboard_u64 (cnt->exec_count), + cpu_index,1 ); }/*
@@ -114,18 +122,20 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) cnt->start_addr = pc; cnt->trans_count =1 ; cnt->insns = insns; + cnt->exec_count =qemu_plugin_scoreboard_new (sizeof (uint64_t ));g_hash_table_insert (hotblocks, (gpointer ) hash, (gpointer ) cnt); }g_mutex_unlock (&lock);if (do_inline) { -qemu_plugin_register_vcpu_tb_exec_inline (tb,QEMU_PLUGIN_INLINE_ADD_U64 , - &cnt->exec_count,1 ); +qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu ( + tb,QEMU_PLUGIN_INLINE_ADD_U64 , +qemu_plugin_scoreboard_u64 (cnt->exec_count),1 ); }else {qemu_plugin_register_vcpu_tb_exec_cb (tb, vcpu_tb_exec,QEMU_PLUGIN_CB_NO_REGS , - (void *)hash); + (void *)cnt); } }
Signature · 1 line
2.39.2
[PULL 20/29] tests/plugin/insn: migrate to new per_vcpu API
In reply to Alex BennéeFrom: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
Message-Id: <[email protected]>
tests/plugin/insn.c +50 -56
@@ -16,25 +16,21 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; -#define MAX_CPUS 8/* lets not go nuts */ - -typedef struct { -uint64_t insn_count; -}InstructionCount ; - -static InstructionCount counts[MAX_CPUS ]; -static uint64_t inline_insn_count; +static qemu_plugin_u64 insn_count;static bool do_inline;static bool do_size;static GArray *sizes; +typedef struct { +uint64_t hits; +uint64_t last_hit; +uint64_t total_delta; +}MatchCount ; +typedef struct {char *match_string; -uint64_t hits[MAX_CPUS ]; -uint64_t last_hit[MAX_CPUS ]; -uint64_t total_delta[MAX_CPUS ]; -GPtrArray *history[MAX_CPUS ]; +struct qemu_plugin_scoreboard *counts;/* MatchCount */ }Match ;static GArray *matches;
@@ -67,41 +63,40 @@ static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index)static void vcpu_insn_exec_before (unsigned int cpu_index,void *udata) { -unsigned int i = cpu_index %MAX_CPUS ; -InstructionCount *c = &counts[i]; - - c->insn_count++; +qemu_plugin_u64_add (insn_count, cpu_index,1 ); }static void vcpu_insn_matched_exec_before (unsigned int cpu_index,void *udata) { -unsigned int i = cpu_index %MAX_CPUS ;Instruction *insn = (Instruction *) udata; -Match *match = insn->match; +Match *insn_match = insn->match; +MatchCount *match =qemu_plugin_scoreboard_find (insn_match->counts, + cpu_index); +g_autoptr (GString) ts =g_string_new ("" ); insn->hits++;g_string_append_printf (ts,"0x%" PRIx64", '%s', %" PRId64" hits" , insn->vaddr, insn->disas, insn->hits); -uint64_t icount = counts[i].insn_count; -uint64_t delta = icount - match->last_hit[i]; +uint64_t icount =qemu_plugin_u64_get (insn_count, cpu_index); +uint64_t delta = icount - match->last_hit; - match->hits[i]++; - match->total_delta[i] += delta; + match->hits++; + match->total_delta += delta;g_string_append_printf (ts, -", %" PRId64" match hits, " -"Δ+%" PRId64" since last match," +" , cpu %u," +" %" PRId64" match hits," +" Δ+%" PRId64" since last match," " %" PRId64" avg insns/match\n" , - match->hits[i], delta, - match->total_delta[i] / match->hits[i]); + cpu_index, + match->hits, delta, + match->total_delta / match->hits); - match->last_hit[i] = icount; + match->last_hit = icount;qemu_plugin_outs (ts->str); - -g_ptr_array_add (match->history[i], insn); }static void vcpu_tb_trans (qemu_plugin_id_t id,struct qemu_plugin_tb *tb)
@@ -113,8 +108,8 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)struct qemu_plugin_insn *insn =qemu_plugin_tb_get_insn (tb, i);if (do_inline) { -qemu_plugin_register_vcpu_insn_exec_inline ( - insn,QEMU_PLUGIN_INLINE_ADD_U64 , &inline_insn_count,1 ); +qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu ( + insn,QEMU_PLUGIN_INLINE_ADD_U64 , insn_count,1 ); }else {uint64_t vaddr =qemu_plugin_insn_vaddr (insn); qemu_plugin_register_vcpu_insn_exec_cb(
@@ -136,10 +131,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)* information about the instruction which we also need to * save if there is a hit. */ -if (matches) { +if (matches->len) {char *insn_disas =qemu_plugin_insn_disas (insn); -int j; -for (j =0 ; j < matches->len; j++) { +for (int j =0 ; j < matches->len; j++) {Match *m = &g_array_index (matches, Match, j);if (g_str_has_prefix (insn_disas, m->match_string)) {Instruction *rec =g_new0 (Instruction,1 );
@@ -169,36 +163,33 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) "len %d bytes: %ld insns\n", i, *cnt); } } - }else if (do_inline) { -g_string_append_printf (out,"insns: %" PRIu64"\n" , inline_insn_count); }else { -uint64_t total_insns =0 ; -for (i =0 ; i <MAX_CPUS ; i++) { -InstructionCount *c = &counts[i]; -if (c->insn_count) { -g_string_append_printf (out,"cpu %d insns: %" PRIu64"\n" , - i, c->insn_count); - total_insns += c->insn_count; - } +for (i =0 ; i <qemu_plugin_num_vcpus (); i++) { +g_string_append_printf (out,"cpu %d insns: %" PRIu64"\n" , + i,qemu_plugin_u64_get (insn_count, i)); }g_string_append_printf (out,"total insns: %" PRIu64"\n" , - total_insns); +qemu_plugin_u64_sum (insn_count)); }qemu_plugin_outs (out->str); + +qemu_plugin_scoreboard_free (insn_count.score); +for (i =0 ; i < matches->len; ++i) { +Match *m = &g_array_index (matches, Match, i); +g_free (m->match_string); +qemu_plugin_scoreboard_free (m->counts); + } +g_array_free (matches, TRUE); +g_array_free (sizes, TRUE); }/* Add a match to the array of matches */ static void parse_match (char *match) { -Match new_match = { .match_string = match }; -int i; -for (i =0 ; i <MAX_CPUS ; i++) { - new_match.history[i] =g_ptr_array_new (); - } -if (!matches) { - matches =g_array_new (false, true,sizeof (Match)); - } +Match new_match = { + .match_string =g_strdup (match), + .counts =qemu_plugin_scoreboard_new (sizeof (MatchCount)) };g_array_append_val (matches, new_match); }
@@ -206,6 +197,10 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,const qemu_info_t *info, int argc, char **argv) { + matches =g_array_new (false, true,sizeof (Match)); +/* null terminated so 0 is not a special case */ + sizes =g_array_new (true, true,sizeof (unsigned long )); +for (int i =0 ; i < argc; i++) {char *opt = argv[i];g_auto (GStrv) tokens =g_strsplit (opt,"=" ,2 );
@@ -227,9 +222,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, } } -if (do_size) { - sizes =g_array_new (true, true,sizeof (unsigned long )); - } + insn_count =qemu_plugin_scoreboard_u64 ( +qemu_plugin_scoreboard_new (sizeof (uint64_t )));/* Register init, translation block and exit callbacks */ qemu_plugin_register_vcpu_init_cb (id, vcpu_init);
Signature · 1 line
2.39.2
[PULL 27/29] disas/hppa: honour show_opcodes
In reply to Alex BennéeMessage-Id: <[email protected]>
disas/hppa.c +5 -3
@@ -1972,9 +1972,11 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info) insn =bfd_getb32 (buffer); - info->fprintf_func (info->stream," %02x %02x %02x %02x " , - (insn >>24 ) &0xff , (insn >>16 ) &0xff , - (insn >>8 ) &0xff , insn &0xff ); +if (info->show_opcodes) { + info->fprintf_func (info->stream," %02x %02x %02x %02x " , + (insn >>24 ) &0xff , (insn >>16 ) &0xff , + (insn >>8 ) &0xff , insn &0xff ); + }for (i =0 ; i <NUMOPCODES ; ++i) {
Signature · 1 line
2.39.2
[PULL 28/29] target/loongarch: honour show_opcodes when disassembling
In reply to Alex BennéeThis makes the output suitable when used for plugins.
Message-Id: <[email protected]>
target/loongarch/disas.c +9 -4
@@ -120,10 +120,15 @@ static const char *get_csr_name(unsigned num) csr_names[num] : "Undefined CSR"; } -#define output (C ,INSN ,FMT , ...) \ -{ \ - (C)->info->fprintf_func((C)->info->stream, "%08x %-9s\t" FMT, \ - (C)->insn, INSN, ##__VA_ARGS__); \ +#define output (C ,INSN ,FMT , ...) \ + { \ + if ((C)->info->show_opcodes) { \ + (C)->info->fprintf_func((C)->info->stream, "%08x %-9s\t" FMT,\ + (C)->insn, INSN, ##__VA_ARGS__); \ + } else { \ + (C)->info->fprintf_func((C)->info->stream, "%-9s\t" FMT, \ + INSN, ##__VA_ARGS__); \ + } \ }#include "decode-insns.c.inc"
Signature · 1 line
2.39.2
[PULL 26/29] disas: introduce show_opcodes
In reply to Alex BennéeFor plugins we don't expect the raw opcodes in the disassembly. We already deal with this by hand crafting our capstone call but for other diassemblers we need a flag. Introduce show_opcodes which defaults to off.
Message-Id: <[email protected]>
include/disas/dis-asm.h +8 -0
@@ -396,6 +396,14 @@ typedef struct disassemble_info {/* Command line options specific to the target disassembler. */ char * disassembler_options; +/* +* When true instruct the disassembler it may preface the +* disassembly with the opcodes values if it wants to. This is +* mainly for the benefit of the plugin interface which doesn't want +* that. +*/ +bool show_opcodes; +/* Field intended to be used by targets in any way they deem suitable. */ void *target_info;
disas/disas.c +1 -0
@@ -299,6 +299,7 @@ void disas(FILE *out, const void *code, size_t size) s.info.buffer = code; s.info.buffer_vma = (uintptr_t )code; s.info.buffer_length = size; + s.info.show_opcodes = true;if (s.info.cap_arch >=0 &&cap_disas_host (&s.info, code, size)) {return ;
Signature · 1 line
2.39.2
Re: [PULL 26/29] disas: introduce show_opcodes
Quoted 33 lines · Alex Bennée
For plugins we don't expect the raw opcodes in the disassembly. We already deal with this by hand crafting our capstone call but for other diassemblers we need a flag. Introduce
show_opcodeswhich defaults to off.Reviewed-by Richard Henderson <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
include/disas/dis-asm.h +8
-0@@ -396,6 +396,14 @@ typedef struct disassemble_info {/* Command line options specific to the target disassembler. */ char * disassembler_options; +/* +* When true instruct the disassembler it may preface the +* disassembly with the opcodes values if it wants to. This is +* mainly for the benefit of the plugin interface which doesn't want +* that. +*/ +bool show_opcodes; +/* Field intended to be used by targets in any way they deem suitable. */ void *target_info;disas/disas.c +0
-0
disas/disas.c void disas(FILE *out, const void *code, size_t size) · line 305
Quoted 7 lines
disas/disas.c +1
-0@@ -299,6 +299,7 @@ void disas(FILE *out, const void *code, size_t size) s.info.buffer = code; s.info.buffer_vma = (uintptr_t )code; s.info.buffer_length = size; + s.info.show_opcodes = true;if (s.info.cap_arch >=0 &&cap_disas_host (&s.info, code, size)) {return ;
I know it's too late now for a patch review, but anyway: What about the other spots that set up a "CPUDebug" struct? Like monitor_disas() or target_disas() ? Shouldn't we initialize the new struct member there, too?
Thomas
Re: [PULL 26/29] disas: introduce show_opcodes
Quoted 34 lines · Thomas Huth
Quoted 33 lines · Alex Bennée
For plugins we don't expect the raw opcodes in the disassembly. We already deal with this by hand crafting our capstone call but for other diassemblers we need a flag. Introduce
show_opcodeswhich defaults to off.Reviewed-by Richard Henderson <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
include/disas/dis-asm.h +7
-0@@ -396,6 +396,14 @@ typedef struct disassemble_info {/* Command line options specific to the target disassembler. */ char * disassembler_options; +/* +* When true instruct the disassembler it may preface the +* disassembly with the opcodes values if it wants to. This is +* mainly for the benefit of the plugin interface which doesn't want +* that. +*/ + bool show_opcodes; +/* Field intended to be used by targets in any way they deem suitable. */ void *target_info; diff --git a/disas/disas.c b/disas/disas.cindex
0d2d06c2ecc..17170d291ec100644disas/disas.c +1
-0@@ -299,6 +299,7 @@ void disas(FILE *out, const void *code, size_t size) s.info.buffer = code; s.info.buffer_vma = (uintptr_t )code; s.info.buffer_length = size; + s.info.show_opcodes = true;
Quoted 8 lines
disas/disas.c void disas(FILE *out, const void *code, size_t size) · line 305
Quoted 3 lines
disas/disas.c +0
-0if (s.info.cap_arch >=0 &&cap_disas_host (&s.info, code, size)) {return ;I know it's too late now for a patch review, but anyway: What about the other spots that set up a "CPUDebug" struct? Like
monitor_disas()ortarget_disas()? Shouldn't we initialize the new struct member there, too?
Hmm maybe. I can post some follow up fixes.
Quoted 2 lines
Thomas
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
[PULL 21/29] tests/plugin/bb: migrate to new per_vcpu API
In reply to Alex BennéeFrom: Pierrick Bouvier <[email protected]>
Message-Id: <[email protected]>
Message-Id: <[email protected]>
tests/plugin/bb.c +26 -37
@@ -17,27 +17,25 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;typedef struct { -GMutex lock; -int index;uint64_t bb_count;uint64_t insn_count; }CPUCount ; -/* Used by the inline & linux-user counts */ -static bool do_inline; -static CPUCount inline_count; +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64 bb_count; +static qemu_plugin_u64 insn_count; +static bool do_inline;/* Dump running CPU total on idle? */ static bool idle_report; -static GPtrArray *counts; -static int max_cpus; -static void gen_one_cpu_report (CPUCount *count,GString *report) +static void gen_one_cpu_report (CPUCount *count,GString *report, +unsigned int cpu_index) {if (count->bb_count) {g_string_append_printf (report,"CPU%d: " "bb's: %" PRIu64", insns: %" PRIu64"\n" , - count->index, + cpu_index, count->bb_count, count->insn_count); } }
@@ -46,20 +44,23 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) {g_autoptr (GString) report =g_string_new ("" ); -if (do_inline || !max_cpus) { -g_string_printf (report,"bb's: %" PRIu64", insns: %" PRIu64"\n" , - inline_count.bb_count, inline_count.insn_count); - }else { -g_ptr_array_foreach (counts, (GFunc ) gen_one_cpu_report, report); +for (int i =0 ; i <qemu_plugin_num_vcpus (); ++i) { +CPUCount *count =qemu_plugin_scoreboard_find (counts, i); +gen_one_cpu_report (count, report, i); } +g_string_append_printf (report,"Total: " +"bb's: %" PRIu64", insns: %" PRIu64"\n" , +qemu_plugin_u64_sum (bb_count), +qemu_plugin_u64_sum (insn_count));qemu_plugin_outs (report->str); +qemu_plugin_scoreboard_free (counts); }static void vcpu_idle (qemu_plugin_id_t id,unsigned int cpu_index) { -CPUCount *count =g_ptr_array_index (counts, cpu_index); +CPUCount *count =qemu_plugin_scoreboard_find (counts, cpu_index);g_autoptr (GString) report =g_string_new ("" ); -gen_one_cpu_report (count, report); +gen_one_cpu_report (count, report, cpu_index);if (report->len >0 ) {g_string_prepend (report,"Idling " );
@@ -69,14 +70,11 @@ static void vcpu_idle(qemu_plugin_id_t id, unsigned int cpu_index)static void vcpu_tb_exec (unsigned int cpu_index,void *udata) { -CPUCount *count = max_cpus ? -g_ptr_array_index (counts, cpu_index) : &inline_count; +CPUCount *count =qemu_plugin_scoreboard_find (counts, cpu_index);uintptr_t n_insns = (uintptr_t )udata; -g_mutex_lock (&count->lock); count->insn_count += n_insns; count->bb_count++; -g_mutex_unlock (&count->lock); }static void vcpu_tb_trans (qemu_plugin_id_t id,struct qemu_plugin_tb *tb)
@@ -84,11 +82,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)size_t n_insns =qemu_plugin_tb_n_insns (tb);if (do_inline) { -qemu_plugin_register_vcpu_tb_exec_inline (tb,QEMU_PLUGIN_INLINE_ADD_U64 , - &inline_count.bb_count,1 ); -qemu_plugin_register_vcpu_tb_exec_inline (tb,QEMU_PLUGIN_INLINE_ADD_U64 , - &inline_count.insn_count, - n_insns); +qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu ( + tb,QEMU_PLUGIN_INLINE_ADD_U64 , bb_count,1 ); +qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu ( + tb,QEMU_PLUGIN_INLINE_ADD_U64 , insn_count, n_insns); }else { qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS,
@@ -121,18 +118,10 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, } } -if (info->system_emulation && !do_inline) { - max_cpus = info->system.max_vcpus; - counts =g_ptr_array_new (); -for (i =0 ; i < max_cpus; i++) { -CPUCount *count =g_new0 (CPUCount,1 ); -g_mutex_init (&count->lock); - count->index = i; -g_ptr_array_add (counts, count); - } - }else if (!do_inline) { -g_mutex_init (&inline_count.lock); - } + counts =qemu_plugin_scoreboard_new (sizeof (CPUCount)); + bb_count =qemu_plugin_scoreboard_u64_in_struct (counts, CPUCount, bb_count); + insn_count =qemu_plugin_scoreboard_u64_in_struct ( + counts, CPUCount, insn_count);if (idle_report) {qemu_plugin_register_vcpu_idle_cb (id, vcpu_idle);
Signature · 1 line
2.39.2
Peter Maydell
AppliedQuoted 13 lines · Alex Bennée
The following changes since commit
db596ae19040574e41d086e78469014191d7d7fc:Merge tag 'pull-target-arm-20240305' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2024-03-05 13:54:54 +0000)
are available in the Git repository at:
https://gitlab.com/stsquad/qemu.git tags/pull-maintainer-updates-060324-1
for you to fetch changes up to
db7e8b1f75662cf957f6bfad938ed112488518ed:target/riscv: honour
show_opcodeswhen disassembling (2024-03-06 12:35:51 +0000)
Quoted 8 lines
----------------------------------------------------------------
maintainer updates (tests, gdbstub, plugins):- expand
QOS_PATH_MAX_ELEMENT_SIZEto avoid LTO issues
- support fork-follow-mode in gdbstub
- new thread-safe scoreboard API for TCG plugins
- suppress showing opcodes in plugin disassembly
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/9.0
for any user-visible changes.
-- PMM