cpu: Introduce CPUSystemOperations structure
cover cpu: Introduce CPUSystemOperations structure
Hi,
This series is inspired on Claudio TCG work.
Instead of separate TCG from other accelerators, here we separate sysemu operations (system VS user).
This is part 1, overall preparation. Part 2 will make this field a pointer, similarly to commit 78271684719 ("cpu: tcg_ops:
move to tcg-cpu-ops.h, keep a pointer in CPUClass").
Regards,
Phil.
Philippe Mathieu-Daudé (16):
target: Set CPUClass::vmsd instead of DeviceClass::vmsd
cpu: Un-inline cpu_get_phys_page_debug and cpu_asidx_from_attrs
cpu: Introduce cpu_virtio_is_big_endian()
cpu: Directly use cpu_write_elf*() fallback handlers in place
cpu: Directly use get_paging_enabled() fallback handlers in place
cpu: Directly use get_memory_mapping() fallback handlers in place
cpu: Introduce CPUSystemOperations structure
cpu: Move CPUClass::vmsd to CPUSystemOperations
cpu: Move CPUClass::virtio_is_big_endian to CPUSystemOperations
cpu: Move CPUClass::get_crash_info to CPUSystemOperations
cpu: Move CPUClass::write_elf* to CPUSystemOperations
cpu: Move CPUClass::asidx_from_attrs to CPUSystemOperations
cpu: Move CPUClass::get_phys_page_debug to CPUSystemOperations
cpu: Move CPUClass::get_memory_mapping to CPUSystemOperations
cpu: Move CPUClass::get_paging_enabled to CPUSystemOperations
cpu: Restrict cpu_paging_enabled / cpu_get_memory_mapping to sysemu
include/hw/core/cpu.h | 162 ++++++++++++++++++-------------- cpu.c | 12 +-- hw/core/cpu.c | 112 ++++++++++++---------- hw/virtio/virtio.c | 4 +- target/alpha/cpu.c | 4 +- target/arm/cpu.c | 12 +-- target/avr/cpu.c | 4 +- target/cris/cpu.c | 4 +- target/hppa/cpu.c | 4 +- target/i386/cpu.c | 20 ++-- target/lm32/cpu.c | 4 +- target/m68k/cpu.c | 4 +- target/microblaze/cpu.c | 4 +- target/mips/cpu.c | 4 +- target/moxie/cpu.c | 4 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 4 +- target/riscv/cpu.c | 4 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 8 +- target/sh4/cpu.c | 4 +- target/sparc/cpu.c | 4 +- target/tricore/cpu.c | 2 +- target/unicore32/cpu.c | 4 +- target/xtensa/cpu.c | 4 +- target/ppc/translate_init.c.inc | 10 +- 26 files changed, 218 insertions(+), 188 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/16 target: Set CPUClass::vmsd instead of DeviceClass::vmsd
The cpu model is the single device available in user-mode. Since we want to restrict some fields to user-mode emulation, we prefer to set the vmsd field of CPUClass, rather than the DeviceClass one.
--- target/alpha/cpu.c | 2 +- target/cris/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-)
target/alpha/cpu.c +1 -1
@@ -237,7 +237,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = alpha_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug; - dc->vmsd = &vmstate_alpha_cpu; + cc->vmsd = &vmstate_alpha_cpu;#endif cc->disas_set_info = alpha_cpu_disas_set_info;
target/cris/cpu.c +1 -1
@@ -293,7 +293,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = cris_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = cris_cpu_get_phys_page_debug; - dc->vmsd = &vmstate_cris_cpu; + cc->vmsd = &vmstate_cris_cpu;#endif cc->gdb_num_core_regs =49 ;
target/hppa/cpu.c +1 -1
@@ -162,7 +162,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = hppa_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = hppa_cpu_get_phys_page_debug; - dc->vmsd = &vmstate_hppa_cpu; + cc->vmsd = &vmstate_hppa_cpu;#endif cc->disas_set_info = hppa_cpu_disas_set_info; cc->gdb_num_core_regs =128 ;
target/m68k/cpu.c +1 -1
@@ -533,7 +533,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->gdb_write_register = m68k_cpu_gdb_write_register;#if defined(CONFIG_SOFTMMU ) cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug; - dc->vmsd = &vmstate_m68k_cpu; + cc->vmsd = &vmstate_m68k_cpu;#endif cc->disas_set_info = m68k_cpu_disas_set_info;
target/microblaze/cpu.c +1 -1
@@ -387,7 +387,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_attrs_debug = mb_cpu_get_phys_page_attrs_debug; - dc->vmsd = &vmstate_mb_cpu; + cc->vmsd = &vmstate_mb_cpu;#endif device_class_set_props (dc, mb_properties); cc->gdb_num_core_regs =32 +27 ;
target/openrisc/cpu.c +1 -1
@@ -204,7 +204,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = openrisc_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = openrisc_cpu_get_phys_page_debug; - dc->vmsd = &vmstate_openrisc_cpu; + cc->vmsd = &vmstate_openrisc_cpu;#endif cc->gdb_num_core_regs =32 +3 ; cc->disas_set_info = openrisc_disas_set_info;
target/sh4/cpu.c +1 -1
@@ -262,7 +262,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs =59 ; - dc->vmsd = &vmstate_sh_cpu; + cc->vmsd = &vmstate_sh_cpu; cc->tcg_ops = &superh_tcg_ops; }
target/unicore32/cpu.c +1 -1
@@ -146,7 +146,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = uc32_cpu_dump_state; cc->set_pc = uc32_cpu_set_pc; cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug; - dc->vmsd = &vmstate_uc32_cpu; + cc->vmsd = &vmstate_uc32_cpu; cc->tcg_ops = &uc32_tcg_ops; }
target/xtensa/cpu.c +1 -1
@@ -218,7 +218,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug;#endif cc->disas_set_info = xtensa_cpu_disas_set_info; - dc->vmsd = &vmstate_xtensa_cpu; + cc->vmsd = &vmstate_xtensa_cpu; cc->tcg_ops = &xtensa_tcg_ops; }
Signature · 1 line
2.26.2
PATCH 2/16 cpu: Un-inline cpu_get_phys_page_debug and cpu_asidx_from_attrs
In reply to Philippe Mathieu-DaudéTo be able to later extract the cpu_get_phys_page_debug() and cpu_asidx_from_attrs() handlers from CPUClass, un-inline them from "hw/core/cpu.h".
--- include/hw/core/cpu.h | 33 ++++----------------------------- hw/core/cpu.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 29 deletions(-)
include/hw/core/cpu.h +4 -29
@@ -578,18 +578,8 @@ void cpu_dump_statistics(CPUState *cpu, int flags);* * Returns: Corresponding physical page address or -1 if no page found. */ -static inline hwaddr cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr, -MemTxAttrs *attrs) -{ -CPUClass *cc =CPU_GET_CLASS (cpu); - -if (cc->get_phys_page_attrs_debug) { -return cc->get_phys_page_attrs_debug (cpu, addr, attrs); - } -/* Fallback for CPUs which don't implement the _attrs_ hook */ - *attrs =MEMTXATTRS_UNSPECIFIED ; -return cc->get_phys_page_debug (cpu, addr); -} +hwaddr cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr, +MemTxAttrs *attrs);/** * cpu_get_phys_page_debug:
@@ -601,12 +591,7 @@ static inline hwaddr cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,* * Returns: Corresponding physical page address or -1 if no page found. */ -static inline hwaddr cpu_get_phys_page_debug (CPUState *cpu,vaddr addr) -{ -MemTxAttrs attrs = {}; - -return cpu_get_phys_page_attrs_debug (cpu, addr, &attrs); -} +hwaddr cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);/** cpu_asidx_from_attrs: * @cpu: CPU
@@ -615,17 +600,7 @@ static inline hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr addr)* Returns the address space index specifying the CPU AddressSpace * to use for a memory access with the given transaction attributes. */ -static inline int cpu_asidx_from_attrs (CPUState *cpu,MemTxAttrs attrs) -{ -CPUClass *cc =CPU_GET_CLASS (cpu); -int ret =0 ; - -if (cc->asidx_from_attrs) { - ret = cc->asidx_from_attrs (cpu, attrs); -assert (ret < cpu->num_ases && ret >=0 ); - } -return ret; -} +int cpu_asidx_from_attrs (CPUState *cpu,MemTxAttrs attrs);#endif /* CONFIG_USER_ONLY */
hw/core/cpu.c +32 -0
@@ -94,6 +94,38 @@ static void cpu_common_get_memory_mapping(CPUState *cpu,error_setg (errp,"Obtaining memory mappings is unsupported on this CPU." ); } +hwaddr cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr, +MemTxAttrs *attrs) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + +if (cc->get_phys_page_attrs_debug) { +return cc->get_phys_page_attrs_debug (cpu, addr, attrs); + } +/* Fallback for CPUs which don't implement the _attrs_ hook */ + *attrs =MEMTXATTRS_UNSPECIFIED ; +return cc->get_phys_page_debug (cpu, addr); +} + +hwaddr cpu_get_phys_page_debug (CPUState *cpu,vaddr addr) +{ +MemTxAttrs attrs = {}; + +return cpu_get_phys_page_attrs_debug (cpu, addr, &attrs); +} + +int cpu_asidx_from_attrs (CPUState *cpu,MemTxAttrs attrs) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); +int ret =0 ; + +if (cc->asidx_from_attrs) { + ret = cc->asidx_from_attrs (cpu, attrs); +assert (ret < cpu->num_ases && ret >=0 ); + } +return ret; +} +/* Resetting the IRQ comes from across the code base so we take the * BQL here if we need to. cpu_interrupt assumes it is held.*/ void cpu_reset_interrupt (CPUState *cpu,int mask)
Signature · 1 line
2.26.2
PATCH 3/16 cpu: Introduce cpu_virtio_is_big_endian()
In reply to Philippe Mathieu-DaudéIntroduce the cpu_virtio_is_big_endian() generic helper to avoid calling CPUClass internal virtio_is_big_endian() one.
--- include/hw/core/cpu.h | 9 +++++++++ hw/core/cpu.c | 8 ++++++-- hw/virtio/virtio.c | 4 +--- 3 files changed, 16 insertions(+), 5 deletions(-)
include/hw/core/cpu.h +9 -0
@@ -602,6 +602,15 @@ hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);*/ int cpu_asidx_from_attrs (CPUState *cpu,MemTxAttrs attrs); +/** +* cpu_virtio_is_big_endian: +* @cpu: CPU + +* Returns %true if a CPU which supports runtime configurable endianness +* is currently big-endian. +*/ +bool cpu_virtio_is_big_endian (CPUState *cpu); +#endif /* CONFIG_USER_ONLY */ /**
hw/core/cpu.c +6 -2
@@ -218,8 +218,13 @@ static int cpu_common_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg)return 0 ; } -static bool cpu_common_virtio_is_big_endian (CPUState *cpu) +bool cpu_virtio_is_big_endian (CPUState *cpu) { +CPUClass *cc =CPU_GET_CLASS (cpu); + +if (cc->virtio_is_big_endian) { +return cc->virtio_is_big_endian (cpu); + }return target_words_bigendian (); }
@@ -438,7 +443,6 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->write_elf64_note = cpu_common_write_elf64_note; k->gdb_read_register = cpu_common_gdb_read_register; k->gdb_write_register = cpu_common_gdb_write_register; - k->virtio_is_big_endian = cpu_common_virtio_is_big_endian;set_bit (DEVICE_CATEGORY_CPU , dc->categories); dc->realize = cpu_common_realizefn; dc->unrealize = cpu_common_unrealizefn;
hw/virtio/virtio.c +1 -3
@@ -1973,9 +1973,7 @@ static enum virtio_device_endian virtio_default_endian(void)static enum virtio_device_endian virtio_current_cpu_endian (void ) { -CPUClass *cc =CPU_GET_CLASS (current_cpu); - -if (cc->virtio_is_big_endian (current_cpu)) { +if (cpu_virtio_is_big_endian (current_cpu)) {return VIRTIO_DEVICE_ENDIAN_BIG ; }else {return VIRTIO_DEVICE_ENDIAN_LITTLE ;
Signature · 1 line
2.26.2
PATCH 4/16 cpu: Directly use cpu_write_elf*() fallback handlers in place
In reply to Philippe Mathieu-DaudéNo code directly accesses CPUClass::write_elf*() handlers out of hw/core/cpu.c (the rest are assignation in target/ code):
$ git grep -F -- '->write_elf' hw/core/cpu.c:157: return (*cc->write_elf32_qemunote)(f, cpu, opaque); hw/core/cpu.c:171: return (*cc->write_elf32_note)(f, cpu, cpuid, opaque); hw/core/cpu.c:186: return (*cc->write_elf64_qemunote)(f, cpu, opaque); hw/core/cpu.c:200: return (*cc->write_elf64_note)(f, cpu, cpuid, opaque); hw/core/cpu.c:440: k->write_elf32_qemunote = cpu_common_write_elf32_qemunote; hw/core/cpu.c:441: k->write_elf32_note = cpu_common_write_elf32_note; hw/core/cpu.c:442: k->write_elf64_qemunote = cpu_common_write_elf64_qemunote; hw/core/cpu.c:443: k->write_elf64_note = cpu_common_write_elf64_note; target/arm/cpu.c:2304: cc->write_elf64_note = arm_cpu_write_elf64_note; target/arm/cpu.c:2305: cc->write_elf32_note = arm_cpu_write_elf32_note; target/i386/cpu.c:7425: cc->write_elf64_note = x86_cpu_write_elf64_note; target/i386/cpu.c:7426: cc->write_elf64_qemunote = x86_cpu_write_elf64_qemunote; target/i386/cpu.c:7427: cc->write_elf32_note = x86_cpu_write_elf32_note; target/i386/cpu.c:7428: cc->write_elf32_qemunote = x86_cpu_write_elf32_qemunote; target/ppc/translate_init.c.inc:10891: cc->write_elf64_note = ppc64_cpu_write_elf64_note; target/ppc/translate_init.c.inc:10892: cc->write_elf32_note = ppc32_cpu_write_elf32_note; target/s390x/cpu.c:522: cc->write_elf64_note = s390_cpu_write_elf64_note;
Check the handler presence in place and remove the common fallback code.
--- hw/core/cpu.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-)
hw/core/cpu.c +12 -31
@@ -154,60 +154,45 @@ int cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu, {CPUClass *cc =CPU_GET_CLASS (cpu); +if (!cc->write_elf32_qemunote) { +return 0 ; + }return (*cc->write_elf32_qemunote)(f, cpu, opaque); } -static int cpu_common_write_elf32_qemunote (WriteCoreDumpFunction f, -CPUState *cpu,void *opaque) -{ -return 0 ; -} -int cpu_write_elf32_note (WriteCoreDumpFunction f,CPUState *cpu,int cpuid,void *opaque) {CPUClass *cc =CPU_GET_CLASS (cpu); +if (!cc->write_elf32_note) { +return -1 ; + }return (*cc->write_elf32_note)(f, cpu, cpuid, opaque); } -static int cpu_common_write_elf32_note (WriteCoreDumpFunction f, -CPUState *cpu,int cpuid, -void *opaque) -{ -return -1 ; -} -int cpu_write_elf64_qemunote (WriteCoreDumpFunction f,CPUState *cpu,void *opaque) {CPUClass *cc =CPU_GET_CLASS (cpu); +if (!cc->write_elf64_qemunote) { +return 0 ; + }return (*cc->write_elf64_qemunote)(f, cpu, opaque); } -static int cpu_common_write_elf64_qemunote (WriteCoreDumpFunction f, -CPUState *cpu,void *opaque) -{ -return 0 ; -} -int cpu_write_elf64_note (WriteCoreDumpFunction f,CPUState *cpu,int cpuid,void *opaque) {CPUClass *cc =CPU_GET_CLASS (cpu); +if (!cc->write_elf64_note) { +return -1 ; + }return (*cc->write_elf64_note)(f, cpu, cpuid, opaque); } -static int cpu_common_write_elf64_note (WriteCoreDumpFunction f, -CPUState *cpu,int cpuid, -void *opaque) -{ -return -1 ; -} - -static int cpu_common_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg) {return 0 ;
@@ -437,10 +422,6 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->has_work = cpu_common_has_work; k->get_paging_enabled = cpu_common_get_paging_enabled; k->get_memory_mapping = cpu_common_get_memory_mapping; - k->write_elf32_qemunote = cpu_common_write_elf32_qemunote; - k->write_elf32_note = cpu_common_write_elf32_note; - k->write_elf64_qemunote = cpu_common_write_elf64_qemunote; - k->write_elf64_note = cpu_common_write_elf64_note; k->gdb_read_register = cpu_common_gdb_read_register; k->gdb_write_register = cpu_common_gdb_write_register;set_bit (DEVICE_CATEGORY_CPU , dc->categories);
Signature · 1 line
2.26.2
PATCH 5/16 cpu: Directly use get_paging_enabled() fallback handlers in place
In reply to Philippe Mathieu-DaudéNo code uses CPUClass::get_paging_enabled() outside of hw/core/cpu.c:
$ git grep -F -- '->get_paging_enabled' hw/core/cpu.c:74: return cc->get_paging_enabled(cpu); hw/core/cpu.c:438: k->get_paging_enabled = cpu_common_get_paging_enabled; target/i386/cpu.c:7418: cc->get_paging_enabled = x86_cpu_get_paging_enabled;
Check the handler presence in place and remove the common fallback code.
--- hw/core/cpu.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
hw/core/cpu.c +3 -5
@@ -71,11 +71,10 @@ bool cpu_paging_enabled(const CPUState *cpu) {CPUClass *cc =CPU_GET_CLASS (cpu); -return cc->get_paging_enabled (cpu); -} +if (cc->get_paging_enabled) { +return cc->get_paging_enabled (cpu); + } -static bool cpu_common_get_paging_enabled (const CPUState *cpu) -{return false; }
@@ -420,7 +419,6 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->parse_features = cpu_common_parse_features; k->get_arch_id = cpu_common_get_arch_id; k->has_work = cpu_common_has_work; - k->get_paging_enabled = cpu_common_get_paging_enabled; k->get_memory_mapping = cpu_common_get_memory_mapping; k->gdb_read_register = cpu_common_gdb_read_register; k->gdb_write_register = cpu_common_gdb_write_register;
Signature · 1 line
2.26.2
PATCH 6/16 cpu: Directly use get_memory_mapping() fallback handlers in place
In reply to Philippe Mathieu-DaudéNo code uses CPUClass::get_memory_mapping() outside of hw/core/cpu.c:
$ git grep -F -- '->get_memory_mapping' hw/core/cpu.c:87: cc->get_memory_mapping(cpu, list, errp); hw/core/cpu.c:439: k->get_memory_mapping = cpu_common_get_memory_mapping; target/i386/cpu.c:7422: cc->get_memory_mapping = x86_cpu_get_memory_mapping;
Check the handler presence in place and remove the common fallback code.
--- hw/core/cpu.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
hw/core/cpu.c +4 -7
@@ -83,13 +83,11 @@ void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list, {CPUClass *cc =CPU_GET_CLASS (cpu); - cc->get_memory_mapping (cpu, list, errp); -} +if (cc->get_memory_mapping) { + cc->get_memory_mapping (cpu, list, errp); +return ; + } -static void cpu_common_get_memory_mapping (CPUState *cpu, -MemoryMappingList *list, -Error **errp) -{error_setg (errp,"Obtaining memory mappings is unsupported on this CPU." ); }
@@ -419,7 +417,6 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->parse_features = cpu_common_parse_features; k->get_arch_id = cpu_common_get_arch_id; k->has_work = cpu_common_has_work; - k->get_memory_mapping = cpu_common_get_memory_mapping; k->gdb_read_register = cpu_common_gdb_read_register; k->gdb_write_register = cpu_common_gdb_write_register;set_bit (DEVICE_CATEGORY_CPU , dc->categories);
Signature · 1 line
2.26.2
PATCH 7/16 cpu: Introduce CPUSystemOperations structure
In reply to Philippe Mathieu-DaudéIntroduce a structure to hold handler specific to sysemu.
--- include/hw/core/cpu.h | 9 +++++++++ 1 file changed, 9 insertions(+)
include/hw/core/cpu.h +9 -0
@@ -80,6 +80,12 @@ struct TCGCPUOps;/* see accel-cpu.h */ struct AccelCPUClass ; +/* +* struct CPUSystemOperations: System operations specific to a CPU class +*/ +typedef struct CPUSystemOperations { +}CPUSystemOperations ; +/** * CPUClass: * @class_by_name: Callback to map -cpu command line model name to an
@@ -190,6 +196,9 @@ struct CPUClass {bool gdb_stop_before_watchpoint;struct AccelCPUClass *accel_cpu; +/* when system emulation is not available, this pointer is NULL */ +struct CPUSystemOperations system_ops; +/* when TCG is not available, this pointer is NULL */ struct TCGCPUOps *tcg_ops; };
Signature · 1 line
2.26.2
Quoted 12 lines · Philippe Mathieu-Daudé
Introduce a structure to hold handler specific to sysemu.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/core/cpu.h | 9 +++++++++ 1 file changed, 9 insertions(+)include/hw/core/cpu.h +0
-0
include/hw/core/cpu.h struct TCGCPUOps; · line 86
Quoted 7 lines
include/hw/core/cpu.h +4
-0@@ -80,6 +80,12 @@ struct TCGCPUOps;/* see accel-cpu.h */ struct AccelCPUClass ; +/* +* struct CPUSystemOperations: System operations specific to a CPU class +*/ +typedef struct CPUSystemOperations {
I'd suggest for consistency and brevity:
SysemuCPUOps .
Let me tell you my full train of thought, just so you understand exactly where I am coming from:
in my view all this camelcase is nonsense, as is typedef. They just cause problems and solve none.
However, considering the existing QEMU conventions, the existence of QOM,
for consistency with the rest of the QEMU code base, especially when looking at stuff around CPUClass, the convention is to use this camel case stuff for objects, so in lieu of
tcg_cpu_ops
I went with TCGCPUOps
(TCG is the standard way to call tcg when case is an option, same for CPU, then Ops).
Here for consistency I would say:
Sysemu (as we are standardizing on calling system emulation/virtualization "sysemu") +CPUOps as before.
=
SysemuCPUOps.
What do you think?
Ciao,
Claudio
Quoted 16 lines
include/hw/core/cpu.h +5
-0+} CPUSystemOperations; +/** * CPUClass: * @class_by_name: Callback to map -cpu command line model name to an @@ -190,6 +196,9 @@ struct CPUClass {bool gdb_stop_before_watchpoint;struct AccelCPUClass *accel_cpu; +/* when system emulation is not available, this pointer is NULL */ +struct CPUSystemOperations system_ops; +/* when TCG is not available, this pointer is NULL */ struct TCGCPUOps *tcg_ops; };
Quoted 25 lines · Philippe Mathieu-Daudé
Introduce a structure to hold handler specific to sysemu.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/core/cpu.h | 9 +++++++++ 1 file changed, 9 insertions(+)include/hw/core/cpu.h +6
-0@@ -80,6 +80,12 @@ struct TCGCPUOps;/* see accel-cpu.h */ struct AccelCPUClass ; +/* +* struct CPUSystemOperations: System operations specific to a CPU class +*/ +typedef struct CPUSystemOperations { +}CPUSystemOperations ; +/** * CPUClass: * @class_by_name: Callback to map -cpu command line model name to an
include/hw/core/cpu.h struct CPUClass { · line 200
Quoted 5 lines
include/hw/core/cpu.h +2
-0@@ -190,6 +196,9 @@ struct CPUClass {bool gdb_stop_before_watchpoint;struct AccelCPUClass *accel_cpu; +/* when system emulation is not available, this pointer is NULL */ +struct CPUSystemOperations system_ops;
and here again for future code base consistency I would say "sysemu_ops".
So we will focus in the future on the "sysemu" keyword for system emulation (in directories, comments, macros etc).
Ciao,
Claudio
Quoted 5 lines
include/hw/core/cpu.h +1
-0+/* when TCG is not available, this pointer is NULL */ struct TCGCPUOps *tcg_ops; };
PATCH 8/16 cpu: Move CPUClass::vmsd to CPUSystemOperations
In reply to Philippe Mathieu-DaudéMigration is specific to system emulation.
--- include/hw/core/cpu.h | 6 ++++-- cpu.c | 12 ++++++------ target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/avr/cpu.c | 2 +- target/cris/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/cpu.c | 2 +- target/lm32/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/moxie/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/riscv/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- 21 files changed, 29 insertions(+), 27 deletions(-)
include/hw/core/cpu.h +4 -2
@@ -84,6 +84,10 @@ struct AccelCPUClass;* struct CPUSystemOperations: System operations specific to a CPU class */ typedef struct CPUSystemOperations { +/** +* @vmsd: State description for migration. +*/ +const VMStateDescription *vmsd; }CPUSystemOperations ;/**
@@ -128,7 +132,6 @@ typedef struct CPUSystemOperations {* 32-bit VM coredump. * @write_elf32_qemunote: Callback for writing a CPU- and QEMU-specific ELF * note to a 32-bit VM coredump. -* @vmsd: State description for migration. * @gdb_num_core_regs: Number of core registers accessible to GDB. * @gdb_core_xml_file: File name for core registers GDB XML description. * @gdb_stop_before_watchpoint: Indicates whether GDB expects the CPU to stop
@@ -183,7 +186,6 @@ struct CPUClass {int (*write_elf32_qemunote)(WriteCoreDumpFunction f,CPUState *cpu,void *opaque); -const VMStateDescription *vmsd;const char *gdb_core_xml_file; gchar * (*gdb_arch_name)(CPUState *cpu);const char * (*gdb_get_dynamic_xml)(CPUState *cpu,const char *xmlname);
cpu.c +6 -6
@@ -138,13 +138,13 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)#endif /* CONFIG_TCG */ #ifdef CONFIG_USER_ONLY -assert (cc->vmsd ==NULL ); +assert (cc->system_ops.vmsd ==NULL );#else if (qdev_get_vmsd (DEVICE (cpu)) ==NULL ) {vmstate_register (NULL , cpu->cpu_index, &vmstate_cpu_common, cpu); } -if (cc->vmsd !=NULL ) { -vmstate_register (NULL , cpu->cpu_index, cc->vmsd, cpu); +if (cc->system_ops.vmsd !=NULL ) { +vmstate_register (NULL , cpu->cpu_index, cc->system_ops.vmsd, cpu); }#endif /* CONFIG_USER_ONLY */ }
@@ -154,10 +154,10 @@ void cpu_exec_unrealizefn(CPUState *cpu)CPUClass *cc =CPU_GET_CLASS (cpu);#ifdef CONFIG_USER_ONLY -assert (cc->vmsd ==NULL ); +assert (cc->system_ops.vmsd ==NULL );#else -if (cc->vmsd !=NULL ) { -vmstate_unregister (NULL , cc->vmsd, cpu); +if (cc->system_ops.vmsd !=NULL ) { +vmstate_unregister (NULL , cc->system_ops.vmsd, cpu); }if (qdev_get_vmsd (DEVICE (cpu)) ==NULL ) {vmstate_unregister (NULL , &vmstate_cpu_common, cpu);
target/alpha/cpu.c +1 -1
@@ -237,7 +237,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = alpha_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_alpha_cpu; + cc->system_ops.vmsd = &vmstate_alpha_cpu;#endif cc->disas_set_info = alpha_cpu_disas_set_info;
target/arm/cpu.c +1 -1
@@ -2299,7 +2299,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug; cc->asidx_from_attrs = arm_asidx_from_attrs; - cc->vmsd = &vmstate_arm_cpu; + cc->system_ops.vmsd = &vmstate_arm_cpu; cc->virtio_is_big_endian = arm_cpu_virtio_is_big_endian; cc->write_elf64_note = arm_cpu_write_elf64_note; cc->write_elf32_note = arm_cpu_write_elf32_note;
target/avr/cpu.c +1 -1
@@ -213,7 +213,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = avr_cpu_set_pc; cc->memory_rw_debug = avr_cpu_memory_rw_debug; cc->get_phys_page_debug = avr_cpu_get_phys_page_debug; - cc->vmsd = &vms_avr_cpu; + cc->system_ops.vmsd = &vms_avr_cpu; cc->disas_set_info = avr_cpu_disas_set_info; cc->gdb_read_register = avr_cpu_gdb_read_register; cc->gdb_write_register = avr_cpu_gdb_write_register;
target/cris/cpu.c +1 -1
@@ -293,7 +293,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = cris_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = cris_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_cris_cpu; + cc->system_ops.vmsd = &vmstate_cris_cpu;#endif cc->gdb_num_core_regs =49 ;
target/hppa/cpu.c +1 -1
@@ -162,7 +162,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = hppa_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = hppa_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_hppa_cpu; + cc->system_ops.vmsd = &vmstate_hppa_cpu;#endif cc->disas_set_info = hppa_cpu_disas_set_info; cc->gdb_num_core_regs =128 ;
target/i386/cpu.c +1 -1
@@ -7426,7 +7426,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->write_elf64_qemunote = x86_cpu_write_elf64_qemunote; cc->write_elf32_note = x86_cpu_write_elf32_note; cc->write_elf32_qemunote = x86_cpu_write_elf32_qemunote; - cc->vmsd = &vmstate_x86_cpu; + cc->system_ops.vmsd = &vmstate_x86_cpu;#endif /* !CONFIG_USER_ONLY */ cc->gdb_arch_name = x86_gdb_arch_name;
target/lm32/cpu.c +1 -1
@@ -241,7 +241,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = lm32_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = lm32_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_lm32_cpu; + cc->system_ops.vmsd = &vmstate_lm32_cpu;#endif cc->gdb_num_core_regs =32 +7 ; cc->gdb_stop_before_watchpoint = true;
target/m68k/cpu.c +1 -1
@@ -533,7 +533,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->gdb_write_register = m68k_cpu_gdb_write_register;#if defined(CONFIG_SOFTMMU ) cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_m68k_cpu; + cc->system_ops.vmsd = &vmstate_m68k_cpu;#endif cc->disas_set_info = m68k_cpu_disas_set_info;
target/microblaze/cpu.c +1 -1
@@ -387,7 +387,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_attrs_debug = mb_cpu_get_phys_page_attrs_debug; - cc->vmsd = &vmstate_mb_cpu; + cc->system_ops.vmsd = &vmstate_mb_cpu;#endif device_class_set_props (dc, mb_properties); cc->gdb_num_core_regs =32 +27 ;
target/mips/cpu.c +1 -1
@@ -720,7 +720,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->gdb_write_register = mips_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = mips_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_mips_cpu; + cc->system_ops.vmsd = &vmstate_mips_cpu;#endif cc->disas_set_info = mips_cpu_disas_set_info; cc->gdb_num_core_regs =73 ;
target/moxie/cpu.c +1 -1
@@ -122,7 +122,7 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = moxie_cpu_set_pc;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_moxie_cpu; + cc->system_ops.vmsd = &vmstate_moxie_cpu;#endif cc->disas_set_info = moxie_cpu_disas_set_info; cc->tcg_ops = &moxie_tcg_ops;
target/openrisc/cpu.c +1 -1
@@ -204,7 +204,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = openrisc_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = openrisc_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_openrisc_cpu; + cc->system_ops.vmsd = &vmstate_openrisc_cpu;#endif cc->gdb_num_core_regs =32 +3 ; cc->disas_set_info = openrisc_disas_set_info;
target/riscv/cpu.c +1 -1
@@ -623,7 +623,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = riscv_cpu_get_phys_page_debug;/* For now, mark unmigratable: */ - cc->vmsd = &vmstate_riscv_cpu; + cc->system_ops.vmsd = &vmstate_riscv_cpu;#endif cc->gdb_arch_name = riscv_gdb_arch_name; cc->gdb_get_dynamic_xml = riscv_gdb_get_dynamic_xml;
target/s390x/cpu.c +1 -1
@@ -517,7 +517,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = s390_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_s390_cpu; + cc->system_ops.vmsd = &vmstate_s390_cpu; cc->get_crash_info = s390_cpu_get_crash_info; cc->write_elf64_note = s390_cpu_write_elf64_note;#endif
target/sh4/cpu.c +1 -1
@@ -262,7 +262,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs =59 ; - cc->vmsd = &vmstate_sh_cpu; + cc->system_ops.vmsd = &vmstate_sh_cpu; cc->tcg_ops = &superh_tcg_ops; }
target/sparc/cpu.c +1 -1
@@ -889,7 +889,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = sparc_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = sparc_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_sparc_cpu; + cc->system_ops.vmsd = &vmstate_sparc_cpu;#endif cc->disas_set_info = cpu_sparc_disas_set_info;
target/unicore32/cpu.c +1 -1
@@ -146,7 +146,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = uc32_cpu_dump_state; cc->set_pc = uc32_cpu_set_pc; cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_uc32_cpu; + cc->system_ops.vmsd = &vmstate_uc32_cpu; cc->tcg_ops = &uc32_tcg_ops; }
target/xtensa/cpu.c +1 -1
@@ -218,7 +218,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug;#endif cc->disas_set_info = xtensa_cpu_disas_set_info; - cc->vmsd = &vmstate_xtensa_cpu; + cc->system_ops.vmsd = &vmstate_xtensa_cpu; cc->tcg_ops = &xtensa_tcg_ops; }
target/ppc/translate_init.c.inc +1 -1
@@ -10885,7 +10885,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = ppc_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_ppc_cpu; + cc->system_ops.vmsd = &vmstate_ppc_cpu; #endif #if defined(CONFIG_SOFTMMU) cc->write_elf64_note = ppc64_cpu_write_elf64_note;
Signature · 1 line
2.26.2
PATCH 9/16 cpu: Move CPUClass::virtio_is_big_endian to CPUSystemOperations
In reply to Philippe Mathieu-DaudéVirtIO devices are only meaningful with system emulation.
--- include/hw/core/cpu.h | 13 ++++++++----- hw/core/cpu.c | 4 ++-- target/arm/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-)
include/hw/core/cpu.h +8 -5
@@ -84,6 +84,14 @@ struct AccelCPUClass;* struct CPUSystemOperations: System operations specific to a CPU class */ typedef struct CPUSystemOperations { + /** + * @virtio_is_big_endian: Callback to return %true if a CPU which supports + * runtime configurable endianness is currently big-endian. + * Non-configurable CPUs can use the default implementation of this method. + * This method should not be used by any callers other than the pre-1.0 + * virtio devices. + */ + bool (*virtio_is_big_endian)(CPUState *cpu); /** * @vmsd: State description for migration. */
@@ -97,10 +105,6 @@ typedef struct CPUSystemOperations {* @parse_features: Callback to parse command line arguments. * @reset_dump_flags: #CPUDumpFlags to use for reset logging. * @has_work: Callback for checking if there is work to do. -* @virtio_is_big_endian: Callback to return %true if a CPU which supports -* runtime configurable endianness is currently big-endian. Non-configurable -* CPUs can use the default implementation of this method. This method should -* not be used by any callers other than the pre-1.0 virtio devices. * @memory_rw_debug: Callback for GDB memory access. * @dump_state: Callback for dumping state. * @dump_statistics: Callback for dumping statistics.
@@ -159,7 +163,6 @@ struct CPUClass {int reset_dump_flags;bool (*has_work)(CPUState *cpu); -bool (*virtio_is_big_endian)(CPUState *cpu);int (*memory_rw_debug)(CPUState *cpu,vaddr addr,uint8_t *buf,int len,bool is_write);void (*dump_state)(CPUState *cpu,FILE *,int flags);
hw/core/cpu.c +2 -2
@@ -204,8 +204,8 @@ bool cpu_virtio_is_big_endian(CPUState *cpu) {CPUClass *cc =CPU_GET_CLASS (cpu); -if (cc->virtio_is_big_endian) { -return cc->virtio_is_big_endian (cpu); +if (cc->system_ops.virtio_is_big_endian) { +return cc->system_ops.virtio_is_big_endian (cpu); }return target_words_bigendian (); }
target/arm/cpu.c +1 -1
@@ -2300,7 +2300,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug; cc->asidx_from_attrs = arm_asidx_from_attrs; cc->system_ops.vmsd = &vmstate_arm_cpu; - cc->virtio_is_big_endian = arm_cpu_virtio_is_big_endian; + cc->system_ops.virtio_is_big_endian = arm_cpu_virtio_is_big_endian; cc->write_elf64_note = arm_cpu_write_elf64_note; cc->write_elf32_note = arm_cpu_write_elf32_note;#endif
target/ppc/translate_init.c.inc +1 -1
@@ -10909,7 +10909,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_core_xml_file = "power-core.xml"; #endif #ifndef CONFIG_USER_ONLY - cc->virtio_is_big_endian = ppc_cpu_is_big_endian; + cc->system_ops.virtio_is_big_endian = ppc_cpu_is_big_endian; #endif cc->disas_set_info = ppc_disas_set_info;
Signature · 1 line
2.26.2
PATCH 10/16 cpu: Move CPUClass::get_crash_info to CPUSystemOperations
In reply to Philippe Mathieu-Daudécpu_get_crash_info() is called on GUEST_PANICKED events, which only occur in system emulation.
--- include/hw/core/cpu.h | 6 +++++- hw/core/cpu.c | 4 ++-- target/i386/cpu.c | 2 +- target/s390x/cpu.c | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-)
include/hw/core/cpu.h +5 -1
@@ -84,6 +84,11 @@ struct AccelCPUClass;* struct CPUSystemOperations: System operations specific to a CPU class */ typedef struct CPUSystemOperations { + /** + * @get_crash_info: Callback for reporting guest crash information in + * GUEST_PANICKED events. + */ + GuestPanicInformation* (*get_crash_info)(CPUState *cpu); /** * @virtio_is_big_endian: Callback to return %true if a CPU which supports * runtime configurable endianness is currently big-endian.
@@ -166,7 +171,6 @@ struct CPUClass {int (*memory_rw_debug)(CPUState *cpu,vaddr addr,uint8_t *buf,int len,bool is_write);void (*dump_state)(CPUState *cpu,FILE *,int flags); - GuestPanicInformation* (*get_crash_info)(CPUState *cpu);void (*dump_statistics)(CPUState *cpu,int flags);int64_t (*get_arch_id)(CPUState *cpu);bool (*get_paging_enabled)(const CPUState *cpu);
hw/core/cpu.c +2 -2
@@ -220,8 +220,8 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cpu)CPUClass *cc =CPU_GET_CLASS (cpu);GuestPanicInformation *res =NULL ; -if (cc->get_crash_info) { - res = cc->get_crash_info (cpu); +if (cc->system_ops.get_crash_info) { + res = cc->system_ops.get_crash_info (cpu); }return res; }
target/i386/cpu.c +1 -1
@@ -7421,7 +7421,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->asidx_from_attrs = x86_asidx_from_attrs; cc->get_memory_mapping = x86_cpu_get_memory_mapping; cc->get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug; - cc->get_crash_info = x86_cpu_get_crash_info; + cc->system_ops.get_crash_info = x86_cpu_get_crash_info; cc->write_elf64_note = x86_cpu_write_elf64_note; cc->write_elf64_qemunote = x86_cpu_write_elf64_qemunote; cc->write_elf32_note = x86_cpu_write_elf32_note;
target/s390x/cpu.c +1 -1
@@ -518,7 +518,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_s390_cpu; - cc->get_crash_info = s390_cpu_get_crash_info; + cc->system_ops.get_crash_info = s390_cpu_get_crash_info; cc->write_elf64_note = s390_cpu_write_elf64_note;#endif cc->disas_set_info = s390_cpu_disas_set_info;
Signature · 1 line
2.26.2
PATCH 11/16 cpu: Move CPUClass::write_elf* to CPUSystemOperations
In reply to Philippe Mathieu-DaudéThe write_elf*() handlers are used to dump vmcore images. This feature is only meaningful for system emulation.
--- include/hw/core/cpu.h | 41 +++++++++++++++++++-------------- hw/core/cpu.c | 16 ++++++------- target/arm/cpu.c | 4 ++-- target/i386/cpu.c | 8 +++---- target/s390x/cpu.c | 2 +- target/ppc/translate_init.c.inc | 4 ++-- 6 files changed, 41 insertions(+), 34 deletions(-)
include/hw/core/cpu.h +24 -17
@@ -89,6 +89,30 @@ typedef struct CPUSystemOperations {* GUEST_PANICKED events. */ GuestPanicInformation* (*get_crash_info)(CPUState *cpu); +/** +* @write_elf32_note: Callback for writing a CPU-specific ELF note to a +* 32-bit VM coredump. +*/ +int (*write_elf32_note)(WriteCoreDumpFunction f,CPUState *cpu, +int cpuid,void *opaque); +/** +* @write_elf64_note: Callback for writing a CPU-specific ELF note to a +* 64-bit VM coredump. +*/ +int (*write_elf64_note)(WriteCoreDumpFunction f,CPUState *cpu, +int cpuid,void *opaque); +/** +* @write_elf32_qemunote: Callback for writing a CPU- and QEMU-specific ELF +* note to a 32-bit VM coredump. +*/ +int (*write_elf32_qemunote)(WriteCoreDumpFunction f,CPUState *cpu, +void *opaque); +/** +* @write_elf64_qemunote: Callback for writing a CPU- and QEMU-specific ELF +* note to a 64-bit VM coredump. +*/ +int (*write_elf64_qemunote)(WriteCoreDumpFunction f,CPUState *cpu, +void *opaque);/** * @virtio_is_big_endian: Callback to return %true if a CPU which supports * runtime configurable endianness is currently big-endian.
@@ -133,14 +157,6 @@ typedef struct CPUSystemOperations {* a memory access with the specified memory transaction attributes. * @gdb_read_register: Callback for letting GDB read a register. * @gdb_write_register: Callback for letting GDB write a register. -* @write_elf64_note: Callback for writing a CPU-specific ELF note to a -* 64-bit VM coredump. -* @write_elf32_qemunote: Callback for writing a CPU- and QEMU-specific ELF -* note to a 32-bit VM coredump. -* @write_elf32_note: Callback for writing a CPU-specific ELF note to a -* 32-bit VM coredump. -* @write_elf32_qemunote: Callback for writing a CPU- and QEMU-specific ELF -* note to a 32-bit VM coredump. * @gdb_num_core_regs: Number of core registers accessible to GDB. * @gdb_core_xml_file: File name for core registers GDB XML description. * @gdb_stop_before_watchpoint: Indicates whether GDB expects the CPU to stop
@@ -184,15 +200,6 @@ struct CPUClass {int (*gdb_read_register)(CPUState *cpu,GByteArray *buf,int reg);int (*gdb_write_register)(CPUState *cpu,uint8_t *buf,int reg); -int (*write_elf64_note)(WriteCoreDumpFunction f,CPUState *cpu, -int cpuid,void *opaque); -int (*write_elf64_qemunote)(WriteCoreDumpFunction f,CPUState *cpu, -void *opaque); -int (*write_elf32_note)(WriteCoreDumpFunction f,CPUState *cpu, -int cpuid,void *opaque); -int (*write_elf32_qemunote)(WriteCoreDumpFunction f,CPUState *cpu, -void *opaque); -const char *gdb_core_xml_file; gchar * (*gdb_arch_name)(CPUState *cpu);const char * (*gdb_get_dynamic_xml)(CPUState *cpu,const char *xmlname);
hw/core/cpu.c +8 -8
@@ -151,10 +151,10 @@ int cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu, {CPUClass *cc =CPU_GET_CLASS (cpu); -if (!cc->write_elf32_qemunote) { +if (!cc->system_ops.write_elf32_qemunote) {return 0 ; } -return (*cc->write_elf32_qemunote)(f, cpu, opaque); +return (*cc->system_ops.write_elf32_qemunote)(f, cpu, opaque); } int cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cpu,
@@ -162,10 +162,10 @@ int cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cpu, {CPUClass *cc =CPU_GET_CLASS (cpu); -if (!cc->write_elf32_note) { +if (!cc->system_ops.write_elf32_note) {return -1 ; } -return (*cc->write_elf32_note)(f, cpu, cpuid, opaque); +return (*cc->system_ops.write_elf32_note)(f, cpu, cpuid, opaque); } int cpu_write_elf64_qemunote(WriteCoreDumpFunction f, CPUState *cpu,
@@ -173,10 +173,10 @@ int cpu_write_elf64_qemunote(WriteCoreDumpFunction f, CPUState *cpu, {CPUClass *cc =CPU_GET_CLASS (cpu); -if (!cc->write_elf64_qemunote) { +if (!cc->system_ops.write_elf64_qemunote) {return 0 ; } -return (*cc->write_elf64_qemunote)(f, cpu, opaque); +return (*cc->system_ops.write_elf64_qemunote)(f, cpu, opaque); } int cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cpu,
@@ -184,10 +184,10 @@ int cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cpu, {CPUClass *cc =CPU_GET_CLASS (cpu); -if (!cc->write_elf64_note) { +if (!cc->system_ops.write_elf64_note) {return -1 ; } -return (*cc->write_elf64_note)(f, cpu, cpuid, opaque); +return (*cc->system_ops.write_elf64_note)(f, cpu, cpuid, opaque); }static int cpu_common_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg)
target/arm/cpu.c +2 -2
@@ -2301,8 +2301,8 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->asidx_from_attrs = arm_asidx_from_attrs; cc->system_ops.vmsd = &vmstate_arm_cpu; cc->system_ops.virtio_is_big_endian = arm_cpu_virtio_is_big_endian; - cc->write_elf64_note = arm_cpu_write_elf64_note; - cc->write_elf32_note = arm_cpu_write_elf32_note; + cc->system_ops.write_elf64_note = arm_cpu_write_elf64_note; + cc->system_ops.write_elf32_note = arm_cpu_write_elf32_note;#endif cc->gdb_num_core_regs =26 ; cc->gdb_core_xml_file ="arm-core.xml" ;
target/i386/cpu.c +4 -4
@@ -7422,10 +7422,10 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->get_memory_mapping = x86_cpu_get_memory_mapping; cc->get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug; cc->system_ops.get_crash_info = x86_cpu_get_crash_info; - cc->write_elf64_note = x86_cpu_write_elf64_note; - cc->write_elf64_qemunote = x86_cpu_write_elf64_qemunote; - cc->write_elf32_note = x86_cpu_write_elf32_note; - cc->write_elf32_qemunote = x86_cpu_write_elf32_qemunote; + cc->system_ops.write_elf64_note = x86_cpu_write_elf64_note; + cc->system_ops.write_elf64_qemunote = x86_cpu_write_elf64_qemunote; + cc->system_ops.write_elf32_note = x86_cpu_write_elf32_note; + cc->system_ops.write_elf32_qemunote = x86_cpu_write_elf32_qemunote; cc->system_ops.vmsd = &vmstate_x86_cpu;#endif /* !CONFIG_USER_ONLY */
target/s390x/cpu.c +1 -1
@@ -519,7 +519,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_s390_cpu; cc->system_ops.get_crash_info = s390_cpu_get_crash_info; - cc->write_elf64_note = s390_cpu_write_elf64_note; + cc->system_ops.write_elf64_note = s390_cpu_write_elf64_note;#endif cc->disas_set_info = s390_cpu_disas_set_info; cc->gdb_num_core_regs =S390_NUM_CORE_REGS ;
target/ppc/translate_init.c.inc +2 -2
@@ -10888,8 +10888,8 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->system_ops.vmsd = &vmstate_ppc_cpu; #endif #if defined(CONFIG_SOFTMMU) - cc->write_elf64_note = ppc64_cpu_write_elf64_note; - cc->write_elf32_note = ppc32_cpu_write_elf32_note; + cc->system_ops.write_elf64_note = ppc64_cpu_write_elf64_note; + cc->system_ops.write_elf32_note = ppc32_cpu_write_elf32_note; #endif cc->gdb_num_core_regs = 71;
Signature · 1 line
2.26.2
PATCH 12/16 cpu: Move CPUClass::asidx_from_attrs to CPUSystemOperations
In reply to Philippe Mathieu-Daudé--- include/hw/core/cpu.h | 8 +++++--- hw/core/cpu.c | 4 ++-- target/arm/cpu.c | 2 +- target/i386/cpu.c | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-)
include/hw/core/cpu.h +5 -3
@@ -84,6 +84,11 @@ struct AccelCPUClass;* struct CPUSystemOperations: System operations specific to a CPU class */ typedef struct CPUSystemOperations { + /** + * @asidx_from_attrs: Callback to return the CPU AddressSpace to use for + * a memory access with the specified memory transaction attributes. + */ + int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs); /** * @get_crash_info: Callback for reporting guest crash information in * GUEST_PANICKED events.
@@ -153,8 +158,6 @@ typedef struct CPUSystemOperations {* associated memory transaction attributes to use for the access. * CPUs which use memory transaction attributes should implement this * instead of get_phys_page_debug. -* @asidx_from_attrs: Callback to return the CPU AddressSpace to use for -* a memory access with the specified memory transaction attributes. * @gdb_read_register: Callback for letting GDB read a register. * @gdb_write_register: Callback for letting GDB write a register. * @gdb_num_core_regs: Number of core registers accessible to GDB.
@@ -196,7 +199,6 @@ struct CPUClass {hwaddr (*get_phys_page_debug)(CPUState *cpu,vaddr addr);hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu,vaddr addr,MemTxAttrs *attrs); -int (*asidx_from_attrs)(CPUState *cpu,MemTxAttrs attrs);int (*gdb_read_register)(CPUState *cpu,GByteArray *buf,int reg);int (*gdb_write_register)(CPUState *cpu,uint8_t *buf,int reg);
hw/core/cpu.c +2 -2
@@ -116,8 +116,8 @@ int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs)CPUClass *cc =CPU_GET_CLASS (cpu);int ret =0 ; -if (cc->asidx_from_attrs) { - ret = cc->asidx_from_attrs (cpu, attrs); +if (cc->system_ops.asidx_from_attrs) { + ret = cc->system_ops.asidx_from_attrs (cpu, attrs);assert (ret < cpu->num_ases && ret >=0 ); }return ret;
target/arm/cpu.c +1 -1
@@ -2298,7 +2298,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = arm_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug; - cc->asidx_from_attrs = arm_asidx_from_attrs; + cc->system_ops.asidx_from_attrs = arm_asidx_from_attrs; cc->system_ops.vmsd = &vmstate_arm_cpu; cc->system_ops.virtio_is_big_endian = arm_cpu_virtio_is_big_endian; cc->system_ops.write_elf64_note = arm_cpu_write_elf64_note;
target/i386/cpu.c +1 -1
@@ -7418,7 +7418,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->get_paging_enabled = x86_cpu_get_paging_enabled;#ifndef CONFIG_USER_ONLY - cc->asidx_from_attrs = x86_asidx_from_attrs; + cc->system_ops.asidx_from_attrs = x86_asidx_from_attrs; cc->get_memory_mapping = x86_cpu_get_memory_mapping; cc->get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug; cc->system_ops.get_crash_info = x86_cpu_get_crash_info;
Signature · 1 line
2.26.2
PATCH 13/16 cpu: Move CPUClass::get_phys_page_debug to CPUSystemOperations
In reply to Philippe Mathieu-Daudé--- include/hw/core/cpu.h | 21 +++++++++++++-------- hw/core/cpu.c | 6 +++--- target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/avr/cpu.c | 2 +- target/cris/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/cpu.c | 2 +- target/lm32/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/moxie/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- 24 files changed, 38 insertions(+), 33 deletions(-)
include/hw/core/cpu.h +13 -8
@@ -84,6 +84,19 @@ struct AccelCPUClass;* struct CPUSystemOperations: System operations specific to a CPU class */ typedef struct CPUSystemOperations { + /** + * @get_phys_page_debug: Callback for obtaining a physical address. + */ + hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr); + /** + * @get_phys_page_attrs_debug: Callback for obtaining a physical address + * and the associated memory transaction attributes to use for the + * access. + * CPUs which use memory transaction attributes should implement this + * instead of get_phys_page_debug. + */ + hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr, + MemTxAttrs *attrs); /** * @asidx_from_attrs: Callback to return the CPU AddressSpace to use for * a memory access with the specified memory transaction attributes.
@@ -153,11 +166,6 @@ typedef struct CPUSystemOperations {* If the target behaviour here is anything other than "set * the PC register to the value passed in" then the target must * also implement the synchronize_from_tb hook. -* @get_phys_page_debug: Callback for obtaining a physical address. -* @get_phys_page_attrs_debug: Callback for obtaining a physical address and the -* associated memory transaction attributes to use for the access. -* CPUs which use memory transaction attributes should implement this -* instead of get_phys_page_debug. * @gdb_read_register: Callback for letting GDB read a register. * @gdb_write_register: Callback for letting GDB write a register. * @gdb_num_core_regs: Number of core registers accessible to GDB.
@@ -196,9 +204,6 @@ struct CPUClass {void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list,Error **errp);void (*set_pc)(CPUState *cpu,vaddr value); -hwaddr (*get_phys_page_debug)(CPUState *cpu,vaddr addr); -hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu,vaddr addr, -MemTxAttrs *attrs);int (*gdb_read_register)(CPUState *cpu,GByteArray *buf,int reg);int (*gdb_write_register)(CPUState *cpu,uint8_t *buf,int reg);
hw/core/cpu.c +3 -3
@@ -96,12 +96,12 @@ hwaddr cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, {CPUClass *cc =CPU_GET_CLASS (cpu); -if (cc->get_phys_page_attrs_debug) { -return cc->get_phys_page_attrs_debug (cpu, addr, attrs); +if (cc->system_ops.get_phys_page_attrs_debug) { +return cc->system_ops.get_phys_page_attrs_debug (cpu, addr, attrs); }/* Fallback for CPUs which don't implement the _attrs_ hook */ *attrs =MEMTXATTRS_UNSPECIFIED ; -return cc->get_phys_page_debug (cpu, addr); +return cc->system_ops.get_phys_page_debug (cpu, addr); }hwaddr cpu_get_phys_page_debug (CPUState *cpu,vaddr addr)
target/alpha/cpu.c +1 -1
@@ -236,7 +236,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = alpha_cpu_gdb_read_register; cc->gdb_write_register = alpha_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = alpha_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_alpha_cpu;#endif cc->disas_set_info = alpha_cpu_disas_set_info;
target/arm/cpu.c +1 -1
@@ -2297,7 +2297,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = arm_cpu_gdb_read_register; cc->gdb_write_register = arm_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug; + cc->system_ops.get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug; cc->system_ops.asidx_from_attrs = arm_asidx_from_attrs; cc->system_ops.vmsd = &vmstate_arm_cpu; cc->system_ops.virtio_is_big_endian = arm_cpu_virtio_is_big_endian;
target/avr/cpu.c +1 -1
@@ -212,7 +212,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = avr_cpu_dump_state; cc->set_pc = avr_cpu_set_pc; cc->memory_rw_debug = avr_cpu_memory_rw_debug; - cc->get_phys_page_debug = avr_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = avr_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vms_avr_cpu; cc->disas_set_info = avr_cpu_disas_set_info; cc->gdb_read_register = avr_cpu_gdb_read_register;
target/cris/cpu.c +1 -1
@@ -292,7 +292,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = cris_cpu_gdb_read_register; cc->gdb_write_register = cris_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = cris_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = cris_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_cris_cpu;#endif
target/hppa/cpu.c +1 -1
@@ -161,7 +161,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = hppa_cpu_gdb_read_register; cc->gdb_write_register = hppa_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = hppa_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = hppa_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_hppa_cpu;#endif cc->disas_set_info = hppa_cpu_disas_set_info;
target/i386/cpu.c +1 -1
@@ -7420,7 +7420,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->system_ops.asidx_from_attrs = x86_asidx_from_attrs; cc->get_memory_mapping = x86_cpu_get_memory_mapping; - cc->get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug; + cc->system_ops.get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug; cc->system_ops.get_crash_info = x86_cpu_get_crash_info; cc->system_ops.write_elf64_note = x86_cpu_write_elf64_note; cc->system_ops.write_elf64_qemunote = x86_cpu_write_elf64_qemunote;
target/lm32/cpu.c +1 -1
@@ -240,7 +240,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = lm32_cpu_gdb_read_register; cc->gdb_write_register = lm32_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = lm32_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = lm32_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_lm32_cpu;#endif cc->gdb_num_core_regs =32 +7 ;
target/m68k/cpu.c +1 -1
@@ -532,7 +532,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->gdb_read_register = m68k_cpu_gdb_read_register; cc->gdb_write_register = m68k_cpu_gdb_write_register;#if defined(CONFIG_SOFTMMU ) - cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = m68k_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_m68k_cpu;#endif cc->disas_set_info = m68k_cpu_disas_set_info;
target/microblaze/cpu.c +1 -1
@@ -386,7 +386,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = mb_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_attrs_debug = mb_cpu_get_phys_page_attrs_debug; + cc->system_ops.get_phys_page_attrs_debug = mb_cpu_get_phys_page_attrs_debug; cc->system_ops.vmsd = &vmstate_mb_cpu;#endif device_class_set_props (dc, mb_properties);
target/mips/cpu.c +1 -1
@@ -719,7 +719,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->gdb_read_register = mips_cpu_gdb_read_register; cc->gdb_write_register = mips_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = mips_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = mips_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_mips_cpu;#endif cc->disas_set_info = mips_cpu_disas_set_info;
target/moxie/cpu.c +1 -1
@@ -121,7 +121,7 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = moxie_cpu_dump_state; cc->set_pc = moxie_cpu_set_pc;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = moxie_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_moxie_cpu;#endif cc->disas_set_info = moxie_cpu_disas_set_info;
target/nios2/cpu.c +1 -1
@@ -237,7 +237,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = nios2_cpu_set_pc; cc->disas_set_info = nios2_cpu_disas_set_info;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = nios2_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = nios2_cpu_get_phys_page_debug;#endif cc->gdb_read_register = nios2_cpu_gdb_read_register; cc->gdb_write_register = nios2_cpu_gdb_write_register;
target/openrisc/cpu.c +1 -1
@@ -203,7 +203,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = openrisc_cpu_gdb_read_register; cc->gdb_write_register = openrisc_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = openrisc_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = openrisc_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_openrisc_cpu;#endif cc->gdb_num_core_regs =32 +3 ;
target/riscv/cpu.c +1 -1
@@ -621,7 +621,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) cc->gdb_stop_before_watchpoint = true; cc->disas_set_info = riscv_cpu_disas_set_info;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = riscv_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = riscv_cpu_get_phys_page_debug;/* For now, mark unmigratable: */ cc->system_ops.vmsd = &vmstate_riscv_cpu;#endif
target/rx/cpu.c +1 -1
@@ -204,7 +204,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void *data) cc->gdb_read_register = rx_cpu_gdb_read_register; cc->gdb_write_register = rx_cpu_gdb_write_register; - cc->get_phys_page_debug = rx_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = rx_cpu_get_phys_page_debug; cc->disas_set_info = rx_cpu_disas_set_info; cc->gdb_num_core_regs =26 ;
target/s390x/cpu.c +1 -1
@@ -516,7 +516,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = s390_cpu_gdb_read_register; cc->gdb_write_register = s390_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = s390_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_s390_cpu; cc->system_ops.get_crash_info = s390_cpu_get_crash_info; cc->system_ops.write_elf64_note = s390_cpu_write_elf64_note;
target/sh4/cpu.c +1 -1
@@ -256,7 +256,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = superh_cpu_gdb_read_register; cc->gdb_write_register = superh_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = superh_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = superh_cpu_get_phys_page_debug;#endif cc->disas_set_info = superh_cpu_disas_set_info;
target/sparc/cpu.c +1 -1
@@ -888,7 +888,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = sparc_cpu_gdb_read_register; cc->gdb_write_register = sparc_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = sparc_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = sparc_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_sparc_cpu;#endif cc->disas_set_info = cpu_sparc_disas_set_info;
target/tricore/cpu.c +1 -1
@@ -170,7 +170,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data) cc->dump_state = tricore_cpu_dump_state; cc->set_pc = tricore_cpu_set_pc; - cc->get_phys_page_debug = tricore_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = tricore_cpu_get_phys_page_debug; cc->tcg_ops = &tricore_tcg_ops; }
target/unicore32/cpu.c +1 -1
@@ -145,7 +145,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = uc32_cpu_has_work; cc->dump_state = uc32_cpu_dump_state; cc->set_pc = uc32_cpu_set_pc; - cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = uc32_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_uc32_cpu; cc->tcg_ops = &uc32_tcg_ops; }
target/xtensa/cpu.c +1 -1
@@ -215,7 +215,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = xtensa_cpu_gdb_write_register; cc->gdb_stop_before_watchpoint = true;#ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = xtensa_cpu_get_phys_page_debug;#endif cc->disas_set_info = xtensa_cpu_disas_set_info; cc->system_ops.vmsd = &vmstate_xtensa_cpu;
target/ppc/translate_init.c.inc +1 -1
@@ -10884,7 +10884,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = ppc_cpu_gdb_read_register; cc->gdb_write_register = ppc_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY - cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; + cc->system_ops.get_phys_page_debug = ppc_cpu_get_phys_page_debug; cc->system_ops.vmsd = &vmstate_ppc_cpu; #endif #if defined(CONFIG_SOFTMMU)
Signature · 1 line
2.26.2
PATCH 14/16 cpu: Move CPUClass::get_memory_mapping to CPUSystemOperations
In reply to Philippe Mathieu-Daudé--- include/hw/core/cpu.h | 8 +++++--- hw/core/cpu.c | 4 ++-- target/i386/cpu.c | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-)
include/hw/core/cpu.h +5 -3
@@ -84,6 +84,11 @@ struct AccelCPUClass;* struct CPUSystemOperations: System operations specific to a CPU class */ typedef struct CPUSystemOperations { + /** + * @get_memory_mapping: Callback for obtaining the memory mappings. + */ + void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list, + Error **errp); /** * @get_phys_page_debug: Callback for obtaining a physical address. */
@@ -157,7 +162,6 @@ typedef struct CPUSystemOperations {* @dump_statistics: Callback for dumping statistics. * @get_arch_id: Callback for getting architecture-dependent CPU ID. * @get_paging_enabled: Callback for inquiring whether paging is enabled. -* @get_memory_mapping: Callback for obtaining the memory mappings. * @set_pc: Callback for setting the Program Counter register. This * should have the semantics used by the target architecture when * setting the PC from a source such as an ELF file entry point;
@@ -201,8 +205,6 @@ struct CPUClass {void (*dump_statistics)(CPUState *cpu,int flags);int64_t (*get_arch_id)(CPUState *cpu);bool (*get_paging_enabled)(const CPUState *cpu); -void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list, -Error **errp);void (*set_pc)(CPUState *cpu,vaddr value);int (*gdb_read_register)(CPUState *cpu,GByteArray *buf,int reg);int (*gdb_write_register)(CPUState *cpu,uint8_t *buf,int reg);
hw/core/cpu.c +2 -2
@@ -83,8 +83,8 @@ void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list, {CPUClass *cc =CPU_GET_CLASS (cpu); -if (cc->get_memory_mapping) { - cc->get_memory_mapping (cpu, list, errp); +if (cc->system_ops.get_memory_mapping) { + cc->system_ops.get_memory_mapping (cpu, list, errp);return ; }
target/i386/cpu.c +1 -1
@@ -7419,7 +7419,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->system_ops.asidx_from_attrs = x86_asidx_from_attrs; - cc->get_memory_mapping = x86_cpu_get_memory_mapping; + cc->system_ops.get_memory_mapping = x86_cpu_get_memory_mapping; cc->system_ops.get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug; cc->system_ops.get_crash_info = x86_cpu_get_crash_info; cc->system_ops.write_elf64_note = x86_cpu_write_elf64_note;
Signature · 1 line
2.26.2
PATCH 15/16 cpu: Move CPUClass::get_paging_enabled to CPUSystemOperations
In reply to Philippe Mathieu-Daudé--- include/hw/core/cpu.h | 6 ++++-- hw/core/cpu.c | 4 ++-- target/i386/cpu.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-)
include/hw/core/cpu.h +4 -2
@@ -89,6 +89,10 @@ typedef struct CPUSystemOperations {*/ void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list,Error **errp); +/** +* @get_paging_enabled: Callback for inquiring whether paging is enabled. +*/ +bool (*get_paging_enabled)(const CPUState *cpu);/** * @get_phys_page_debug: Callback for obtaining a physical address. */
@@ -161,7 +165,6 @@ typedef struct CPUSystemOperations {* @dump_state: Callback for dumping state. * @dump_statistics: Callback for dumping statistics. * @get_arch_id: Callback for getting architecture-dependent CPU ID. -* @get_paging_enabled: Callback for inquiring whether paging is enabled. * @set_pc: Callback for setting the Program Counter register. This * should have the semantics used by the target architecture when * setting the PC from a source such as an ELF file entry point;
@@ -204,7 +207,6 @@ struct CPUClass {void (*dump_state)(CPUState *cpu,FILE *,int flags);void (*dump_statistics)(CPUState *cpu,int flags);int64_t (*get_arch_id)(CPUState *cpu); -bool (*get_paging_enabled)(const CPUState *cpu);void (*set_pc)(CPUState *cpu,vaddr value);int (*gdb_read_register)(CPUState *cpu,GByteArray *buf,int reg);int (*gdb_write_register)(CPUState *cpu,uint8_t *buf,int reg);
hw/core/cpu.c +2 -2
@@ -71,8 +71,8 @@ bool cpu_paging_enabled(const CPUState *cpu) {CPUClass *cc =CPU_GET_CLASS (cpu); -if (cc->get_paging_enabled) { -return cc->get_paging_enabled (cpu); +if (cc->system_ops.get_paging_enabled) { +return cc->system_ops.get_paging_enabled (cpu); }return false;
target/i386/cpu.c +1 -1
@@ -7415,7 +7415,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = x86_cpu_gdb_read_register; cc->gdb_write_register = x86_cpu_gdb_write_register; cc->get_arch_id = x86_cpu_get_arch_id; - cc->get_paging_enabled = x86_cpu_get_paging_enabled; + cc->system_ops.get_paging_enabled = x86_cpu_get_paging_enabled;#ifndef CONFIG_USER_ONLY cc->system_ops.asidx_from_attrs = x86_asidx_from_attrs;
Signature · 1 line
2.26.2
PATCH 16/16 cpu: Restrict cpu_paging_enabled / cpu_get_memory_mapping to sysemu
In reply to Philippe Mathieu-Daudé--- include/hw/core/cpu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/hw/core/cpu.h +2 -2
@@ -499,6 +499,8 @@ static inline void cpu_tb_jmp_cache_clear(CPUState *cpu)extern bool mttcg_enabled;#define qemu_tcg_mttcg_enabled () (mttcg_enabled) +#if !defined(CONFIG_USER_ONLY ) +/** * cpu_paging_enabled: * @cpu: The CPU whose state is to be inspected.
@@ -516,8 +518,6 @@ bool cpu_paging_enabled(const CPUState *cpu);void cpu_get_memory_mapping (CPUState *cpu,MemoryMappingList *list,Error **errp); -#if !defined(CONFIG_USER_ONLY ) -/** * cpu_write_elf64_note: * @f: pointer to a function that writes memory to a file
Signature · 1 line
2.26.2