target/misc: Header cleanups around "cpu.h"
v2 cover target/misc: Header cleanups around "cpu.h"
These patches are part of a big refactor cleanup around "cpu.h". Most changes should be trivial IMHO.
Since v1:
- dropped patches including "cpu.h" in multiply included 'helper.h'
- dropped Hexagon patch
- better split sysemu fields in RISC-V's CPUArchState
Bernhard Beschow (1):
target/loongarch/cpu: Remove unused "sysbus.h" header
Philippe Mathieu-Daudé (8):
target/alpha: Remove obsolete STATUS document target/loongarch/cpu: Restrict "memory.h" header to sysemu target/ppc/internal: Restrict MMU declarations to sysemu target/ppc/kvm: Remove unused "sysbus.h" header target/riscv/cpu: Move Floating-Point fields closer target/riscv/cpu: Restrict some sysemu-specific fields from
CPUArchState
target/sparc/sysemu: Remove pointless CONFIG_USER_ONLY guard target/xtensa/cpu: Include missing "memory.h" header
target/alpha/STATUS | 28 ---------------------------- target/loongarch/cpu.h | 3 ++- target/ppc/internal.h | 5 +++++ target/ppc/kvm.c | 1 - target/riscv/cpu.h | 23 +++++++++++++---------- target/sparc/mmu_helper.c | 2 -- target/xtensa/cpu.c | 3 +++ 7 files changed, 23 insertions(+), 42 deletions(-) delete mode 100644 target/alpha/STATUS
Signature · 1 line
2.38.1
PATCH v2 1/9 target/alpha: Remove obsolete STATUS document
Likely out of sync: last update is from 2008
(commit d1412eb240), 12 years ago.
--- target/alpha/STATUS | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 target/alpha/STATUS
target/alpha/STATUS deleted +0 -28
@@ -1,28 +0,0 @@ -(to be completed) - -Alpha emulation structure: -cpu.h : CPU definitions globally exported -exec.h : CPU definitions used only for translated code execution -helper.c : helpers that can be called either by the translated code - or the QEMU core, including the exception handler. -op_helper.c : helpers that can be called only from TCG -helper.h : TCG helpers prototypes -translate.c : Alpha instructions to micro-operations translator - -Code translator status: -The Alpha CPU instruction emulation should be quite complete with the -limitation that the VAX floating-point load and stores are not tested. -The 4 MMU modes are implemented. - -Linux user mode emulation status: -a few programs start to run. Most crash at a certain point, dereferencing a -NULL pointer. It seems that the UNIQUE register is not initialized properly. -It may appear that old executables, not relying on TLS support, run but -this is to be proved... - -Full system emulation status: -* Alpha PALCode emulation is in a very early stage and is not sufficient - to run any real OS. The alpha-softmmu target is not enabled for now. -* no hardware platform description is implemented -* there might be problems in the Alpha PALCode dedicated instructions - that would prevent to use a native PALCode image.
Signature · 1 line
2.38.1
Re: [PATCH v2 1/9] target/alpha: Remove obsolete STATUS document
Quoted 8 lines · Philippe Mathieu-Daudé
Likely out of sync: last update is from 2008
(commitd1412eb240), 12 years ago.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/alpha/STATUS | 28 ---------------------------- 1 file changed, 28 deletions(-)delete mode 100644 target/alpha/STATUS
r~
PATCH v2 2/9 target/loongarch/cpu: Remove unused "sysbus.h" header
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
The cpu is used in both user and system emulation context while sysbus.h is system-only. Remove it since it's not needed anyway.
--- target/loongarch/cpu.h | 1 - 1 file changed, 1 deletion(-)
target/loongarch/cpu.h +0 -1
@@ -13,7 +13,6 @@#include "hw/registerfields.h" #include "qemu/timer.h" #include "exec/memory.h" -#include "hw/sysbus.h" #include "cpu-csr.h" #define IOCSRF_TEMP 0
Signature · 1 line
2.38.1
PATCH v2 3/9 target/loongarch/cpu: Restrict "memory.h" header to sysemu
In reply to Philippe Mathieu-DaudéMissed in 0093b9a5ee ("target/loongarch: Adjust functions and structure to support user-mode") while cleaning commit f84a2aacf5 ("target/loongarch: Add LoongArch IOCSR instruction").
--- target/loongarch/cpu.h | 2 ++ 1 file changed, 2 insertions(+)
target/loongarch/cpu.h +2 -0
@@ -12,7 +12,9 @@#include "fpu/softfloat-types.h" #include "hw/registerfields.h" #include "qemu/timer.h" +#ifndef CONFIG_USER_ONLY #include "exec/memory.h" +#endif #include "cpu-csr.h" #define IOCSRF_TEMP 0
Signature · 1 line
2.38.1
PATCH v2 4/9 target/ppc/internal: Restrict MMU declarations to sysemu
In reply to Philippe Mathieu-DaudéThe 'hwaddr' type is only available / meaningful on system emulation.
--- target/ppc/internal.h | 5 +++++ 1 file changed, 5 insertions(+)
target/ppc/internal.h +5 -0
@@ -242,9 +242,12 @@ static inline int prot_for_access_type(MMUAccessType access_type)g_assert_not_reached (); } +#ifndef CONFIG_USER_ONLY +/* PowerPC MMU emulation */ typedef struct mmu_ctx_t mmu_ctx_t ; +bool ppc_xlate (PowerPCCPU *cpu,vaddr eaddr,MMUAccessType access_type,hwaddr *raddrp,int *psizep,int *protp,int mmu_idx,bool guest_visible);
@@ -266,6 +269,8 @@ struct mmu_ctx_t { int nx; /* Non-execute area */ }; +#endif /* !CONFIG_USER_ONLY */ +/* Common routines used by software and hardware TLBs emulation */ static inline int pte_is_valid (target_ulong pte0) {
Signature · 1 line
2.38.1
PATCH v2 5/9 target/ppc/kvm: Remove unused "sysbus.h" header
In reply to Philippe Mathieu-DaudéNothing requires SysBus declarations here.
--- target/ppc/kvm.c | 1 - 1 file changed, 1 deletion(-)
target/ppc/kvm.c +0 -1
@@ -32,7 +32,6 @@#include "sysemu/device_tree.h" #include "mmu-hash64.h" -#include "hw/sysbus.h" #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_cpu_core.h" #include "hw/hw.h"
Signature · 1 line
2.38.1
Re: [PATCH v2 5/9] target/ppc/kvm: Remove unused "sysbus.h" header
Quoted 6 lines · Philippe Mathieu-Daudé
Nothing requires SysBus declarations here.
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/ppc/kvm.c | 1 - 1 file changed, 1 deletion(-)
r~
PATCH v2 6/9 target/riscv/cpu: Move Floating-Point fields closer
In reply to Philippe Mathieu-Daudé--- target/riscv/cpu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/riscv/cpu.h +3 -3
@@ -143,7 +143,6 @@ typedef struct PMUCTRState {struct CPUArchState {target_ulong gpr[32 ];target_ulong gprh[32 ];/* 64 top bits of the 128-bit registers */ -uint64_t fpr[32 ];/* assume both F and D extensions */ /* vector coprocessor state. */ uint64_t vreg[32 * RV_VLEN_MAX / 64] QEMU_ALIGNED(16);
@@ -158,7 +157,10 @@ struct CPUArchState {target_ulong load_res;target_ulong load_val; +/* Floating-Point state */ +uint64_t fpr[32 ];/* assume both F and D extensions */ target_ulong frm; +float_status fp_status;target_ulong badaddr;target_ulong bins;
@@ -372,8 +374,6 @@ struct CPUArchState {target_ulong cur_pmmask;target_ulong cur_pmbase; -float_status fp_status; -/* Fields from here on are preserved across CPU reset. */ QEMUTimer *stimer;/* Internal timer for S-mode interrupt */ QEMUTimer *vstimer;/* Internal timer for VS-mode interrupt */
Signature · 1 line
2.38.1
Re: [PATCH v2 6/9] target/riscv/cpu: Move Floating-Point fields closer
Quoted 4 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/riscv/cpu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
r~
PATCH v2 7/9 target/riscv/cpu: Restrict some sysemu-specific fields from CPUArchState
In reply to Philippe Mathieu-DaudéThe 'hwaddr' type is only available / meaningful on system emulation.
--- target/riscv/cpu.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
target/riscv/cpu.h +10 -7
@@ -370,7 +370,7 @@ struct CPUArchState {uint64_t menvcfg;target_ulong senvcfg;uint64_t henvcfg; -#endif +target_ulong cur_pmmask;target_ulong cur_pmbase;
@@ -388,6 +388,7 @@ struct CPUArchState {uint64_t kvm_timer_compare;uint64_t kvm_timer_state;uint64_t kvm_timer_frequency; +#endif };OBJECT_DECLARE_CPU_TYPE (RISCVCPU , RISCVCPUClass,RISCV_CPU )
@@ -553,12 +554,20 @@ bool riscv_cpu_virt_enabled(CPURISCVState *env);void riscv_cpu_set_virt_enabled (CPURISCVState *env,bool enable);bool riscv_cpu_two_stage_lookup (int mmu_idx);int riscv_cpu_mmu_index (CPURISCVState *env,bool ifetch); +#ifndef CONFIG_USER_ONLY +hwaddr riscv_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); G_NORETURN 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); +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); +#endif char *riscv_isa_string (RISCVCPU *cpu);void riscv_cpu_list (void );
@@ -566,12 +575,6 @@ 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); -hwaddr riscv_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);bool riscv_cpu_exec_interrupt (CPUState *cs,int interrupt_request);void riscv_cpu_swap_hypervisor_regs (CPURISCVState *env);int riscv_cpu_claim_interrupts (RISCVCPU *cpu,uint64_t interrupts);
Signature · 1 line
2.38.1
Re: [PATCH v2 7/9] target/riscv/cpu: Restrict some sysemu-specific fields from CPUArchState
Quoted 21 lines · Philippe Mathieu-Daudé
The 'hwaddr' type is only available / meaningful on system emulation.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/riscv/cpu.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)target/riscv/cpu.h +1
-1@@ -370,7 +370,7 @@ struct CPUArchState {uint64_t menvcfg;target_ulong senvcfg;uint64_t henvcfg; -#endif +target_ulong cur_pmmask;target_ulong cur_pmbase;
target/riscv/cpu.h struct CPUArchState { · line 392
Quoted 5 lines
target/riscv/cpu.h +1
-0@@ -388,6 +388,7 @@ struct CPUArchState {uint64_t kvm_timer_compare;uint64_t kvm_timer_state;uint64_t kvm_timer_frequency; +#endif };
Sorry this patch is not complete, as various of these fields are in use in common emulation code (so build fails on linux-user) :/
PATCH v2 8/9 target/sparc/sysemu: Remove pointless CONFIG_USER_ONLY guard
In reply to Philippe Mathieu-DaudéCommit caac44a52a ("target/sparc: Make sparc_cpu_tlb_fill sysemu only") restricted mmu_helper.c to system emulation. Checking whether CONFIG_USER_ONLY is defined is now pointless.
--- target/sparc/mmu_helper.c | 2 -- 1 file changed, 2 deletions(-)
target/sparc/mmu_helper.c +0 -2
@@ -924,7 +924,6 @@ hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)return phys_addr; } -#ifndef CONFIG_USER_ONLY G_NORETURN void sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx,
@@ -942,4 +941,3 @@ G_NORETURN void sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,cpu_raise_exception_ra (env,TT_UNALIGNED , retaddr); } -#endif /* !CONFIG_USER_ONLY */
Signature · 1 line
2.38.1
PATCH v2 9/9 target/xtensa/cpu: Include missing "memory.h" header
In reply to Philippe Mathieu-DaudéUnder system emulation, xtensa_cpu_initfn() calls memory_region_init_io(), itself declared in "exec/memory.h".
--- target/xtensa/cpu.c | 3 +++ 1 file changed, 3 insertions(+)
target/xtensa/cpu.c +3 -0
@@ -35,6 +35,9 @@#include "qemu/module.h" #include "migration/vmstate.h" #include "hw/qdev-clock.h" +#ifndef CONFIG_USER_ONLY +#include "exec/memory.h" +#endif static void xtensa_cpu_set_pc (CPUState *cs,vaddr value)
Signature · 1 line
2.38.1