diff --git a/dump/dump.c b/dump/dump.c index 60ecde0217..23ac689907 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -1873,7 +1873,7 @@ static void dump_init(DumpState *s, int fd, bool has_format, s->dump_info.page_size = qemu_target_page_size(); } - s->note_size = cpu_get_note_size(s->dump_info.d_class, + s->note_size = cpu_get_note_size(first_cpu, s->dump_info.d_class, s->dump_info.d_machine, nr_cpus); assert(s->note_size >= 0); diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c index d04c6a2e6e..03800cd719 100644 --- a/hw/core/cpu-system.c +++ b/hw/core/cpu-system.c @@ -140,6 +140,15 @@ int cpu_get_dump_info(const CPUState *cpu, ArchDumpInfo *info, return 0; } +ssize_t cpu_get_note_size(const CPUState *cpu, int class, int machine, + int nr_cpus) +{ + if (!cpu->cc->sysemu_ops->get_note_size) { + return -1; + } + return cpu->cc->sysemu_ops->get_note_size(cpu, class, machine, nr_cpus); +} + bool cpu_internal_is_big_endian(CPUState *cpu) { if (cpu->cc->sysemu_ops->internal_is_big_endian) { diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index d80a6a4e75..a3b4c6c08a 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -712,6 +712,19 @@ int cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu, int cpu_get_dump_info(const CPUState *cpu, ArchDumpInfo *info, const GuestPhysBlockList *guest_phys_blocks); +/** + * cpu_get_note_size: + * @cpu: The CPU whose memory is to be dumped + * @class: ELF class reported by cpu_get_dump_info() + * @machine: ELF machine reported by cpu_get_dump_info() + * @nr_cpus: Number of CPUs to be dumped + * + * Returns: size of the ELF notes needed to dump @nr_cpus CPUs, + * or -1 if not supported. + */ +ssize_t cpu_get_note_size(const CPUState *cpu, int class, int machine, + int nr_cpus); + /** * cpu_memory_rw_debug: * @cpu: The CPU whose memory is to be accessed diff --git a/include/system/dump-arch.h b/include/system/dump-arch.h index eccf61dc3e..86b9ae15b6 100644 --- a/include/system/dump-arch.h +++ b/include/system/dump-arch.h @@ -27,6 +27,4 @@ struct ArchDumpInfo { void (*arch_cleanup_fn)(DumpState *s); }; -ssize_t cpu_get_note_size(int class, int machine, int nr_cpus); - #endif diff --git a/stubs/dump.c b/stubs/dump.c deleted file mode 100644 index 2ce3c5e274..0000000000 --- a/stubs/dump.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * QEMU dump - * - * Copyright Fujitsu, Corp. 2011, 2012 - * - * Authors: - * Wen Congyang - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - * - */ - -#include "qemu/osdep.h" -#include "system/dump-arch.h" - -ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) -{ - return -1; -} - diff --git a/stubs/meson.build b/stubs/meson.build index dcb67ce529..4a26f795a6 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -71,7 +71,6 @@ if have_system # adding more of these. If the symbol is used in specific_ss, # in particular, consider defining a preprocessor macro via # Kconfig or configs/targets/. - stub_ss.add(files('dump.c')) stub_ss.add(files('cmos.c')) stub_ss.add(files('fw_cfg.c')) if igvm.found() diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c index a09f7c59db..01fb2942d1 100644 --- a/target/arm/arch_dump.c +++ b/target/arm/arch_dump.c @@ -451,8 +451,3 @@ size_t arm_get_note_size(const CPUState *cs, int class, int machine, return note_size * nr_cpus; } - -ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) -{ - return arm_get_note_size(first_cpu, class, machine, nr_cpus); -} diff --git a/target/i386/arch_dump.c b/target/i386/arch_dump.c index 270adb0446..9e39fea84c 100644 --- a/target/i386/arch_dump.c +++ b/target/i386/arch_dump.c @@ -459,8 +459,3 @@ size_t x86_get_note_size(const CPUState *cs, int class, int machine, return (elf_note_size + qemu_note_size) * nr_cpus; } - -ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) -{ - return x86_get_note_size(first_cpu, class, machine, nr_cpus); -} diff --git a/target/loongarch/arch_dump.c b/target/loongarch/arch_dump.c index 47036105e0..1e2d8eba85 100644 --- a/target/loongarch/arch_dump.c +++ b/target/loongarch/arch_dump.c @@ -161,8 +161,3 @@ size_t loongarch_get_note_size(const CPUState *cs, int class, return note_size * nr_cpus; } - -ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) -{ - return loongarch_get_note_size(first_cpu, class, machine, nr_cpus); -} diff --git a/target/ppc/arch_dump.c b/target/ppc/arch_dump.c index 42e5cf936d..bbfb6674bc 100644 --- a/target/ppc/arch_dump.c +++ b/target/ppc/arch_dump.c @@ -267,11 +267,6 @@ size_t ppc_get_note_size(const CPUState *cs, int class, int machine, return (elf_note_size) * nr_cpus; } -ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) -{ - return ppc_get_note_size(first_cpu, class, machine, nr_cpus); -} - static int ppc_write_all_elf_notes(const char *note_name, WriteCoreDumpFunction f, PowerPCCPU *cpu, int id, diff --git a/target/riscv/arch_dump.c b/target/riscv/arch_dump.c index 06b66a5685..19222ae18b 100644 --- a/target/riscv/arch_dump.c +++ b/target/riscv/arch_dump.c @@ -193,8 +193,3 @@ size_t riscv_get_note_size(const CPUState *cs, int class, int machine, return note_size * nr_cpus; } - -ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) -{ - return riscv_get_note_size(first_cpu, class, machine, nr_cpus); -} diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c index 5092835afc..965ed6be39 100644 --- a/target/s390x/arch_dump.c +++ b/target/s390x/arch_dump.c @@ -495,8 +495,3 @@ size_t s390_get_note_size(const CPUState *cs, int class, int machine, return (elf_note_size) * nr_cpus; } - -ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) -{ - return s390_get_note_size(first_cpu, class, machine, nr_cpus); -}