[PATCH v3 00/23] multi-target: remove dump functions duplication

Pierrick Bouvier posted 23 patches 1 week ago
There is a newer version of this series
dump/dump.c                      | 27 +++++++++++++++++++--------
include/hw/core/sysemu-cpu-ops.h | 13 +++++++++++++
include/qemu/target-info.h       |  8 ++++++++
include/qemu/typedefs.h          |  2 ++
include/system/dump-arch.h       |  5 -----
stubs/dump.c                     | 27 ---------------------------
stubs/meson.build                |  1 -
target-info.c                    |  6 ++++++
target/arm/arch_dump.c           | 18 ++++++------------
target/arm/cpu.c                 |  2 ++
target/arm/internals.h           |  4 ++++
target/i386/arch_dump.c          | 10 ++++++----
target/i386/cpu-internal.h       |  5 +++++
target/i386/cpu.c                |  2 ++
target/loongarch/arch_dump.c     |  7 ++++---
target/loongarch/cpu.c           |  2 ++
target/loongarch/internals.h     |  5 +++++
target/ppc/arch_dump.c           | 16 ++++++----------
target/ppc/cpu.h                 |  6 +++---
target/ppc/cpu_init.c            |  2 ++
target/ppc/internal.h            |  7 +++++++
target/riscv/arch_dump.c         | 18 +++++++-----------
target/riscv/cpu.c               |  2 ++
target/riscv/internals.h         |  4 ++++
target/s390x/arch_dump.c         |  7 ++++---
target/s390x/cpu-system.c        |  2 ++
target/s390x/s390x-internal.h    |  5 +++++
27 files changed, 126 insertions(+), 87 deletions(-)
delete mode 100644 stubs/dump.c
[PATCH v3 00/23] multi-target: remove dump functions duplication
Posted by Pierrick Bouvier 1 week ago
This series removes duplication of cpu_get_note_size and cpu_get_dump_info per
target. For this, we define a new sysemu operations for a given cpu, and
implement it per target.

Existing implementations were using first_cpu, which is what we continue to do.
When we'll work on heterogeneous later, we can revisit this to either forbid a
dump, or perform a dump for each target active. Meanwhile, add a check if we run
heterogeneous emulation, and refuse to dump if that's the case.

v3
--

- riscv_get_dump_info: add const to riscv cpu
- use forward decl for ArchDumpInfo instead of including system/dump.h
- use forward decl for GuestPhysBlockList instead of including system/memory_mapping.h
- update comment for get_note_size sysemu ops
- add target_heterogeneous to target_info: returns false for now
- edit commit description for dump_init changes about why we can have first_cpu null
- add target_heterogeneous check in dump_init
- rebased on master (previous "based on" is not needed anymore)

v2
--

- Add new ops to existing SysEmuOps instead of a new DumpOps.

Pierrick Bouvier (23):
  target-info: add target_heterogeneous
  dump/dump: do not dump machine if doing heterogeneous emulation
  include/qemu/typedefs: add ArchDumpInfo
  include/qemu/typedefs: add GuestPhysBlockList
  hw/core/sysemu-cpu-ops: add get_dump_info
  target/arm: implement get_dump_info sysemu op
  target/i386: implement get_dump_info sysemu op
  target/ppc/cpu: constify cpu parameter for
    ppc_interrupts_little_endian
  target/ppc: implement get_dump_info sysemu op
  target/riscv: implement get_dump_info sysemu op
  target/s390x: implement get_dump_info sysemu op
  target/loongarch: implement get_dump_info sysemu op
  dump: use get_dump_info sysemu op
  dump: remove cpu_get_dump_info
  hw/core/sysemu-cpu-ops: add get_note_size
  target/arm: implement get_note_size sysemu op
  target/i386: implement get_note_size sysemu op
  target/ppc: implement get_note_size sysemu op
  target/riscv: implement get_note_size sysemu op
  target/s390x: implement get_note_size sysemu op
  target/loongarch: implement get_note_size sysemu op
  dump: use get_note_size sysemu op
  dump: remove cpu_get_note_size

 dump/dump.c                      | 27 +++++++++++++++++++--------
 include/hw/core/sysemu-cpu-ops.h | 13 +++++++++++++
 include/qemu/target-info.h       |  8 ++++++++
 include/qemu/typedefs.h          |  2 ++
 include/system/dump-arch.h       |  5 -----
 stubs/dump.c                     | 27 ---------------------------
 stubs/meson.build                |  1 -
 target-info.c                    |  6 ++++++
 target/arm/arch_dump.c           | 18 ++++++------------
 target/arm/cpu.c                 |  2 ++
 target/arm/internals.h           |  4 ++++
 target/i386/arch_dump.c          | 10 ++++++----
 target/i386/cpu-internal.h       |  5 +++++
 target/i386/cpu.c                |  2 ++
 target/loongarch/arch_dump.c     |  7 ++++---
 target/loongarch/cpu.c           |  2 ++
 target/loongarch/internals.h     |  5 +++++
 target/ppc/arch_dump.c           | 16 ++++++----------
 target/ppc/cpu.h                 |  6 +++---
 target/ppc/cpu_init.c            |  2 ++
 target/ppc/internal.h            |  7 +++++++
 target/riscv/arch_dump.c         | 18 +++++++-----------
 target/riscv/cpu.c               |  2 ++
 target/riscv/internals.h         |  4 ++++
 target/s390x/arch_dump.c         |  7 ++++---
 target/s390x/cpu-system.c        |  2 ++
 target/s390x/s390x-internal.h    |  5 +++++
 27 files changed, 126 insertions(+), 87 deletions(-)
 delete mode 100644 stubs/dump.c

-- 
2.47.3
Re: [PATCH v3 00/23] multi-target: remove dump functions duplication
Posted by Pierrick Bouvier 4 days, 17 hours ago
On 10/16/2026 11:13 AM, Pierrick Bouvier wrote:
> This series removes duplication of cpu_get_note_size and cpu_get_dump_info per
> target. For this, we define a new sysemu operations for a given cpu, and
> implement it per target.
> 
> Existing implementations were using first_cpu, which is what we continue to do.
> When we'll work on heterogeneous later, we can revisit this to either forbid a
> dump, or perform a dump for each target active. Meanwhile, add a check if we run
> heterogeneous emulation, and refuse to dump if that's the case.
> 
> v3
> --
> 
> - riscv_get_dump_info: add const to riscv cpu
> - use forward decl for ArchDumpInfo instead of including system/dump.h
> - use forward decl for GuestPhysBlockList instead of including system/memory_mapping.h
> - update comment for get_note_size sysemu ops
> - add target_heterogeneous to target_info: returns false for now
> - edit commit description for dump_init changes about why we can have first_cpu null
> - add target_heterogeneous check in dump_init
> - rebased on master (previous "based on" is not needed anymore)
> 
> v2
> --
> 
> - Add new ops to existing SysEmuOps instead of a new DumpOps.
>

Sent v4, adding global wrappers for cpu_get_dump_info and
cpu_get_note_size. See:
https://lore.kernel.org/qemu-devel/20261019212648.154493-1-pierrick.bouvier@oss.qualcomm.com/T/#t

Regards,
Pierrick