mbox series

[00/32] accel/tcg: Improve disassembly for target and plugin

Message ID 20240405102459.462551-1-richard.henderson@linaro.org
Headers show
Series accel/tcg: Improve disassembly for target and plugin | expand

Message

Richard Henderson April 5, 2024, 10:24 a.m. UTC
Based-on: 20240404230611.21231-1-richard.henderson@linaro.org
("[PATCH v2 00/21] Rewrite plugin code generation")

While I was trying to debug something the other week, I noticed
that hppa_cpu_get_phys_page_debug was not using the same cpu state
as the translator, which meant that the disassembler read from a
different page than the translator, producing garbage.

I considered several ways to fix the issue, but I thought the
most effective would be to re-use the host page resolution that
the translator has already done.

Second, the same mechanism can be used to clean up plugin access
to each instruction's bytes and disassembly.

Third, the cache used for plugin access to mmio can be used to
allow s390x execute to disassemble the insn.

Finally, with the change to how plugins capture insn data, we
can and should use translator_ld* for everything the target wants
to read during translation.


r~


Richard Henderson (32):
  accel/tcg: Use vaddr in translator_ld*
  accel/tcg: Hide in_same_page outside of a target-specific context
  accel/tcg: Pass DisasContextBase to translator_fake_ldb
  accel/tcg: Reorg translator_ld*
  accel/tcg: Cap the translation block when we encounter mmio
  accel/tcg: Record mmio bytes during translation
  accel/tcg: Record when translator_fake_ldb is used
  accel/tcg: Record DisasContextBase in tcg_ctx for plugins
  plugins: Copy memory in qemu_plugin_insn_data
  accel/tcg: Implement translator_st
  plugins: Use translator_st for qemu_plugin_insn_data
  plugins: Read mem_only directly from TB cflags
  plugins: Use DisasContextBase for qemu_plugin_insn_haddr
  plugins: Use DisasContextBase for qemu_plugin_tb_vaddr
  plugins: Merge  alloc_tcg_plugin_context into plugin_gen_tb_start
  accel/tcg: Provide default implementation of disas_log
  accel/tcg: Return bool from TranslatorOps.disas_log
  disas: Split disas.c
  disas: Use translator_st to get disassembly data
  accel/tcg: Introduce translator_fake_ld
  target/s390x: Fix translator_fake_ld length
  target/s390x: Disassemble EXECUTEd instructions
  target/hexagon: Use translator_ldl in pkt_crosses_page
  target/microblaze: Use translator_ldl
  target/i386: Use translator_ldub for everything
  target/avr: Use translator_ldl
  target/cris: Use translator_ld* in cris_fetch
  target/cris: Use cris_fetch in translate_v10.c.inc
  target/riscv: Use translator_ld* for everything
  target/rx: Use translator_ld*
  target/xtensa: Use translator_ldub in xtensa_insn_len
  target/s390x: Use translator_lduw in get_next_pc

 disas/disas-internal.h           |   4 +
 include/disas/disas.h            |   9 +-
 include/exec/plugin-gen.h        |   7 +-
 include/exec/translator.h        |  70 +++++--
 include/qemu/plugin.h            |  22 +-
 include/qemu/qemu-plugin.h       |  15 +-
 include/qemu/typedefs.h          |   1 +
 include/tcg/tcg.h                |   1 +
 accel/tcg/plugin-gen.c           |  63 +++---
 accel/tcg/translator.c           | 331 +++++++++++++++++++-----------
 contrib/plugins/execlog.c        |   5 +-
 contrib/plugins/howvec.c         |   4 +-
 disas/disas-common.c             | 103 ++++++++++
 disas/disas-host.c               | 129 ++++++++++++
 disas/disas-mon.c                |  15 ++
 disas/disas-target.c             |  99 +++++++++
 disas/disas.c                    | 337 -------------------------------
 disas/objdump.c                  |  37 ++++
 plugins/api.c                    |  57 ++++--
 target/alpha/translate.c         |   9 -
 target/arm/tcg/translate-a64.c   |  11 -
 target/arm/tcg/translate.c       |  12 --
 target/avr/translate.c           |  11 +-
 target/cris/translate.c          |  37 +---
 target/hexagon/translate.c       |  11 +-
 target/hppa/translate.c          |  21 +-
 target/i386/tcg/translate.c      |  19 +-
 target/loongarch/tcg/translate.c |   8 -
 target/m68k/translate.c          |   9 -
 target/microblaze/translate.c    |  11 +-
 target/mips/tcg/translate.c      |   9 -
 target/nios2/translate.c         |  10 +-
 target/openrisc/translate.c      |  11 -
 target/ppc/translate.c           |   9 -
 target/riscv/translate.c         |  24 +--
 target/rx/translate.c            |  35 ++--
 target/s390x/tcg/translate.c     |  26 ++-
 target/sh4/translate.c           |   9 -
 target/sparc/translate.c         |   9 -
 target/tricore/translate.c       |   9 -
 target/xtensa/translate.c        |  12 +-
 tcg/tcg.c                        |  12 --
 target/cris/translate_v10.c.inc  |  30 +--
 disas/meson.build                |   8 +-
 44 files changed, 819 insertions(+), 862 deletions(-)
 create mode 100644 disas/disas-common.c
 create mode 100644 disas/disas-host.c
 create mode 100644 disas/disas-target.c
 delete mode 100644 disas/disas.c
 create mode 100644 disas/objdump.c