cpu: Introduce SysemuCPUOps structure
Subsystems (2)
v7 cover cpu: Introduce SysemuCPUOps structure
Missing review: 2-5 (new) and 13
Hi,
This series is inspired on Claudio TCG work.
Instead of separate TCG from other accelerators, here we separate sysemu operations (system VS user).
Since v6:
- Rebased (3 targets removed, Claudio's target/i386 series merged)
- Addressed Richard & David comments
Since v5:
- Rework patch 10 after Peter Maydell explanation on v3:
https://www.mail-archive.com/[email protected]/msg800849.html
Since v4:
- Removed watchpoint patches (need more work) (Richard)
- Merged patch 1 & 7 "Move CPUClass::vmsd to SysemuCPUOps" (Eduardo)
- Reworded cpu_virtio_is_big_endian description (Greg)
- Move write_elf() in target/riscv/cpu.c (rebased on top of 43a965888)
- Added R-b tags
Since v3:
- SysemuCPUOps const (Richard)
- added missing xtensa #ifdef'ry
- added missing aa64/sve #ifdef'ry
- added Laurent R-b
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 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/23:[down] 'NOTFORMERGE target/arm: Restrict MTE code to softmmu' 002/23:[down] 'cpu: Restrict target cpu_do_transaction_failed() handlers to s= ysemu'
003/23:[down] 'cpu: Restrict target cpu_do_unaligned_access() handlers to sys= emu'
004/23:[down] 'cpu: Remove duplicated 'sysemu/hw_accel.h' header' 005/23:[down] 'cpu: Split as cpu-common / cpu-sysemu' 006/23:[0002] [FC] 'cpu: Un-inline cpu_get_phys_page_debug and cpu_asidx_from= _attrs'
007/23:[0010] [FC] 'cpu: Introduce cpu_virtio_is_big_endian()' 008/23:[0088] [FC] 'cpu: Directly use cpu_write_elf*() fallback handlers in p= lace'
009/23:[0022] [FC] 'cpu: Directly use get_paging_enabled() fallback handlers = in place'
010/23:[0026] [FC] 'cpu: Directly use get_memory_mapping() fallback handlers = in place'
011/23:[0007] [FC] 'cpu: Assert DeviceClass::vmsd is NULL on user emulation' 012/23:[0004] [FC] 'cpu: Rename CPUClass vmsd -> legacy_vmsd' 013/23:[down] 'cpu: Move AVR target vmsd field from CPUClass to DeviceClass' 014/23:[0014] [FC] 'cpu: Introduce SysemuCPUOps structure' 015/23:[0003] [FC] 'cpu: Move CPUClass::vmsd to SysemuCPUOps' 016/23:[0002] [FC] 'cpu: Move CPUClass::virtio_is_big_endian to SysemuCPUOps' 017/23:[----] [--] 'cpu: Move CPUClass::get_crash_info to SysemuCPUOps' 018/23:[----] [-C] 'cpu: Move CPUClass::write_elf* to SysemuCPUOps' 019/23:[----] [--] 'cpu: Move CPUClass::asidx_from_attrs to SysemuCPUOps' 020/23:[0055] [FC] 'cpu: Move CPUClass::get_phys_page_debug to SysemuCPUOps' 021/23:[----] [--] 'cpu: Move CPUClass::get_memory_mapping to SysemuCPUOps' 022/23:[----] [--] 'cpu: Move CPUClass::get_paging_enabled to SysemuCPUOps' 023/23:[0012] [FC] 'cpu: Restrict "hw/core/sysemu-cpu-ops.h" to target/cpu.c'
Regards,
Phil.
Philippe Mathieu-Daud=C3=A9 (23):
NOTFORMERGE target/arm: Restrict MTE code to softmmu
cpu: Restrict target cpu_do_transaction_failed() handlers to sysemu
cpu: Restrict target cpu_do_unaligned_access() handlers to sysemu
cpu: Remove duplicated 'sysemu/hw_accel.h' header
cpu: Split as cpu-common / cpu-sysemu
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: Assert DeviceClass::vmsd is NULL on user emulation
cpu: Rename CPUClass vmsd -> legacy_vmsd
cpu: Move AVR target vmsd field from CPUClass to DeviceClass
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
include/hw/core/cpu.h | 92 +++++---------------
include/hw/core/sysemu-cpu-ops.h | 92 ++++++++++++++++++++
include/migration/vmstate.h | 2 -
target/alpha/cpu.h | 12 ++-
target/arm/cpu.h | 9 +-
target/arm/internals.h | 2 +
target/avr/cpu.h | 1 +
target/cris/cpu.h | 7 +-
target/hexagon/cpu.h | 3 +
target/hppa/cpu.h | 5 +-
target/i386/cpu.h | 9 +-
target/m68k/cpu.h | 10 ++-
target/microblaze/cpu.h | 11 +--
target/mips/cpu.h | 3 +
target/mips/tcg/tcg-internal.h | 6 +-
target/nios2/cpu.h | 4 +-
target/openrisc/cpu.h | 6 +-
target/ppc/cpu.h | 5 +-
target/ppc/internal.h | 2 +
target/riscv/cpu.h | 21 +++--
target/rx/cpu.h | 5 ++
target/s390x/cpu.h | 3 +
target/s390x/internal.h | 2 +
target/sh4/cpu.h | 11 ++-
target/sparc/cpu.h | 14 +--
target/tricore/cpu.h | 5 ++
target/xtensa/cpu.h | 19 ++--
cpu.c | 18 ++--
hw/core/{cpu.c =3D> cpu-common.c} | 116 -------------------------
hw/core/cpu-sysemu.c | 145 +++++++++++++++++++++++++++++++
hw/virtio/virtio.c | 4 +-
stubs/vmstate.c | 2 -
target/alpha/cpu.c | 8 +-
target/arm/cpu.c | 18 ++--
target/arm/tlb_helper.c | 4 +-
target/avr/cpu.c | 8 +-
target/avr/machine.c | 4 +-
target/cris/cpu.c | 8 +-
target/hppa/cpu.c | 8 +-
target/i386/cpu.c | 28 +++---
target/m68k/cpu.c | 8 +-
target/microblaze/cpu.c | 8 +-
target/microblaze/helper.c | 35 ++++----
target/mips/cpu.c | 10 ++-
target/nios2/cpu.c | 8 +-
target/openrisc/cpu.c | 8 +-
target/ppc/excp_helper.c | 3 +-
target/riscv/cpu.c | 14 ++-
target/rx/cpu.c | 10 ++-
target/s390x/cpu.c | 14 ++-
target/sh4/cpu.c | 11 ++-
target/sparc/cpu.c | 10 ++-
target/sparc/ldst_helper.c | 5 +-
target/tricore/cpu.c | 6 +-
target/xtensa/cpu.c | 10 ++-
target/ppc/translate_init.c.inc | 20 +++--
hw/core/meson.build | 3 +-
target/arm/meson.build | 6 +-
58 files changed, 587 insertions(+), 334 deletions(-)
create mode 100644 include/hw/core/sysemu-cpu-ops.h
rename hw/core/{cpu.c =3D> cpu-common.c} (73%)
create mode 100644 hw/core/cpu-sysemu.c--=20
2.26.3
PATCH v7 1/23 NOTFORMERGE target/arm: Restrict MTE code to softmmu
The following patches require the "arm cleanup experiment for kvm-only build" [*] series with split various user/sysemu and tcg/kvm code from the target/arm/ directory.
To be able to build the following patches waiting the series get merged, simply restrict the MTE code to the softmmu source set.
[*] https://lists.gnu.org/archive/html/qemu-devel/2021-04/msg02908.html
--- target/arm/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
target/arm/meson.build +5 -1
@@ -41,7 +41,6 @@ 'cpu64.c', 'gdbstub64.c', 'helper-a64.c', - 'mte_helper.c', 'pauth_helper.c', 'sve_helper.c', 'translate-a64.c',
@@ -49,6 +48,11 @@ )) arm_softmmu_ss = ss.source_set() + +arm_softmmu_ss.add(when: 'TARGET_AARCH64', if_true: files( + 'mte_helper.c', +)) + arm_softmmu_ss.add(files( 'arch_dump.c', 'arm-powerctl.c',
Signature · 1 line
2.26.3
PATCH v7 2/23 cpu: Restrict target cpu_do_transaction_failed() handlers to sysemu
In reply to Philippe Mathieu-DaudéIn commit cbc183d2d9f ("cpu: move cc->transaction_failed to tcg_ops") we restricted the do_transaction_failed() handler to the sysemu part of TCGCPUOps, but forgot to restrict the target specific declarations.
--- target/arm/internals.h | 2 ++ target/m68k/cpu.h | 2 ++ target/riscv/cpu.h | 10 +++++----- target/xtensa/cpu.h | 8 ++++---- 4 files changed, 13 insertions(+), 9 deletions(-)
target/arm/internals.h +2 -0
@@ -583,6 +583,7 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); +#if !defined(CONFIG_USER_ONLY )/* arm_cpu_do_transaction_failed: handle a memory system error response * (eg "no device/memory present at address") by raising an external abort * exception
@@ -592,6 +593,7 @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,MMUAccessType access_type, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr); +#endif /* Call any registered EL change hooks */ static inline void arm_call_pre_el_change_hook (ARMCPU *cpu)
target/m68k/cpu.h +2 -0
@@ -572,10 +572,12 @@ static inline int cpu_mmu_index (CPUM68KState *env, bool ifetch)bool m68k_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr); +#if !defined(CONFIG_USER_ONLY )void m68k_cpu_transaction_failed (CPUState *cs,hwaddr physaddr,vaddr addr,unsigned size,MMUAccessType access_type,int mmu_idx,MemTxAttrs attrs,MemTxResult response,uintptr_t retaddr); +#endif typedef CPUM68KState CPUArchState ;typedef M68kCPU ArchCPU ;
target/riscv/cpu.h +5 -5
@@ -346,11 +346,6 @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,bool riscv_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr); -void riscv_cpu_do_transaction_failed (CPUState *cs,hwaddr physaddr, -vaddr addr,unsigned size, -MMUAccessType access_type, -int mmu_idx,MemTxAttrs attrs, -MemTxResult response,uintptr_t retaddr);char *riscv_isa_string (RISCVCPU *cpu);void riscv_cpu_list (void );
@@ -359,6 +354,11 @@ void riscv_cpu_list(void);#define cpu_mmu_index riscv_cpu_mmu_index#ifndef CONFIG_USER_ONLY +void riscv_cpu_do_transaction_failed (CPUState *cs,hwaddr physaddr, +vaddr addr,unsigned size, +MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr);void riscv_cpu_swap_hypervisor_regs (CPURISCVState *env);int riscv_cpu_claim_interrupts (RISCVCPU *cpu,uint32_t interrupts);uint32_t riscv_cpu_update_mip (RISCVCPU *cpu,uint32_t mask,uint32_t value);
target/xtensa/cpu.h +4 -4
@@ -569,10 +569,6 @@ bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, bool probe, uintptr_t retaddr);void xtensa_cpu_do_interrupt (CPUState *cpu);bool xtensa_cpu_exec_interrupt (CPUState *cpu,int interrupt_request); -void xtensa_cpu_do_transaction_failed (CPUState *cs,hwaddr physaddr,vaddr addr, -unsigned size,MMUAccessType access_type, -int mmu_idx,MemTxAttrs attrs, -MemTxResult response,uintptr_t retaddr);void xtensa_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr xtensa_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); void xtensa_count_regs(const XtensaConfig *config,
@@ -675,6 +671,10 @@ static inline int xtensa_get_cring(const CPUXtensaState *env) }#ifndef CONFIG_USER_ONLY +void xtensa_cpu_do_transaction_failed (CPUState *cs,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr);int xtensa_get_physical_addr (CPUXtensaState *env,bool update_tlb,uint32_t vaddr,int is_write,int mmu_idx,uint32_t *paddr,uint32_t *page_size,unsigned *access);
Signature · 1 line
2.26.3
Re: [PATCH v7 02/23] cpu: Restrict target cpu_do_transaction_failed() handlers to sysemu
Quoted 11 lines · Philippe Mathieu-Daudé
In commit
cbc183d2d9f("cpu: movecc->transaction_failedtotcg_ops") we restricted thedo_transaction_failed()handler to the sysemu part of TCGCPUOps, but forgot to restrict the target specific declarations.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/arm/internals.h | 2 ++ target/m68k/cpu.h | 2 ++ target/riscv/cpu.h | 10 +++++----- target/xtensa/cpu.h | 8 ++++---- 4 files changed, 13 insertions(+), 9 deletions(-)
What do the extra ifdefs buy us? Surely the fact that the symbol is not present in the user-only, and would produce link errors if used, is sufficient?
r~
Re: [PATCH v7 02/23] cpu: Restrict target cpu_do_transaction_failed() handlers to sysemu
Quoted 13 lines · Richard Henderson
Quoted 11 lines · Philippe Mathieu-Daudé
In commit
cbc183d2d9f("cpu: movecc->transaction_failedtotcg_ops") we restricted thedo_transaction_failed()handler to the sysemu part of TCGCPUOps, but forgot to restrict the target specific declarations.Signed-off-by Philippe Mathieu-Daudé<[email protected]>---
target/arm/internals.h| 2 ++
target/m68k/cpu.h | 2 ++
target/riscv/cpu.h | 10 +++++-----
target/xtensa/cpu.h | 8 ++++----4 files changed, 13 insertions(+), 9 deletions(-)
Quoted 3 lines
What do the extra ifdefs buy us? Surely the fact that the symbol is not present in the user-only, and would produce link errors if used, is sufficient?
Last month on another series you told me we should declare prototypes that can't be used :) However I agree we want *less* #ifdef'ry, not more.
The ARM declarations is fixed in Claudio's accel rework.
For the m68k/riscv/xtensa targets I'll see if I can move it elsewhere in the same file (if there is already such #ifdef'ry), it is worthwhile to move the declaration in another (sysemu) header, or simply do nothing.
Thanks,
Phil.
Re: [PATCH v7 02/23] cpu: Restrict target cpu_do_transaction_failed() handlers to sysemu
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 3 lines
What do the extra ifdefs buy us? Surely the fact that the symbol is not present in the user-only, and would produce link errors if used, is sufficient?
Last month on another series you told me we should declare prototypes that can't be used :) However I agree we want *less* #ifdef'ry, not more.
Should or shouldn't?
Anyway, I don't think any of these declarations belong in cpu.h. There's no reason for any external user to reference them, as they ought to be using the hw/core/ cpu_* functions.
In an ideal world, we'd move them into some target/foo/sysemu/internal.h or something, which would involve no ifdefs and still give you the isolation.
But for the bulk of the targets, I think it's just easier to leave them alone.
r~
PATCH v7 3/23 cpu: Restrict target cpu_do_unaligned_access() handlers to sysemu
In reply to Philippe Mathieu-DaudéCommit 8535dd702dd ("cpu: move do_unaligned_access to tcg_ops") restricted the do_unaligned_access() handler to the sysemu part of TCGCPUOps, but only restricted the HPPA declaration. Restrict the other targets.
--- target/alpha/cpu.h | 7 ++++--- target/arm/internals.h | 2 +- target/microblaze/cpu.h | 7 ++++--- target/mips/tcg/tcg-internal.h | 6 +++--- target/nios2/cpu.h | 3 ++- target/ppc/internal.h | 2 ++ target/riscv/cpu.h | 6 +++--- target/s390x/internal.h | 2 ++ target/sh4/cpu.h | 6 +++--- target/sparc/cpu.h | 9 +++++---- target/xtensa/cpu.h | 6 +++--- target/arm/tlb_helper.c | 4 ++-- target/microblaze/helper.c | 35 +++++++++++++++++----------------- target/ppc/excp_helper.c | 3 ++- target/sparc/ldst_helper.c | 5 ++--- 15 files changed, 56 insertions(+), 47 deletions(-)
target/alpha/cpu.h +4 -3
@@ -274,6 +274,10 @@ struct AlphaCPU {#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_alpha_cpu; + +void alpha_cpu_do_unaligned_access (CPUState *cpu,vaddr addr, +MMUAccessType access_type, +int mmu_idx,uintptr_t retaddr);#endif void alpha_cpu_do_interrupt (CPUState *cpu);
@@ -282,9 +286,6 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags);hwaddr alpha_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int alpha_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int alpha_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); -void alpha_cpu_do_unaligned_access (CPUState *cpu,vaddr addr, -MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr);#define cpu_list alpha_cpu_list#define cpu_signal_handler cpu_alpha_signal_handler
target/arm/internals.h +1 -1
@@ -578,12 +578,12 @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate);* tables */ bool arm_s1_regime_using_lpae_format (CPUARMState *env,ARMMMUIdx mmu_idx); +#if !defined(CONFIG_USER_ONLY )/* Raise a data fault alignment exception for the specified virtual address */ void arm_cpu_do_unaligned_access (CPUState *cs,vaddr vaddr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr); -#if !defined(CONFIG_USER_ONLY )/* arm_cpu_do_transaction_failed: handle a memory system error response * (eg "no device/memory present at address") by raising an external abort * exception
target/microblaze/cpu.h +4 -3
@@ -357,9 +357,6 @@ struct MicroBlazeCPU {void mb_cpu_do_interrupt (CPUState *cs);bool mb_cpu_exec_interrupt (CPUState *cs,int int_req); -void mb_cpu_do_unaligned_access (CPUState *cs,vaddr vaddr, -MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr);void mb_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr mb_cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr,MemTxAttrs *attrs);
@@ -420,6 +417,10 @@ static inline void cpu_get_tb_cpu_state(CPUMBState *env, target_ulong *pc, }#if !defined(CONFIG_USER_ONLY ) + +void mb_cpu_do_unaligned_access (CPUState *cs,vaddr vaddr, +MMUAccessType access_type, +int mmu_idx,uintptr_t retaddr); void mb_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, int mmu_idx, MemTxAttrs attrs,
target/mips/tcg/tcg-internal.h +3 -3
@@ -23,9 +23,6 @@ bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req);bool mips_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr); -void mips_cpu_do_unaligned_access (CPUState *cpu,vaddr addr, -MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr);const char *mips_exception_name (int32_t exception);
@@ -57,6 +54,9 @@ void mips_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,MMUAccessType access_type, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr); +void mips_cpu_do_unaligned_access (CPUState *cpu,vaddr addr, +MMUAccessType access_type, +int mmu_idx,uintptr_t retaddr);void cpu_mips_tlb_flush (CPUMIPSState *env);#endif /* !CONFIG_USER_ONLY */
target/nios2/cpu.h +2 -1
@@ -197,10 +197,11 @@ int cpu_nios2_signal_handler(int host_signum, void *pinfo, void *puc);void dump_mmu (CPUNios2State *env);void nios2_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr nios2_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); +#ifndef CONFIG_USER_ONLY void nios2_cpu_do_unaligned_access (CPUState *cpu,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr); - +#endif void do_nios2_semihosting (CPUNios2State *env);#define CPU_RESOLVING_TYPE TYPE_NIOS2_CPU
target/ppc/internal.h +2 -0
@@ -211,10 +211,12 @@ void helper_compute_fprf_float16(CPUPPCState *env, float16 arg);void helper_compute_fprf_float32 (CPUPPCState *env,float32 arg);void helper_compute_fprf_float128 (CPUPPCState *env,float128 arg); +#if !defined(CONFIG_USER_ONLY )/* Raise a data fault alignment exception for the specified virtual address */ void ppc_cpu_do_unaligned_access (CPUState *cs,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr); +#endif /* translate.c */
target/riscv/cpu.h +3 -3
@@ -340,9 +340,6 @@ void riscv_cpu_set_force_hs_excep(CPURISCVState *env, bool enable);bool riscv_cpu_two_stage_lookup (int mmu_idx);int riscv_cpu_mmu_index (CPURISCVState *env,bool ifetch);hwaddr riscv_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); -void riscv_cpu_do_unaligned_access (CPUState *cs,vaddr addr, -MMUAccessType access_type,int mmu_idx, -uintptr_t retaddr);bool riscv_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr);
@@ -354,6 +351,9 @@ void riscv_cpu_list(void);#define cpu_mmu_index riscv_cpu_mmu_index#ifndef CONFIG_USER_ONLY +void riscv_cpu_do_unaligned_access (CPUState *cs,vaddr addr, +MMUAccessType access_type,int mmu_idx, +uintptr_t retaddr); void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type,
target/s390x/internal.h +2 -0
@@ -269,9 +269,11 @@ bool s390_cpu_exec_interrupt(CPUState *cpu, int int_req);bool s390_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr); +#if !defined(CONFIG_USER_ONLY )void s390x_cpu_do_unaligned_access (CPUState *cs,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr); +#endif /* fpu_helper.c */
target/sh4/cpu.h +3 -3
@@ -210,9 +210,6 @@ void superh_cpu_dump_state(CPUState *cpu, FILE *f, int flags);hwaddr superh_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int superh_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int superh_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); -void superh_cpu_do_unaligned_access (CPUState *cpu,vaddr addr, -MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr);void sh4_translate_init (void ); int cpu_sh4_signal_handler(int host_signum, void *pinfo,
@@ -240,6 +237,9 @@ uint32_t cpu_sh4_read_mmaped_utlb_data(CPUSH4State *s, hwaddr addr);void cpu_sh4_write_mmaped_utlb_data (CPUSH4State *s,hwaddr addr,uint32_t mem_value); +void superh_cpu_do_unaligned_access (CPUState *cpu,vaddr addr, +MMUAccessType access_type, +int mmu_idx,uintptr_t retaddr);#endif int cpu_sh4_is_cached (CPUSH4State * env,target_ulong addr);
target/sparc/cpu.h +5 -4
@@ -568,6 +568,11 @@ struct SPARCCPU {#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_sparc_cpu; + +void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, +MMUAccessType access_type, +int mmu_idx, +uintptr_t retaddr);#endif void sparc_cpu_do_interrupt (CPUState *cpu);
@@ -575,10 +580,6 @@ void sparc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);hwaddr sparc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int sparc_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int sparc_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); -void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, -MMUAccessType access_type, -int mmu_idx, -uintptr_t retaddr); void cpu_raise_exception_ra(CPUSPARCState *, int, uintptr_t) QEMU_NORETURN;#ifndef NO_CPU_IO_DEFS
target/xtensa/cpu.h +3 -3
@@ -575,9 +575,6 @@ void xtensa_count_regs(const XtensaConfig *config, unsigned *n_regs, unsigned *n_core_regs);int xtensa_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int xtensa_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); -void xtensa_cpu_do_unaligned_access (CPUState *cpu,vaddr addr, -MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr);#define cpu_signal_handler cpu_xtensa_signal_handler#define cpu_list xtensa_cpu_list
@@ -671,6 +668,9 @@ static inline int xtensa_get_cring(const CPUXtensaState *env) }#ifndef CONFIG_USER_ONLY +void xtensa_cpu_do_unaligned_access (CPUState *cpu,vaddr addr, +MMUAccessType access_type, +int mmu_idx,uintptr_t retaddr); void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, int mmu_idx, MemTxAttrs attrs,
target/arm/tlb_helper.c +2 -2
@@ -108,6 +108,8 @@ static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr,raise_exception (env, exc, syn, target_el); } +#if !defined(CONFIG_USER_ONLY ) +/* Raise a data fault alignment exception for the specified virtual address */ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, MMUAccessType access_type,
@@ -123,8 +125,6 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,arm_deliver_fault (cpu, vaddr, access_type, mmu_idx, &fi); } -#if !defined(CONFIG_USER_ONLY ) -/* * arm_cpu_do_transaction_failed: handle a memory system error response * (eg "no device/memory present at address") by raising an external abort
target/microblaze/helper.c +18 -17
@@ -271,23 +271,6 @@ hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,return paddr; } -#endif - -bool mb_cpu_exec_interrupt (CPUState *cs,int interrupt_request) -{ -MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); -CPUMBState *env = &cpu->env; - -if ((interrupt_request &CPU_INTERRUPT_HARD ) - && (env->msr &MSR_IE ) - && !(env->msr & (MSR_EIP |MSR_BIP )) - && !(env->iflags & (D_FLAG |IMM_FLAG ))) { - cs->exception_index =EXCP_IRQ ; -mb_cpu_do_interrupt (cs); -return true; - } -return false; -} void mb_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type,
@@ -316,3 +299,21 @@ void mb_cpu_do_unaligned_access(CPUState *cs, vaddr addr, cs->exception_index =EXCP_HW_EXCP ; cpu_loop_exit(cs); } + +#endif + +bool mb_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); +CPUMBState *env = &cpu->env; + +if ((interrupt_request &CPU_INTERRUPT_HARD ) + && (env->msr &MSR_IE ) + && !(env->msr & (MSR_EIP |MSR_BIP )) + && !(env->iflags & (D_FLAG |IMM_FLAG ))) { + cs->exception_index =EXCP_IRQ ; +mb_cpu_do_interrupt (cs); +return true; + } +return false; +}
target/ppc/excp_helper.c +2 -1
@@ -1523,7 +1523,6 @@ void helper_book3s_msgsndp(CPUPPCState *env, target_ulong rb)book3s_msgsnd_common (pir,PPC_INTERRUPT_DOORBELL ); }#endif -#endif void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, MMUAccessType access_type,
@@ -1540,3 +1539,5 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, env->error_code = insn &0x03FF0000 ; cpu_loop_exit(cs); } + +#endif /* !CONFIG_USER_ONLY */
target/sparc/ldst_helper.c +2 -3
@@ -1957,9 +1957,7 @@ void sparc_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,sparc_raise_mmu_fault (cs, physaddr, is_write, is_exec, is_asi, size, retaddr); } -#endif -#if !defined(CONFIG_USER_ONLY ) void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx,
@@ -1974,4 +1972,5 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,#endif cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr); } -#endif + +#endif /* !CONFIG_USER_ONLY */
Signature · 1 line
2.26.3
PATCH v7 4/23 cpu: Remove duplicated 'sysemu/hw_accel.h' header
In reply to Philippe Mathieu-Daudé--- hw/core/cpu.c | 1 - 1 file changed, 1 deletion(-)
hw/core/cpu.c +0 -1
@@ -34,7 +34,6 @@#include "hw/qdev-properties.h" #include "trace/trace-root.h" #include "qemu/plugin.h" -#include "sysemu/hw_accel.h" CPUState *cpu_by_arch_id (int64_t id) {
Signature · 1 line
2.26.3
Re: [PATCH v7 04/23] cpu: Remove duplicated 'sysemu/hw_accel.h' header
Quoted 4 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/core/cpu.c | 1 - 1 file changed, 1 deletion(-)
r~
PATCH v7 5/23 cpu: Split as cpu-common / cpu-sysemu
In reply to Philippe Mathieu-DaudéThe current cpu.c contains sysemu-specific methods. To avoid building them in user-mode builds, split the current cpu.c as cpu-common.c / cpu-sysemu.c.
Start by moving cpu_get_crash_info().
---
hw/core/{cpu.c => cpu-common.c} | 17 -----------------
hw/core/cpu-sysemu.c | 34 +++++++++++++++++++++++++++++++++
hw/core/meson.build | 3 ++-
3 files changed, 36 insertions(+), 18 deletions(-)
rename hw/core/{cpu.c => cpu-common.c} (96%)
create mode 100644 hw/core/cpu-sysemu.chw/core/cpu-common.c renamed from hw/core/cpu.c +0 -17
@@ -190,23 +190,6 @@ static bool cpu_common_virtio_is_big_endian(CPUState *cpu)return target_words_bigendian (); } -/* -* XXX the following #if is always true because this is a common_ss -* module, so target CONFIG_* is never defined. -*/ -#if !defined(CONFIG_USER_ONLY ) -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); - } -return res; -} -#endif -void cpu_dump_state (CPUState *cpu,FILE *f,int flags) {CPUClass *cc =CPU_GET_CLASS (cpu);
hw/core/cpu-sysemu.c new file +34 -0
@@ -0,0 +1,34 @@ +/* +* QEMU CPU model (system emulation specific) +* +* Copyright (c) 2012-2014 SUSE LINUX Products GmbH +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see +* <http://www.gnu.org/licenses/gpl-2.0.html> +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/core/cpu.h" + +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); + } +return res; +}
hw/core/meson.build +2 -1
@@ -13,7 +13,7 @@ 'qdev-clock.c', ) -common_ss.add(files('cpu.c')) +common_ss.add(files('cpu-common.c')) common_ss.add(when: 'CONFIG_FITLOADER', if_true: files('loader-fit.c')) common_ss.add(when: 'CONFIG_GENERIC_LOADER', if_true: files('generic-loader.c')) common_ss.add(when: ['CONFIG_GUEST_LOADER', fdt], if_true: files('guest-loader.c'))
@@ -25,6 +25,7 @@ common_ss.add(when: 'CONFIG_XILINX_AXI', if_true: files('stream.c')) softmmu_ss.add(files( + 'cpu-sysemu.c', 'fw-path-provider.c', 'loader.c', 'machine-hmp-cmds.c',
Signature · 1 line
2.26.3
Re: [PATCH v7 05/23] cpu: Split as cpu-common / cpu-sysemu
Quoted 6 lines · Philippe Mathieu-Daudé
The current
cpu.ccontains sysemu-specific methods. To avoid building them in user-mode builds, split the currentcpu.cascpu-common.c/cpu-sysemu.c.Start by moving
cpu_get_crash_info().
Quoted 8 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/core/{cpu.c => cpu-common.c} | 17 ----------------- hw/core/cpu-sysemu.c | 34 +++++++++++++++++++++++++++++++++ hw/core/meson.build | 3 ++- 3 files changed, 36 insertions(+), 18 deletions(-)rename
hw/core/{cpu.c=>cpu-common.c} (96%)
create mode 100644hw/core/cpu-sysemu.c
r~
PATCH v7 6/23 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-sysemu.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 29 deletions(-)
include/hw/core/cpu.h +4 -29
@@ -586,18 +586,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:
@@ -609,12 +599,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
@@ -623,17 +608,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-sysemu.c +32 -0
@@ -22,6 +22,38 @@#include "qapi/error.h" #include "hw/core/cpu.h" +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; +} +GuestPanicInformation *cpu_get_crash_info (CPUState *cpu) {CPUClass *cc =CPU_GET_CLASS (cpu);
Signature · 1 line
2.26.3
PATCH v7 7/23 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.
Similarly to commit bf7663c4bd8 ("cpu: introduce CPUClass::virtio_is_big_endian()"), we keep 'virtio' in the method name to hint this handler shouldn't be called anywhere but from the virtio code.
--- include/hw/core/cpu.h | 9 +++++++++ hw/core/cpu-common.c | 6 ------ hw/core/cpu-sysemu.c | 10 ++++++++++ hw/virtio/virtio.c | 4 +--- 4 files changed, 20 insertions(+), 9 deletions(-)
include/hw/core/cpu.h +9 -0
@@ -610,6 +610,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-common.c +0 -6
@@ -185,11 +185,6 @@ 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) -{ -return target_words_bigendian (); -} -void cpu_dump_state (CPUState *cpu,FILE *f,int flags) {CPUClass *cc =CPU_GET_CLASS (cpu);
@@ -388,7 +383,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/core/cpu-sysemu.c +10 -0
@@ -54,6 +54,16 @@ int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs)return ret; } +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 (); +} +GuestPanicInformation *cpu_get_crash_info (CPUState *cpu) {CPUClass *cc =CPU_GET_CLASS (cpu);
hw/virtio/virtio.c +1 -3
@@ -1972,9 +1972,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.3
PATCH v7 8/23 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-common.c | 63 -------------------------------------------- hw/core/cpu-sysemu.c | 44 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 63 deletions(-)
hw/core/cpu-common.c +0 -63
@@ -116,65 +116,6 @@ void cpu_exit(CPUState *cpu)qatomic_set (&cpu->icount_decr_ptr->u16.high,-1 ); } -int cpu_write_elf32_qemunote (WriteCoreDumpFunction f,CPUState *cpu, -void *opaque) -{ -CPUClass *cc =CPU_GET_CLASS (cpu); - -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); - -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); - -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); - -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 ;
@@ -377,10 +318,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);
hw/core/cpu-sysemu.c +44 -0
50 lines not on this page · raw message
Signature · 1 line
2.26.3
PATCH v7 9/23 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-common.c | 13 ------------- hw/core/cpu-sysemu.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 13 deletions(-)
hw/core/cpu-common.c +0 -13
@@ -66,18 +66,6 @@ CPUState *cpu_create(const char *typename)return cpu; } -bool cpu_paging_enabled (const CPUState *cpu) -{ -CPUClass *cc =CPU_GET_CLASS (cpu); - -return cc->get_paging_enabled (cpu); -} - -static bool cpu_common_get_paging_enabled (const CPUState *cpu) -{ -return false; -} -void cpu_get_memory_mapping (CPUState *cpu,MemoryMappingList *list,Error **errp) {
@@ -316,7 +304,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;
hw/core/cpu-sysemu.c +11 -0
@@ -22,6 +22,17 @@#include "qapi/error.h" #include "hw/core/cpu.h" +bool cpu_paging_enabled (const CPUState *cpu) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + +if (cc->get_paging_enabled) { +return cc->get_paging_enabled (cpu); + } + +return false; +} +hwaddr cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr,MemTxAttrs *attrs) {
Signature · 1 line
2.26.3
PATCH v7 10/23 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-common.c | 16 ---------------- hw/core/cpu-sysemu.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 16 deletions(-)
hw/core/cpu-common.c +0 -16
@@ -66,21 +66,6 @@ CPUState *cpu_create(const char *typename)return cpu; } -void cpu_get_memory_mapping (CPUState *cpu,MemoryMappingList *list, -Error **errp) -{ -CPUClass *cc =CPU_GET_CLASS (cpu); - - cc->get_memory_mapping (cpu, list, errp); -} - -static void cpu_common_get_memory_mapping (CPUState *cpu, -MemoryMappingList *list, -Error **errp) -{ -error_setg (errp,"Obtaining memory mappings is unsupported on this CPU." ); -} -/* 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)
@@ -304,7 +289,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);
hw/core/cpu-sysemu.c +13 -0
@@ -33,6 +33,19 @@ bool cpu_paging_enabled(const CPUState *cpu)return false; } +void cpu_get_memory_mapping (CPUState *cpu,MemoryMappingList *list, +Error **errp) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + +if (cc->get_memory_mapping) { + cc->get_memory_mapping (cpu, list, errp); +return ; + } + +error_setg (errp,"Obtaining memory mappings is unsupported on this CPU." ); +} +hwaddr cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr,MemTxAttrs *attrs) {
Signature · 1 line
2.26.3
PATCH v7 11/23 cpu: Assert DeviceClass::vmsd is NULL on user emulation
In reply to Philippe Mathieu-DaudéMigration is specific to system emulation.
Restrict current DeviceClass::vmsd to sysemu using #ifdef'ry, and assert in cpu_exec_realizefn() that dc->vmsd not set under user emulation.
---
v7: Check vmsd->unmigratable (David)
--- cpu.c | 2 ++ target/sh4/cpu.c | 5 +++-- target/xtensa/cpu.c | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-)
cpu.c +2 -0
@@ -141,6 +141,8 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)#endif /* CONFIG_TCG */ #ifdef CONFIG_USER_ONLY +assert (qdev_get_vmsd (DEVICE (cpu)) ==NULL || +qdev_get_vmsd (DEVICE (cpu))->unmigratable);assert (cc->vmsd ==NULL );#else if (qdev_get_vmsd (DEVICE (cpu)) ==NULL ) {
target/sh4/cpu.c +3 -2
@@ -218,10 +218,12 @@ 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 , }; +#endif #include "hw/core/tcg-cpu-ops.h"
@@ -257,12 +259,11 @@ 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; + dc->vmsd = &vmstate_sh_cpu;#endif cc->disas_set_info = superh_cpu_disas_set_info; cc->gdb_num_core_regs =59 ; - - dc->vmsd = &vmstate_sh_cpu; cc->tcg_ops = &superh_tcg_ops; }
target/xtensa/cpu.c +3 -1
@@ -176,10 +176,12 @@ static void xtensa_cpu_initfn(Object *obj)#endif } +#ifndef CONFIG_USER_ONLY static const VMStateDescription vmstate_xtensa_cpu = { .name ="cpu" , .unmigratable =1 , }; +#endif #include "hw/core/tcg-cpu-ops.h"
@@ -216,9 +218,9 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_stop_before_watchpoint = true;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug; + dc->vmsd = &vmstate_xtensa_cpu;#endif cc->disas_set_info = xtensa_cpu_disas_set_info; - dc->vmsd = &vmstate_xtensa_cpu; cc->tcg_ops = &xtensa_tcg_ops; }
Signature · 1 line
2.26.3
PATCH v7 12/23 cpu: Rename CPUClass vmsd -> legacy_vmsd
In reply to Philippe Mathieu-DaudéQuoting Peter Maydell [*]:
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.
To avoid new targets to start using type (2), rename cc->vmsd as cc->legacy_vmsd. The correct field to implement is dc->vmsd (the DeviceClass one).
See also commit b170fce3dd0 ("cpu: Register VMStateDescription through CPUState") for historic background.
[*] https://www.mail-archive.com/[email protected]/msg800849.html
--- include/hw/core/cpu.h | 5 +++-- cpu.c | 12 ++++++------ target/arm/cpu.c | 2 +- target/avr/cpu.c | 2 +- target/i386/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/riscv/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- 10 files changed, 17 insertions(+), 16 deletions(-)
include/hw/core/cpu.h +3 -2
@@ -122,7 +122,8 @@ 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. +* @legacy_vmsd: Legacy state description for migration. +* Do not use in new targets, use #DeviceClass::vmsd instead. * @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
@@ -177,7 +178,7 @@ struct CPUClass {int (*write_elf32_qemunote)(WriteCoreDumpFunction f,CPUState *cpu,void *opaque); -const VMStateDescription *vmsd; +const VMStateDescription *legacy_vmsd;const char *gdb_core_xml_file; gchar * (*gdb_arch_name)(CPUState *cpu);const char * (*gdb_get_dynamic_xml)(CPUState *cpu,const char *xmlname);
cpu.c +6 -6
@@ -143,13 +143,13 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)#ifdef CONFIG_USER_ONLY assert (qdev_get_vmsd (DEVICE (cpu)) ==NULL ||qdev_get_vmsd (DEVICE (cpu))->unmigratable); -assert (cc->vmsd ==NULL ); +assert (cc->legacy_vmsd ==NULL );#else if (qdev_get_vmsd (DEVICE (cpu)) ==NULL ) {vmstate_register (NULL , cpu->cpu_index, &vmstate_cpu_common, cpu); } -if (cc->vmsd !=NULL ) { -vmstate_register (NULL , cpu->cpu_index, cc->vmsd, cpu); +if (cc->legacy_vmsd !=NULL ) { +vmstate_register (NULL , cpu->cpu_index, cc->legacy_vmsd, cpu); }#endif /* CONFIG_USER_ONLY */ }
@@ -159,10 +159,10 @@ void cpu_exec_unrealizefn(CPUState *cpu)CPUClass *cc =CPU_GET_CLASS (cpu);#ifdef CONFIG_USER_ONLY -assert (cc->vmsd ==NULL ); +assert (cc->legacy_vmsd ==NULL );#else -if (cc->vmsd !=NULL ) { -vmstate_unregister (NULL , cc->vmsd, cpu); +if (cc->legacy_vmsd !=NULL ) { +vmstate_unregister (NULL , cc->legacy_vmsd, cpu); }if (qdev_get_vmsd (DEVICE (cpu)) ==NULL ) {vmstate_unregister (NULL , &vmstate_cpu_common, cpu);
target/arm/cpu.c +1 -1
@@ -1981,7 +1981,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug; cc->asidx_from_attrs = arm_asidx_from_attrs; - cc->vmsd = &vmstate_arm_cpu; + cc->legacy_vmsd = &vmstate_arm_cpu; cc->virtio_is_big_endian = arm_cpu_virtio_is_big_endian; cc->write_elf64_note = arm_cpu_write_elf64_note; cc->write_elf32_note = arm_cpu_write_elf32_note;
target/avr/cpu.c +1 -1
@@ -213,7 +213,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = avr_cpu_set_pc; cc->memory_rw_debug = avr_cpu_memory_rw_debug; cc->get_phys_page_debug = avr_cpu_get_phys_page_debug; - cc->vmsd = &vms_avr_cpu; + cc->legacy_vmsd = &vms_avr_cpu; cc->disas_set_info = avr_cpu_disas_set_info; cc->gdb_read_register = avr_cpu_gdb_read_register; cc->gdb_write_register = avr_cpu_gdb_write_register;
target/i386/cpu.c +1 -1
@@ -6749,7 +6749,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->write_elf64_qemunote = x86_cpu_write_elf64_qemunote; cc->write_elf32_note = x86_cpu_write_elf32_note; cc->write_elf32_qemunote = x86_cpu_write_elf32_qemunote; - cc->vmsd = &vmstate_x86_cpu; + cc->legacy_vmsd = &vmstate_x86_cpu;#endif /* !CONFIG_USER_ONLY */ cc->gdb_arch_name = x86_gdb_arch_name;
target/mips/cpu.c +1 -1
@@ -561,7 +561,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->gdb_write_register = mips_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = mips_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_mips_cpu; + cc->legacy_vmsd = &vmstate_mips_cpu;#endif cc->disas_set_info = mips_cpu_disas_set_info; cc->gdb_num_core_regs =73 ;
target/riscv/cpu.c +1 -1
@@ -638,7 +638,7 @@ 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; - cc->vmsd = &vmstate_riscv_cpu; + cc->legacy_vmsd = &vmstate_riscv_cpu; cc->write_elf64_note = riscv_cpu_write_elf64_note; cc->write_elf32_note = riscv_cpu_write_elf32_note;#endif
target/s390x/cpu.c +1 -1
@@ -516,7 +516,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = s390_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_s390_cpu; + cc->legacy_vmsd = &vmstate_s390_cpu; cc->get_crash_info = s390_cpu_get_crash_info; cc->write_elf64_note = s390_cpu_write_elf64_note;#endif
target/sparc/cpu.c +1 -1
@@ -889,7 +889,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = sparc_cpu_gdb_write_register;#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = sparc_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_sparc_cpu; + cc->legacy_vmsd = &vmstate_sparc_cpu;#endif cc->disas_set_info = cpu_sparc_disas_set_info;
target/ppc/translate_init.c.inc +1 -1
@@ -10279,7 +10279,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = ppc_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; - cc->vmsd = &vmstate_ppc_cpu; + cc->legacy_vmsd = &vmstate_ppc_cpu; #endif #if defined(CONFIG_SOFTMMU) cc->write_elf64_note = ppc64_cpu_write_elf64_note;
Signature · 1 line
2.26.3
PATCH v7 13/23 cpu: Move AVR target vmsd field from CPUClass to DeviceClass
In reply to Philippe Mathieu-DaudéSee rationale in previous commit. Targets should use the vmsd field of DeviceClass, not CPUClass. As migration is not important on the AVR target, break the migration compatibility and set the DeviceClass vmsd field. To feel safer, increment the vmstate version.
---
v7: Increment vmstate version (Richard)
--- target/avr/cpu.c | 2 +- target/avr/machine.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
target/avr/cpu.c +1 -1
@@ -213,7 +213,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = avr_cpu_set_pc; cc->memory_rw_debug = avr_cpu_memory_rw_debug; cc->get_phys_page_debug = avr_cpu_get_phys_page_debug; - cc->legacy_vmsd = &vms_avr_cpu; + dc->vmsd = &vms_avr_cpu; cc->disas_set_info = avr_cpu_disas_set_info; cc->gdb_read_register = avr_cpu_gdb_read_register; cc->gdb_write_register = avr_cpu_gdb_write_register;
target/avr/machine.c +2 -2
@@ -98,8 +98,8 @@ static const VMStateInfo vms_eind = {const VMStateDescription vms_avr_cpu = { .name ="cpu" , - .version_id =0 , - .minimum_version_id =0 , + .version_id =1 , + .minimum_version_id =1 , .fields = (VMStateField []) {VMSTATE_UINT32 (env.pc_w,AVRCPU ),VMSTATE_UINT32 (env.sp,AVRCPU ),
Signature · 1 line
2.26.3
Re: [PATCH v7 13/23] cpu: Move AVR target vmsd field from CPUClass to DeviceClass
Quoted 5 lines · Philippe Mathieu-Daudé
See rationale in previous commit. Targets should use the vmsd field of DeviceClass, not CPUClass. As migration is not important on the AVR target, break the migration compatibility and set the DeviceClass vmsd field. To feel safer, increment the vmstate version.
Quoted 7 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>---
v7: Increment vmstate version (Richard)--- target/avr/cpu.c | 2 +- target/avr/machine.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
r~
PATCH v7 14/23 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/m68k/cpu.c | 6 ++++++ target/microblaze/cpu.c | 6 ++++++ target/mips/cpu.c | 6 ++++++ 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 | 4 ++++ target/sparc/cpu.c | 6 ++++++ target/tricore/cpu.c | 4 ++++ target/xtensa/cpu.c | 4 ++++ target/ppc/translate_init.c.inc | 6 ++++++ 21 files changed, 134 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
@@ -191,6 +193,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 const 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; dc->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
@@ -1942,6 +1942,11 @@ static gchar *arm_gdb_arch_name(CPUState *cs)return g_strdup ("arm" ); } +#ifndef CONFIG_USER_ONLY +static const struct SysemuCPUOps arm_sysemu_ops = { +}; +#endif +#ifdef CONFIG_TCG static struct TCGCPUOps arm_tcg_ops = { .initialize = arm_translate_init,
@@ -1985,6 +1990,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 const 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; dc->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 const 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; dc->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 const 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; dc->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
@@ -6714,6 +6714,11 @@ static Property x86_cpu_properties[] = { DEFINE_PROP_END_OF_LIST() }; +#ifndef CONFIG_USER_ONLY +static const struct SysemuCPUOps i386_sysemu_ops = { +}; +#endif +static void x86_cpu_common_class_init (ObjectClass *oc,void *data) {X86CPUClass *xcc =X86_CPU_CLASS (oc);
@@ -6750,6 +6755,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->legacy_vmsd = &vmstate_x86_cpu; + cc->sysemu_ops = &i386_sysemu_ops;#endif /* !CONFIG_USER_ONLY */ cc->gdb_arch_name = x86_gdb_arch_name;
target/m68k/cpu.c +6 -0
@@ -503,6 +503,11 @@ static const VMStateDescription vmstate_m68k_cpu = { };#endif +#ifndef CONFIG_USER_ONLY +static const struct SysemuCPUOps m68k_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps m68k_tcg_ops = {
@@ -535,6 +540,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; dc->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 const 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; dc->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
@@ -521,6 +521,11 @@ static Property mips_cpu_properties[] = { DEFINE_PROP_END_OF_LIST() }; +#ifndef CONFIG_USER_ONLY +static const struct SysemuCPUOps mips_sysemu_ops = { +}; +#endif +#ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h" /*
@@ -562,6 +567,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->legacy_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/nios2/cpu.c +6 -0
@@ -207,6 +207,11 @@ static Property nios2_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +#ifndef CONFIG_USER_ONLY +static const 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 const 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; dc->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
@@ -596,6 +596,11 @@ static const char *riscv_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname)return NULL ; } +#ifndef CONFIG_USER_ONLY +static const struct SysemuCPUOps riscv_sysemu_ops = { +}; +#endif +#include "hw/core/tcg-cpu-ops.h" static struct TCGCPUOps riscv_tcg_ops = {
@@ -639,6 +644,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = riscv_cpu_get_phys_page_debug; cc->legacy_vmsd = &vmstate_riscv_cpu; + cc->sysemu_ops = &riscv_sysemu_ops; cc->write_elf64_note = riscv_cpu_write_elf64_note; cc->write_elf32_note = riscv_cpu_write_elf32_note;#endif
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 const 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
@@ -476,6 +476,11 @@ static void s390_cpu_reset_full(DeviceState *dev)return s390_cpu_reset (s,S390_CPU_RESET_CLEAR ); } +#ifndef CONFIG_USER_ONLY +static const struct SysemuCPUOps s390_sysemu_ops = { +}; +#endif +#ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h"
@@ -519,6 +524,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->legacy_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 +4 -0
@@ -223,6 +223,9 @@ static const VMStateDescription vmstate_sh_cpu = { .name = "cpu", .unmigratable = 1, }; + +static const struct SysemuCPUOps sh4_sysemu_ops = { +};#endif #include "hw/core/tcg-cpu-ops.h"
@@ -259,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; dc->vmsd = &vmstate_sh_cpu;#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 const 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->legacy_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 const 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/xtensa/cpu.c +4 -0
@@ -181,6 +181,9 @@ static const VMStateDescription vmstate_xtensa_cpu = { .name = "cpu", .unmigratable = 1, }; + +static const struct SysemuCPUOps xtensa_sysemu_ops = { +};#endif #include "hw/core/tcg-cpu-ops.h"
@@ -217,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; dc->vmsd = &vmstate_xtensa_cpu;#endif
target/ppc/translate_init.c.inc +6 -0
@@ -10237,6 +10237,11 @@ static Property ppc_cpu_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +#ifndef CONFIG_USER_ONLY +static const struct SysemuCPUOps ppc_sysemu_ops = { +}; +#endif + #ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h"
@@ -10280,6 +10285,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->legacy_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.3
PATCH v7 15/23 cpu: Move CPUClass::vmsd to SysemuCPUOps
In reply to Philippe Mathieu-DaudéMigration is specific to system emulation.
- Move the CPUClass::vmsd field to SysemuCPUOps,
- restrict VMSTATE_CPU() macro to sysemu,
- vmstate_dummy is now unused, remove it.
--- include/hw/core/cpu.h | 8 ++------ include/hw/core/sysemu-cpu-ops.h | 6 ++++++ include/migration/vmstate.h | 2 -- cpu.c | 15 +++++++-------- stubs/vmstate.c | 2 -- target/arm/cpu.c | 2 +- target/i386/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/riscv/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- 12 files changed, 22 insertions(+), 25 deletions(-)
include/hw/core/cpu.h +2 -6
@@ -124,8 +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. -* @legacy_vmsd: Legacy state description for migration. -* Do not use in new targets, use #DeviceClass::vmsd instead. * @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
@@ -180,7 +178,6 @@ struct CPUClass {int (*write_elf32_qemunote)(WriteCoreDumpFunction f,CPUState *cpu,void *opaque); -const VMStateDescription *legacy_vmsd;const char *gdb_core_xml_file; gchar * (*gdb_arch_name)(CPUState *cpu);const char * (*gdb_get_dynamic_xml)(CPUState *cpu,const char *xmlname);
@@ -1064,10 +1061,8 @@ bool target_words_bigendian(void);#ifdef NEED_CPU_H #ifdef CONFIG_SOFTMMU +extern const VMStateDescription vmstate_cpu_common; -#else -#define vmstate_cpu_common vmstate_dummy -#endif #define VMSTATE_CPU () { \ .name = "parent_obj", \
@@ -1076,6 +1071,7 @@ extern const VMStateDescription vmstate_cpu_common; .flags = VMS_STRUCT, \ .offset = 0, \ } +#endif /* CONFIG_SOFTMMU */ #endif /* NEED_CPU_H */
include/hw/core/sysemu-cpu-ops.h +6 -0
@@ -16,6 +16,12 @@* struct SysemuCPUOps: System operations specific to a CPU class */ typedef struct SysemuCPUOps { +/** +* @legacy_vmsd: Legacy state for migration. +* Do not use in new targets, use #DeviceClass::vmsd instead. +*/ +const VMStateDescription *legacy_vmsd; + }SysemuCPUOps ;#endif /* SYSEMU_CPU_OPS_H */
include/migration/vmstate.h +0 -2
@@ -194,8 +194,6 @@ struct VMStateDescription {const VMStateDescription **subsections; }; -extern const VMStateDescription vmstate_dummy; -extern const VMStateInfo vmstate_info_bool;extern const VMStateInfo vmstate_info_int8;
cpu.c +7 -8
@@ -127,7 +127,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);if (!accel_cpu_realizefn (cpu, errp)) {
@@ -143,26 +145,23 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)#ifdef CONFIG_USER_ONLY assert (qdev_get_vmsd (DEVICE (cpu)) ==NULL ||qdev_get_vmsd (DEVICE (cpu))->unmigratable); -assert (cc->legacy_vmsd ==NULL );#else if (qdev_get_vmsd (DEVICE (cpu)) ==NULL ) {vmstate_register (NULL , cpu->cpu_index, &vmstate_cpu_common, cpu); } -if (cc->legacy_vmsd !=NULL ) { -vmstate_register (NULL , cpu->cpu_index, cc->legacy_vmsd, cpu); +if (cc->sysemu_ops->legacy_vmsd !=NULL ) { +vmstate_register (NULL , cpu->cpu_index, cc->sysemu_ops->legacy_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->legacy_vmsd ==NULL ); -#else -if (cc->legacy_vmsd !=NULL ) { -vmstate_unregister (NULL , cc->legacy_vmsd, cpu); +if (cc->sysemu_ops->legacy_vmsd !=NULL ) { +vmstate_unregister (NULL , cc->sysemu_ops->legacy_vmsd, cpu); }if (qdev_get_vmsd (DEVICE (cpu)) ==NULL ) {vmstate_unregister (NULL , &vmstate_cpu_common, cpu);
stubs/vmstate.c +0 -2
@@ -1,8 +1,6 @@#include "qemu/osdep.h" #include "migration/vmstate.h" -const VMStateDescription vmstate_dummy = {}; - int vmstate_register_with_alias_id(VMStateIf *obj, uint32_t instance_id, const VMStateDescription *vmsd,
target/arm/cpu.c +1 -1
@@ -1944,6 +1944,7 @@ static gchar *arm_gdb_arch_name(CPUState *cs)#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps arm_sysemu_ops = { + .legacy_vmsd = &vmstate_arm_cpu, };#endif
@@ -1986,7 +1987,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->legacy_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/i386/cpu.c +1 -1
@@ -6716,6 +6716,7 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps i386_sysemu_ops = { + .legacy_vmsd = &vmstate_x86_cpu, };#endif
@@ -6754,7 +6755,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->legacy_vmsd = &vmstate_x86_cpu; cc->sysemu_ops = &i386_sysemu_ops;#endif /* !CONFIG_USER_ONLY */
target/mips/cpu.c +1 -1
@@ -523,6 +523,7 @@ static Property mips_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps mips_sysemu_ops = { + .legacy_vmsd = &vmstate_mips_cpu, };#endif
@@ -566,7 +567,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->legacy_vmsd = &vmstate_mips_cpu; cc->sysemu_ops = &mips_sysemu_ops;#endif cc->disas_set_info = mips_cpu_disas_set_info;
target/riscv/cpu.c +1 -1
@@ -598,6 +598,7 @@ static const char *riscv_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname)#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps riscv_sysemu_ops = { + .legacy_vmsd = &vmstate_riscv_cpu, };#endif
@@ -643,7 +644,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; - cc->legacy_vmsd = &vmstate_riscv_cpu; cc->sysemu_ops = &riscv_sysemu_ops; cc->write_elf64_note = riscv_cpu_write_elf64_note; cc->write_elf32_note = riscv_cpu_write_elf32_note;
target/s390x/cpu.c +1 -1
@@ -478,6 +478,7 @@ static void s390_cpu_reset_full(DeviceState *dev)#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps s390_sysemu_ops = { + .legacy_vmsd = &vmstate_s390_cpu, };#endif
@@ -521,7 +522,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->legacy_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/sparc/cpu.c +1 -1
@@ -850,6 +850,7 @@ static Property sparc_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps sparc_sysemu_ops = { + .legacy_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->legacy_vmsd = &vmstate_sparc_cpu; cc->sysemu_ops = &sparc_sysemu_ops;#endif cc->disas_set_info = cpu_sparc_disas_set_info;
target/ppc/translate_init.c.inc +1 -1
@@ -10239,6 +10239,7 @@ static Property ppc_cpu_properties[] = { #ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps ppc_sysemu_ops = { + .legacy_vmsd = &vmstate_ppc_cpu, }; #endif
@@ -10284,7 +10285,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->legacy_vmsd = &vmstate_ppc_cpu; cc->sysemu_ops = &ppc_sysemu_ops; #endif #if defined(CONFIG_SOFTMMU)
Signature · 1 line
2.26.3
PATCH v7 16/23 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 | 9 +++++++++ hw/core/cpu-sysemu.c | 5 +++-- target/arm/cpu.c | 2 +- target/ppc/translate_init.c.inc | 4 +--- 5 files changed, 14 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 +9 -0
@@ -16,6 +16,15 @@* 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); + /** * @legacy_vmsd: Legacy state for migration. * Do not use in new targets, use #DeviceClass::vmsd instead.
hw/core/cpu-sysemu.c +3 -2
@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/core/cpu.h" +#include "hw/core/sysemu-cpu-ops.h" bool cpu_paging_enabled (const CPUState *cpu) {
@@ -126,8 +127,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
@@ -1944,6 +1944,7 @@ static gchar *arm_gdb_arch_name(CPUState *cs)#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps arm_sysemu_ops = { + .virtio_is_big_endian = arm_cpu_virtio_is_big_endian, .legacy_vmsd = &vmstate_arm_cpu, };#endif
@@ -1987,7 +1988,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
@@ -10239,6 +10239,7 @@ static Property ppc_cpu_properties[] = { #ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps ppc_sysemu_ops = { + .virtio_is_big_endian = ppc_cpu_is_big_endian, .legacy_vmsd = &vmstate_ppc_cpu, }; #endif
@@ -10307,9 +10308,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.3
PATCH v7 17/23 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-sysemu.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-sysemu.c +2 -2
@@ -138,8 +138,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
@@ -6716,6 +6716,7 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps i386_sysemu_ops = { + .get_crash_info = x86_cpu_get_crash_info, .legacy_vmsd = &vmstate_x86_cpu, };#endif
@@ -6750,7 +6751,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
@@ -478,6 +478,7 @@ static void s390_cpu_reset_full(DeviceState *dev)#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps s390_sysemu_ops = { + .get_crash_info = s390_cpu_get_crash_info, .legacy_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->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.3
PATCH v7 18/23 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-sysemu.c | 16 ++++++++-------- target/arm/cpu.c | 4 ++-- target/i386/cpu.c | 8 ++++---- target/riscv/cpu.c | 4 ++-- target/s390x/cpu.c | 2 +- target/ppc/translate_init.c.inc | 6 ++---- 8 files changed, 43 insertions(+), 38 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-sysemu.c +8 -8
@@ -84,10 +84,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,
@@ -95,10 +95,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,
@@ -106,10 +106,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,
@@ -117,10 +117,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); }bool cpu_virtio_is_big_endian (CPUState *cpu)
target/arm/cpu.c +2 -2
@@ -1944,6 +1944,8 @@ static gchar *arm_gdb_arch_name(CPUState *cs)#ifndef CONFIG_USER_ONLY static const 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, .legacy_vmsd = &vmstate_arm_cpu, };
@@ -1988,8 +1990,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
@@ -6717,6 +6717,10 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static const 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, .legacy_vmsd = &vmstate_x86_cpu, };#endif
@@ -6751,10 +6755,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/riscv/cpu.c +2 -2
@@ -598,6 +598,8 @@ static const char *riscv_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname)#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps riscv_sysemu_ops = { + .write_elf64_note = riscv_cpu_write_elf64_note, + .write_elf32_note = riscv_cpu_write_elf32_note, .legacy_vmsd = &vmstate_riscv_cpu, };#endif
@@ -645,8 +647,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = riscv_cpu_get_phys_page_debug; cc->sysemu_ops = &riscv_sysemu_ops; - cc->write_elf64_note = riscv_cpu_write_elf64_note; - cc->write_elf32_note = riscv_cpu_write_elf32_note;#endif cc->gdb_arch_name = riscv_gdb_arch_name; cc->gdb_get_dynamic_xml = riscv_gdb_get_dynamic_xml;
target/s390x/cpu.c +1 -1
@@ -479,6 +479,7 @@ static void s390_cpu_reset_full(DeviceState *dev)#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps s390_sysemu_ops = { .get_crash_info = s390_cpu_get_crash_info, + .write_elf64_note = s390_cpu_write_elf64_note, .legacy_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->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
@@ -10239,6 +10239,8 @@ static Property ppc_cpu_properties[] = { #ifndef CONFIG_USER_ONLY static const 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, .legacy_vmsd = &vmstate_ppc_cpu, };
@@ -10288,10 +10290,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.3
PATCH v7 19/23 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-sysemu.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-sysemu.c +2 -2
@@ -72,8 +72,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
@@ -1944,6 +1944,7 @@ static gchar *arm_gdb_arch_name(CPUState *cs)#ifndef CONFIG_USER_ONLY static const 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,
@@ -1989,7 +1990,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
@@ -6716,6 +6716,7 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static const 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,
@@ -6752,7 +6753,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.3
PATCH v7 20/23 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 +++++++++++++ target/alpha/cpu.h | 2 +- target/arm/cpu.h | 6 +++--- target/cris/cpu.h | 4 ++-- target/hppa/cpu.h | 2 +- target/i386/cpu.h | 6 +++--- target/m68k/cpu.h | 5 ++++- target/microblaze/cpu.h | 5 ++--- target/nios2/cpu.h | 2 +- target/openrisc/cpu.h | 3 ++- target/ppc/cpu.h | 2 +- target/riscv/cpu.h | 2 +- target/rx/cpu.h | 2 ++ target/sh4/cpu.h | 2 +- target/sparc/cpu.h | 2 +- target/tricore/cpu.h | 2 ++ target/xtensa/cpu.h | 2 +- hw/core/cpu-sysemu.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/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- target/ppc/translate_init.c.inc | 2 +- 38 files changed, 63 insertions(+), 51 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.
target/alpha/cpu.h +1 -1
@@ -275,6 +275,7 @@ struct AlphaCPU {#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_alpha_cpu; +hwaddr alpha_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);void alpha_cpu_do_unaligned_access (CPUState *cpu,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr);
@@ -283,7 +284,6 @@ void alpha_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,void alpha_cpu_do_interrupt (CPUState *cpu);bool alpha_cpu_exec_interrupt (CPUState *cpu,int int_req);void alpha_cpu_dump_state (CPUState *cs,FILE *f,int flags); -hwaddr alpha_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int alpha_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int alpha_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/arm/cpu.h +3 -3
@@ -1026,15 +1026,15 @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz);#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_arm_cpu; + +hwaddr arm_cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr, +MemTxAttrs *attrs);#endif void arm_cpu_do_interrupt (CPUState *cpu);void arm_v7m_cpu_do_interrupt (CPUState *cpu);bool arm_cpu_exec_interrupt (CPUState *cpu,int int_req); -hwaddr arm_cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr, -MemTxAttrs *attrs); -int arm_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int arm_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/cris/cpu.h +2 -2
@@ -185,6 +185,8 @@ struct CRISCPU {#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_cris_cpu; + +hwaddr cris_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#endif void cris_cpu_do_interrupt (CPUState *cpu);
@@ -193,8 +195,6 @@ bool cris_cpu_exec_interrupt(CPUState *cpu, int int_req);void cris_cpu_dump_state (CPUState *cs,FILE *f,int flags); -hwaddr cris_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); -int crisv10_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int cris_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int cris_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/hppa/cpu.h +1 -1
@@ -322,7 +322,6 @@ void cpu_hppa_change_prot_id(CPUHPPAState *env);#define cpu_signal_handler cpu_hppa_signal_handlerint cpu_hppa_signal_handler (int host_signum,void *pinfo,void *puc); -hwaddr hppa_cpu_get_phys_page_debug (CPUState *cs,vaddr addr);int hppa_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int hppa_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);void hppa_cpu_do_interrupt (CPUState *cpu);
@@ -332,6 +331,7 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr);#ifndef CONFIG_USER_ONLY +hwaddr hppa_cpu_get_phys_page_debug (CPUState *cs,vaddr addr);int hppa_get_physical_address (CPUHPPAState *env,vaddr addr,int mmu_idx,int type,hwaddr *pphys,int *pprot);extern const MemoryRegionOps hppa_io_eir_ops;
target/i386/cpu.h +3 -3
@@ -1800,6 +1800,9 @@ struct X86CPU {#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_x86_cpu; + +hwaddr x86_cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr, +MemTxAttrs *attrs);#endif int x86_cpu_pending_interrupt (CPUState *cs,int interrupt_request);
@@ -1818,9 +1821,6 @@ void x86_cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,void x86_cpu_dump_state (CPUState *cs,FILE *f,int flags); -hwaddr x86_cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr, -MemTxAttrs *attrs); -int x86_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int x86_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/m68k/cpu.h +4 -1
@@ -169,10 +169,13 @@ struct M68kCPU {void m68k_cpu_do_interrupt (CPUState *cpu);bool m68k_cpu_exec_interrupt (CPUState *cpu,int int_req);void m68k_cpu_dump_state (CPUState *cpu,FILE *f,int flags); -hwaddr m68k_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int m68k_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int m68k_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); +#if !defined(CONFIG_USER_ONLY ) +hwaddr m68k_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); +#endif +void m68k_tcg_init (void );void m68k_cpu_init_gdb (M68kCPU *cpu);/*
target/microblaze/cpu.h +2 -3
@@ -358,8 +358,6 @@ struct MicroBlazeCPU {void mb_cpu_do_interrupt (CPUState *cs);bool mb_cpu_exec_interrupt (CPUState *cs,int int_req);void mb_cpu_dump_state (CPUState *cpu,FILE *f,int flags); -hwaddr mb_cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr, -MemTxAttrs *attrs);int mb_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int mb_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
@@ -417,7 +415,8 @@ static inline void cpu_get_tb_cpu_state(CPUMBState *env, target_ulong *pc, }#if !defined(CONFIG_USER_ONLY ) - +hwaddr mb_cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr, +MemTxAttrs *attrs);void mb_cpu_do_unaligned_access (CPUState *cs,vaddr vaddr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr);
target/nios2/cpu.h +1 -1
@@ -196,8 +196,8 @@ void nios2_cpu_do_interrupt(CPUState *cs);int cpu_nios2_signal_handler (int host_signum,void *pinfo,void *puc);void dump_mmu (CPUNios2State *env);void nios2_cpu_dump_state (CPUState *cpu,FILE *f,int flags); -hwaddr nios2_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#ifndef CONFIG_USER_ONLY +hwaddr nios2_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);void nios2_cpu_do_unaligned_access (CPUState *cpu,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr);
target/openrisc/cpu.h +2 -1
@@ -315,7 +315,6 @@ void cpu_openrisc_list(void);void openrisc_cpu_do_interrupt (CPUState *cpu);bool openrisc_cpu_exec_interrupt (CPUState *cpu,int int_req);void openrisc_cpu_dump_state (CPUState *cpu,FILE *f,int flags); -hwaddr openrisc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int openrisc_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int openrisc_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);void openrisc_translate_init (void );
@@ -331,6 +330,8 @@ int print_insn_or1k(bfd_vma addr, disassemble_info *info);#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_openrisc_cpu; +hwaddr openrisc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); +/* hw/openrisc_pic.c */ void cpu_openrisc_pic_init (OpenRISCCPU *cpu);
target/ppc/cpu.h +1 -1
@@ -1261,7 +1261,6 @@ void ppc_cpu_do_interrupt(CPUState *cpu);bool ppc_cpu_exec_interrupt (CPUState *cpu,int int_req);void ppc_cpu_dump_state (CPUState *cpu,FILE *f,int flags);void ppc_cpu_dump_statistics (CPUState *cpu,int flags); -hwaddr ppc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int ppc_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int ppc_cpu_gdb_read_register_apple (CPUState *cpu,GByteArray *buf,int reg);int ppc_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
@@ -1275,6 +1274,7 @@ int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,int ppc32_cpu_write_elf32_note (WriteCoreDumpFunction f,CPUState *cs,int cpuid,void *opaque);#ifndef CONFIG_USER_ONLY +hwaddr ppc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);void ppc_cpu_do_system_reset (CPUState *cs);void ppc_cpu_do_fwnmi_machine_check (CPUState *cs,target_ulong vector);extern const VMStateDescription vmstate_ppc_cpu;
target/riscv/cpu.h +1 -1
@@ -339,7 +339,6 @@ bool riscv_cpu_force_hs_excep_enabled(CPURISCVState *env);void riscv_cpu_set_force_hs_excep (CPURISCVState *env,bool enable);bool riscv_cpu_two_stage_lookup (int mmu_idx);int riscv_cpu_mmu_index (CPURISCVState *env,bool ifetch); -hwaddr riscv_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);bool riscv_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr);
@@ -351,6 +350,7 @@ void riscv_cpu_list(void);#define cpu_mmu_index riscv_cpu_mmu_index#ifndef CONFIG_USER_ONLY +hwaddr riscv_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);void riscv_cpu_do_unaligned_access (CPUState *cs,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr);
target/rx/cpu.h +2 -0
@@ -129,7 +129,9 @@ bool rx_cpu_exec_interrupt(CPUState *cpu, int int_req);void rx_cpu_dump_state (CPUState *cpu,FILE *f,int flags);int rx_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int rx_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); +#ifndef CONFIG_USER_ONLY hwaddr rx_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); +#endif void rx_translate_init (void ); int cpu_rx_signal_handler(int host_signum, void *pinfo,
target/sh4/cpu.h +1 -1
@@ -207,7 +207,6 @@ struct SuperHCPU {void superh_cpu_do_interrupt (CPUState *cpu);bool superh_cpu_exec_interrupt (CPUState *cpu,int int_req);void superh_cpu_dump_state (CPUState *cpu,FILE *f,int flags); -hwaddr superh_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int superh_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int superh_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
@@ -237,6 +236,7 @@ uint32_t cpu_sh4_read_mmaped_utlb_data(CPUSH4State *s, hwaddr addr);void cpu_sh4_write_mmaped_utlb_data (CPUSH4State *s,hwaddr addr,uint32_t mem_value); +hwaddr superh_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);void superh_cpu_do_unaligned_access (CPUState *cpu,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr);
target/sparc/cpu.h +1 -1
@@ -569,6 +569,7 @@ struct SPARCCPU {#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_sparc_cpu; +hwaddr sparc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx,
@@ -577,7 +578,6 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,void sparc_cpu_do_interrupt (CPUState *cpu);void sparc_cpu_dump_state (CPUState *cpu,FILE *f,int flags); -hwaddr sparc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int sparc_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int sparc_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); void cpu_raise_exception_ra(CPUSPARCState *, int, uintptr_t) QEMU_NORETURN;
target/tricore/cpu.h +2 -0
@@ -207,7 +207,9 @@ struct TriCoreCPU { }; +#ifndef CONFIG_USER_ONLY hwaddr tricore_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); +#endif void tricore_cpu_dump_state (CPUState *cpu,FILE *f,int flags);
target/xtensa/cpu.h +1 -1
@@ -570,7 +570,6 @@ bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,void xtensa_cpu_do_interrupt (CPUState *cpu);bool xtensa_cpu_exec_interrupt (CPUState *cpu,int interrupt_request);void xtensa_cpu_dump_state (CPUState *cpu,FILE *f,int flags); -hwaddr xtensa_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);void xtensa_count_regs (const XtensaConfig *config,unsigned *n_regs,unsigned *n_core_regs);int xtensa_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);
@@ -668,6 +667,7 @@ static inline int xtensa_get_cring(const CPUXtensaState *env) }#ifndef CONFIG_USER_ONLY +hwaddr xtensa_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);void xtensa_cpu_do_unaligned_access (CPUState *cpu,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr);
hw/core/cpu-sysemu.c +3 -3
@@ -52,12 +52,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 const struct SysemuCPUOps alpha_sysemu_ops = { + .get_phys_page_debug = alpha_cpu_get_phys_page_debug, };#endif
@@ -241,7 +242,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; dc->vmsd = &vmstate_alpha_cpu; cc->sysemu_ops = &alpha_sysemu_ops;#endif
target/arm/cpu.c +1 -1
@@ -1944,6 +1944,7 @@ static gchar *arm_gdb_arch_name(CPUState *cs)#ifndef CONFIG_USER_ONLY static const 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,
@@ -1989,7 +1990,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 const struct SysemuCPUOps avr_sysemu_ops = { + .get_phys_page_debug = avr_cpu_get_phys_page_debug, };#include "hw/core/tcg-cpu-ops.h"
@@ -215,7 +216,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; dc->vmsd = &vms_avr_cpu; cc->sysemu_ops = &avr_sysemu_ops; cc->disas_set_info = avr_cpu_disas_set_info;
target/cris/cpu.c +1 -1
@@ -195,6 +195,7 @@ static void cris_cpu_initfn(Object *obj)#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps cris_sysemu_ops = { + .get_phys_page_debug = cris_cpu_get_phys_page_debug, };#endif
@@ -297,7 +298,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; dc->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 const struct SysemuCPUOps hppa_sysemu_ops = { + .get_phys_page_debug = hppa_cpu_get_phys_page_debug, };#endif
@@ -166,7 +167,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; dc->vmsd = &vmstate_hppa_cpu; cc->sysemu_ops = &hppa_sysemu_ops;#endif
target/i386/cpu.c +1 -1
@@ -6716,6 +6716,7 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static const 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,
@@ -6754,7 +6755,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/m68k/cpu.c +1 -1
@@ -505,6 +505,7 @@ static const VMStateDescription vmstate_m68k_cpu = {#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps m68k_sysemu_ops = { + .get_phys_page_debug = m68k_cpu_get_phys_page_debug, };#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; dc->vmsd = &vmstate_m68k_cpu; cc->sysemu_ops = &m68k_sysemu_ops;#endif
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 const struct SysemuCPUOps mb_sysemu_ops = { + .get_phys_page_attrs_debug = mb_cpu_get_phys_page_attrs_debug, };#endif
@@ -391,7 +392,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; dc->vmsd = &vmstate_mb_cpu; cc->sysemu_ops = &mb_sysemu_ops;#endif
target/mips/cpu.c +1 -1
@@ -523,6 +523,7 @@ static Property mips_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps mips_sysemu_ops = { + .get_phys_page_debug = mips_cpu_get_phys_page_debug, .legacy_vmsd = &vmstate_mips_cpu, };#endif
@@ -566,7 +567,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/nios2/cpu.c +1 -1
@@ -209,6 +209,7 @@ static Property nios2_properties[] = {#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps nios2_sysemu_ops = { + .get_phys_page_debug = nios2_cpu_get_phys_page_debug, };#endif
@@ -242,7 +243,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 const struct SysemuCPUOps openrisc_sysemu_ops = { + .get_phys_page_debug = openrisc_cpu_get_phys_page_debug, };#endif
@@ -208,7 +209,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; dc->vmsd = &vmstate_openrisc_cpu; cc->sysemu_ops = &openrisc_sysemu_ops;#endif
target/riscv/cpu.c +1 -1
@@ -598,6 +598,7 @@ static const char *riscv_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname)#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps riscv_sysemu_ops = { + .get_phys_page_debug = riscv_cpu_get_phys_page_debug, .write_elf64_note = riscv_cpu_write_elf64_note, .write_elf32_note = riscv_cpu_write_elf32_note, .legacy_vmsd = &vmstate_riscv_cpu,
@@ -645,7 +646,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
@@ -175,6 +175,7 @@ static void rx_cpu_init(Object *obj)#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps rx_sysemu_ops = { + .get_phys_page_debug = rx_cpu_get_phys_page_debug, };#endif
@@ -212,7 +213,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
@@ -478,6 +478,7 @@ static void s390_cpu_reset_full(DeviceState *dev)#ifndef CONFIG_USER_ONLY static const 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, .legacy_vmsd = &vmstate_s390_cpu,
@@ -523,7 +524,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 const struct SysemuCPUOps sh4_sysemu_ops = { + .get_phys_page_debug = superh_cpu_get_phys_page_debug, };#endif
@@ -261,7 +262,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; dc->vmsd = &vmstate_sh_cpu;#endif
target/sparc/cpu.c +1 -1
@@ -850,6 +850,7 @@ static Property sparc_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static const struct SysemuCPUOps sparc_sysemu_ops = { + .get_phys_page_debug = sparc_cpu_get_phys_page_debug, .legacy_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
@@ -143,6 +143,7 @@ static void tc27x_initfn(Object *obj) }static const struct SysemuCPUOps tricore_sysemu_ops = { + .get_phys_page_debug = tricore_cpu_get_phys_page_debug, };#include "hw/core/tcg-cpu-ops.h"
@@ -173,7 +174,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/xtensa/cpu.c +1 -1
@@ -183,6 +183,7 @@ static const VMStateDescription vmstate_xtensa_cpu = { };static const struct SysemuCPUOps xtensa_sysemu_ops = { + .get_phys_page_debug = xtensa_cpu_get_phys_page_debug, };#endif
@@ -221,7 +222,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; dc->vmsd = &vmstate_xtensa_cpu;#endif cc->disas_set_info = xtensa_cpu_disas_set_info;
target/ppc/translate_init.c.inc +1 -1
@@ -10239,6 +10239,7 @@ static Property ppc_cpu_properties[] = { #ifndef CONFIG_USER_ONLY static const 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,
@@ -10287,7 +10288,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.3
PATCH v7 21/23 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-sysemu.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-sysemu.c +2 -2
@@ -39,8 +39,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
@@ -6716,6 +6716,7 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static const 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,
@@ -6754,7 +6755,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.3
PATCH v7 22/23 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-sysemu.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-sysemu.c +2 -2
@@ -27,8 +27,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
@@ -6485,12 +6485,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) {
@@ -6717,6 +6719,7 @@ static Property x86_cpu_properties[] = {#ifndef CONFIG_USER_ONLY static const 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,
@@ -6752,7 +6755,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.3
PATCH v7 23/23 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/m68k/cpu.h | 3 +++ target/microblaze/cpu.h | 1 + target/mips/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 | 3 +++ target/s390x/cpu.h | 3 +++ target/sh4/cpu.h | 3 +++ target/sparc/cpu.h | 3 +++ target/tricore/cpu.h | 3 +++ target/xtensa/cpu.h | 3 +++ cpu.c | 1 + 22 files changed, 57 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
@@ -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 /* 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/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/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 +3 -0
@@ -25,6 +25,9 @@#include "cpu-qom.h" #include "exec/cpu-defs.h" +#ifndef CONFIG_USER_ONLY +#include "hw/core/sysemu-cpu-ops.h" +#endif /* 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/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/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"
Signature · 1 line
2.26.3
Quoted 1 line · Philippe Mathieu-Daudé
Missing review: 2-5 (new) and 13
Ping for review? :)
Quoted 168 lines
This series is inspired on Claudio TCG work.
Instead of separate TCG from other accelerators, here we separate sysemu operations (system VS user).
Since v6:
- Rebased (3 targets removed, Claudio's target/i386 series merged)
- Addressed Richard & David commentsSince v5:
- Rework patch 10 after Peter Maydell explanation on v3:
https://www.mail-archive.com/[email protected]/msg800849.htmlSince v4:
- Removed watchpoint patches (need more work) (Richard)
- Merged patch 1 & 7 "MoveCPUClass::vmsdto SysemuCPUOps" (Eduardo)
- Rewordedcpu_virtio_is_big_endiandescription (Greg)
- Movewrite_elf()intarget/riscv/cpu.c(rebased on top of43a965888)
- Added R-b tagsSince v3:
- SysemuCPUOps const (Richard)
- added missing xtensa #ifdef'ry
- added missing aa64/sve #ifdef'ry
- added Laurent R-bSince v2:
- fixed lm32/unicore32
- removeUSER_ONLYifdef'ry from "cpu.h" (Claudio)Since v1:
- Name 'sysemu' (Claudio)
- change each field progressively (Richard)$ git backport-diff 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= ly001/23:[down] 'NOTFORMERGE target/arm: Restrict MTE code to softmmu' 002/23:[down] 'cpu: Restrict target
cpu_do_transaction_failed()handlers to s= ysemu'
003/23:[down] 'cpu: Restrict targetcpu_do_unaligned_access()handlers to sys= emu'
004/23:[down] 'cpu: Remove duplicated 'sysemu/hw_accel.h' header' 005/23:[down] 'cpu: Split as cpu-common / cpu-sysemu' 006/23:[0002] [FC] 'cpu: Un-inlinecpu_get_phys_page_debugand cpu_asidx_from=_attrs'
007/23:[0010] [FC] 'cpu: Introducecpu_virtio_is_big_endian()' 008/23:[0088] [FC] 'cpu: Directly use cpu_write_elf*() fallback handlers in p= lace'
009/23:[0022] [FC] 'cpu: Directly useget_paging_enabled()fallback handlers = in place'
010/23:[0026] [FC] 'cpu: Directly useget_memory_mapping()fallback handlers = in place'
011/23:[0007] [FC] 'cpu: AssertDeviceClass::vmsdis NULL on user emulation' 012/23:[0004] [FC] 'cpu: Rename CPUClass vmsd ->legacy_vmsd' 013/23:[down] 'cpu: Move AVR target vmsd field from CPUClass to DeviceClass' 014/23:[0014] [FC] 'cpu: Introduce SysemuCPUOps structure' 015/23:[0003] [FC] 'cpu: MoveCPUClass::vmsdto SysemuCPUOps' 016/23:[0002] [FC] 'cpu: MoveCPUClass::virtio_is_big_endianto SysemuCPUOps' 017/23:[----] [--] 'cpu: MoveCPUClass::get_crash_infoto SysemuCPUOps' 018/23:[----] [-C] 'cpu: Move CPUClass::write_elf* to SysemuCPUOps' 019/23:[----] [--] 'cpu: MoveCPUClass::asidx_from_attrsto SysemuCPUOps' 020/23:[0055] [FC] 'cpu: MoveCPUClass::get_phys_page_debugto SysemuCPUOps' 021/23:[----] [--] 'cpu: MoveCPUClass::get_memory_mappingto SysemuCPUOps' 022/23:[----] [--] 'cpu: MoveCPUClass::get_paging_enabledto SysemuCPUOps' 023/23:[0012] [FC] 'cpu: Restrict "hw/core/sysemu-cpu-ops.h" totarget/cpu.c'Regards,
Phil.
Philippe Mathieu-Daud=C3=A9 (23):
NOTFORMERGE target/arm: Restrict MTE code to softmmu
cpu: Restrict targetcpu_do_transaction_failed()handlers to sysemu
cpu: Restrict targetcpu_do_unaligned_access()handlers to sysemu
cpu: Remove duplicated 'sysemu/hw_accel.h' header
cpu: Split as cpu-common / cpu-sysemu
cpu: Un-inlinecpu_get_phys_page_debugandcpu_asidx_from_attrs
cpu: Introducecpu_virtio_is_big_endian()
cpu: Directly use cpu_write_elf*() fallback handlers in place
cpu: Directly useget_paging_enabled()fallback handlers in place
cpu: Directly useget_memory_mapping()fallback handlers in place
cpu: AssertDeviceClass::vmsdis NULL on user emulation
cpu: Rename CPUClass vmsd ->legacy_vmsd
cpu: Move AVR target vmsd field from CPUClass to DeviceClass
cpu: Introduce SysemuCPUOps structure
cpu: MoveCPUClass::vmsdto SysemuCPUOps
cpu: MoveCPUClass::virtio_is_big_endianto SysemuCPUOps
cpu: MoveCPUClass::get_crash_infoto SysemuCPUOps
cpu: Move CPUClass::write_elf* to SysemuCPUOps
cpu: MoveCPUClass::asidx_from_attrsto SysemuCPUOps
cpu: MoveCPUClass::get_phys_page_debugto SysemuCPUOps
cpu: MoveCPUClass::get_memory_mappingto SysemuCPUOps
cpu: MoveCPUClass::get_paging_enabledto SysemuCPUOps
cpu: Restrict "hw/core/sysemu-cpu-ops.h" totarget/cpu.cinclude/hw/core/cpu.h | 92 +++++--------------- include/hw/core/sysemu-cpu-ops.h | 92 ++++++++++++++++++++ include/migration/vmstate.h | 2 - target/alpha/cpu.h | 12 ++- target/arm/cpu.h | 9 +- target/arm/internals.h | 2 + target/avr/cpu.h | 1 + target/cris/cpu.h | 7 +- target/hexagon/cpu.h | 3 + target/hppa/cpu.h | 5 +- target/i386/cpu.h | 9 +- target/m68k/cpu.h | 10 ++- target/microblaze/cpu.h | 11 +-- target/mips/cpu.h | 3 + target/mips/tcg/tcg-internal.h | 6 +- target/nios2/cpu.h | 4 +- target/openrisc/cpu.h | 6 +- target/ppc/cpu.h | 5 +- target/ppc/internal.h | 2 + target/riscv/cpu.h | 21 +++-- target/rx/cpu.h | 5 ++ target/s390x/cpu.h | 3 + target/s390x/internal.h | 2 + target/sh4/cpu.h | 11 ++- target/sparc/cpu.h | 14 +-- target/tricore/cpu.h | 5 ++ target/xtensa/cpu.h | 19 ++-- cpu.c | 18 ++-- hw/core/{cpu.c =3D> cpu-common.c} | 116 ------------------------- hw/core/cpu-sysemu.c | 145 +++++++++++++++++++++++++++++++ hw/virtio/virtio.c | 4 +- stubs/vmstate.c | 2 - target/alpha/cpu.c | 8 +- target/arm/cpu.c | 18 ++-- target/arm/tlb_helper.c | 4 +- target/avr/cpu.c | 8 +- target/avr/machine.c | 4 +- target/cris/cpu.c | 8 +- target/hppa/cpu.c | 8 +- target/i386/cpu.c | 28 +++--- target/m68k/cpu.c | 8 +- target/microblaze/cpu.c | 8 +- target/microblaze/helper.c | 35 ++++---- target/mips/cpu.c | 10 ++- target/nios2/cpu.c | 8 +- target/openrisc/cpu.c | 8 +- target/ppc/excp_helper.c | 3 +- target/riscv/cpu.c | 14 ++- target/rx/cpu.c | 10 ++- target/s390x/cpu.c | 14 ++- target/sh4/cpu.c | 11 ++- target/sparc/cpu.c | 10 ++- target/sparc/ldst_helper.c | 5 +- target/tricore/cpu.c | 6 +- target/xtensa/cpu.c | 10 ++- target/ppc/translate_init.c.inc | 20 +++-- hw/core/meson.build | 3 +- target/arm/meson.build | 6 +- 58 files changed, 587 insertions(+), 334 deletions(-) create mode 100644 include/hw/core/sysemu-cpu-ops.h rename hw/core/{cpu.c =3D> cpu-common.c} (73%) create mode 100644 hw/core/cpu-sysemu.c--=20
2.26.3
Quoted 11 lines · Philippe Mathieu-Daudé
cpu: Remove duplicated '
sysemu/hw_accel.h' header
cpu: Split as cpu-common / cpu-sysemu
cpu: Un-inlinecpu_get_phys_page_debugandcpu_asidx_from_attrs
cpu: Introducecpu_virtio_is_big_endian()
cpu: Directly use cpu_write_elf*() fallback handlers in place
cpu: Directly useget_paging_enabled()fallback handlers in place
cpu: Directly useget_memory_mapping()fallback handlers in place
cpu: AssertDeviceClass::vmsdis NULL on user emulation
cpu: Rename CPUClass vmsd ->legacy_vmsd
cpu: Move AVR target vmsd field from CPUClass to DeviceClass
cpu: Introduce SysemuCPUOps structure
Quoted 8 lines
cpu: Move
CPUClass::vmsdto SysemuCPUOps
cpu: MoveCPUClass::virtio_is_big_endianto SysemuCPUOps
cpu: MoveCPUClass::get_crash_infoto SysemuCPUOps
cpu: Move CPUClass::write_elf* to SysemuCPUOps
cpu: MoveCPUClass::asidx_from_attrsto SysemuCPUOps
cpu: MoveCPUClass::get_phys_page_debugto SysemuCPUOps
cpu: MoveCPUClass::get_memory_mappingto SysemuCPUOps
cpu: MoveCPUClass::get_paging_enabledto SysemuCPUOps
I've queued all of these to tcg-next, fixing minor patch conflicts on the way.
Most of which were the reorg going on in target/ppc/.
Quoted 1 line
cpu: Restrict "
hw/core/sysemu-cpu-ops.h" totarget/cpu.c
I squashed this one back into "Introduce SysemuCPUOps structure", and moved the target/*/ includes from cpu.h next to where the structure is declared.
r~