cpu: Introduce SysemuCPUOps structure, remove watchpoints from usermode
v3 cover cpu: Introduce SysemuCPUOps structure, remove watchpoints from usermode
Hi,
This series is inspired on Claudio TCG work.
Instead of separate TCG from other accelerators, here we separate sysemu operations (system VS user).
Patches 1-6 are generic cleanups.
Patches 7-15 move from CPUClass to SysemuCPUOps
Patch 16 restricts SysemuCPUOps to sysemu
Patches 17-25 remove watchpoint code from user emulation Patches 26-27 remove USER_ONLY #ifdef'ry from "cpu.h"
Since v2:
- fixed lm32/unicore32
- remove USER_ONLY ifdef'ry from "cpu.h" (Claudio)
Since v1:
- Name 'sysemu' (Claudio)
- change each field progressively (Richard)
$ git backport-diff -u v2 Key: [----] : patches are identical [####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only The flags [FC] indicate (F)unctional and (C)ontextual differences, respective= ly
001/27:[----] [--] 'target: Set CPUClass::vmsd instead of DeviceClass::vmsd' 002/27:[----] [--] 'cpu: Un-inline cpu_get_phys_page_debug and cpu_asidx_from= _attrs'
003/27:[----] [--] 'cpu: Introduce cpu_virtio_is_big_endian()' 004/27:[----] [--] 'cpu: Directly use cpu_write_elf*() fallback handlers in p= lace'
005/27:[----] [--] 'cpu: Directly use get_paging_enabled() fallback handlers = in place'
006/27:[----] [--] 'cpu: Directly use get_memory_mapping() fallback handlers = in place'
007/27:[----] [--] 'cpu: Introduce SysemuCPUOps structure' 008/27:[----] [--] 'cpu: Move CPUClass::vmsd to SysemuCPUOps' 009/27:[----] [--] 'cpu: Move CPUClass::virtio_is_big_endian to SysemuCPUOps' 010/27:[----] [--] 'cpu: Move CPUClass::get_crash_info to SysemuCPUOps' 011/27:[----] [--] 'cpu: Move CPUClass::write_elf* to SysemuCPUOps' 012/27:[----] [--] 'cpu: Move CPUClass::asidx_from_attrs to SysemuCPUOps' 013/27:[----] [--] 'cpu: Move CPUClass::get_phys_page_debug to SysemuCPUOps' 014/27:[----] [--] 'cpu: Move CPUClass::get_memory_mapping to SysemuCPUOps' 015/27:[----] [--] 'cpu: Move CPUClass::get_paging_enabled to SysemuCPUOps' 016/27:[0084] [FC] 'cpu: Restrict "hw/core/sysemu-cpu-ops.h" to target/cpu.c' 017/27:[down] 'linux-user: Remove dead code'
018/27:[down] 'gdbstub: Remove watchpoint dead code in gdbserver_fork()' 019/27:[down] 'target/arm/internals: Fix code style for checkpatch.pl' 020/27:[down] 'target/arm: Move code blocks around'
021/27:[down] 'target/arm: Refactor some function bodies' 022/27:[down] 'target/arm: Restrict watchpoint code to system emulation' 023/27:[down] 'target/i386: Restrict watchpoint code to system emulation' 024/27:[down] 'accel/tcg/cpu-exec: Restrict watchpoint code to system emulati= on'
025/27:[down] 'cpu: Remove watchpoint stubs for user emulation' 026/27:[down] 'cpu: Fix code style for checkpatch.pl' 027/27:[down] 'cpu: Move sysemu specific declarations to 'sysemu-cpu-ops.h''
Regards,
Phil.
Supersedes: <[email protected]>
Philippe Mathieu-Daud=C3=A9 (27):
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 SysemuCPUOps structure
cpu: Move CPUClass::vmsd to SysemuCPUOps
cpu: Move CPUClass::virtio_is_big_endian to SysemuCPUOps
cpu: Move CPUClass::get_crash_info to SysemuCPUOps
cpu: Move CPUClass::write_elf* to SysemuCPUOps
cpu: Move CPUClass::asidx_from_attrs to SysemuCPUOps
cpu: Move CPUClass::get_phys_page_debug to SysemuCPUOps
cpu: Move CPUClass::get_memory_mapping to SysemuCPUOps
cpu: Move CPUClass::get_paging_enabled to SysemuCPUOps
cpu: Restrict "hw/core/sysemu-cpu-ops.h" to target/cpu.c
linux-user: Remove dead code
gdbstub: Remove watchpoint dead code in gdbserver_fork() target/arm/internals: Fix code style for checkpatch.pl target/arm: Move code blocks around
target/arm: Refactor some function bodies
target/arm: Restrict watchpoint code to system emulation target/i386: Restrict watchpoint code to system emulation accel/tcg/cpu-exec: Restrict watchpoint code to system emulation
cpu: Remove watchpoint stubs for user emulation
cpu: Fix code style for checkpatch.pl
cpu: Move sysemu specific declarations to 'sysemu-cpu-ops.h'
include/hw/core/cpu.h | 258 +------------------------------ include/hw/core/sysemu-cpu-ops.h | 244 +++++++++++++++++++++++++++++ target/alpha/cpu.h | 3 + target/arm/cpu.h | 3 + target/arm/internals.h | 34 ++-- target/avr/cpu.h | 1 + target/cris/cpu.h | 3 + target/hexagon/cpu.h | 3 + target/hppa/cpu.h | 3 + target/i386/cpu.h | 3 + target/lm32/cpu.h | 3 + target/m68k/cpu.h | 3 + target/microblaze/cpu.h | 1 + target/mips/cpu.h | 3 + target/moxie/cpu.h | 3 + target/nios2/cpu.h | 1 + target/openrisc/cpu.h | 3 + target/ppc/cpu.h | 3 + target/riscv/cpu.h | 3 + target/rx/cpu.h | 1 + target/s390x/cpu.h | 3 + target/sh4/cpu.h | 3 + target/sparc/cpu.h | 3 + target/tilegx/cpu.h | 3 + target/tricore/cpu.h | 3 + target/unicore32/cpu.h | 3 + target/xtensa/cpu.h | 3 + accel/tcg/cpu-exec.c | 5 +- cpu.c | 19 ++- gdbstub.c | 2 +- hw/core/cpu.c | 113 ++++++++------ hw/virtio/virtio.c | 4 +- linux-user/main.c | 5 - softmmu/physmem.c | 1 + target/alpha/cpu.c | 10 +- target/arm/cpu.c | 22 ++- target/arm/debug_helper.c | 102 ++++++------ target/arm/helper.c | 9 +- target/avr/cpu.c | 8 +- target/cris/cpu.c | 10 +- target/hppa/cpu.c | 10 +- target/i386/cpu.c | 31 ++-- target/lm32/cpu.c | 10 +- target/m68k/cpu.c | 10 +- target/microblaze/cpu.c | 10 +- target/mips/cpu.c | 10 +- target/moxie/cpu.c | 10 +- target/nios2/cpu.c | 15 +- target/openrisc/cpu.c | 10 +- target/riscv/cpu.c | 12 +- target/rx/cpu.c | 16 +- target/s390x/cpu.c | 14 +- target/sh4/cpu.c | 10 +- target/sparc/cpu.c | 10 +- target/tricore/cpu.c | 13 +- target/unicore32/cpu.c | 8 +- target/xtensa/cpu.c | 10 +- target/ppc/translate_init.c.inc | 20 +-- 58 files changed, 686 insertions(+), 453 deletions(-) create mode 100644 include/hw/core/sysemu-cpu-ops.h
--=20
2.26.2
PATCH v3 1/27 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
Re: [PATCH v3 01/27] target: Set CPUClass::vmsd instead of DeviceClass::vmsd
Quoted 6 lines · Philippe Mathieu-Daudé
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.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Is this going to have an externally visible effect?
If it does, how can we make sure it's safe?
If it does not, do you know why CPUClass::vmsd exists in the first place?
Do you think it would be simpler to just squash this patch into
[PATCH v3 08/27] cpu: Move CPUClass::vmsd to SysemuCPUOps
?
Signature · 1 line
Eduardo
Re: [PATCH v3 01/27] target: Set CPUClass::vmsd instead of DeviceClass::vmsd
+Juan
Quoted 9 lines · Eduardo Habkost
Quoted 6 lines · Philippe Mathieu-Daudé
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.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Is this going to have an externally visible effect?
On system emulation, no, because unchanged.
On user emulation migration it is not used, the symbol is here to satisfy linking:
include/hw/core/cpu.h-1070-#ifdef CONFIG_SOFTMMU include/hw/core/cpu.h-1071-extern const VMStateDescription vmstate_cpu_common;
include/hw/core/cpu.h-1072-#else include/hw/core/cpu.h:1073:#define vmstate_cpu_common vmstate_dummy include/hw/core/cpu.h-1074-#endif include/migration/vmstate.h:197:extern const VMStateDescription vmstate_dummy;
stubs/vmstate.c:4:const VMStateDescription vmstate_dummy = {};
Quoted 4 lines
If it does, how can we make sure it's safe?
If it does not, do you know why
CPUClass::vmsdexists in the first place?
My guess is CPUState is the only device used in user emulation, so it would be a way to restrict the vmstate_dummy to CPU and not to any DeviceState?
But looking at the introductory commit:
commit b170fce3dd06372f7bfec9a780ebcb1fce6d57e4
Author: Andreas Färber <[email protected]> Date: Sun Jan 20 20:23:22 2013 +0100
cpu: Register VMStateDescription through CPUState
In comparison to DeviceClass::vmsd, CPU VMState is split in two, "cpu_common" and "cpu", and uses cpu_index as instance_id instead of -1. Therefore add a CPU-specific CPUClass::vmsd field.
Unlike the legacy CPUArchState registration, rather register CPUState.
Juan, do you remember?
Quoted 4 lines
Do you think it would be simpler to just squash this patch into
[PATCH v3 08/27] cpu: MoveCPUClass::vmsdto SysemuCPUOps
?
Certainly cleaner, I'll respin!
Thanks,
Phil.
Re: [PATCH v3 01/27] target: Set CPUClass::vmsd instead of DeviceClass::vmsd
Quoted 12 lines · Philippe Mathieu-Daudé
My guess is CPUState is the only device used in user emulation, so it would be a way to restrict the
vmstate_dummyto CPU and not to any DeviceState?But looking at the introductory commit:
commit
b170fce3dd06372f7bfec9a780ebcb1fce6d57e4Author: Andreas Färber <[email protected]> Date: Sun Jan 20 20:23:22 2013 +0100cpu: Register VMStateDescription through CPUState
Quoted 7 lines
In comparison to
DeviceClass::vmsd, CPU VMState is split in two, "cpu_common" and "cpu", and usescpu_indexasinstance_idinstead of -1. Therefore add a CPU-specificCPUClass::vmsdfield.Unlike the legacy CPUArchState registration, rather register CPUState.
Juan, do you remember?
Oh yes, I remember this. There are two ways to handle migration for a CPU object:
(1) like any other device, so it has a dc->vmsd that covers
migration for the whole object. As usual for objects that are a subclass of a parent that has state, the first entry in the VMStateDescription field list is VMSTATE_CPU(), which migrates the cpu_common fields, followed by whatever the CPU's own migration fields are.
(2) a backwards-compatible mechanism for CPUs that were
originally migrated using manual "write fields to the migration stream structures". The on-the-wire migration format
for those is based on the 'env' pointer (which isn't a QOM object), and the cpu_common part of the migration data is elsewhere.
cpu_exec_realizefn() handles both possibilities:
* for type 1, dc->vmsd is set and cc->vmsd is not,
so cpu_exec_realizefn() does nothing, and the standard "register dc->vmsd for a device" code does everything needed
* for type 2, dc->vmsd is NULL and so we register the vmstate_cpu_common directly to handle the cpu-common fields, and the cc->vmsd to handle the per-CPU stuff
You can't change a CPU from one type to the other without breaking migration compatibility, which is why some guest architectures are stuck on the cc->vmsd form. New targets should use dc->vmsd.
thanks
-- PMM
Re: [PATCH v3 01/27] target: Set CPUClass::vmsd instead of DeviceClass::vmsd
Quoted 44 lines · Peter Maydell
Quoted 12 lines · Philippe Mathieu-Daudé
My guess is CPUState is the only device used in user emulation, so it would be a way to restrict the
vmstate_dummyto CPU and not to any DeviceState?But looking at the introductory commit:
commit
b170fce3dd06372f7bfec9a780ebcb1fce6d57e4Author: Andreas Färber <[email protected]> Date: Sun Jan 20 20:23:22 2013 +0100cpu: Register VMStateDescription through CPUState
Quoted 7 lines
In comparison to
DeviceClass::vmsd, CPU VMState is split in two, "cpu_common" and "cpu", and usescpu_indexasinstance_idinstead of -1. Therefore add a CPU-specificCPUClass::vmsdfield.Unlike the legacy CPUArchState registration, rather register CPUState.
Juan, do you remember?
Oh yes, I remember this. There are two ways to handle migration for a CPU object:
(1) like any other device, so it has a
dc->vmsdthat covers
migration for the whole object. As usual for objects that are a subclass of a parent that has state, the first entry in the VMStateDescription field list isVMSTATE_CPU(), which migrates thecpu_commonfields, followed by whatever the CPU's own migration fields are.
(2) a backwards-compatible mechanism for CPUs that were
originally migrated using manual "write fields to the migration stream structures". The on-the-wire migration format
for those is based on the 'env' pointer (which isn't a QOM object), and thecpu_commonpart of the migration data is elsewhere.
cpu_exec_realizefn()handles both possibilities:
* for type 1,dc->vmsdis set andcc->vmsdis not,
socpu_exec_realizefn()does nothing, and the standard "registerdc->vmsdfor a device" code does everything needed
* for type 2,dc->vmsdis NULL and so we register thevmstate_cpu_commondirectly to handle the cpu-common fields, and thecc->vmsdto handle the per-CPU stuff
Quoted 3 lines
You can't change a CPU from one type to the other without breaking migration compatibility, which is why some guest architectures are stuck on the
cc->vmsdform. New targets should usedc->vmsd.
Doh I just post v5. I guess I'll have to revisit patch #7, because I likely blew type 2 migration:
https://patchew.org/QEMU/[email protected]/[email protected]/
Re: [PATCH v3 01/27] target: Set CPUClass::vmsd instead of DeviceClass::vmsd
Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 24 lines · Peter Maydell
Quoted 12 lines · Philippe Mathieu-Daudé
My guess is CPUState is the only device used in user emulation, so it would be a way to restrict the
vmstate_dummyto CPU and not to any DeviceState?But looking at the introductory commit:
commit
b170fce3dd06372f7bfec9a780ebcb1fce6d57e4Author: Andreas Färber <[email protected]> Date: Sun Jan 20 20:23:22 2013 +0100cpu: Register VMStateDescription through CPUState
Quoted 7 lines
In comparison to
DeviceClass::vmsd, CPU VMState is split in two, "cpu_common" and "cpu", and usescpu_indexasinstance_idinstead of -1. Therefore add a CPU-specificCPUClass::vmsdfield.Unlike the legacy CPUArchState registration, rather register CPUState.
Juan, do you remember?
Oh yes, I remember this. There are two ways to handle migration for a CPU object:
Quoted 6 lines
Quoted 6 lines
(1) like any other device, so it has a
dc->vmsdthat covers
migration for the whole object. As usual for objects that are a subclass of a parent that has state, the first entry in the VMStateDescription field list isVMSTATE_CPU(), which migrates thecpu_commonfields, followed by whatever the CPU's own migration fields are.
target/alpha/cpu.c:240: dc->vmsd = &vmstate_alpha_cpu;
target/cris/cpu.c:296: dc->vmsd = &vmstate_cris_cpu; target/hppa/cpu.c:165: dc->vmsd = &vmstate_hppa_cpu; target/m68k/cpu.c:537: dc->vmsd = &vmstate_m68k_cpu;
target/microblaze/cpu.c:390: dc->vmsd = &vmstate_mb_cpu;target/openrisc/cpu.c:207: dc->vmsd = &vmstate_openrisc_cpu;target/sh4/cpu.c:265: dc->vmsd = &vmstate_sh_cpu;target/unicore32/cpu.c:149: dc->vmsd = &vmstate_uc32_cpu;target/xtensa/cpu.c:221: dc->vmsd = &vmstate_xtensa_cpu;
Quoted 5 lines
Quoted 5 lines
(2) a backwards-compatible mechanism for CPUs that were
originally migrated using manual "write fields to the migration stream structures". The on-the-wire migration format
for those is based on the 'env' pointer (which isn't a QOM object), and thecpu_commonpart of the migration data is elsewhere.
target/arm/cpu.c:1985: cc->vmsd = &vmstate_arm_cpu;target/avr/cpu.c:216: cc->vmsd = &vms_avr_cpu;target/i386/cpu.c:7434: cc->vmsd = &vmstate_x86_cpu;target/lm32/cpu.c:244: cc->vmsd = &vmstate_lm32_cpu;target/mips/cpu.c:723: cc->vmsd = &vmstate_mips_cpu;target/moxie/cpu.c:125: cc->vmsd = &vmstate_moxie_cpu;
target/ppc/translate_init.c.inc:10923: cc->vmsd = &vmstate_ppc_cpu;
target/riscv/cpu.c:627: cc->vmsd = &vmstate_riscv_cpu; target/s390x/cpu.c:520: cc->vmsd = &vmstate_s390_cpu; target/sparc/cpu.c:892: cc->vmsd = &vmstate_sparc_cpu;
Quoted 11 lines
Quoted 11 lines
cpu_exec_realizefn()handles both possibilities:
* for type 1,dc->vmsdis set andcc->vmsdis not,
socpu_exec_realizefn()does nothing, and the standard "registerdc->vmsdfor a device" code does everything needed
* for type 2,dc->vmsdis NULL and so we register thevmstate_cpu_commondirectly to handle the cpu-common fields, and thecc->vmsdto handle the per-CPU stuffYou can't change a CPU from one type to the other without breaking migration compatibility, which is why some guest architectures are stuck on the
cc->vmsdform. New targets should usedc->vmsd.
IOW new targets should use type 1.
Looking at type 2:
a) targets added 'recently' with the incorrect type 2:
target/avr/cpu.c:216: cc->vmsd = &vms_avr_cpu;target/riscv/cpu.c:627: cc->vmsd = &vmstate_riscv_cpu;
b) targets where migration isn't really an issue:
target/lm32/cpu.c:244: cc->vmsd = &vmstate_lm32_cpu;target/moxie/cpu.c:125: cc->vmsd = &vmstate_moxie_cpu;
c) targets where migration could be broken:
target/mips/cpu.c:723: cc->vmsd = &vmstate_mips_cpu;target/sparc/cpu.c:892: cc->vmsd = &vmstate_sparc_cpu;
d) KVM targets ("security boundary" or Tier-1) are left:
target/arm/cpu.c:1985: cc->vmsd = &vmstate_arm_cpu;target/i386/cpu.c:7434: cc->vmsd = &vmstate_x86_cpu;
target/ppc/translate_init.c.inc:10923: cc->vmsd = &vmstate_ppc_cpu;target/s390x/cpu.c:520: cc->vmsd = &vmstate_s390_cpu;
Isn't "machine type" what allows us to change migration stream? All targets in d) do support that.
How could we enforce no new type 2 targets?
Thanks,
Phil.
Re: [PATCH v3 01/27] target: Set CPUClass::vmsd instead of DeviceClass::vmsd
Quoted 22 lines · Philippe Mathieu-Daudé
IOW new targets should use type 1.
Looking at type 2:
a) targets added 'recently' with the incorrect type 2:
target/avr/cpu.c:216:cc->vmsd=&vms_avr_cpu;target/riscv/cpu.c:627:cc->vmsd=&vmstate_riscv_cpu;b) targets where migration isn't really an issue:
target/lm32/cpu.c:244:cc->vmsd=&vmstate_lm32_cpu;target/moxie/cpu.c:125:cc->vmsd=&vmstate_moxie_cpu;c) targets where migration could be broken:
target/mips/cpu.c:723:cc->vmsd=&vmstate_mips_cpu;target/sparc/cpu.c:892:cc->vmsd=&vmstate_sparc_cpu;d) KVM targets ("security boundary" or Tier-1) are left:
Quoted 8 lines
target/arm/cpu.c:1985:cc->vmsd=&vmstate_arm_cpu;target/i386/cpu.c:7434:cc->vmsd=&vmstate_x86_cpu;
target/ppc/translate_init.c.inc:10923:cc->vmsd=&vmstate_ppc_cpu;target/s390x/cpu.c:520:cc->vmsd=&vmstate_s390_cpu;Isn't "machine type" what allows us to change migration stream? All targets in d) do support that.
Versioned machine types allow us to change the migration stream if we do it in a forwards-compatible way (and if we're feeling kind to RH as a downstream perhaps even backwards-compatible); but new QEMU still has to be able to read the migration stream produced by old QEMU for the "virt-5.2" board, or whatever.
In some cases I think we also like to maintain migration compat on a "best-effort" basis; I think Mark likes to handle the SPARC guests that way.
thanks
-- PMM
Re: [PATCH v3 01/27] target: Set CPUClass::vmsd instead of DeviceClass::vmsd
Quoted 38 lines · Peter Maydell
Quoted 22 lines · Philippe Mathieu-Daudé
IOW new targets should use type 1.
Looking at type 2:
a) targets added 'recently' with the incorrect type 2:
target/avr/cpu.c:216:cc->vmsd=&vms_avr_cpu;target/riscv/cpu.c:627:cc->vmsd=&vmstate_riscv_cpu;b) targets where migration isn't really an issue:
target/lm32/cpu.c:244:cc->vmsd=&vmstate_lm32_cpu;target/moxie/cpu.c:125:cc->vmsd=&vmstate_moxie_cpu;c) targets where migration could be broken:
target/mips/cpu.c:723:cc->vmsd=&vmstate_mips_cpu;target/sparc/cpu.c:892:cc->vmsd=&vmstate_sparc_cpu;d) KVM targets ("security boundary" or Tier-1) are left:
Quoted 8 lines
target/arm/cpu.c:1985:cc->vmsd=&vmstate_arm_cpu;target/i386/cpu.c:7434:cc->vmsd=&vmstate_x86_cpu;
target/ppc/translate_init.c.inc:10923:cc->vmsd=&vmstate_ppc_cpu;target/s390x/cpu.c:520:cc->vmsd=&vmstate_s390_cpu;Isn't "machine type" what allows us to change migration stream? All targets in d) do support that.
Versioned machine types allow us to change the migration stream if we do it in a forwards-compatible way (and if we're feeling kind to RH as a downstream perhaps even backwards-compatible); but new QEMU still has to be able to read the migration stream produced by old QEMU for the "virt-5.2" board, or whatever.
Quoted 3 lines
In some cases I think we also like to maintain migration compat on a "best-effort" basis; I think Mark likes to handle the SPARC guests that way.
What I don't understand if is there is a possibility to eventually remove the CPUClass::vmsd (even long and painful), or if it is directly impossible and we are doomed to keep maintaining both.
PATCH v3 2/27 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 v3 3/27 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 v3 4/27 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 v3 5/27 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 v3 6/27 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 v3 7/27 cpu: Introduce SysemuCPUOps structure
In reply to Philippe Mathieu-DaudéIntroduce a structure to hold handler specific to sysemu.
--- include/hw/core/cpu.h | 5 +++++ include/hw/core/sysemu-cpu-ops.h | 21 +++++++++++++++++++++ target/alpha/cpu.c | 6 ++++++ target/arm/cpu.c | 6 ++++++ target/avr/cpu.c | 4 ++++ target/cris/cpu.c | 6 ++++++ target/hppa/cpu.c | 6 ++++++ target/i386/cpu.c | 6 ++++++ target/lm32/cpu.c | 6 ++++++ target/m68k/cpu.c | 6 ++++++ target/microblaze/cpu.c | 6 ++++++ target/mips/cpu.c | 6 ++++++ target/moxie/cpu.c | 4 ++++ target/nios2/cpu.c | 6 ++++++ target/openrisc/cpu.c | 6 ++++++ target/riscv/cpu.c | 6 ++++++ target/rx/cpu.c | 8 ++++++++ target/s390x/cpu.c | 6 ++++++ target/sh4/cpu.c | 6 ++++++ target/sparc/cpu.c | 6 ++++++ target/tricore/cpu.c | 4 ++++ target/unicore32/cpu.c | 4 ++++ target/xtensa/cpu.c | 6 ++++++ target/ppc/translate_init.c.inc | 6 ++++++ 24 files changed, 152 insertions(+) create mode 100644 include/hw/core/sysemu-cpu-ops.h
include/hw/core/cpu.h +5 -0
@@ -80,6 +80,8 @@ struct TCGCPUOps;/* see accel-cpu.h */ struct AccelCPUClass ; +#include "hw/core/sysemu-cpu-ops.h" +/** * CPUClass: * @class_by_name: Callback to map -cpu command line model name to an
@@ -190,6 +192,9 @@ struct CPUClass {bool gdb_stop_before_watchpoint;struct AccelCPUClass *accel_cpu; +/* when system emulation is not available, this pointer is NULL */ +const struct SysemuCPUOps *sysemu_ops; +/* when TCG is not available, this pointer is NULL */ struct TCGCPUOps *tcg_ops; };
include/hw/core/sysemu-cpu-ops.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* CPU operations specific to system emulation +* +* Copyright (c) 2012 SUSE LINUX Products GmbH +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef SYSEMU_CPU_OPS_H +#define SYSEMU_CPU_OPS_H + +#include "hw/core/cpu.h" + +/* +* struct SysemuCPUOps: System operations specific to a CPU class +*/ +typedef struct SysemuCPUOps { +}SysemuCPUOps ; + +#endif /* SYSEMU_CPU_OPS_H */
target/alpha/cpu.c +6 -0
@@ -206,6 +206,11 @@ static void alpha_cpu_initfn(Object *obj)#endif } +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps alpha_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps alpha_tcg_ops = {
@@ -238,6 +243,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug; cc->vmsd = &vmstate_alpha_cpu; + cc->sysemu_ops = &alpha_sysemu_ops;#endif cc->disas_set_info = alpha_cpu_disas_set_info;
target/arm/cpu.c +6 -0
@@ -2260,6 +2260,11 @@ static gchar *arm_gdb_arch_name(CPUState *cs)return g_strdup ("arm" ); } +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps arm_sysemu_ops = { +}; +#endif +#ifdef CONFIG_TCG static struct TCGCPUOps arm_tcg_ops = { .initialize = arm_translate_init,
@@ -2303,6 +2308,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) 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; + cc->sysemu_ops = &arm_sysemu_ops;#endif cc->gdb_num_core_regs =26 ; cc->gdb_core_xml_file ="arm-core.xml" ;
target/avr/cpu.c +4 -0
@@ -184,6 +184,9 @@ static void avr_cpu_dump_state(CPUState *cs, FILE *f, int flags)qemu_fprintf (f,"\n" ); } +static struct SysemuCPUOps avr_sysemu_ops = { +}; +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps avr_tcg_ops = {
@@ -214,6 +217,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) 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->sysemu_ops = &avr_sysemu_ops; 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 +6 -0
@@ -193,6 +193,11 @@ static void cris_cpu_initfn(Object *obj)#endif } +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps cris_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps crisv10_tcg_ops = {
@@ -294,6 +299,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = cris_cpu_get_phys_page_debug; cc->vmsd = &vmstate_cris_cpu; + cc->sysemu_ops = &cris_sysemu_ops;#endif cc->gdb_num_core_regs =49 ;
target/hppa/cpu.c +6 -0
@@ -131,6 +131,11 @@ static ObjectClass *hppa_cpu_class_by_name(const char *cpu_model)return object_class_by_name (TYPE_HPPA_CPU ); } +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps hppa_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps hppa_tcg_ops = {
@@ -163,6 +168,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = hppa_cpu_get_phys_page_debug; cc->vmsd = &vmstate_hppa_cpu; + cc->sysemu_ops = &hppa_sysemu_ops;#endif cc->disas_set_info = hppa_cpu_disas_set_info; cc->gdb_num_core_regs =128 ;
target/i386/cpu.c +6 -0
@@ -7386,6 +7386,11 @@ static Property x86_cpu_properties[] = { DEFINE_PROP_END_OF_LIST() }; +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps i386_sysemu_ops = { +}; +#endif +static void x86_cpu_common_class_init (ObjectClass *oc,void *data) {X86CPUClass *xcc =X86_CPU_CLASS (oc);
@@ -7427,6 +7432,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->write_elf32_note = x86_cpu_write_elf32_note; cc->write_elf32_qemunote = x86_cpu_write_elf32_qemunote; cc->vmsd = &vmstate_x86_cpu; + cc->sysemu_ops = &i386_sysemu_ops;#endif /* !CONFIG_USER_ONLY */ cc->gdb_arch_name = x86_gdb_arch_name;
target/lm32/cpu.c +6 -0
@@ -210,6 +210,11 @@ static ObjectClass *lm32_cpu_class_by_name(const char *cpu_model)return oc; } +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps lm32_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps lm32_tcg_ops = {
@@ -242,6 +247,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = lm32_cpu_get_phys_page_debug; cc->vmsd = &vmstate_lm32_cpu; + cc->sysemu_ops = &lm32_sysemu_ops;#endif cc->gdb_num_core_regs =32 +7 ; cc->gdb_stop_before_watchpoint = true;
target/m68k/cpu.c +6 -0
@@ -502,6 +502,11 @@ static const VMStateDescription vmstate_m68k_cpu = { };#endif +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps m68k_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps m68k_tcg_ops = {
@@ -534,6 +539,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data)#if defined(CONFIG_SOFTMMU ) cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug; cc->vmsd = &vmstate_m68k_cpu; + cc->sysemu_ops = &m68k_sysemu_ops;#endif cc->disas_set_info = m68k_cpu_disas_set_info;
target/microblaze/cpu.c +6 -0
@@ -352,6 +352,11 @@ static ObjectClass *mb_cpu_class_by_name(const char *cpu_model)return object_class_by_name (TYPE_MICROBLAZE_CPU ); } +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps mb_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps mb_tcg_ops = {
@@ -388,6 +393,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->sysemu_ops = &mb_sysemu_ops;#endif device_class_set_props (dc, mb_properties); cc->gdb_num_core_regs =32 +27 ;
target/mips/cpu.c +6 -0
@@ -680,6 +680,11 @@ static Property mips_cpu_properties[] = { DEFINE_PROP_END_OF_LIST() }; +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps mips_sysemu_ops = { +}; +#endif +#ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h" /*
@@ -721,6 +726,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = mips_cpu_get_phys_page_debug; cc->vmsd = &vmstate_mips_cpu; + cc->sysemu_ops = &mips_sysemu_ops;#endif cc->disas_set_info = mips_cpu_disas_set_info; cc->gdb_num_core_regs =73 ;
target/moxie/cpu.c +4 -0
@@ -94,6 +94,9 @@ static ObjectClass *moxie_cpu_class_by_name(const char *cpu_model)return oc; } +static struct SysemuCPUOps moxie_sysemu_ops = { +}; +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps moxie_tcg_ops = {
@@ -125,6 +128,7 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->vmsd = &vmstate_moxie_cpu;#endif cc->disas_set_info = moxie_cpu_disas_set_info; + cc->sysemu_ops = &moxie_sysemu_ops; cc->tcg_ops = &moxie_tcg_ops; }
target/nios2/cpu.c +6 -0
@@ -207,6 +207,11 @@ static Property nios2_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps nios2_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps nios2_tcg_ops = {
@@ -238,6 +243,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data) 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->sysemu_ops = &nios2_sysemu_ops;#endif cc->gdb_read_register = nios2_cpu_gdb_read_register; cc->gdb_write_register = nios2_cpu_gdb_write_register;
target/openrisc/cpu.c +6 -0
@@ -174,6 +174,11 @@ static void openrisc_any_initfn(Object *obj) | (IMMUCFGR_NTS & (ctz32(TLB_SIZE) << 2)); } +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps openrisc_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps openrisc_tcg_ops = {
@@ -205,6 +210,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = openrisc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_openrisc_cpu; + cc->sysemu_ops = &openrisc_sysemu_ops;#endif cc->gdb_num_core_regs =32 +3 ; cc->disas_set_info = openrisc_disas_set_info;
target/riscv/cpu.c +6 -0
@@ -580,6 +580,11 @@ static const char *riscv_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname)return NULL ; } +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps riscv_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps riscv_tcg_ops = {
@@ -624,6 +629,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) cc->get_phys_page_debug = riscv_cpu_get_phys_page_debug;/* For now, mark unmigratable: */ cc->vmsd = &vmstate_riscv_cpu; + cc->sysemu_ops = &riscv_sysemu_ops;#endif cc->gdb_arch_name = riscv_gdb_arch_name; cc->gdb_get_dynamic_xml = riscv_gdb_get_dynamic_xml;
target/rx/cpu.c +8 -0
@@ -173,6 +173,11 @@ static void rx_cpu_init(Object *obj)qdev_init_gpio_in (DEVICE (cpu), rx_cpu_set_irq,2 ); } +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps rx_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps rx_tcg_ops = {
@@ -202,6 +207,9 @@ static void rx_cpu_class_init(ObjectClass *klass, void *data) cc->dump_state = rx_cpu_dump_state; cc->set_pc = rx_cpu_set_pc; +#ifndef CONFIG_USER_ONLY + cc->sysemu_ops = &rx_sysemu_ops; +#endif 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;
target/s390x/cpu.c +6 -0
@@ -477,6 +477,11 @@ static void s390_cpu_reset_full(DeviceState *dev)return s390_cpu_reset (s,S390_CPU_RESET_CLEAR ); } +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps s390_sysemu_ops = { +}; +#endif +#ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h"
@@ -520,6 +525,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->vmsd = &vmstate_s390_cpu; cc->get_crash_info = s390_cpu_get_crash_info; cc->write_elf64_note = s390_cpu_write_elf64_note; + cc->sysemu_ops = &s390_sysemu_ops;#endif cc->disas_set_info = s390_cpu_disas_set_info; cc->gdb_num_core_regs =S390_NUM_CORE_REGS ;
target/sh4/cpu.c +6 -0
@@ -223,6 +223,11 @@ static const VMStateDescription vmstate_sh_cpu = { .unmigratable = 1, }; +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps sh4_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps superh_tcg_ops = {
@@ -257,6 +262,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) 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->sysemu_ops = &sh4_sysemu_ops;#endif cc->disas_set_info = superh_cpu_disas_set_info;
target/sparc/cpu.c +6 -0
@@ -848,6 +848,11 @@ static Property sparc_cpu_properties[] = { DEFINE_PROP_END_OF_LIST() }; +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps sparc_sysemu_ops = { +}; +#endif +#ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h"
@@ -890,6 +895,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = sparc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_sparc_cpu; + cc->sysemu_ops = &sparc_sysemu_ops;#endif cc->disas_set_info = cpu_sparc_disas_set_info;
target/tricore/cpu.c +4 -0
@@ -142,6 +142,9 @@ static void tc27x_initfn(Object *obj)set_feature (&cpu->env,TRICORE_FEATURE_161 ); } +static struct SysemuCPUOps tricore_sysemu_ops = { +}; +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps tricore_tcg_ops = {
@@ -171,6 +174,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->sysemu_ops = &tricore_sysemu_ops; cc->tcg_ops = &tricore_tcg_ops; }
target/unicore32/cpu.c +4 -0
@@ -120,6 +120,9 @@ static const VMStateDescription vmstate_uc32_cpu = { .unmigratable = 1, }; +static struct SysemuCPUOps uc32_sysemu_ops = { +}; +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps uc32_tcg_ops = {
@@ -147,6 +150,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = uc32_cpu_set_pc; cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug; cc->vmsd = &vmstate_uc32_cpu; + cc->sysemu_ops = &uc32_sysemu_ops; cc->tcg_ops = &uc32_tcg_ops; }
target/xtensa/cpu.c +6 -0
@@ -181,6 +181,11 @@ static const VMStateDescription vmstate_xtensa_cpu = { .unmigratable = 1, }; +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps xtensa_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps xtensa_tcg_ops = {
@@ -215,6 +220,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->sysemu_ops = &xtensa_sysemu_ops; cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug;#endif cc->disas_set_info = xtensa_cpu_disas_set_info;
target/ppc/translate_init.c.inc +6 -0
@@ -10843,6 +10843,11 @@ static Property ppc_cpu_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +#ifndef CONFIG_USER_ONLY +static struct SysemuCPUOps ppc_sysemu_ops = { +}; +#endif + #ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h"
@@ -10886,6 +10891,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_ppc_cpu; + cc->sysemu_ops = &ppc_sysemu_ops; #endif #if defined(CONFIG_SOFTMMU) cc->write_elf64_note = ppc64_cpu_write_elf64_note;
Signature · 1 line
2.26.2
Re: [PATCH v3 07/27] cpu: Introduce SysemuCPUOps structure
Quoted 1 line · Philippe Mathieu-Daudé
+static struct SysemuCPUOps
alpha_sysemu_ops= {
const, for all of them.
r~
PATCH v3 8/27 cpu: Move CPUClass::vmsd to SysemuCPUOps
In reply to Philippe Mathieu-DaudéMigration is specific to system emulation.
--- include/hw/core/cpu.h | 2 -- include/hw/core/sysemu-cpu-ops.h | 4 ++++ cpu.c | 18 ++++++++---------- 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 | 7 +++++++ target/openrisc/cpu.c | 2 +- target/riscv/cpu.c | 4 ++-- target/rx/cpu.c | 6 ++++++ target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 4 ++-- target/sparc/cpu.c | 2 +- target/tricore/cpu.c | 7 +++++++ target/unicore32/cpu.c | 2 +- target/xtensa/cpu.c | 4 ++-- target/ppc/translate_init.c.inc | 2 +- 25 files changed, 54 insertions(+), 34 deletions(-)
include/hw/core/cpu.h +0 -2
@@ -124,7 +124,6 @@ struct AccelCPUClass;* 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
@@ -179,7 +178,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);
include/hw/core/sysemu-cpu-ops.h +4 -0
@@ -16,6 +16,10 @@* struct SysemuCPUOps: System operations specific to a CPU class */ typedef struct SysemuCPUOps { +/** +* @vmsd: State description for migration. +*/ +const VMStateDescription *vmsd; }SysemuCPUOps ;#endif /* SYSEMU_CPU_OPS_H */
cpu.c +8 -10
@@ -126,7 +126,9 @@ const VMStateDescription vmstate_cpu_common = {void cpu_exec_realizefn (CPUState *cpu,Error **errp) { +#ifndef CONFIG_USER_ONLY CPUClass *cc =CPU_GET_CLASS (cpu); +#endif cpu_list_add (cpu);
@@ -137,27 +139,23 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) }#endif /* CONFIG_TCG */ -#ifdef CONFIG_USER_ONLY -assert (cc->vmsd ==NULL ); -#else +#ifndef CONFIG_USER_ONLY 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->sysemu_ops->vmsd !=NULL ) { +vmstate_register (NULL , cpu->cpu_index, cc->sysemu_ops->vmsd, cpu); }#endif /* CONFIG_USER_ONLY */ }void cpu_exec_unrealizefn (CPUState *cpu) { +#ifndef CONFIG_USER_ONLY CPUClass *cc =CPU_GET_CLASS (cpu); -#ifdef CONFIG_USER_ONLY -assert (cc->vmsd ==NULL ); -#else -if (cc->vmsd !=NULL ) { -vmstate_unregister (NULL , cc->vmsd, cpu); +if (cc->sysemu_ops->vmsd !=NULL ) { +vmstate_unregister (NULL , cc->sysemu_ops->vmsd, cpu); }if (qdev_get_vmsd (DEVICE (cpu)) ==NULL ) {vmstate_unregister (NULL , &vmstate_cpu_common, cpu);
target/alpha/cpu.c +1 -1
@@ -208,6 +208,7 @@ static void alpha_cpu_initfn(Object *obj)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps alpha_sysemu_ops = { + .vmsd = &vmstate_alpha_cpu, };#endif
@@ -242,7 +243,6 @@ 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->sysemu_ops = &alpha_sysemu_ops;#endif cc->disas_set_info = alpha_cpu_disas_set_info;
target/arm/cpu.c +1 -1
@@ -2262,6 +2262,7 @@ static gchar *arm_gdb_arch_name(CPUState *cs)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps arm_sysemu_ops = { + .vmsd = &vmstate_arm_cpu, };#endif
@@ -2304,7 +2305,6 @@ 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->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
@@ -185,6 +185,7 @@ static void avr_cpu_dump_state(CPUState *cs, FILE *f, int flags) }static struct SysemuCPUOps avr_sysemu_ops = { + .vmsd = &vms_avr_cpu, };#include "hw/core/tcg-cpu-ops.h"
@@ -216,7 +217,6 @@ 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->sysemu_ops = &avr_sysemu_ops; cc->disas_set_info = avr_cpu_disas_set_info; cc->gdb_read_register = avr_cpu_gdb_read_register;
target/cris/cpu.c +1 -1
@@ -195,6 +195,7 @@ static void cris_cpu_initfn(Object *obj)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps cris_sysemu_ops = { + .vmsd = &vmstate_cris_cpu, };#endif
@@ -298,7 +299,6 @@ 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->sysemu_ops = &cris_sysemu_ops;#endif
target/hppa/cpu.c +1 -1
@@ -133,6 +133,7 @@ static ObjectClass *hppa_cpu_class_by_name(const char *cpu_model)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps hppa_sysemu_ops = { + .vmsd = &vmstate_hppa_cpu, };#endif
@@ -167,7 +168,6 @@ 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->sysemu_ops = &hppa_sysemu_ops;#endif cc->disas_set_info = hppa_cpu_disas_set_info;
target/i386/cpu.c +1 -1
@@ -7388,6 +7388,7 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps i386_sysemu_ops = { + .vmsd = &vmstate_x86_cpu, };#endif
@@ -7431,7 +7432,6 @@ 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->sysemu_ops = &i386_sysemu_ops;#endif /* !CONFIG_USER_ONLY */
target/lm32/cpu.c +1 -1
@@ -212,6 +212,7 @@ static ObjectClass *lm32_cpu_class_by_name(const char *cpu_model)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps lm32_sysemu_ops = { + .vmsd = &vmstate_lm32_cpu, };#endif
@@ -246,7 +247,6 @@ 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->sysemu_ops = &lm32_sysemu_ops;#endif cc->gdb_num_core_regs =32 +7 ;
target/m68k/cpu.c +1 -1
@@ -504,6 +504,7 @@ static const VMStateDescription vmstate_m68k_cpu = {#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps m68k_sysemu_ops = { + .vmsd = &vmstate_m68k_cpu, };#endif
@@ -538,7 +539,6 @@ 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->sysemu_ops = &m68k_sysemu_ops;#endif cc->disas_set_info = m68k_cpu_disas_set_info;
target/microblaze/cpu.c +1 -1
@@ -354,6 +354,7 @@ static ObjectClass *mb_cpu_class_by_name(const char *cpu_model)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps mb_sysemu_ops = { + .vmsd = &vmstate_mb_cpu, };#endif
@@ -392,7 +393,6 @@ 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->sysemu_ops = &mb_sysemu_ops;#endif device_class_set_props (dc, mb_properties);
target/mips/cpu.c +1 -1
@@ -682,6 +682,7 @@ static Property mips_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps mips_sysemu_ops = { + .vmsd = &vmstate_mips_cpu, };#endif
@@ -725,7 +726,6 @@ 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->sysemu_ops = &mips_sysemu_ops;#endif cc->disas_set_info = mips_cpu_disas_set_info;
target/moxie/cpu.c +1 -1
@@ -95,6 +95,7 @@ static ObjectClass *moxie_cpu_class_by_name(const char *cpu_model) }static struct SysemuCPUOps moxie_sysemu_ops = { + .vmsd = &vmstate_moxie_cpu, };#include "hw/core/tcg-cpu-ops.h"
@@ -125,7 +126,6 @@ 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;#endif cc->disas_set_info = moxie_cpu_disas_set_info; cc->sysemu_ops = &moxie_sysemu_ops;
target/nios2/cpu.c +7 -0
@@ -25,6 +25,7 @@#include "exec/log.h" #include "exec/gdbstub.h" #include "hw/qdev-properties.h" +#include "migration/vmstate.h" static void nios2_cpu_set_pc (CPUState *cs,vaddr value) {
@@ -208,7 +209,13 @@ static Property nios2_properties[] = { };#ifndef CONFIG_USER_ONLY +static const VMStateDescription vmstate_nios2_cpu = { + .name ="cpu" , + .unmigratable =1 , +}; +static struct SysemuCPUOps nios2_sysemu_ops = { + .vmsd = &vmstate_nios2_cpu, };#endif
target/openrisc/cpu.c +1 -1
@@ -176,6 +176,7 @@ static void openrisc_any_initfn(Object *obj)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps openrisc_sysemu_ops = { + .vmsd = &vmstate_openrisc_cpu, };#endif
@@ -209,7 +210,6 @@ 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->sysemu_ops = &openrisc_sysemu_ops;#endif cc->gdb_num_core_regs =32 +3 ;
target/riscv/cpu.c +2 -2
@@ -582,6 +582,8 @@ static const char *riscv_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps riscv_sysemu_ops = { +/* For now, mark unmigratable: */ + .vmsd = &vmstate_riscv_cpu, };#endif
@@ -627,8 +629,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) cc->disas_set_info = riscv_cpu_disas_set_info;#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->sysemu_ops = &riscv_sysemu_ops;#endif cc->gdb_arch_name = riscv_gdb_arch_name;
target/rx/cpu.c +6 -0
@@ -174,7 +174,13 @@ static void rx_cpu_init(Object *obj) }#ifndef CONFIG_USER_ONLY +static const VMStateDescription vmstate_rx_cpu = { + .name ="cpu" , + .unmigratable =1 , +}; +static struct SysemuCPUOps rx_sysemu_ops = { + .vmsd = &vmstate_rx_cpu, };#endif
target/s390x/cpu.c +1 -1
@@ -479,6 +479,7 @@ static void s390_cpu_reset_full(DeviceState *dev)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps s390_sysemu_ops = { + .vmsd = &vmstate_s390_cpu, };#endif
@@ -522,7 +523,6 @@ 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->get_crash_info = s390_cpu_get_crash_info; cc->write_elf64_note = s390_cpu_write_elf64_note; cc->sysemu_ops = &s390_sysemu_ops;
target/sh4/cpu.c +2 -2
@@ -218,13 +218,14 @@ static void superh_cpu_initfn(Object *obj) env->movcal_backup_tail = &(env->movcal_backup); } +#ifndef CONFIG_USER_ONLY static const VMStateDescription vmstate_sh_cpu = { .name ="cpu" , .unmigratable =1 , }; -#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps sh4_sysemu_ops = { + .vmsd = &vmstate_sh_cpu, };#endif
@@ -268,7 +269,6 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs =59 ; - cc->vmsd = &vmstate_sh_cpu; cc->tcg_ops = &superh_tcg_ops; }
target/sparc/cpu.c +1 -1
@@ -850,6 +850,7 @@ static Property sparc_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps sparc_sysemu_ops = { + .vmsd = &vmstate_sparc_cpu, };#endif
@@ -894,7 +895,6 @@ 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->sysemu_ops = &sparc_sysemu_ops;#endif cc->disas_set_info = cpu_sparc_disas_set_info;
target/tricore/cpu.c +7 -0
@@ -22,6 +22,7 @@#include "cpu.h" #include "exec/exec-all.h" #include "qemu/error-report.h" +#include "migration/vmstate.h" static inline void set_feature (CPUTriCoreState *env,int feature) {
@@ -142,7 +143,13 @@ static void tc27x_initfn(Object *obj)set_feature (&cpu->env,TRICORE_FEATURE_161 ); } +static const VMStateDescription vmstate_tricore_cpu = { + .name ="cpu" , + .unmigratable =1 , +}; +static struct SysemuCPUOps tricore_sysemu_ops = { + .vmsd = &vmstate_tricore_cpu, };#include "hw/core/tcg-cpu-ops.h"
target/unicore32/cpu.c +1 -1
@@ -121,6 +121,7 @@ static const VMStateDescription vmstate_uc32_cpu = { };static struct SysemuCPUOps uc32_sysemu_ops = { + .vmsd = &vmstate_uc32_cpu, };#include "hw/core/tcg-cpu-ops.h"
@@ -149,7 +150,6 @@ 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->sysemu_ops = &uc32_sysemu_ops; cc->tcg_ops = &uc32_tcg_ops; }
target/xtensa/cpu.c +2 -2
@@ -176,13 +176,14 @@ static void xtensa_cpu_initfn(Object *obj)#endif } +#ifndef CONFIG_USER_ONLY static const VMStateDescription vmstate_xtensa_cpu = { .name ="cpu" , .unmigratable =1 , }; -#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps xtensa_sysemu_ops = { + .vmsd = &vmstate_xtensa_cpu, };#endif
@@ -224,7 +225,6 @@ 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->tcg_ops = &xtensa_tcg_ops; }
target/ppc/translate_init.c.inc +1 -1
@@ -10845,6 +10845,7 @@ static Property ppc_cpu_properties[] = { #ifndef CONFIG_USER_ONLY static struct SysemuCPUOps ppc_sysemu_ops = { + .vmsd = &vmstate_ppc_cpu, }; #endif
@@ -10890,7 +10891,6 @@ 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->sysemu_ops = &ppc_sysemu_ops; #endif #if defined(CONFIG_SOFTMMU)
Signature · 1 line
2.26.2
PATCH v3 9/27 cpu: Move CPUClass::virtio_is_big_endian to SysemuCPUOps
In reply to Philippe Mathieu-DaudéVirtIO devices are only meaningful with system emulation.
--- include/hw/core/cpu.h | 5 ----- include/hw/core/sysemu-cpu-ops.h | 8 ++++++++ hw/core/cpu.c | 4 ++-- target/arm/cpu.c | 2 +- target/ppc/translate_init.c.inc | 4 +--- 5 files changed, 12 insertions(+), 11 deletions(-)
include/hw/core/cpu.h +0 -5
@@ -89,10 +89,6 @@ struct AccelCPUClass;* @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.
@@ -151,7 +147,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);
include/hw/core/sysemu-cpu-ops.h +8 -0
@@ -16,6 +16,14 @@* struct SysemuCPUOps: System operations specific to a CPU class */ typedef struct SysemuCPUOps { + /** + * @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. */
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->sysemu_ops->virtio_is_big_endian) { +return cc->sysemu_ops->virtio_is_big_endian (cpu); }return target_words_bigendian (); }
target/arm/cpu.c +1 -1
@@ -2262,6 +2262,7 @@ static gchar *arm_gdb_arch_name(CPUState *cs)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps arm_sysemu_ops = { + .virtio_is_big_endian = arm_cpu_virtio_is_big_endian, .vmsd = &vmstate_arm_cpu, };#endif
@@ -2305,7 +2306,6 @@ 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->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->sysemu_ops = &arm_sysemu_ops;
target/ppc/translate_init.c.inc +1 -3
@@ -10845,6 +10845,7 @@ static Property ppc_cpu_properties[] = { #ifndef CONFIG_USER_ONLY static struct SysemuCPUOps ppc_sysemu_ops = { + .virtio_is_big_endian = ppc_cpu_is_big_endian, .vmsd = &vmstate_ppc_cpu, }; #endif
@@ -10913,9 +10914,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_core_xml_file = "power64-core.xml"; #else cc->gdb_core_xml_file = "power-core.xml"; -#endif -#ifndef CONFIG_USER_ONLY - cc->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 v3 10/27 cpu: Move CPUClass::get_crash_info to SysemuCPUOps
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 | 1 - include/hw/core/sysemu-cpu-ops.h | 5 +++++ hw/core/cpu.c | 4 ++-- target/i386/cpu.c | 2 +- target/s390x/cpu.c | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-)
include/hw/core/cpu.h +0 -1
@@ -150,7 +150,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);
include/hw/core/sysemu-cpu-ops.h +5 -0
@@ -16,6 +16,11 @@* struct SysemuCPUOps: System operations specific to a CPU class */ typedef struct SysemuCPUOps { + /** + * @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.
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->sysemu_ops->get_crash_info) { + res = cc->sysemu_ops->get_crash_info (cpu); }return res; }
target/i386/cpu.c +1 -1
@@ -7388,6 +7388,7 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps i386_sysemu_ops = { + .get_crash_info = x86_cpu_get_crash_info, .vmsd = &vmstate_x86_cpu, };#endif
@@ -7427,7 +7428,6 @@ 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->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
@@ -479,6 +479,7 @@ static void s390_cpu_reset_full(DeviceState *dev)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps s390_sysemu_ops = { + .get_crash_info = s390_cpu_get_crash_info, .vmsd = &vmstate_s390_cpu, };#endif
@@ -523,7 +524,6 @@ 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->get_crash_info = s390_cpu_get_crash_info; cc->write_elf64_note = s390_cpu_write_elf64_note; cc->sysemu_ops = &s390_sysemu_ops;#endif
Signature · 1 line
2.26.2
PATCH v3 11/27 cpu: Move CPUClass::write_elf* to SysemuCPUOps
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 | 17 ----------------- include/hw/core/sysemu-cpu-ops.h | 24 ++++++++++++++++++++++++ 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 | 6 ++---- 7 files changed, 41 insertions(+), 36 deletions(-)
include/hw/core/cpu.h +0 -17
@@ -112,14 +112,6 @@ struct AccelCPUClass;* 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
@@ -163,15 +155,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);
include/hw/core/sysemu-cpu-ops.h +24 -0
@@ -21,6 +21,30 @@ typedef struct SysemuCPUOps {* 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.
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->sysemu_ops->write_elf32_qemunote) {return 0 ; } -return (*cc->write_elf32_qemunote)(f, cpu, opaque); +return (*cc->sysemu_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->sysemu_ops->write_elf32_note) {return -1 ; } -return (*cc->write_elf32_note)(f, cpu, cpuid, opaque); +return (*cc->sysemu_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->sysemu_ops->write_elf64_qemunote) {return 0 ; } -return (*cc->write_elf64_qemunote)(f, cpu, opaque); +return (*cc->sysemu_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->sysemu_ops->write_elf64_note) {return -1 ; } -return (*cc->write_elf64_note)(f, cpu, cpuid, opaque); +return (*cc->sysemu_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
@@ -2262,6 +2262,8 @@ static gchar *arm_gdb_arch_name(CPUState *cs)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps arm_sysemu_ops = { + .write_elf32_note = arm_cpu_write_elf32_note, + .write_elf64_note = arm_cpu_write_elf64_note, .virtio_is_big_endian = arm_cpu_virtio_is_big_endian, .vmsd = &vmstate_arm_cpu, };
@@ -2306,8 +2308,6 @@ 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->write_elf64_note = arm_cpu_write_elf64_note; - cc->write_elf32_note = arm_cpu_write_elf32_note; cc->sysemu_ops = &arm_sysemu_ops;#endif cc->gdb_num_core_regs =26 ;
target/i386/cpu.c +4 -4
@@ -7389,6 +7389,10 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps i386_sysemu_ops = { .get_crash_info = x86_cpu_get_crash_info, + .write_elf32_note = x86_cpu_write_elf32_note, + .write_elf64_note = x86_cpu_write_elf64_note, + .write_elf32_qemunote = x86_cpu_write_elf32_qemunote, + .write_elf64_qemunote = x86_cpu_write_elf64_qemunote, .vmsd = &vmstate_x86_cpu, };#endif
@@ -7428,10 +7432,6 @@ 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->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->sysemu_ops = &i386_sysemu_ops;#endif /* !CONFIG_USER_ONLY */
target/s390x/cpu.c +1 -1
@@ -480,6 +480,7 @@ static void s390_cpu_reset_full(DeviceState *dev)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps s390_sysemu_ops = { .get_crash_info = s390_cpu_get_crash_info, + .write_elf64_note = s390_cpu_write_elf64_note, .vmsd = &vmstate_s390_cpu, };#endif
@@ -524,7 +525,6 @@ 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->write_elf64_note = s390_cpu_write_elf64_note; cc->sysemu_ops = &s390_sysemu_ops;#endif cc->disas_set_info = s390_cpu_disas_set_info;
target/ppc/translate_init.c.inc +2 -4
@@ -10845,6 +10845,8 @@ static Property ppc_cpu_properties[] = { #ifndef CONFIG_USER_ONLY static struct SysemuCPUOps ppc_sysemu_ops = { + .write_elf32_note = ppc32_cpu_write_elf32_note, + .write_elf64_note = ppc64_cpu_write_elf64_note, .virtio_is_big_endian = ppc_cpu_is_big_endian, .vmsd = &vmstate_ppc_cpu, };
@@ -10894,10 +10896,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; cc->sysemu_ops = &ppc_sysemu_ops; #endif -#if defined(CONFIG_SOFTMMU) - cc->write_elf64_note = ppc64_cpu_write_elf64_note; - cc->write_elf32_note = ppc32_cpu_write_elf32_note; -#endif cc->gdb_num_core_regs = 71; #ifndef CONFIG_USER_ONLY
Signature · 1 line
2.26.2
PATCH v3 12/27 cpu: Move CPUClass::asidx_from_attrs to SysemuCPUOps
In reply to Philippe Mathieu-Daudé--- include/hw/core/cpu.h | 3 --- include/hw/core/sysemu-cpu-ops.h | 5 +++++ hw/core/cpu.c | 4 ++-- target/arm/cpu.c | 2 +- target/i386/cpu.c | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-)
include/hw/core/cpu.h +0 -3
@@ -108,8 +108,6 @@ struct AccelCPUClass;* 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.
@@ -151,7 +149,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);
include/hw/core/sysemu-cpu-ops.h +5 -0
@@ -16,6 +16,11 @@* struct SysemuCPUOps: System operations specific to a CPU class */ typedef struct SysemuCPUOps { + /** + * @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.
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->sysemu_ops->asidx_from_attrs) { + ret = cc->sysemu_ops->asidx_from_attrs (cpu, attrs);assert (ret < cpu->num_ases && ret >=0 ); }return ret;
target/arm/cpu.c +1 -1
@@ -2262,6 +2262,7 @@ static gchar *arm_gdb_arch_name(CPUState *cs)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps arm_sysemu_ops = { + .asidx_from_attrs = arm_asidx_from_attrs, .write_elf32_note = arm_cpu_write_elf32_note, .write_elf64_note = arm_cpu_write_elf64_note, .virtio_is_big_endian = arm_cpu_virtio_is_big_endian,
@@ -2307,7 +2308,6 @@ 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->sysemu_ops = &arm_sysemu_ops;#endif cc->gdb_num_core_regs =26 ;
target/i386/cpu.c +1 -1
@@ -7388,6 +7388,7 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps i386_sysemu_ops = { + .asidx_from_attrs = x86_asidx_from_attrs, .get_crash_info = x86_cpu_get_crash_info, .write_elf32_note = x86_cpu_write_elf32_note, .write_elf64_note = x86_cpu_write_elf64_note,
@@ -7429,7 +7430,6 @@ 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->get_memory_mapping = x86_cpu_get_memory_mapping; cc->get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug; cc->sysemu_ops = &i386_sysemu_ops;
Signature · 1 line
2.26.2
PATCH v3 13/27 cpu: Move CPUClass::get_phys_page_debug to SysemuCPUOps
In reply to Philippe Mathieu-Daudé--- include/hw/core/cpu.h | 8 -------- include/hw/core/sysemu-cpu-ops.h | 13 +++++++++++++ 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 | 4 +--- 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 +- 25 files changed, 38 insertions(+), 35 deletions(-)
include/hw/core/cpu.h +0 -8
@@ -103,11 +103,6 @@ struct AccelCPUClass;* 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.
@@ -146,9 +141,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);
include/hw/core/sysemu-cpu-ops.h +13 -0
@@ -16,6 +16,19 @@* struct SysemuCPUOps: System operations specific to a CPU class */ typedef struct SysemuCPUOps { + /** + * @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.
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->sysemu_ops->get_phys_page_attrs_debug) { +return cc->sysemu_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->sysemu_ops->get_phys_page_debug (cpu, addr); }hwaddr cpu_get_phys_page_debug (CPUState *cpu,vaddr addr)
target/alpha/cpu.c +1 -1
@@ -208,6 +208,7 @@ static void alpha_cpu_initfn(Object *obj)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps alpha_sysemu_ops = { + .get_phys_page_debug = alpha_cpu_get_phys_page_debug, .vmsd = &vmstate_alpha_cpu, };#endif
@@ -242,7 +243,6 @@ 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->sysemu_ops = &alpha_sysemu_ops;#endif cc->disas_set_info = alpha_cpu_disas_set_info;
target/arm/cpu.c +1 -1
@@ -2262,6 +2262,7 @@ static gchar *arm_gdb_arch_name(CPUState *cs)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps arm_sysemu_ops = { + .get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug, .asidx_from_attrs = arm_asidx_from_attrs, .write_elf32_note = arm_cpu_write_elf32_note, .write_elf64_note = arm_cpu_write_elf64_note,
@@ -2307,7 +2308,6 @@ 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->sysemu_ops = &arm_sysemu_ops;#endif cc->gdb_num_core_regs =26 ;
target/avr/cpu.c +1 -1
@@ -185,6 +185,7 @@ static void avr_cpu_dump_state(CPUState *cs, FILE *f, int flags) }static struct SysemuCPUOps avr_sysemu_ops = { + .get_phys_page_debug = avr_cpu_get_phys_page_debug, .vmsd = &vms_avr_cpu, };
@@ -216,7 +217,6 @@ 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->sysemu_ops = &avr_sysemu_ops; cc->disas_set_info = avr_cpu_disas_set_info; cc->gdb_read_register = avr_cpu_gdb_read_register;
target/cris/cpu.c +1 -1
@@ -195,6 +195,7 @@ static void cris_cpu_initfn(Object *obj)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps cris_sysemu_ops = { + .get_phys_page_debug = cris_cpu_get_phys_page_debug, .vmsd = &vmstate_cris_cpu, };#endif
@@ -298,7 +299,6 @@ 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->sysemu_ops = &cris_sysemu_ops;#endif
target/hppa/cpu.c +1 -1
@@ -133,6 +133,7 @@ static ObjectClass *hppa_cpu_class_by_name(const char *cpu_model)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps hppa_sysemu_ops = { + .get_phys_page_debug = hppa_cpu_get_phys_page_debug, .vmsd = &vmstate_hppa_cpu, };#endif
@@ -167,7 +168,6 @@ 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->sysemu_ops = &hppa_sysemu_ops;#endif cc->disas_set_info = hppa_cpu_disas_set_info;
target/i386/cpu.c +1 -1
@@ -7388,6 +7388,7 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps i386_sysemu_ops = { + .get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug, .asidx_from_attrs = x86_asidx_from_attrs, .get_crash_info = x86_cpu_get_crash_info, .write_elf32_note = x86_cpu_write_elf32_note,
@@ -7431,7 +7432,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->get_memory_mapping = x86_cpu_get_memory_mapping; - cc->get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug; cc->sysemu_ops = &i386_sysemu_ops;#endif /* !CONFIG_USER_ONLY */
target/lm32/cpu.c +1 -1
@@ -212,6 +212,7 @@ static ObjectClass *lm32_cpu_class_by_name(const char *cpu_model)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps lm32_sysemu_ops = { + .get_phys_page_debug = lm32_cpu_get_phys_page_debug, .vmsd = &vmstate_lm32_cpu, };#endif
@@ -246,7 +247,6 @@ 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->sysemu_ops = &lm32_sysemu_ops;#endif cc->gdb_num_core_regs =32 +7 ;
target/m68k/cpu.c +1 -1
@@ -504,6 +504,7 @@ static const VMStateDescription vmstate_m68k_cpu = {#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps m68k_sysemu_ops = { + .get_phys_page_debug = m68k_cpu_get_phys_page_debug, .vmsd = &vmstate_m68k_cpu, };#endif
@@ -538,7 +539,6 @@ 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->sysemu_ops = &m68k_sysemu_ops;#endif cc->disas_set_info = m68k_cpu_disas_set_info;
target/microblaze/cpu.c +1 -1
@@ -354,6 +354,7 @@ static ObjectClass *mb_cpu_class_by_name(const char *cpu_model)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps mb_sysemu_ops = { + .get_phys_page_attrs_debug = mb_cpu_get_phys_page_attrs_debug, .vmsd = &vmstate_mb_cpu, };#endif
@@ -392,7 +393,6 @@ 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->sysemu_ops = &mb_sysemu_ops;#endif device_class_set_props (dc, mb_properties);
target/mips/cpu.c +1 -1
@@ -682,6 +682,7 @@ static Property mips_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps mips_sysemu_ops = { + .get_phys_page_debug = mips_cpu_get_phys_page_debug, .vmsd = &vmstate_mips_cpu, };#endif
@@ -725,7 +726,6 @@ 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->sysemu_ops = &mips_sysemu_ops;#endif cc->disas_set_info = mips_cpu_disas_set_info;
target/moxie/cpu.c +1 -3
@@ -95,6 +95,7 @@ static ObjectClass *moxie_cpu_class_by_name(const char *cpu_model) }static struct SysemuCPUOps moxie_sysemu_ops = { + .get_phys_page_debug = moxie_cpu_get_phys_page_debug, .vmsd = &vmstate_moxie_cpu, };
@@ -124,9 +125,6 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = moxie_cpu_has_work; 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; -#endif cc->disas_set_info = moxie_cpu_disas_set_info; cc->sysemu_ops = &moxie_sysemu_ops; cc->tcg_ops = &moxie_tcg_ops;
target/nios2/cpu.c +1 -1
@@ -215,6 +215,7 @@ static const VMStateDescription vmstate_nios2_cpu = { };static struct SysemuCPUOps nios2_sysemu_ops = { + .get_phys_page_debug = nios2_cpu_get_phys_page_debug, .vmsd = &vmstate_nios2_cpu, };#endif
@@ -249,7 +250,6 @@ 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->sysemu_ops = &nios2_sysemu_ops;#endif cc->gdb_read_register = nios2_cpu_gdb_read_register;
target/openrisc/cpu.c +1 -1
@@ -176,6 +176,7 @@ static void openrisc_any_initfn(Object *obj)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps openrisc_sysemu_ops = { + .get_phys_page_debug = openrisc_cpu_get_phys_page_debug, .vmsd = &vmstate_openrisc_cpu, };#endif
@@ -209,7 +210,6 @@ 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->sysemu_ops = &openrisc_sysemu_ops;#endif cc->gdb_num_core_regs =32 +3 ;
target/riscv/cpu.c +1 -1
@@ -582,6 +582,7 @@ static const char *riscv_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps riscv_sysemu_ops = { + .get_phys_page_debug = riscv_cpu_get_phys_page_debug,/* For now, mark unmigratable: */ .vmsd = &vmstate_riscv_cpu, };
@@ -628,7 +629,6 @@ 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->sysemu_ops = &riscv_sysemu_ops;#endif cc->gdb_arch_name = riscv_gdb_arch_name;
target/rx/cpu.c +1 -1
@@ -180,6 +180,7 @@ static const VMStateDescription vmstate_rx_cpu = { };static struct SysemuCPUOps rx_sysemu_ops = { + .get_phys_page_debug = rx_cpu_get_phys_page_debug, .vmsd = &vmstate_rx_cpu, };#endif
@@ -218,7 +219,6 @@ static void rx_cpu_class_init(ObjectClass *klass, void *data)#endif 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->disas_set_info = rx_cpu_disas_set_info; cc->gdb_num_core_regs =26 ;
target/s390x/cpu.c +1 -1
@@ -479,6 +479,7 @@ static void s390_cpu_reset_full(DeviceState *dev)#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps s390_sysemu_ops = { + .get_phys_page_debug = s390_cpu_get_phys_page_debug, .get_crash_info = s390_cpu_get_crash_info, .write_elf64_note = s390_cpu_write_elf64_note, .vmsd = &vmstate_s390_cpu,
@@ -524,7 +525,6 @@ 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->sysemu_ops = &s390_sysemu_ops;#endif cc->disas_set_info = s390_cpu_disas_set_info;
target/sh4/cpu.c +1 -1
@@ -225,6 +225,7 @@ static const VMStateDescription vmstate_sh_cpu = { };static struct SysemuCPUOps sh4_sysemu_ops = { + .get_phys_page_debug = superh_cpu_get_phys_page_debug, .vmsd = &vmstate_sh_cpu, };#endif
@@ -262,7 +263,6 @@ 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->sysemu_ops = &sh4_sysemu_ops;#endif cc->disas_set_info = superh_cpu_disas_set_info;
target/sparc/cpu.c +1 -1
@@ -850,6 +850,7 @@ static Property sparc_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps sparc_sysemu_ops = { + .get_phys_page_debug = sparc_cpu_get_phys_page_debug, .vmsd = &vmstate_sparc_cpu, };#endif
@@ -894,7 +895,6 @@ 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->sysemu_ops = &sparc_sysemu_ops;#endif cc->disas_set_info = cpu_sparc_disas_set_info;
target/tricore/cpu.c +1 -1
@@ -149,6 +149,7 @@ static const VMStateDescription vmstate_tricore_cpu = { };static struct SysemuCPUOps tricore_sysemu_ops = { + .get_phys_page_debug = tricore_cpu_get_phys_page_debug, .vmsd = &vmstate_tricore_cpu, };
@@ -180,7 +181,6 @@ 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->sysemu_ops = &tricore_sysemu_ops; cc->tcg_ops = &tricore_tcg_ops; }
target/unicore32/cpu.c +1 -1
@@ -121,6 +121,7 @@ static const VMStateDescription vmstate_uc32_cpu = { };static struct SysemuCPUOps uc32_sysemu_ops = { + .get_phys_page_debug = uc32_cpu_get_phys_page_debug, .vmsd = &vmstate_uc32_cpu, };
@@ -149,7 +150,6 @@ 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->sysemu_ops = &uc32_sysemu_ops; cc->tcg_ops = &uc32_tcg_ops; }
target/xtensa/cpu.c +1 -1
@@ -183,6 +183,7 @@ static const VMStateDescription vmstate_xtensa_cpu = { };static struct SysemuCPUOps xtensa_sysemu_ops = { + .get_phys_page_debug = xtensa_cpu_get_phys_page_debug, .vmsd = &vmstate_xtensa_cpu, };#endif
@@ -222,7 +223,6 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_stop_before_watchpoint = true;#ifndef CONFIG_USER_ONLY cc->sysemu_ops = &xtensa_sysemu_ops; - cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug;#endif cc->disas_set_info = xtensa_cpu_disas_set_info; cc->tcg_ops = &xtensa_tcg_ops;
target/ppc/translate_init.c.inc +1 -1
@@ -10845,6 +10845,7 @@ static Property ppc_cpu_properties[] = { #ifndef CONFIG_USER_ONLY static struct SysemuCPUOps ppc_sysemu_ops = { + .get_phys_page_debug = ppc_cpu_get_phys_page_debug, .write_elf32_note = ppc32_cpu_write_elf32_note, .write_elf64_note = ppc64_cpu_write_elf64_note, .virtio_is_big_endian = ppc_cpu_is_big_endian,
@@ -10893,7 +10894,6 @@ 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->sysemu_ops = &ppc_sysemu_ops; #endif
Signature · 1 line
2.26.2
PATCH v3 14/27 cpu: Move CPUClass::get_memory_mapping to SysemuCPUOps
In reply to Philippe Mathieu-Daudé--- include/hw/core/cpu.h | 3 --- include/hw/core/sysemu-cpu-ops.h | 5 +++++ hw/core/cpu.c | 4 ++-- target/i386/cpu.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-)
include/hw/core/cpu.h +0 -3
@@ -94,7 +94,6 @@ struct AccelCPUClass;* @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;
@@ -138,8 +137,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);
include/hw/core/sysemu-cpu-ops.h +5 -0
@@ -16,6 +16,11 @@* struct SysemuCPUOps: System operations specific to a CPU class */ typedef struct SysemuCPUOps { + /** + * @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. */
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->sysemu_ops->get_memory_mapping) { + cc->sysemu_ops->get_memory_mapping (cpu, list, errp);return ; }
target/i386/cpu.c +1 -1
@@ -7388,6 +7388,7 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps i386_sysemu_ops = { + .get_memory_mapping = x86_cpu_get_memory_mapping, .get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug, .asidx_from_attrs = x86_asidx_from_attrs, .get_crash_info = x86_cpu_get_crash_info,
@@ -7431,7 +7432,6 @@ 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->get_memory_mapping = x86_cpu_get_memory_mapping; cc->sysemu_ops = &i386_sysemu_ops;#endif /* !CONFIG_USER_ONLY */
Signature · 1 line
2.26.2
PATCH v3 15/27 cpu: Move CPUClass::get_paging_enabled to SysemuCPUOps
In reply to Philippe Mathieu-Daudé--- include/hw/core/cpu.h | 2 -- include/hw/core/sysemu-cpu-ops.h | 4 ++++ hw/core/cpu.c | 4 ++-- target/i386/cpu.c | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-)
include/hw/core/cpu.h +0 -2
@@ -93,7 +93,6 @@ struct AccelCPUClass;* @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;
@@ -136,7 +135,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);
include/hw/core/sysemu-cpu-ops.h +4 -0
@@ -21,6 +21,10 @@ typedef struct SysemuCPUOps {*/ 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. */
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->sysemu_ops->get_paging_enabled) { +return cc->sysemu_ops->get_paging_enabled (cpu); }return false;
target/i386/cpu.c +3 -1
@@ -7157,12 +7157,14 @@ static int64_t x86_cpu_get_arch_id(CPUState *cs)return cpu->apic_id; } +#if !defined(CONFIG_USER_ONLY )static bool x86_cpu_get_paging_enabled (const CPUState *cs) {X86CPU *cpu =X86_CPU (cs);return cpu->env.cr[0 ] &CR0_PG_MASK ; } +#endif /* !CONFIG_USER_ONLY */ static void x86_cpu_set_pc (CPUState *cs,vaddr value) {
@@ -7389,6 +7391,7 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static struct SysemuCPUOps i386_sysemu_ops = { .get_memory_mapping = x86_cpu_get_memory_mapping, + .get_paging_enabled = x86_cpu_get_paging_enabled, .get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug, .asidx_from_attrs = x86_asidx_from_attrs, .get_crash_info = x86_cpu_get_crash_info,
@@ -7429,7 +7432,6 @@ 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;#ifndef CONFIG_USER_ONLY cc->sysemu_ops = &i386_sysemu_ops;
Signature · 1 line
2.26.2
PATCH v3 16/27 cpu: Restrict "hw/core/sysemu-cpu-ops.h" to target/cpu.c
In reply to Philippe Mathieu-DaudéSomehow similar to commit 78271684719 ("cpu: tcg_ops: move to tcg-cpu-ops.h, keep a pointer in CPUClass"):
We cannot in principle make the SysEmu Operations field definitions conditional on CONFIG_SOFTMMU in code that is included by both common_ss and specific_ss modules.
Therefore, what we can do safely to restrict the SysEmu fields to system emulation builds, is to move all sysemu operations into a separate header file, which is only included by system-specific code.
This leaves just a NULL pointer in the cpu.h for the user-mode builds.
--- include/hw/core/cpu.h | 3 ++- target/alpha/cpu.h | 3 +++ target/arm/cpu.h | 3 +++ target/avr/cpu.h | 1 + target/cris/cpu.h | 3 +++ target/hexagon/cpu.h | 3 +++ target/hppa/cpu.h | 3 +++ target/i386/cpu.h | 3 +++ target/lm32/cpu.h | 3 +++ target/m68k/cpu.h | 3 +++ target/microblaze/cpu.h | 1 + target/mips/cpu.h | 3 +++ target/moxie/cpu.h | 3 +++ target/nios2/cpu.h | 1 + target/openrisc/cpu.h | 3 +++ target/ppc/cpu.h | 3 +++ target/riscv/cpu.h | 3 +++ target/rx/cpu.h | 1 + target/s390x/cpu.h | 3 +++ target/sh4/cpu.h | 3 +++ target/sparc/cpu.h | 3 +++ target/tilegx/cpu.h | 3 +++ target/tricore/cpu.h | 3 +++ target/unicore32/cpu.h | 3 +++ target/xtensa/cpu.h | 3 +++ cpu.c | 1 + hw/core/cpu.c | 1 + 27 files changed, 68 insertions(+), 1 deletion(-)
include/hw/core/cpu.h +2 -1
@@ -80,7 +80,8 @@ struct TCGCPUOps;/* see accel-cpu.h */ struct AccelCPUClass ; -#include "hw/core/sysemu-cpu-ops.h" +/* see sysemu-cpu-ops.h */ +struct SysemuCPUOps ;/** * CPUClass:
target/alpha/cpu.h +3 -0
@@ -22,6 +22,9 @@#include "cpu-qom.h" #include "exec/cpu-defs.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif /* Alpha processors have a weak memory model */ #define TCG_GUEST_DEFAULT_MO (0)
target/arm/cpu.h +3 -0
@@ -25,6 +25,9 @@#include "cpu-qom.h" #include "exec/cpu-defs.h" #include "qapi/qapi-types-common.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif /* ARM processors have a weak memory model */ #define TCG_GUEST_DEFAULT_MO (0)
target/avr/cpu.h +1 -0
@@ -23,6 +23,7 @@#include "cpu-qom.h" #include "exec/cpu-defs.h" +#include "hw/core/sysemu-cpu-ops.h" #ifdef CONFIG_USER_ONLY #error "AVR 8-bit does not support user mode"
target/cris/cpu.h +3 -0
@@ -23,6 +23,9 @@#include "cpu-qom.h" #include "exec/cpu-defs.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif #define EXCP_NMI 1#define EXCP_GURU 2
target/hexagon/cpu.h +3 -0
@@ -26,6 +26,9 @@ typedef struct CPUHexagonState CPUHexagonState;#include "qemu-common.h" #include "exec/cpu-defs.h" #include "hex_regs.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif #define NUM_PREGS 4#define TOTAL_PER_THREAD_REGS 64
target/hppa/cpu.h +3 -0
@@ -23,6 +23,9 @@#include "cpu-qom.h" #include "exec/cpu-defs.h" #include "exec/memory.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif /* PA-RISC 1.x processors have a strong memory model. */ /* ??? While we do not yet implement PA-RISC 2.0, those processors have
target/i386/cpu.h +3 -0
@@ -25,6 +25,9 @@#include "kvm/hyperv-proto.h" #include "exec/cpu-defs.h" #include "qapi/qapi-types-common.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif /* The x86 has a strong memory model with some store-after-load re-ordering */ #define TCG_GUEST_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD)
target/lm32/cpu.h +3 -0
@@ -22,6 +22,9 @@#include "cpu-qom.h" #include "exec/cpu-defs.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif typedef struct CPULM32State CPULM32State ;
target/m68k/cpu.h +3 -0
@@ -23,6 +23,9 @@#include "exec/cpu-defs.h" #include "cpu-qom.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif #define OS_BYTE 0#define OS_WORD 1
target/microblaze/cpu.h +1 -0
@@ -26,6 +26,7 @@typedef struct CPUMBState CPUMBState ;#if !defined(CONFIG_USER_ONLY ) +#include "hw/core/sysemu-cpu-ops.h" #include "mmu.h" #endif
target/mips/cpu.h +3 -0
@@ -6,6 +6,9 @@#include "fpu/softfloat-types.h" #include "hw/clock.h" #include "mips-defs.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif #define TCG_GUEST_DEFAULT_MO (0)
target/moxie/cpu.h +3 -0
@@ -22,6 +22,9 @@#include "exec/cpu-defs.h" #include "qom/object.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif #define MOXIE_EX_DIV0 0#define MOXIE_EX_BAD 1
target/nios2/cpu.h +1 -0
@@ -27,6 +27,7 @@typedef struct CPUNios2State CPUNios2State ;#if !defined(CONFIG_USER_ONLY ) +#include "hw/core/sysemu-cpu-ops.h" #include "mmu.h" #endif
target/openrisc/cpu.h +3 -0
@@ -23,6 +23,9 @@#include "exec/cpu-defs.h" #include "hw/core/cpu.h" #include "qom/object.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif /* cpu_openrisc_map_address_* in CPUOpenRISCTLBContext need this decl. */ struct OpenRISCCPU ;
target/ppc/cpu.h +3 -0
@@ -24,6 +24,9 @@#include "exec/cpu-defs.h" #include "cpu-qom.h" #include "qom/object.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif #define TCG_GUEST_DEFAULT_MO 0
target/riscv/cpu.h +3 -0
@@ -25,6 +25,9 @@#include "exec/cpu-defs.h" #include "fpu/softfloat-types.h" #include "qom/object.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif #define TCG_GUEST_DEFAULT_MO 0
target/rx/cpu.h +1 -0
@@ -25,6 +25,7 @@#include "cpu-qom.h" #include "exec/cpu-defs.h" +#include "hw/core/sysemu-cpu-ops.h" /* PSW define */ REG32 (PSW ,0 )
target/s390x/cpu.h +3 -0
@@ -28,6 +28,9 @@#include "cpu-qom.h" #include "cpu_models.h" #include "exec/cpu-defs.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif #define ELF_MACHINE_UNAME "S390X"
target/sh4/cpu.h +3 -0
@@ -22,6 +22,9 @@#include "cpu-qom.h" #include "exec/cpu-defs.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif /* CPU Subtypes */ #define SH_CPU_SH7750 (1 << 0)
target/sparc/cpu.h +3 -0
@@ -4,6 +4,9 @@#include "qemu/bswap.h" #include "cpu-qom.h" #include "exec/cpu-defs.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif #if !defined(TARGET_SPARC64 )#define TARGET_DPREGS 16
target/tilegx/cpu.h +3 -0
@@ -22,6 +22,9 @@#include "exec/cpu-defs.h" #include "qom/object.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif /* TILE-Gx common register alias */ #define TILEGX_R_RE 0/* 0 register, for function/syscall return value */
target/tricore/cpu.h +3 -0
@@ -23,6 +23,9 @@#include "cpu-qom.h" #include "exec/cpu-defs.h" #include "tricore-defs.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif struct tricore_boot_info ;
target/unicore32/cpu.h +3 -0
@@ -14,6 +14,9 @@#include "cpu-qom.h" #include "exec/cpu-defs.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif typedef struct CPUUniCore32State { /* Regs for current mode. */
target/xtensa/cpu.h +3 -0
@@ -31,6 +31,9 @@#include "cpu-qom.h" #include "exec/cpu-defs.h" #include "xtensa-isa.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif /* Xtensa processors have a weak memory model */ #define TCG_GUEST_DEFAULT_MO (0)
cpu.c +1 -0
@@ -29,6 +29,7 @@#ifdef CONFIG_USER_ONLY #include "qemu.h" #else +#include "hw/core/sysemu-cpu-ops.h" #include "exec/address-spaces.h" #endif #include "sysemu/tcg.h"
hw/core/cpu.c +1 -0
@@ -35,6 +35,7 @@#include "trace/trace-root.h" #include "qemu/plugin.h" #include "sysemu/hw_accel.h" +#include "hw/core/sysemu-cpu-ops.h" CPUState *cpu_by_arch_id (int64_t id) {
Signature · 1 line
2.26.2
PATCH v3 17/27 linux-user: Remove dead code
In reply to Philippe Mathieu-DaudéWe can not use watchpoints in user-mode emulation because we need the softmmu slow path to detect accesses to watchpointed memory. This code is expanded as empty stub in "hw/core/cpu.h" anyway, so we can drop it.
--- linux-user/main.c | 5 ----- 1 file changed, 5 deletions(-)
linux-user/main.c +0 -5
@@ -200,7 +200,6 @@ CPUArchState *cpu_copy(CPUArchState *env)CPUState *new_cpu =cpu_create (cpu_type);CPUArchState *new_env = new_cpu->env_ptr;CPUBreakpoint *bp; -CPUWatchpoint *wp;/* Reset non arch specific state */ cpu_reset (new_cpu);
@@ -211,13 +210,9 @@ CPUArchState *cpu_copy(CPUArchState *env)Note: Once we support ptrace with hw-debug register access, make sure BP_CPU break/watchpoints are handled correctly on clone. */ QTAILQ_INIT (&new_cpu->breakpoints); -QTAILQ_INIT (&new_cpu->watchpoints); QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {cpu_breakpoint_insert (new_cpu, bp->pc, bp->flags,NULL ); } - QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { -cpu_watchpoint_insert (new_cpu, wp->vaddr, wp->len, wp->flags,NULL ); - }return new_env; }
Signature · 1 line
2.26.2
Re: [PATCH v3 17/27] linux-user: Remove dead code
Le 02/03/2021 à 15:58, Philippe Mathieu-Daudé a écrit :
Quoted 27 lines
We can not use watchpoints in user-mode emulation because we need the softmmu slow path to detect accesses to watchpointed memory. This code is expanded as empty stub in "
hw/core/cpu.h" anyway, so we can drop it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- linux-user/main.c | 5 ----- 1 file changed, 5 deletions(-)linux-user/main.c +0
-1@@ -200,7 +200,6 @@ CPUArchState *cpu_copy(CPUArchState *env)CPUState *new_cpu =cpu_create (cpu_type);CPUArchState *new_env = new_cpu->env_ptr;CPUBreakpoint *bp; -CPUWatchpoint *wp;/* Reset non arch specific state */ cpu_reset (new_cpu);@@ -211,13 +210,9 @@ CPUArchState *cpu_copy(CPUArchState *env)Note: Once we support ptrace with hw-debug register access, make sure BP_CPU break/watchpoints are handled correctly on clone. */ QTAILQ_INIT (&new_cpu->breakpoints);
linux-user/main.c CPUArchState *cpu_copy(CPUArchState *env) · line 218
Quoted 10 lines
linux-user/main.c +0
-4-QTAILQ_INIT (&new_cpu->watchpoints); QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {cpu_breakpoint_insert (new_cpu, bp->pc, bp->flags,NULL ); } - QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { -cpu_watchpoint_insert (new_cpu, wp->vaddr, wp->len, wp->flags,NULL ); - }return new_env; }
PATCH v3 18/27 gdbstub: Remove watchpoint dead code in gdbserver_fork()
In reply to Philippe Mathieu-Daudégdbserver_fork() is only used in user emulation where we can not use watchpoints because we need the softmmu slow path to detect accesses to watchpointed memory. This code doesn't do anything as declared as stubs in "hw/core/cpu.h". Drop it.
--- gdbstub.c | 1 - 1 file changed, 1 deletion(-)
gdbstub.c +0 -1
@@ -3349,7 +3349,6 @@ void gdbserver_fork(CPUState *cpu)close (gdbserver_state.fd); gdbserver_state.fd =-1 ; cpu_breakpoint_remove_all(cpu, BP_GDB); - cpu_watchpoint_remove_all(cpu, BP_GDB); }#else static int gdb_chr_can_receive (void *opaque)
Signature · 1 line
2.26.2