Unaligned access for user-only
Subsystems (2)
v2 cover Unaligned access for user-only
This began with Peter wanting a cpu_ldst.h interface that can handle alignment info for Arm M-profile system mode, which will also compile for user-only without ifdefs. This is patch 32.
Once I had that interface, I thought I might as well enforce the requested alignment in user-only. There are plenty of cases where we ought to have been doing that for quite a while. This took rather more work than I imagined to start.
So far only x86 host has been fully converted to handle unaligned operations in user-only mode. I'll get to the others later. But the added testcase is fairly broad, and caught lots of bugs and/or missing code between target/ and linux-user/.
Changes for v2:
* Cleanup prctl(2), add support for prctl(PR_GET/SET_UNALIGN).
* Adjustments for ppc and sparc reporting address during alignment fault.
r~
Richard Henderson (55):
hw/core: Make do_unaligned_access noreturn
hw/core: Make do_unaligned_access available to user-only target/alpha: Implement do_unaligned_access for user-only target/arm: Implement do_unaligned_access for user-only target/hppa: Implement do_unaligned_access for user-only target/microblaze: Do not set MO_ALIGN for user-only target/mips: Implement do_unaligned_access for user-only target/ppc: Move SPR_DSISR setting to powerpc_excp target/ppc: Set fault address in ppc_cpu_do_unaligned_access target/ppc: Implement do_unaligned_access for user-only target/riscv: Implement do_unaligned_access for user-only target/s390x: Implement do_unaligned_access for user-only target/sh4: Set fault address in superh_cpu_do_unaligned_access target/sh4: Implement do_unaligned_access for user-only target/sparc: Remove DEBUG_UNALIGNED
target/sparc: Split out build_sfsr
target/sparc: Set fault address in sparc_cpu_do_unaligned_access target/sparc: Implement do_unaligned_access for user-only target/xtensa: Implement do_unaligned_access for user-only accel/tcg: Report unaligned atomics for user-only accel/tcg: Drop signness in tracing in cputlb.c
tcg: Expand MO_SIZE to 3 bits
tcg: Rename TCGMemOpIdx to MemOpIdx
tcg: Split out MemOpIdx to exec/memopidx.h
trace/mem: Pass MemOpIdx to trace_mem_get_info accel/tcg: Pass MemOpIdx to atomic_trace_*_post
plugins: Reorg arguments to qemu_plugin_vcpu_mem_cb
trace: Split guest_mem_before
target/arm: Use MO_128 for 16 byte atomics target/i386: Use MO_128 for 16 byte atomics target/ppc: Use MO_128 for 16 byte atomics target/s390x: Use MO_128 for 16 byte atomics target/hexagon: Implement cpu_mmu_index
accel/tcg: Add cpu_{ld,st}*_mmu interfaces
accel/tcg: Move cpu_atomic decls to exec/cpu_ldst.h target/mips: Use cpu_*_data_ra for msa load/store target/mips: Use 8-byte memory ops for msa load/store target/s390x: Use cpu_*_mmu instead of helper_*_mmu target/sparc: Use cpu_*_mmu instead of helper_*_mmu target/arm: Use cpu_*_mmu instead of helper_*_mmu
tcg: Move helper_*_mmu decls to tcg/tcg-ldst.h
tcg: Add helper_unaligned_mmu for user-only sigbus tcg/i386: Support raising sigbus for user-only tests/tcg/multiarch: Add sigbus.c
linux-user: Split out do_prctl and subroutines
linux-user: Disable more prctl subcodes
hw/core/cpu: Re-sort the non-pointers to the end of CPUClass
linux-user: Add code for PR_GET/SET_UNALIGN hw/core/cpu: Move cpu properties to cpu-sysemu.c hw/core/cpu: Add prctl-unalign-sigbus property for user-only target/alpha: Reorg fp memory operations target/alpha: Reorg integer memory operations target/alpha: Implement prctl_unalign_sigbus target/hppa: Implement prctl_unalign_sigbus target/sh4: Implement prctl_unalign_sigbus
docs/devel/loads-stores.rst | 52 +- accel/tcg/atomic_template.h | 73 ++- accel/tcg/internal.h | 4 + hw/core/cpu-common.h | 17 + include/exec/cpu_ldst.h | 332 ++++++------- include/exec/memop.h | 14 +- include/exec/memopidx.h | 55 +++ include/hw/core/cpu.h | 14 +- include/hw/core/tcg-cpu-ops.h | 15 +- include/qemu/plugin.h | 26 +- include/tcg/tcg-ldst.h | 79 ++++ include/tcg/tcg.h | 197 +------- linux-user/aarch64/target_syscall.h | 23 - linux-user/mips/target_syscall.h | 6 - linux-user/mips64/target_syscall.h | 6 - target/alpha/cpu.h | 9 +- target/arm/internals.h | 3 +- target/hexagon/cpu.h | 9 + target/hppa/cpu.h | 5 +- target/microblaze/cpu.h | 2 +- target/mips/tcg/tcg-internal.h | 4 +- target/nios2/cpu.h | 4 +- target/ppc/internal.h | 4 +- target/riscv/cpu.h | 2 +- target/s390x/s390x-internal.h | 4 +- target/sh4/cpu.h | 8 +- target/xtensa/cpu.h | 4 +- tcg/i386/tcg-target.h | 2 - trace/mem.h | 63 --- accel/tcg/cpu-exec-common.c | 12 + accel/tcg/cputlb.c | 495 +++++++------------ accel/tcg/plugin-gen.c | 5 +- accel/tcg/user-exec.c | 435 +++++++---------- hw/core/cpu-common.c | 18 +- hw/core/cpu-sysemu.c | 24 + hw/core/cpu-user.c | 37 ++ linux-user/aarch64/cpu_loop.c | 4 + linux-user/arm/cpu_loop.c | 43 +- linux-user/hppa/cpu_loop.c | 2 +- linux-user/mips/cpu_loop.c | 20 +- linux-user/ppc/cpu_loop.c | 2 +- linux-user/riscv/cpu_loop.c | 7 + linux-user/sh4/cpu_loop.c | 8 + linux-user/sparc/cpu_loop.c | 11 + linux-user/syscall.c | 709 +++++++++++++++++----------- plugins/api.c | 19 +- plugins/core.c | 10 +- target/alpha/cpu.c | 2 +- target/alpha/mem_helper.c | 8 +- target/alpha/translate.c | 188 ++++---- target/arm/cpu.c | 2 +- target/arm/cpu_tcg.c | 2 +- target/arm/helper-a64.c | 77 +-- target/arm/m_helper.c | 8 +- target/arm/translate-a64.c | 2 +- target/hppa/cpu.c | 16 +- target/hppa/translate.c | 19 +- target/i386/tcg/mem_helper.c | 4 +- target/m68k/op_helper.c | 3 +- target/microblaze/translate.c | 16 + target/mips/cpu.c | 2 +- target/mips/tcg/msa_helper.c | 395 ++++------------ target/mips/tcg/op_helper.c | 3 +- target/mips/tcg/user/tlb_helper.c | 23 +- target/ppc/cpu_init.c | 2 +- target/ppc/excp_helper.c | 35 +- target/ppc/mem_helper.c | 1 - target/ppc/translate.c | 12 +- target/riscv/cpu.c | 2 +- target/riscv/cpu_helper.c | 8 +- target/s390x/cpu.c | 2 +- target/s390x/tcg/excp_helper.c | 28 +- target/s390x/tcg/mem_helper.c | 31 +- target/sh4/cpu.c | 2 +- target/sh4/op_helper.c | 8 +- target/sh4/translate.c | 50 +- target/sparc/cpu.c | 2 +- target/sparc/ldst_helper.c | 38 +- target/sparc/mmu_helper.c | 92 +++- target/xtensa/cpu.c | 2 +- target/xtensa/helper.c | 30 +- tcg/optimize.c | 2 +- tcg/tcg-op.c | 60 +-- tcg/tcg.c | 3 +- tcg/tci.c | 15 +- tests/tcg/multiarch/sigbus.c | 68 +++ accel/tcg/atomic_common.c.inc | 43 +- accel/tcg/ldst_common.c.inc | 307 ++++++++++++ target/s390x/tcg/translate_vx.c.inc | 2 +- tcg/aarch64/tcg-target.c.inc | 18 +- tcg/arm/tcg-target.c.inc | 14 +- tcg/i386/tcg-target.c.inc | 128 ++++- tcg/mips/tcg-target.c.inc | 16 +- tcg/ppc/tcg-target.c.inc | 18 +- tcg/riscv/tcg-target.c.inc | 20 +- tcg/s390/tcg-target.c.inc | 14 +- tcg/sparc/tcg-target.c.inc | 20 +- tcg/tcg-ldst.c.inc | 2 +- hw/core/meson.build | 4 + trace-events | 18 +- 100 files changed, 2549 insertions(+), 2235 deletions(-) create mode 100644 hw/core/cpu-common.h create mode 100644 include/exec/memopidx.h create mode 100644 include/tcg/tcg-ldst.h delete mode 100644 trace/mem.h create mode 100644 hw/core/cpu-user.c create mode 100644 tests/tcg/multiarch/sigbus.c create mode 100644 accel/tcg/ldst_common.c.inc
Signature · 1 line
2.25.1
PATCH v2 1/55 hw/core: Make do_unaligned_access noreturn
While we may have had some thought of allowing system-mode to return from this hook, we have no guests that require this.
--- include/hw/core/tcg-cpu-ops.h | 3 ++- target/alpha/cpu.h | 4 ++-- target/arm/internals.h | 3 ++- target/microblaze/cpu.h | 2 +- target/mips/tcg/tcg-internal.h | 4 ++-- target/nios2/cpu.h | 4 ++-- target/ppc/internal.h | 4 ++-- target/riscv/cpu.h | 2 +- target/s390x/s390x-internal.h | 4 ++-- target/sh4/cpu.h | 4 ++-- target/xtensa/cpu.h | 4 ++-- target/hppa/cpu.c | 7 ++++--- 12 files changed, 24 insertions(+), 21 deletions(-)
include/hw/core/tcg-cpu-ops.h +2 -1
@@ -72,10 +72,11 @@ struct TCGCPUOps { MemTxResult response, uintptr_t retaddr);/** * @do_unaligned_access: Callback for unaligned access handling +* The callback must exit via raising an exception. */ void (*do_unaligned_access)(CPUState *cpu, vaddr addr, MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr); + int mmu_idx, uintptr_t retaddr) QEMU_NORETURN;/** * @adjust_watchpoint_address: hack for cpu_check_watchpoint used by ARM
target/alpha/cpu.h +2 -2
@@ -283,8 +283,8 @@ 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); + MMUAccessType access_type, int mmu_idx, + uintptr_t retaddr) QEMU_NORETURN;#define cpu_list alpha_cpu_list#define cpu_signal_handler cpu_alpha_signal_handler
target/arm/internals.h +2 -1
@@ -594,7 +594,8 @@ bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx);/* 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); + int mmu_idx, uintptr_t retaddr) + QEMU_NORETURN;/* 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/cpu.h +1 -1
@@ -359,7 +359,7 @@ 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); + int mmu_idx, uintptr_t retaddr) QEMU_NORETURN;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);
target/mips/tcg/tcg-internal.h +2 -2
@@ -24,8 +24,8 @@ 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); + MMUAccessType access_type, int mmu_idx, + uintptr_t retaddr) QEMU_NORETURN;const char *mips_exception_name (int32_t exception);
target/nios2/cpu.h +2 -2
@@ -198,8 +198,8 @@ 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); void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, -MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr); + MMUAccessType access_type, int mmu_idx, + uintptr_t retaddr) QEMU_NORETURN;void do_nios2_semihosting (CPUNios2State *env);
target/ppc/internal.h +2 -2
@@ -213,8 +213,8 @@ void helper_compute_fprf_float128(CPUPPCState *env, float128 arg);/* 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); + MMUAccessType access_type, int mmu_idx, + uintptr_t retaddr) QEMU_NORETURN;/* translate.c */
target/riscv/cpu.h +1 -1
@@ -345,7 +345,7 @@ 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); + uintptr_t retaddr) QEMU_NORETURN;bool riscv_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr);
target/s390x/s390x-internal.h +2 -2
@@ -274,8 +274,8 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr, -MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr); + MMUAccessType access_type, int mmu_idx, + uintptr_t retaddr) QEMU_NORETURN;/* fpu_helper.c */
target/sh4/cpu.h +2 -2
@@ -211,8 +211,8 @@ 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); + MMUAccessType access_type, int mmu_idx, + uintptr_t retaddr) QEMU_NORETURN;void sh4_translate_init (void ); int cpu_sh4_signal_handler(int host_signum, void *pinfo,
target/xtensa/cpu.h +2 -2
@@ -579,8 +579,8 @@ void xtensa_count_regs(const XtensaConfig *config,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); + MMUAccessType access_type, int mmu_idx, + uintptr_t retaddr) QEMU_NORETURN;#define cpu_signal_handler cpu_xtensa_signal_handler#define cpu_list xtensa_cpu_list
target/hppa/cpu.c +4 -3
@@ -72,9 +72,10 @@ static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info) }#ifndef CONFIG_USER_ONLY -static void hppa_cpu_do_unaligned_access (CPUState *cs,vaddr addr, -MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr) +static void QEMU_NORETURN +hppa_cpu_do_unaligned_access (CPUState *cs,vaddr addr, +MMUAccessType access_type,int mmu_idx, +uintptr_t retaddr) {HPPACPU *cpu =HPPA_CPU (cs);CPUHPPAState *env = &cpu->env;
Signature · 1 line
2.25.1
Re: [PATCH v2 01/55] hw/core: Make do_unaligned_access noreturn
Quoted 39 lines · Richard Henderson
While we may have had some thought of allowing system-mode to return from this hook, we have no guests that require this.
Signed-off-by Richard Henderson <[email protected]>--- include/hw/core/tcg-cpu-ops.h | 3 ++- target/alpha/cpu.h | 4 ++-- target/arm/internals.h | 3 ++- target/microblaze/cpu.h | 2 +- target/mips/tcg/tcg-internal.h | 4 ++-- target/nios2/cpu.h | 4 ++-- target/ppc/internal.h | 4 ++-- target/riscv/cpu.h | 2 +- target/s390x/s390x-internal.h | 4 ++-- target/sh4/cpu.h | 4 ++-- target/xtensa/cpu.h | 4 ++-- target/hppa/cpu.c | 7 ++++--- 12 files changed, 24 insertions(+), 21 deletions(-)target/alpha/cpu.h +2
-2@@ -283,8 +283,8 @@ 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); + MMUAccessType access_type, int mmu_idx, + uintptr_t retaddr) QEMU_NORETURN;#define cpu_list alpha_cpu_list#define cpu_signal_handler cpu_alpha_signal_handlertarget/arm/internals.h +0
-0
target/arm/internals.h bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx); · line 598
Quoted 6 lines
target/arm/internals.h +2
-1@@ -594,7 +594,8 @@ bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx);/* 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); + int mmu_idx, uintptr_t retaddr) + QEMU_NORETURN;
This one ended misaligned, I'd align as:
QEMU_NORETURN;
Otherwise:
Re: [PATCH v2 01/55] hw/core: Make do_unaligned_access noreturn
In reply to Richard HendersonQuoted 41 lines · Richard Henderson
While we may have had some thought of allowing system-mode to return from this hook, we have no guests that require this.
Signed-off-by Richard Henderson <[email protected]>--- include/hw/core/tcg-cpu-ops.h | 3 ++- target/alpha/cpu.h | 4 ++-- target/arm/internals.h | 3 ++- target/microblaze/cpu.h | 2 +- target/mips/tcg/tcg-internal.h | 4 ++-- target/nios2/cpu.h | 4 ++-- target/ppc/internal.h | 4 ++-- target/riscv/cpu.h | 2 +- target/s390x/s390x-internal.h | 4 ++-- target/sh4/cpu.h | 4 ++-- target/xtensa/cpu.h | 4 ++-- target/hppa/cpu.c | 7 ++++--- 12 files changed, 24 insertions(+), 21 deletions(-)include/hw/core/tcg-cpu-ops.h +2
-1@@ -72,10 +72,11 @@ struct TCGCPUOps { MemTxResult response, uintptr_t retaddr);/** * @do_unaligned_access: Callback for unaligned access handling +* The callback must exit via raising an exception. */ void (*do_unaligned_access)(CPUState *cpu, vaddr addr, MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr); + int mmu_idx, uintptr_t retaddr) QEMU_NORETURN;/** * @adjust_watchpoint_address: hack for cpu_check_watchpoint used by ARM target/alpha/cpu.h +0
-0
target/alpha/cpu.h hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); · line 287
Quoted 7 lines
target/alpha/cpu.h +2
-2@@ -283,8 +283,8 @@ 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); + MMUAccessType access_type, int mmu_idx, + uintptr_t retaddr) QEMU_NORETURN;
These trailing QEMU_NORETURN's seem to be fairly uncommon in the existing code. Indeed I'd glanced at this code and was about to suggest one was added. IMHO is scans better when your reading the return type for a function and you can always do:
void QEMU_NORETURN foo_function(bar args);
if you are worried about over indentation. Anyway:
Signature · 1 line
Alex Bennée
Re: [PATCH v2 01/55] hw/core: Make do_unaligned_access noreturn
Quoted 2 lines · Alex Bennée
These trailing QEMU_NORETURN's seem to be fairly uncommon in the existing code.
Showing my age, I suppose. Once upon a time it was the only place you *could* put it in a declaration (as opposed to definition).
r~
PATCH v2 2/55 hw/core: Make do_unaligned_access available to user-only
In reply to Richard HendersonWe shouldn't be ignoring SIGBUS for user-only.
Move our existing TCGCPUOps hook out from CONFIG_SOFTMMU. Move the wrapper, cpu_unaligned_access, to cpu-exec-common.c.
--- accel/tcg/internal.h | 4 ++++ include/hw/core/tcg-cpu-ops.h | 16 ++++++++-------- accel/tcg/cpu-exec-common.c | 12 ++++++++++++ accel/tcg/cputlb.c | 9 --------- 4 files changed, 24 insertions(+), 17 deletions(-)
accel/tcg/internal.h +4 -0
@@ -19,4 +19,8 @@ void QEMU_NORETURN cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);void page_init (void );void tb_htable_init (void ); +void QEMU_NORETURN cpu_unaligned_access(CPUState *cpu, vaddr addr, +MMUAccessType access_type, +int mmu_idx,uintptr_t retaddr); +#endif /* ACCEL_TCG_INTERNAL_H */
include/hw/core/tcg-cpu-ops.h +8 -8
@@ -60,6 +60,14 @@ struct TCGCPUOps {/** @debug_excp_handler: Callback for handling debug exceptions */ void (*debug_excp_handler)(CPUState *cpu); +/** +* @do_unaligned_access: Callback for unaligned access handling +* The callback must exit via raising an exception. +*/ + void (*do_unaligned_access)(CPUState *cpu, vaddr addr, + MMUAccessType access_type, + int mmu_idx, uintptr_t retaddr) QEMU_NORETURN; +#ifdef NEED_CPU_H #ifdef CONFIG_SOFTMMU /**
@@ -70,14 +78,6 @@ struct TCGCPUOps { unsigned size, MMUAccessType access_type, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr); -/** -* @do_unaligned_access: Callback for unaligned access handling -* The callback must exit via raising an exception. -*/ - void (*do_unaligned_access)(CPUState *cpu, vaddr addr, - MMUAccessType access_type, - int mmu_idx, uintptr_t retaddr) QEMU_NORETURN; -/** * @adjust_watchpoint_address: hack for cpu_check_watchpoint used by ARM */
accel/tcg/cpu-exec-common.c +12 -0
@@ -21,6 +21,8 @@#include "sysemu/cpus.h" #include "sysemu/tcg.h" #include "exec/exec-all.h" +#include "hw/core/tcg-cpu-ops.h" +#include "internal.h" bool tcg_allowed;
@@ -81,3 +83,13 @@ void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc) cpu->exception_index =EXCP_ATOMIC ;cpu_loop_exit_restore (cpu, pc); } + +void cpu_unaligned_access (CPUState *cpu,vaddr addr, +MMUAccessType access_type, +int mmu_idx,uintptr_t retaddr) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + +assert (cc->tcg_ops->do_unaligned_access !=NULL ); + cc->tcg_ops->do_unaligned_access (cpu, addr, access_type, mmu_idx, retaddr); +}
accel/tcg/cputlb.c +0 -9
@@ -1306,15 +1306,6 @@ static void tlb_fill(CPUState *cpu, target_ulong addr, int size,assert (ok); } -static inline void cpu_unaligned_access (CPUState *cpu,vaddr addr, -MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr) -{ -CPUClass *cc =CPU_GET_CLASS (cpu); - - cc->tcg_ops->do_unaligned_access (cpu, addr, access_type, mmu_idx, retaddr); -} - static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type,
Signature · 1 line
2.25.1
Re: [PATCH v2 02/55] hw/core: Make do_unaligned_access available to user-only
Quoted 18 lines · Richard Henderson
We shouldn't be ignoring SIGBUS for user-only.
Move our existing TCGCPUOps hook out from
CONFIG_SOFTMMU. Move the wrapper,cpu_unaligned_access, tocpu-exec-common.c.Signed-off-by Richard Henderson <[email protected]>--- accel/tcg/internal.h | 4 ++++ include/hw/core/tcg-cpu-ops.h | 16 ++++++++-------- accel/tcg/cpu-exec-common.c | 12 ++++++++++++ accel/tcg/cputlb.c | 9 --------- 4 files changed, 24 insertions(+), 17 deletions(-)accel/tcg/internal.h +0
-0
accel/tcg/internal.h void QEMU_NORETURN cpu_io_recompile(CPUState *cpu, uintptr_t retaddr); · line 24
Quoted 6 lines
accel/tcg/internal.h +3
-0@@ -19,4 +19,8 @@ void QEMU_NORETURN cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);void page_init (void );void tb_htable_init (void ); +void QEMU_NORETURN cpu_unaligned_access(CPUState *cpu, vaddr addr, +MMUAccessType access_type, +int mmu_idx,uintptr_t retaddr);
Thanks for using noreturn :)
Re: [PATCH v2 02/55] hw/core: Make do_unaligned_access available to user-only
In reply to Richard HendersonQuoted 6 lines · Richard Henderson
We shouldn't be ignoring SIGBUS for user-only.
Move our existing TCGCPUOps hook out from
CONFIG_SOFTMMU. Move the wrapper,cpu_unaligned_access, tocpu-exec-common.c.Signed-off-by Richard Henderson <[email protected]>
Signature · 1 line
Alex Bennée
PATCH v2 3/55 target/alpha: Implement do_unaligned_access for user-only
In reply to Richard Henderson--- target/alpha/cpu.c | 2 +- target/alpha/mem_helper.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-)
target/alpha/cpu.c +1 -1
@@ -220,11 +220,11 @@ static const struct TCGCPUOps alpha_tcg_ops = { .initialize = alpha_translate_init, .cpu_exec_interrupt = alpha_cpu_exec_interrupt, .tlb_fill = alpha_cpu_tlb_fill, + .do_unaligned_access = alpha_cpu_do_unaligned_access, #ifndef CONFIG_USER_ONLY .do_interrupt = alpha_cpu_do_interrupt, .do_transaction_failed = alpha_cpu_do_transaction_failed, - .do_unaligned_access = alpha_cpu_do_unaligned_access, #endif /* !CONFIG_USER_ONLY */ };
target/alpha/mem_helper.c +3 -5
@@ -23,30 +23,28 @@#include "exec/exec-all.h" #include "exec/cpu_ldst.h" -/* Softmmu support */ -#ifndef CONFIG_USER_ONLY void alpha_cpu_do_unaligned_access (CPUState *cs,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr) {AlphaCPU *cpu =ALPHA_CPU (cs);CPUAlphaState *env = &cpu->env; -uint64_t pc;uint32_t insn;cpu_restore_state (cs, retaddr, true); - pc = env->pc; - insn =cpu_ldl_code (env, pc); + insn =cpu_ldl_code (env, env->pc); env->trap_arg0 = addr; env->trap_arg1 = insn >>26 ;/* opcode */ env->trap_arg2 = (insn >>21 ) &31 ;/* dest regno */ + cs->exception_index =EXCP_UNALIGN ; env->error_code =0 ;cpu_loop_exit (cs); } +#ifndef CONFIG_USER_ONLY void alpha_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type,
Signature · 1 line
2.25.1
Re: [PATCH v2 03/55] target/alpha: Implement do_unaligned_access for user-only
Quoted 6 lines · Richard Henderson
Reviewed-by Peter Maydell <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/alpha/cpu.c | 2 +- target/alpha/mem_helper.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-)
PATCH v2 4/55 target/arm: Implement do_unaligned_access for user-only
In reply to Richard Henderson--- linux-user/aarch64/cpu_loop.c | 4 ++++ linux-user/arm/cpu_loop.c | 43 +++++++++++++++++++++++++++-------- target/arm/cpu.c | 2 +- target/arm/cpu_tcg.c | 2 +- 4 files changed, 40 insertions(+), 11 deletions(-)
linux-user/aarch64/cpu_loop.c +4 -0
@@ -137,6 +137,10 @@ void cpu_loop(CPUARMState *env)case 0x11 :/* Synchronous Tag Check Fault */ info.si_code =TARGET_SEGV_MTESERR ;break ; +case 0x21 :/* Alignment fault */ + info.si_signo =TARGET_SIGBUS ; + info.si_code =TARGET_BUS_ADRALN ; +break ;default :g_assert_not_reached (); }
linux-user/arm/cpu_loop.c +34 -9
64 lines not on this page · raw message
target/arm/cpu.c +1 -1
@@ -1987,11 +1987,11 @@ static const struct TCGCPUOps arm_tcg_ops = { .cpu_exec_interrupt = arm_cpu_exec_interrupt, .tlb_fill = arm_cpu_tlb_fill, .debug_excp_handler = arm_debug_excp_handler, + .do_unaligned_access = arm_cpu_do_unaligned_access, #if !defined(CONFIG_USER_ONLY) .do_interrupt = arm_cpu_do_interrupt, .do_transaction_failed = arm_cpu_do_transaction_failed, - .do_unaligned_access = arm_cpu_do_unaligned_access, .adjust_watchpoint_address = arm_adjust_watchpoint_address, .debug_check_watchpoint = arm_debug_check_watchpoint, .debug_check_breakpoint = arm_debug_check_breakpoint,
target/arm/cpu_tcg.c +1 -1
@@ -904,11 +904,11 @@ static const struct TCGCPUOps arm_v7m_tcg_ops = { .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt, .tlb_fill = arm_cpu_tlb_fill, .debug_excp_handler = arm_debug_excp_handler, + .do_unaligned_access = arm_cpu_do_unaligned_access, #if !defined(CONFIG_USER_ONLY) .do_interrupt = arm_v7m_cpu_do_interrupt, .do_transaction_failed = arm_cpu_do_transaction_failed, - .do_unaligned_access = arm_cpu_do_unaligned_access, .adjust_watchpoint_address = arm_adjust_watchpoint_address, .debug_check_watchpoint = arm_debug_check_watchpoint, .debug_check_breakpoint = arm_debug_check_breakpoint,
Signature · 1 line
2.25.1
PATCH v2 5/55 target/hppa: Implement do_unaligned_access for user-only
In reply to Richard Henderson--- linux-user/hppa/cpu_loop.c | 2 +- target/hppa/cpu.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-)
linux-user/hppa/cpu_loop.c +1 -1
@@ -161,7 +161,7 @@ void cpu_loop(CPUHPPAState *env)case EXCP_UNALIGN : info.si_signo =TARGET_SIGBUS ; info.si_errno =0 ; - info.si_code =0 ; + info.si_code =TARGET_BUS_ADRALN ; info._sifields._sigfault._addr = env->cr[CR_IOR ];queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info);break ;
target/hppa/cpu.c +6 -3
@@ -71,7 +71,6 @@ static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info) info->print_insn = print_insn_hppa; } -#ifndef CONFIG_USER_ONLY static void QEMU_NORETURN hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx,
@@ -81,15 +80,19 @@ hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,CPUHPPAState *env = &cpu->env; cs->exception_index =EXCP_UNALIGN ; +#ifdef CONFIG_USER_ONLY +/* Recall that user-only always uses address space 0. */ + env->cr[CR_IOR ] = addr; +#else if (env->psw &PSW_Q ) {/* ??? Needs tweaking for hppa64. */ env->cr[CR_IOR ] = addr; env->cr[CR_ISR ] = addr >>32 ; } +#endif cpu_loop_exit_restore (cs, retaddr); } -#endif /* CONFIG_USER_ONLY */ static void hppa_cpu_realizefn (DeviceState *dev,Error **errp) {
@@ -147,10 +150,10 @@ static const struct TCGCPUOps hppa_tcg_ops = { .synchronize_from_tb = hppa_cpu_synchronize_from_tb, .cpu_exec_interrupt = hppa_cpu_exec_interrupt, .tlb_fill = hppa_cpu_tlb_fill, + .do_unaligned_access = hppa_cpu_do_unaligned_access,#ifndef CONFIG_USER_ONLY .do_interrupt = hppa_cpu_do_interrupt, - .do_unaligned_access = hppa_cpu_do_unaligned_access,#endif /* !CONFIG_USER_ONLY */ };
Signature · 1 line
2.25.1
Re: [PATCH v2 05/55] target/hppa: Implement do_unaligned_access for user-only
+Helge
Quoted 65 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- linux-user/hppa/cpu_loop.c | 2 +- target/hppa/cpu.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-)linux-user/hppa/cpu_loop.c +1
-1@@ -161,7 +161,7 @@ void cpu_loop(CPUHPPAState *env)case EXCP_UNALIGN : info.si_signo =TARGET_SIGBUS ; info.si_errno =0 ; - info.si_code =0 ; + info.si_code =TARGET_BUS_ADRALN ; info._sifields._sigfault._addr = env->cr[CR_IOR ];queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info);break ;target/hppa/cpu.c +6
-3@@ -71,7 +71,6 @@ static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info) info->print_insn = print_insn_hppa; } -#ifndef CONFIG_USER_ONLY static void QEMU_NORETURN hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx,@@ -81,15 +80,19 @@ hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,CPUHPPAState *env = &cpu->env; cs->exception_index =EXCP_UNALIGN ; +#ifdef CONFIG_USER_ONLY +/* Recall that user-only always uses address space 0. */ + env->cr[CR_IOR ] = addr; +#else if (env->psw &PSW_Q ) {/* ??? Needs tweaking for hppa64. */ env->cr[CR_IOR ] = addr; env->cr[CR_ISR ] = addr >>32 ; } +#endif cpu_loop_exit_restore (cs, retaddr); } -#endif /* CONFIG_USER_ONLY */ static void hppa_cpu_realizefn (DeviceState *dev,Error **errp) {@@ -147,10 +150,10 @@ static const struct TCGCPUOps hppa_tcg_ops = { .synchronize_from_tb = hppa_cpu_synchronize_from_tb, .cpu_exec_interrupt = hppa_cpu_exec_interrupt, .tlb_fill = hppa_cpu_tlb_fill, + .do_unaligned_access = hppa_cpu_do_unaligned_access,#ifndef CONFIG_USER_ONLY .do_interrupt = hppa_cpu_do_interrupt, - .do_unaligned_access = hppa_cpu_do_unaligned_access,#endif /* !CONFIG_USER_ONLY */ };
PATCH v2 6/55 target/microblaze: Do not set MO_ALIGN for user-only
In reply to Richard HendersonThe kernel will fix up unaligned accesses, so emulate that by allowing unaligned accesses to succeed.
--- target/microblaze/translate.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
target/microblaze/translate.c +16 -0
@@ -727,6 +727,7 @@ static TCGv compute_ldst_addr_ea(DisasContext *dc, int ra, int rb) }#endif +#ifndef CONFIG_USER_ONLY static void record_unaligned_ess (DisasContext *dc,int rd,MemOp size,bool store) {
@@ -739,6 +740,7 @@ static void record_unaligned_ess(DisasContext *dc, int rd, tcg_set_insn_start_param(dc->insn_start, 1, iflags); } +#endif static bool do_load (DisasContext *dc,int rd,TCGv addr,MemOp mop,int mem_index,bool rev)
@@ -760,12 +762,19 @@ static bool do_load(DisasContext *dc, int rd, TCGv addr, MemOp mop, } } +/* +* For system mode, enforce alignment if the cpu configuration +* requires it. For user-mode, the Linux kernel will have fixed up +* any unaligned access, so emulate that by *not* setting MO_ALIGN. +*/ +#ifndef CONFIG_USER_ONLY if (size >MO_8 && (dc->tb_flags &MSR_EE ) && dc->cfg->unaligned_exceptions) {record_unaligned_ess (dc, rd, size, false); mop |=MO_ALIGN ; } +#endif tcg_gen_qemu_ld_i32 (reg_for_write (dc, rd), addr, mem_index, mop);
@@ -906,12 +915,19 @@ static bool do_store(DisasContext *dc, int rd, TCGv addr, MemOp mop, } } +/* +* For system mode, enforce alignment if the cpu configuration +* requires it. For user-mode, the Linux kernel will have fixed up +* any unaligned access, so emulate that by *not* setting MO_ALIGN. +*/ +#ifndef CONFIG_USER_ONLY if (size >MO_8 && (dc->tb_flags &MSR_EE ) && dc->cfg->unaligned_exceptions) {record_unaligned_ess (dc, rd, size, true); mop |=MO_ALIGN ; } +#endif tcg_gen_qemu_st_i32 (reg_for_read (dc, rd), addr, mem_index, mop);
Signature · 1 line
2.25.1
Re: [PATCH v2 06/55] target/microblaze: Do not set MO_ALIGN for user-only
Quoted 2 lines · Richard Henderson
The kernel will fix up unaligned accesses, so emulate that by allowing unaligned accesses to succeed.
Quoted 70 lines
Cc Edgar E. Iglesias <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/microblaze/translate.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)target/microblaze/translate.c +16
-0@@ -727,6 +727,7 @@ static TCGv compute_ldst_addr_ea(DisasContext *dc, int ra, int rb) }#endif +#ifndef CONFIG_USER_ONLY static void record_unaligned_ess (DisasContext *dc,int rd,MemOp size,bool store) {@@ -739,6 +740,7 @@ static void record_unaligned_ess(DisasContext *dc, int rd, tcg_set_insn_start_param(dc->insn_start, 1, iflags); } +#endif static bool do_load (DisasContext *dc,int rd,TCGv addr,MemOp mop,int mem_index,bool rev)@@ -760,12 +762,19 @@ static bool do_load(DisasContext *dc, int rd, TCGv addr, MemOp mop, } } +/* +* For system mode, enforce alignment if the cpu configuration +* requires it. For user-mode, the Linux kernel will have fixed up +* any unaligned access, so emulate that by *not* setting MO_ALIGN. +*/ +#ifndef CONFIG_USER_ONLY if (size >MO_8 && (dc->tb_flags &MSR_EE ) && dc->cfg->unaligned_exceptions) {record_unaligned_ess (dc, rd, size, false); mop |=MO_ALIGN ; } +#endif tcg_gen_qemu_ld_i32 (reg_for_write (dc, rd), addr, mem_index, mop);@@ -906,12 +915,19 @@ static bool do_store(DisasContext *dc, int rd, TCGv addr, MemOp mop, } } +/* +* For system mode, enforce alignment if the cpu configuration +* requires it. For user-mode, the Linux kernel will have fixed up +* any unaligned access, so emulate that by *not* setting MO_ALIGN. +*/ +#ifndef CONFIG_USER_ONLY if (size >MO_8 && (dc->tb_flags &MSR_EE ) && dc->cfg->unaligned_exceptions) {record_unaligned_ess (dc, rd, size, true); mop |=MO_ALIGN ; } +#endif tcg_gen_qemu_st_i32 (reg_for_read (dc, rd), addr, mem_index, mop);Signature · 1 line
2.25.1
PATCH v2 7/55 target/mips: Implement do_unaligned_access for user-only
In reply to Richard Henderson--- linux-user/mips/cpu_loop.c | 20 ++++++++++++++++---- target/mips/cpu.c | 2 +- target/mips/tcg/op_helper.c | 3 +-- target/mips/tcg/user/tlb_helper.c | 23 +++++++++++------------ 4 files changed, 29 insertions(+), 19 deletions(-)
linux-user/mips/cpu_loop.c +16 -4
@@ -158,12 +158,24 @@ done_syscall:break ;case EXCP_TLBL :case EXCP_TLBS : -case EXCP_AdEL: -case EXCP_AdES: info.si_signo =TARGET_SIGSEGV ; info.si_errno =0 ; -/* XXX: check env->error_code */ - info.si_code =TARGET_SEGV_MAPERR ; + info.si_code = (env->error_code &EXCP_TLB_NOMATCH + ?TARGET_SEGV_MAPERR :TARGET_SEGV_ACCERR ); + info._sifields._sigfault._addr = env->CP0_BadVAddr; +queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +break ; +case EXCP_AdEL: +case EXCP_AdES: +/* +* Note that on real hw AdE is also raised for access to a +* kernel address from user mode instead of a TLB error. +* For simplicity, we do not distinguish this in the user +* version of mips_cpu_tlb_fill so only unaligned comes here. +*/ + info.si_signo =TARGET_SIGBUS ; + info.si_errno =0 ; + info.si_code =TARGET_BUS_ADRALN ; info._sifields._sigfault._addr = env->CP0_BadVAddr;queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info);break ;
target/mips/cpu.c +1 -1
@@ -541,11 +541,11 @@ static const struct TCGCPUOps mips_tcg_ops = { .synchronize_from_tb = mips_cpu_synchronize_from_tb, .cpu_exec_interrupt = mips_cpu_exec_interrupt, .tlb_fill = mips_cpu_tlb_fill, + .do_unaligned_access = mips_cpu_do_unaligned_access, #if !defined(CONFIG_USER_ONLY) .do_interrupt = mips_cpu_do_interrupt, .do_transaction_failed = mips_cpu_do_transaction_failed, - .do_unaligned_access = mips_cpu_do_unaligned_access, .io_recompile_replay_branch = mips_io_recompile_replay_branch, #endif /* !CONFIG_USER_ONLY */ };
target/mips/tcg/op_helper.c +1 -2
@@ -375,8 +375,6 @@ void helper_pmon(CPUMIPSState *env, int function) } } -#if !defined(CONFIG_USER_ONLY ) -void mips_cpu_do_unaligned_access (CPUState *cs,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr)
@@ -402,6 +400,7 @@ void mips_cpu_do_unaligned_access(CPUState *cs, vaddr addr,do_raise_exception_err (env, excp, error_code, retaddr); } +#if !defined(CONFIG_USER_ONLY ) void mips_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type,
target/mips/tcg/user/tlb_helper.c +11 -12
@@ -26,24 +26,23 @@ static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, MMUAccessType access_type) {CPUState *cs =env_cpu (env); +int error_code =0 ; +int flags; - env->error_code =0 ;if (access_type ==MMU_INST_FETCH ) { - env->error_code |=EXCP_INST_NOTAVAIL ; + error_code |=EXCP_INST_NOTAVAIL ; } -/* Reference to kernel address from user mode or supervisor mode */ -/* Reference to supervisor address from user mode */ -if (access_type ==MMU_DATA_STORE ) { - cs->exception_index = EXCP_AdES; - }else { - cs->exception_index = EXCP_AdEL; + flags =page_get_flags (address); +if (!(flags &PAGE_VALID )) { + error_code |=EXCP_TLB_NOMATCH ; } -/* Raise exception */ -if (!(env->hflags &MIPS_HFLAG_DM )) { - env->CP0_BadVAddr = address; - } + cs->exception_index = (access_type ==MMU_DATA_STORE + ?EXCP_TLBS :EXCP_TLBL ); + + env->error_code = error_code; + env->CP0_BadVAddr = address; } bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
Signature · 1 line
2.25.1
Re: [PATCH v2 07/55] target/mips: Implement do_unaligned_access for user-only
Quoted 30 lines · Richard Henderson
Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- linux-user/mips/cpu_loop.c | 20 ++++++++++++++++---- target/mips/cpu.c | 2 +- target/mips/tcg/op_helper.c | 3 +-- target/mips/tcg/user/tlb_helper.c | 23 +++++++++++------------ 4 files changed, 29 insertions(+), 19 deletions(-)linux-user/mips/cpu_loop.c +6
-4@@ -158,12 +158,24 @@ done_syscall:break ;case EXCP_TLBL :case EXCP_TLBS : -case EXCP_AdEL: -case EXCP_AdES: info.si_signo =TARGET_SIGSEGV ; info.si_errno =0 ; -/* XXX: check env->error_code */ - info.si_code =TARGET_SEGV_MAPERR ; + info.si_code = (env->error_code &EXCP_TLB_NOMATCH + ?TARGET_SEGV_MAPERR :TARGET_SEGV_ACCERR ); + info._sifields._sigfault._addr = env->CP0_BadVAddr; +queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +break ; +case EXCP_AdEL:
linux-user/mips/cpu_loop.c done_syscall: · line 178
Quoted 10 lines
linux-user/mips/cpu_loop.c +10
-0+case EXCP_AdES: +/* +* Note that on real hw AdE is also raised for access to a +* kernel address from user mode instead of a TLB error. +* For simplicity, we do not distinguish this in the user +* version of mips_cpu_tlb_fill so only unaligned comes here. +*/ + info.si_signo =TARGET_SIGBUS ; + info.si_errno =0 ; + info.si_code =TARGET_BUS_ADRALN ;
The MIPS kernel code doesn't use si_code BUS_ADRALN for alignment errors, as far as I can see -- it just calls force_sig(SIGBUS):
https://elixir.bootlin.com/linux/latest/source/arch/mips/kernel/unaligned.c#L557
which gets you the same thing our force_sig() does: a code of SI_KERNEL. So I think we should be calling
force_sig(TARGET_SIGBUS);
here rather than filling in a target_siginfo_t and calling queue_signal().
linux-user/mips/cpu_loop.c done_syscall: · line 181
Quoted 3 lines
linux-user/mips/cpu_loop.c +0
-0info._sifields._sigfault._addr = env->CP0_BadVAddr;queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info);break ;
thanks
-- PMM
PATCH v2 8/55 target/ppc: Move SPR_DSISR setting to powerpc_excp
In reply to Richard HendersonBy doing this while sending the exception, we will have already done the unwinding, which makes the ppc_cpu_do_unaligned_access code a bit cleaner.
Update the comment about the expected instruction format.
--- target/ppc/excp_helper.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
target/ppc/excp_helper.c +9 -12
@@ -478,13 +478,15 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)break ; }case POWERPC_EXCP_ALIGN :/* Alignment exception */ -/* Get rS/rD and rA from faulting opcode */ /* -* Note: the opcode fields will not be set properly for a -* direct store load/store, but nobody cares as nobody -* actually uses direct store segments. +* Get rS/rD and rA from faulting opcode. +* Note: We will only invoke ALIGN for atomic operations, +* so all instructions are X-form. */ - env->spr[SPR_DSISR ] |= (env->error_code &0x03FF0000 ) >>16 ; + { +uint32_t insn =cpu_ldl_code (env, env->nip); + env->spr[SPR_DSISR ] |= (insn &0x03FF0000 ) >>16 ; + }break ;case POWERPC_EXCP_PROGRAM :/* Program exception */ switch (env->error_code & ~0xF ) {
@@ -1501,14 +1503,9 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, int mmu_idx, uintptr_t retaddr) {CPUPPCState *env = cs->env_ptr; -uint32_t insn; - -/* Restore state and reload the insn we executed, for filling in DSISR. */ -cpu_restore_state (cs, retaddr, true); - insn =cpu_ldl_code (env, env->nip); cs->exception_index =POWERPC_EXCP_ALIGN ; - env->error_code = insn &0x03FF0000 ; -cpu_loop_exit (cs); + env->error_code =0 ; +cpu_loop_exit_restore (cs, retaddr); }#endif
Signature · 1 line
2.25.1
PATCH v2 9/55 target/ppc: Set fault address in ppc_cpu_do_unaligned_access
In reply to Richard HendersonWe ought to have been recording the virtual address for reporting to the guest trap handler.
--- target/ppc/excp_helper.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
target/ppc/excp_helper.c +14 -0
@@ -1504,6 +1504,20 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, {CPUPPCState *env = cs->env_ptr; +switch (env->mmu_model) { +case POWERPC_MMU_SOFT_4xx: +case POWERPC_MMU_SOFT_4xx_Z: + env->spr[SPR_40x_DEAR] = vaddr; +break ; +case POWERPC_MMU_BOOKE : +case POWERPC_MMU_BOOKE206 : + env->spr[SPR_BOOKE_DEAR ] = vaddr; +break ; +default : + env->spr[SPR_DAR ] = vaddr; +break ; + } + cs->exception_index =POWERPC_EXCP_ALIGN ; env->error_code =0 ;cpu_loop_exit_restore (cs, retaddr);
Signature · 1 line
2.25.1
PATCH v2 10/55 target/ppc: Implement do_unaligned_access for user-only
In reply to Richard HendersonFor simplicity on the linux-user side, always use SPR_DAR.
--- linux-user/ppc/cpu_loop.c | 2 +- target/ppc/cpu_init.c | 2 +- target/ppc/excp_helper.c | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-)
linux-user/ppc/cpu_loop.c +1 -1
@@ -165,7 +165,7 @@ void cpu_loop(CPUPPCState *env) info.si_signo =TARGET_SIGBUS ; info.si_errno =0 ; info.si_code =TARGET_BUS_ADRALN ; - info._sifields._sigfault._addr = env->nip; + info._sifields._sigfault._addr = env->spr[SPR_DAR ];queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info);break ;case POWERPC_EXCP_PROGRAM :/* Program exception */
target/ppc/cpu_init.c +1 -1
@@ -9014,12 +9014,12 @@ static const struct TCGCPUOps ppc_tcg_ops = { .initialize = ppc_translate_init, .cpu_exec_interrupt = ppc_cpu_exec_interrupt, .tlb_fill = ppc_cpu_tlb_fill, + .do_unaligned_access = ppc_cpu_do_unaligned_access, #ifndef CONFIG_USER_ONLY .do_interrupt = ppc_cpu_do_interrupt, .cpu_exec_enter = ppc_cpu_exec_enter, .cpu_exec_exit = ppc_cpu_exec_exit, - .do_unaligned_access = ppc_cpu_do_unaligned_access, #endif /* !CONFIG_USER_ONLY */ };#endif /* CONFIG_TCG */
target/ppc/excp_helper.c +2 -0
@@ -1505,6 +1505,7 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,CPUPPCState *env = cs->env_ptr;switch (env->mmu_model) { +#ifndef CONFIG_USER_ONLY case POWERPC_MMU_SOFT_4xx:case POWERPC_MMU_SOFT_4xx_Z: env->spr[SPR_40x_DEAR] = vaddr;
@@ -1513,6 +1514,7 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,case POWERPC_MMU_BOOKE206 : env->spr[SPR_BOOKE_DEAR ] = vaddr;break ; +#endif default : env->spr[SPR_DAR ] = vaddr;break ;
Signature · 1 line
2.25.1
PATCH v2 11/55 target/riscv: Implement do_unaligned_access for user-only
In reply to Richard Henderson--- linux-user/riscv/cpu_loop.c | 7 +++++++ target/riscv/cpu.c | 2 +- target/riscv/cpu_helper.c | 8 +++++++- 3 files changed, 15 insertions(+), 2 deletions(-)
linux-user/riscv/cpu_loop.c +7 -0
@@ -92,6 +92,13 @@ void cpu_loop(CPURISCVState *env) sigcode =TARGET_SEGV_MAPERR ; sigaddr = env->badaddr;break ; +case RISCV_EXCP_INST_ADDR_MIS : +case RISCV_EXCP_LOAD_ADDR_MIS : +case RISCV_EXCP_STORE_AMO_ADDR_MIS : + signum =TARGET_SIGBUS ; + sigcode =TARGET_BUS_ADRALN ; + sigaddr = env->badaddr; +break ;case RISCV_EXCP_SEMIHOST : env->gpr[xA0] =do_common_semihosting (cs); env->pc +=4 ;
target/riscv/cpu.c +1 -1
@@ -644,11 +644,11 @@ static const struct TCGCPUOps riscv_tcg_ops = { .synchronize_from_tb = riscv_cpu_synchronize_from_tb, .cpu_exec_interrupt = riscv_cpu_exec_interrupt, .tlb_fill = riscv_cpu_tlb_fill, + .do_unaligned_access = riscv_cpu_do_unaligned_access, #ifndef CONFIG_USER_ONLY .do_interrupt = riscv_cpu_do_interrupt, .do_transaction_failed = riscv_cpu_do_transaction_failed, - .do_unaligned_access = riscv_cpu_do_unaligned_access, #endif /* !CONFIG_USER_ONLY */ };
target/riscv/cpu_helper.c +7 -1
@@ -727,6 +727,7 @@ void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,riscv_cpu_two_stage_lookup (mmu_idx);riscv_raise_exception (&cpu->env, cs->exception_index, retaddr); } +#endif /* !CONFIG_USER_ONLY */ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx,
@@ -734,6 +735,7 @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr, {RISCVCPU *cpu =RISCV_CPU (cs);CPURISCVState *env = &cpu->env; +switch (access_type) {case MMU_INST_FETCH : cs->exception_index =RISCV_EXCP_INST_ADDR_MIS ;
@@ -748,11 +750,15 @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,g_assert_not_reached (); } env->badaddr = addr; + +#ifdef CONFIG_USER_ONLY +cpu_loop_exit_restore (cs, retaddr); +#else env->two_stage_lookup =riscv_cpu_virt_enabled (env) ||riscv_cpu_two_stage_lookup (mmu_idx);riscv_raise_exception (env, cs->exception_index, retaddr); +#endif } -#endif /* !CONFIG_USER_ONLY */ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx,
Signature · 1 line
2.25.1
PATCH v2 12/55 target/s390x: Implement do_unaligned_access for user-only
In reply to Richard Henderson--- target/s390x/cpu.c | 2 +- target/s390x/tcg/excp_helper.c | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-)
target/s390x/cpu.c +1 -1
@@ -267,12 +267,12 @@ static void s390_cpu_reset_full(DeviceState *dev)static const struct TCGCPUOps s390_tcg_ops = { .initialize = s390x_translate_init, .tlb_fill = s390_cpu_tlb_fill, + .do_unaligned_access = s390x_cpu_do_unaligned_access, #if !defined(CONFIG_USER_ONLY) .cpu_exec_interrupt = s390_cpu_exec_interrupt, .do_interrupt = s390_cpu_do_interrupt, .debug_excp_handler = s390x_cpu_debug_excp_handler, - .do_unaligned_access = s390x_cpu_do_unaligned_access, #endif /* !CONFIG_USER_ONLY */ };#endif /* CONFIG_TCG */
target/s390x/tcg/excp_helper.c +15 -13
@@ -82,6 +82,21 @@ void HELPER(data_exception)(CPUS390XState *env, uint32_t dxc)tcg_s390_data_exception (env, dxc,GETPC ()); } +/* +* Unaligned accesses are only diagnosed with MO_ALIGN. At the moment, +* this is only for the atomic operations, for which we want to raise a +* specification exception. +*/ +void s390x_cpu_do_unaligned_access (CPUState *cs,vaddr addr, +MMUAccessType access_type, +int mmu_idx,uintptr_t retaddr) +{ +S390CPU *cpu =S390_CPU (cs); +CPUS390XState *env = &cpu->env; + +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , retaddr); +} +#if defined(CONFIG_USER_ONLY )void s390_cpu_do_interrupt (CPUState *cs)
@@ -602,19 +617,6 @@ void s390x_cpu_debug_excp_handler(CPUState *cs) } } -/* Unaligned accesses are only diagnosed with MO_ALIGN. At the moment, -this is only for the atomic operations, for which we want to raise a -specification exception. */ -void s390x_cpu_do_unaligned_access (CPUState *cs,vaddr addr, -MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr) -{ -S390CPU *cpu =S390_CPU (cs); -CPUS390XState *env = &cpu->env; - -tcg_s390_program_interrupt (env,PGM_SPECIFICATION , retaddr); -} - static void QEMU_NORETURN monitor_event(CPUS390XState *env,uint64_t monitor_code,uint8_t monitor_class,uintptr_t ra)
Signature · 1 line
2.25.1
Re: [PATCH v2 12/55] target/s390x: Implement do_unaligned_access for user-only
Quoted 6 lines · Richard Henderson
Reviewed-by David Hildenbrand <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/s390x/cpu.c | 2 +- target/s390x/tcg/excp_helper.c | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-)
PATCH v2 13/55 target/sh4: Set fault address in superh_cpu_do_unaligned_access
In reply to Richard HendersonWe ought to have been recording the virtual address for reporting to the guest trap handler.
--- target/sh4/op_helper.c | 5 +++++ 1 file changed, 5 insertions(+)
target/sh4/op_helper.c +5 -0
@@ -29,6 +29,9 @@ void superh_cpu_do_unaligned_access(CPUState *cs, vaddr addr,MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { + CPUSH4State *env = cs->env_ptr; + + env->tea = addr;switch (access_type) {case MMU_INST_FETCH :case MMU_DATA_LOAD :
@@ -37,6 +40,8 @@ void superh_cpu_do_unaligned_access(CPUState *cs, vaddr addr,case MMU_DATA_STORE : cs->exception_index =0x100 ;break ; +default : +g_assert_not_reached (); }cpu_loop_exit_restore (cs, retaddr); }
Signature · 1 line
2.25.1
PATCH v2 14/55 target/sh4: Implement do_unaligned_access for user-only
In reply to Richard Henderson--- linux-user/sh4/cpu_loop.c | 8 ++++++++ target/sh4/cpu.c | 2 +- target/sh4/op_helper.c | 3 --- 3 files changed, 9 insertions(+), 4 deletions(-)
linux-user/sh4/cpu_loop.c +8 -0
@@ -71,6 +71,14 @@ void cpu_loop(CPUSH4State *env) info._sifields._sigfault._addr = env->tea;queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info);break ; +case 0xe0 : +case 0x100 : + info.si_signo =TARGET_SIGBUS ; + info.si_errno =0 ; + info.si_code =TARGET_BUS_ADRALN ; + info._sifields._sigfault._addr = env->tea; +queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +break ;case EXCP_ATOMIC :cpu_exec_step_atomic (cs); arch_interrupt = false;
target/sh4/cpu.c +1 -1
@@ -238,10 +238,10 @@ static const struct TCGCPUOps superh_tcg_ops = { .synchronize_from_tb = superh_cpu_synchronize_from_tb, .cpu_exec_interrupt = superh_cpu_exec_interrupt, .tlb_fill = superh_cpu_tlb_fill, + .do_unaligned_access = superh_cpu_do_unaligned_access, #ifndef CONFIG_USER_ONLY .do_interrupt = superh_cpu_do_interrupt, - .do_unaligned_access = superh_cpu_do_unaligned_access, .io_recompile_replay_branch = superh_io_recompile_replay_branch, #endif /* !CONFIG_USER_ONLY */ };
target/sh4/op_helper.c +0 -3
@@ -23,7 +23,6 @@#include "exec/cpu_ldst.h" #include "fpu/softfloat.h" -#ifndef CONFIG_USER_ONLY void superh_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type,
@@ -46,8 +45,6 @@ void superh_cpu_do_unaligned_access(CPUState *cs, vaddr addr,cpu_loop_exit_restore (cs, retaddr); } -#endif -void helper_ldtlb (CPUSH4State *env) {#ifdef CONFIG_USER_ONLY
Signature · 1 line
2.25.1
PATCH v2 15/55 target/sparc: Remove DEBUG_UNALIGNED
In reply to Richard HendersonThe printf should have been qemu_log_mask, the parameters themselves no longer compile, and because this is placed before unwinding the PC is actively wrong.
We get better (and correct) logging on the other side of raising the exception, in sparc_cpu_do_interrupt.
--- target/sparc/ldst_helper.c | 9 --------- 1 file changed, 9 deletions(-)
target/sparc/ldst_helper.c +0 -9
@@ -27,7 +27,6 @@//#define DEBUG_MMU //#define DEBUG_MXCC -//#define DEBUG_UNALIGNED //#define DEBUG_UNASSIGNED //#define DEBUG_ASI //#define DEBUG_CACHE_CONTROL
@@ -364,10 +363,6 @@ static void do_check_align(CPUSPARCState *env, target_ulong addr, uint32_t align, uintptr_t ra) {if (addr & align) { -#ifdef DEBUG_UNALIGNED -printf ("Unaligned access to 0x" TARGET_FMT_lx" from 0x" TARGET_FMT_lx -"\n" , addr, env->pc); -#endif cpu_raise_exception_ra (env,TT_UNALIGNED , ra); } }
@@ -1968,10 +1963,6 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,SPARCCPU *cpu =SPARC_CPU (cs);CPUSPARCState *env = &cpu->env; -#ifdef DEBUG_UNALIGNED -printf ("Unaligned access to 0x" TARGET_FMT_lx" from 0x" TARGET_FMT_lx -"\n" , addr, env->pc); -#endif cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr); }#endif
Signature · 1 line
2.25.1
Re: [PATCH v2 15/55] target/sparc: Remove DEBUG_UNALIGNED
Quoted 38 lines · Richard Henderson
The printf should have been
qemu_log_mask, the parameters themselves no longer compile, and because this is placed before unwinding the PC is actively wrong.We get better (and correct) logging on the other side of raising the exception, in
sparc_cpu_do_interrupt.Cc Mark Cave-Ayland <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/sparc/ldst_helper.c | 9 --------- 1 file changed, 9 deletions(-)target/sparc/ldst_helper.c +0
-5@@ -27,7 +27,6 @@//#define DEBUG_MMU //#define DEBUG_MXCC -//#define DEBUG_UNALIGNED //#define DEBUG_UNASSIGNED //#define DEBUG_ASI //#define DEBUG_CACHE_CONTROL @@ -364,10 +363,6 @@ static void do_check_align(CPUSPARCState *env, target_ulong addr, uint32_t align, uintptr_t ra) {if (addr & align) { -#ifdef DEBUG_UNALIGNED -printf ("Unaligned access to 0x" TARGET_FMT_lx" from 0x" TARGET_FMT_lx -"\n" , addr, env->pc); -#endif cpu_raise_exception_ra (env,TT_UNALIGNED , ra); } }
target/sparc/ldst_helper.c void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, · line 1968
Quoted 10 lines
target/sparc/ldst_helper.c +0
-4@@ -1968,10 +1963,6 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,SPARCCPU *cpu =SPARC_CPU (cs);CPUSPARCState *env = &cpu->env; -#ifdef DEBUG_UNALIGNED -printf ("Unaligned access to 0x" TARGET_FMT_lx" from 0x" TARGET_FMT_lx -"\n" , addr, env->pc); -#endif cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr); }#endif
Indeed. I suspect that this was originally intended for developers to capture that an unaligned access occurred rather than processing it correctly.
ATB,
Mark.
PATCH v2 16/55 target/sparc: Split out build_sfsr
In reply to Richard Henderson--- target/sparc/mmu_helper.c | 72 +++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 26 deletions(-)
target/sparc/mmu_helper.c +46 -26
@@ -526,16 +526,60 @@ static inline int ultrasparc_tag_match(SparcTLBEntry *tlb,return 0 ; } +static uint64_t build_sfsr (CPUSPARCState *env,int mmu_idx,int rw) +{ +uint64_t sfsr =SFSR_VALID_BIT ; + +switch (mmu_idx) { +case MMU_PHYS_IDX : + sfsr |=SFSR_CT_NOTRANS ; +break ; +case MMU_USER_IDX : +case MMU_KERNEL_IDX : + sfsr |=SFSR_CT_PRIMARY ; +break ; +case MMU_USER_SECONDARY_IDX : +case MMU_KERNEL_SECONDARY_IDX : + sfsr |=SFSR_CT_SECONDARY ; +break ; +case MMU_NUCLEUS_IDX : + sfsr |=SFSR_CT_NUCLEUS ; +break ; +default : +g_assert_not_reached (); + } + +if (rw ==1 ) { + sfsr |=SFSR_WRITE_BIT ; + }else if (rw ==4 ) { + sfsr |=SFSR_NF_BIT ; + } + +if (env->pstate &PS_PRIV ) { + sfsr |=SFSR_PR_BIT ; + } + +if (env->dmmu.sfsr &SFSR_VALID_BIT ) {/* Fault status register */ + sfsr |=SFSR_OW_BIT ;/* overflow (not read before another fault) */ + } + +/* FIXME: ASI field in SFSR must be set */ + +return sfsr; +} +static int get_physical_address_data (CPUSPARCState *env,hwaddr *physical,int *prot,MemTxAttrs *attrs,target_ulong address,int rw,int mmu_idx) {CPUState *cs =env_cpu (env);unsigned int i; +uint64_t sfsr;uint64_t context; -uint64_t sfsr =0 ;bool is_user = false; + sfsr =build_sfsr (env, mmu_idx, rw); +switch (mmu_idx) {case MMU_PHYS_IDX :g_assert_not_reached ();
@@ -544,29 +588,18 @@ static int get_physical_address_data(CPUSPARCState *env, hwaddr *physical,/* fallthru */ case MMU_KERNEL_IDX : context = env->dmmu.mmu_primary_context &0x1fff ; - sfsr |=SFSR_CT_PRIMARY ;break ;case MMU_USER_SECONDARY_IDX : is_user = true;/* fallthru */ case MMU_KERNEL_SECONDARY_IDX : context = env->dmmu.mmu_secondary_context &0x1fff ; - sfsr |=SFSR_CT_SECONDARY ;break ; -case MMU_NUCLEUS_IDX : - sfsr |=SFSR_CT_NUCLEUS ; -/* FALLTHRU */ default : context =0 ;break ; } -if (rw ==1 ) { - sfsr |=SFSR_WRITE_BIT ; - }else if (rw ==4 ) { - sfsr |=SFSR_NF_BIT ; - } -for (i =0 ; i <64 ; i++) {/* ctx match, vaddr match, valid? */ if (ultrasparc_tag_match (&env->dtlb[i], address, context, physical)) {
@@ -616,22 +649,9 @@ static int get_physical_address_data(CPUSPARCState *env, hwaddr *physical,return 0 ; } -if (env->dmmu.sfsr &SFSR_VALID_BIT ) {/* Fault status register */ - sfsr |=SFSR_OW_BIT ;/* overflow (not read before -another fault) */ - } - -if (env->pstate &PS_PRIV ) { - sfsr |=SFSR_PR_BIT ; - } - -/* FIXME: ASI field in SFSR must be set */ - env->dmmu.sfsr = sfsr |SFSR_VALID_BIT ; - + env->dmmu.sfsr = sfsr; env->dmmu.sfar = address;/* Fault address register */ - env->dmmu.tag_access = (address & ~0x1fffULL ) | context; -return 1 ; } }
Signature · 1 line
2.25.1
Re: [PATCH v2 16/55] target/sparc: Split out build_sfsr
Quoted 115 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- target/sparc/mmu_helper.c | 72 +++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 26 deletions(-)target/sparc/mmu_helper.c +45
-22@@ -526,16 +526,60 @@ static inline int ultrasparc_tag_match(SparcTLBEntry *tlb,return 0 ; } +static uint64_t build_sfsr (CPUSPARCState *env,int mmu_idx,int rw) +{ +uint64_t sfsr =SFSR_VALID_BIT ; + +switch (mmu_idx) { +case MMU_PHYS_IDX : + sfsr |=SFSR_CT_NOTRANS ; +break ; +case MMU_USER_IDX : +case MMU_KERNEL_IDX : + sfsr |=SFSR_CT_PRIMARY ; +break ; +case MMU_USER_SECONDARY_IDX : +case MMU_KERNEL_SECONDARY_IDX : + sfsr |=SFSR_CT_SECONDARY ; +break ; +case MMU_NUCLEUS_IDX : + sfsr |=SFSR_CT_NUCLEUS ; +break ; +default : +g_assert_not_reached (); + } + +if (rw ==1 ) { + sfsr |=SFSR_WRITE_BIT ; + }else if (rw ==4 ) { + sfsr |=SFSR_NF_BIT ; + } + +if (env->pstate &PS_PRIV ) { + sfsr |=SFSR_PR_BIT ; + } + +if (env->dmmu.sfsr &SFSR_VALID_BIT ) {/* Fault status register */ + sfsr |=SFSR_OW_BIT ;/* overflow (not read before another fault) */ + } + +/* FIXME: ASI field in SFSR must be set */ + +return sfsr; +} +static int get_physical_address_data (CPUSPARCState *env,hwaddr *physical,int *prot,MemTxAttrs *attrs,target_ulong address,int rw,int mmu_idx) {CPUState *cs =env_cpu (env);unsigned int i; +uint64_t sfsr;uint64_t context; -uint64_t sfsr =0 ;bool is_user = false; + sfsr =build_sfsr (env, mmu_idx, rw); +switch (mmu_idx) {case MMU_PHYS_IDX :g_assert_not_reached ();@@ -544,29 +588,18 @@ static int get_physical_address_data(CPUSPARCState *env, hwaddr *physical,/* fallthru */ case MMU_KERNEL_IDX : context = env->dmmu.mmu_primary_context &0x1fff ; - sfsr |=SFSR_CT_PRIMARY ;break ;case MMU_USER_SECONDARY_IDX : is_user = true;/* fallthru */ case MMU_KERNEL_SECONDARY_IDX : context = env->dmmu.mmu_secondary_context &0x1fff ; - sfsr |=SFSR_CT_SECONDARY ;break ; -case MMU_NUCLEUS_IDX : - sfsr |=SFSR_CT_NUCLEUS ; -/* FALLTHRU */ default : context =0 ;break ; } -if (rw ==1 ) { - sfsr |=SFSR_WRITE_BIT ; - }else if (rw ==4 ) { - sfsr |=SFSR_NF_BIT ; - } -for (i =0 ; i <64 ; i++) {/* ctx match, vaddr match, valid? */ if (ultrasparc_tag_match (&env->dtlb[i], address, context, physical)) {@@ -616,22 +649,9 @@ static int get_physical_address_data(CPUSPARCState *env, hwaddr *physical,return 0 ; } -if (env->dmmu.sfsr &SFSR_VALID_BIT ) {/* Fault status register */ - sfsr |=SFSR_OW_BIT ;/* overflow (not read before -another fault) */ - } - -if (env->pstate &PS_PRIV ) { - sfsr |=SFSR_PR_BIT ; - } - -/* FIXME: ASI field in SFSR must be set */
target/sparc/mmu_helper.c static int get_physical_address_data(CPUSPARCState *env, hwaddr *physical, · line 657
Quoted 10 lines
target/sparc/mmu_helper.c +1
-4- env->dmmu.sfsr = sfsr |SFSR_VALID_BIT ; - + env->dmmu.sfsr = sfsr; env->dmmu.sfar = address;/* Fault address register */ - env->dmmu.tag_access = (address & ~0x1fffULL ) | context; -return 1 ; } }
ATB,
Mark.
PATCH v2 17/55 target/sparc: Set fault address in sparc_cpu_do_unaligned_access
In reply to Richard HendersonWe ought to have been recording the virtual address for reporting to the guest trap handler. Move the function to mmu_helper.c, so that we can re-use code shared with get_physical_address_data.
--- target/sparc/ldst_helper.c | 13 ------------- target/sparc/mmu_helper.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 13 deletions(-)
target/sparc/ldst_helper.c +0 -13
@@ -1953,16 +1953,3 @@ void sparc_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, 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, -uintptr_t retaddr) -{ -SPARCCPU *cpu =SPARC_CPU (cs); -CPUSPARCState *env = &cpu->env; - -cpu_raise_exception_ra (env,TT_UNALIGNED , retaddr); -} -#endif
target/sparc/mmu_helper.c +18 -0
@@ -946,4 +946,22 @@ hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) }return phys_addr; } + +void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, +MMUAccessType access_type, +int mmu_idx, +uintptr_t retaddr) +{ +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env; + +#ifdef TARGET_SPARC64 + env->dmmu.sfsr =build_sfsr (env, mmu_idx, access_type); + env->dmmu.sfar = addr; +#else + env->mmuregs[4 ] = addr;#endif + +cpu_raise_exception_ra (env,TT_UNALIGNED , retaddr); +} +#endif /* CONFIG_USER_ONLY */
Signature · 1 line
2.25.1
Re: [PATCH v2 17/55] target/sparc: Set fault address in sparc_cpu_do_unaligned_access
Quoted 49 lines · Richard Henderson
We ought to have been recording the virtual address for reporting to the guest trap handler. Move the function to
mmu_helper.c, so that we can re-use code shared withget_physical_address_data.Cc Mark Cave-Ayland <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/sparc/ldst_helper.c | 13 ------------- target/sparc/mmu_helper.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 13 deletions(-)target/sparc/ldst_helper.c +0
-13@@ -1953,16 +1953,3 @@ void sparc_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, 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, -uintptr_t retaddr) -{ -SPARCCPU *cpu =SPARC_CPU (cs); -CPUSPARCState *env = &cpu->env; - -cpu_raise_exception_ra (env,TT_UNALIGNED , retaddr); -} -#endif target/sparc/mmu_helper.c +9
-0@@ -946,4 +946,22 @@ hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) }return phys_addr; } + +void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, +MMUAccessType access_type, +int mmu_idx, +uintptr_t retaddr) +{ +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env; +
target/sparc/mmu_helper.c hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) · line 967
Quoted 10 lines
target/sparc/mmu_helper.c +9
-0+#ifdef TARGET_SPARC64 + env->dmmu.sfsr =build_sfsr (env, mmu_idx, access_type); + env->dmmu.sfar = addr; +#else + env->mmuregs[4 ] = addr;#endif + + cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr); +} +#endif /* CONFIG_USER_ONLY */
ATB,
Mark.
PATCH v2 18/55 target/sparc: Implement do_unaligned_access for user-only
In reply to Richard Henderson--- linux-user/sparc/cpu_loop.c | 11 +++++++++++ target/sparc/cpu.c | 2 +- target/sparc/mmu_helper.c | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-)
linux-user/sparc/cpu_loop.c +11 -0
@@ -272,6 +272,17 @@ void cpu_loop (CPUSPARCState *env)queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); }break ; +case TT_UNALIGNED : + info.si_signo =TARGET_SIGBUS ; + info.si_errno =0 ; + info.si_code =TARGET_BUS_ADRALN ; +#ifdef TARGET_SPARC64 + info._sifields._sigfault._addr = env->dmmu.sfar; +#else + info._sifields._sigfault._addr = env->mmuregs[4 ]; +#endif +queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +break ;case EXCP_DEBUG : info.si_signo =TARGET_SIGTRAP ; info.si_errno =0 ;
target/sparc/cpu.c +1 -1
@@ -865,11 +865,11 @@ static const struct TCGCPUOps sparc_tcg_ops = { .synchronize_from_tb = sparc_cpu_synchronize_from_tb, .cpu_exec_interrupt = sparc_cpu_exec_interrupt, .tlb_fill = sparc_cpu_tlb_fill, + .do_unaligned_access = sparc_cpu_do_unaligned_access, #ifndef CONFIG_USER_ONLY .do_interrupt = sparc_cpu_do_interrupt, .do_transaction_failed = sparc_cpu_do_transaction_failed, - .do_unaligned_access = sparc_cpu_do_unaligned_access, #endif /* !CONFIG_USER_ONLY */ };#endif /* CONFIG_TCG */
target/sparc/mmu_helper.c +3 -1
@@ -946,6 +946,7 @@ hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) }return phys_addr; } +#endif /* CONFIG_USER_ONLY */ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type,
@@ -956,7 +957,9 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,CPUSPARCState *env = &cpu->env;#ifdef TARGET_SPARC64 +#ifndef CONFIG_USER_ONLY env->dmmu.sfsr =build_sfsr (env, mmu_idx, access_type); +#endif env->dmmu.sfar = addr;#else env->mmuregs[4 ] = addr;
@@ -964,4 +967,3 @@ void QEMU_NORETURN 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.25.1
Re: [PATCH v2 18/55] target/sparc: Implement do_unaligned_access for user-only
Quoted 70 lines · Richard Henderson
Cc Mark Cave-Ayland <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- linux-user/sparc/cpu_loop.c | 11 +++++++++++ target/sparc/cpu.c | 2 +- target/sparc/mmu_helper.c | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-)linux-user/sparc/cpu_loop.c +11
-0@@ -272,6 +272,17 @@ void cpu_loop (CPUSPARCState *env)queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); }break ; +case TT_UNALIGNED : + info.si_signo =TARGET_SIGBUS ; + info.si_errno =0 ; + info.si_code =TARGET_BUS_ADRALN ; +#ifdef TARGET_SPARC64 + info._sifields._sigfault._addr = env->dmmu.sfar; +#else + info._sifields._sigfault._addr = env->mmuregs[4 ]; +#endif +queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +break ;case EXCP_DEBUG : info.si_signo =TARGET_SIGTRAP ; info.si_errno =0 ;target/sparc/cpu.c +1
-1@@ -865,11 +865,11 @@ static const struct TCGCPUOps sparc_tcg_ops = { .synchronize_from_tb = sparc_cpu_synchronize_from_tb, .cpu_exec_interrupt = sparc_cpu_exec_interrupt, .tlb_fill = sparc_cpu_tlb_fill, + .do_unaligned_access = sparc_cpu_do_unaligned_access, #ifndef CONFIG_USER_ONLY .do_interrupt = sparc_cpu_do_interrupt, .do_transaction_failed = sparc_cpu_do_transaction_failed, - .do_unaligned_access = sparc_cpu_do_unaligned_access, #endif /* !CONFIG_USER_ONLY */ };#endif /* CONFIG_TCG */ target/sparc/mmu_helper.c +3
-0@@ -946,6 +946,7 @@ hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) }return phys_addr; } +#endif /* CONFIG_USER_ONLY */ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type,@@ -956,7 +957,9 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,CPUSPARCState *env = &cpu->env;#ifdef TARGET_SPARC64 +#ifndef CONFIG_USER_ONLY env->dmmu.sfsr =build_sfsr (env, mmu_idx, access_type); +#endif env->dmmu.sfar = addr;#else env->mmuregs[4 ] = addr;
target/sparc/mmu_helper.c void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, · line 967
Quoted 4 lines
target/sparc/mmu_helper.c +0
-1@@ -964,4 +967,3 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,cpu_raise_exception_ra (env,TT_UNALIGNED , retaddr); } -#endif /* CONFIG_USER_ONLY */
I'm fairly weak on the user side, however the setting of the fault address looks okay to me so:
ATB,
Mark.
PATCH v2 19/55 target/xtensa: Implement do_unaligned_access for user-only
In reply to Richard Henderson--- target/xtensa/cpu.c | 2 +- target/xtensa/helper.c | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-)
target/xtensa/cpu.c +1 -1
@@ -195,11 +195,11 @@ static const struct TCGCPUOps xtensa_tcg_ops = { .cpu_exec_interrupt = xtensa_cpu_exec_interrupt, .tlb_fill = xtensa_cpu_tlb_fill, .debug_excp_handler = xtensa_breakpoint_handler, + .do_unaligned_access = xtensa_cpu_do_unaligned_access, #ifndef CONFIG_USER_ONLY .do_interrupt = xtensa_cpu_do_interrupt, .do_transaction_failed = xtensa_cpu_do_transaction_failed, - .do_unaligned_access = xtensa_cpu_do_unaligned_access, #endif /* !CONFIG_USER_ONLY */ };
target/xtensa/helper.c +15 -15
@@ -242,6 +242,21 @@ void xtensa_cpu_list(void) } } +void xtensa_cpu_do_unaligned_access (CPUState *cs, +vaddr addr,MMUAccessType access_type, +int mmu_idx,uintptr_t retaddr) +{ +XtensaCPU *cpu =XTENSA_CPU (cs); +CPUXtensaState *env = &cpu->env; + +assert (xtensa_option_enabled (env->config, +XTENSA_OPTION_UNALIGNED_EXCEPTION )); +cpu_restore_state (CPU (cpu), retaddr, true); +HELPER (exception_cause_vaddr)(env, + env->pc,LOAD_STORE_ALIGNMENT_CAUSE , + addr); +} +#ifdef CONFIG_USER_ONLY bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
@@ -263,21 +278,6 @@ bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,#else /* !CONFIG_USER_ONLY */ -void xtensa_cpu_do_unaligned_access (CPUState *cs, -vaddr addr,MMUAccessType access_type, -int mmu_idx,uintptr_t retaddr) -{ -XtensaCPU *cpu =XTENSA_CPU (cs); -CPUXtensaState *env = &cpu->env; - -assert (xtensa_option_enabled (env->config, -XTENSA_OPTION_UNALIGNED_EXCEPTION )); -cpu_restore_state (CPU (cpu), retaddr, true); -HELPER (exception_cause_vaddr)(env, - env->pc,LOAD_STORE_ALIGNMENT_CAUSE , - addr); -} -bool xtensa_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr)
Signature · 1 line
2.25.1
Re: [PATCH v2 19/55] target/xtensa: Implement do_unaligned_access for user-only
Quoted 7 lines · Richard Henderson
Cc Max Filippov <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/xtensa/cpu.c | 2 +- target/xtensa/helper.c | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-)
Signature · 2 lines
Thanks. -- Max
Re: [PATCH v2 19/55] target/xtensa: Implement do_unaligned_access for user-only
In reply to Richard HendersonQuoted 6 lines · Richard Henderson
Cc Max Filippov <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/xtensa/cpu.c | 2 +- target/xtensa/helper.c | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-)
PATCH v2 20/55 accel/tcg: Report unaligned atomics for user-only
In reply to Richard HendersonUse the newly exposed cpu_unaligned_access for atomic_mmu_lookup, which has access to complete alignment info from the TCGMemOpIdx arg.
--- accel/tcg/user-exec.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
accel/tcg/user-exec.c +13 -1
@@ -28,6 +28,7 @@#include "qemu/atomic128.h" #include "trace/trace-root.h" #include "trace/mem.h" +#include "internal.h" #undef EAX#undef ECX
@@ -1230,11 +1231,22 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, int size, int prot, uintptr_t retaddr) { + MemOp mop = get_memop(oi); +int a_bits =get_alignment_bits (mop); +void *ret; + +/* Enforce guest required alignment. */ +if (unlikely (addr & ((1 << a_bits) -1 ))) { +MMUAccessType t = prot ==PAGE_READ ?MMU_DATA_LOAD :MMU_DATA_STORE ; +cpu_unaligned_access (env_cpu (env), addr, t,get_mmuidx (oi), retaddr); + } +/* Enforce qemu required alignment. */ if (unlikely (addr & (size -1 ))) {cpu_loop_exit_atomic (env_cpu (env), retaddr); } -void *ret =g2h (env_cpu (env), addr); + + ret =g2h (env_cpu (env), addr);set_helper_retaddr (retaddr);return ret; }
Signature · 1 line
2.25.1
Re: [PATCH v2 20/55] accel/tcg: Report unaligned atomics for user-only
Quoted 4 lines · Richard Henderson
Use the newly exposed
cpu_unaligned_accessforatomic_mmu_lookup, which has access to complete alignment info from the TCGMemOpIdx arg.Signed-off-by Richard Henderson <[email protected]>
<snip>
Quoted 6 lines
accel/tcg/user-exec.c +2
-1-void *ret =g2h (env_cpu (env), addr); + + ret =g2h (env_cpu (env), addr);set_helper_retaddr (retaddr);return ret; }
Signature · 1 line
Alex Bennée
Re: [PATCH v2 20/55] accel/tcg: Report unaligned atomics for user-only
In reply to Richard HendersonHi Richard,
Quoted 33 lines · Richard Henderson
Use the newly exposed
cpu_unaligned_accessforatomic_mmu_lookup, which has access to complete alignment info from the TCGMemOpIdx arg.Signed-off-by Richard Henderson <[email protected]>--- accel/tcg/user-exec.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)accel/tcg/user-exec.c +10
-0@@ -28,6 +28,7 @@#include "qemu/atomic128.h" #include "trace/trace-root.h" #include "trace/mem.h" +#include "internal.h" #undef EAX#undef ECX@@ -1230,11 +1231,22 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, int size, int prot, uintptr_t retaddr) { + MemOp mop = get_memop(oi); +int a_bits =get_alignment_bits (mop); +void *ret; + +/* Enforce guest required alignment. */ +if (unlikely (addr & ((1 << a_bits) -1 ))) { +MMUAccessType t = prot ==PAGE_READ ?MMU_DATA_LOAD :MMU_DATA_STORE ; +cpu_unaligned_access (env_cpu (env), addr, t,get_mmuidx (oi), retaddr); + }
accel/tcg/user-exec.c static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, · line 1251
Quoted 10 lines
accel/tcg/user-exec.c +3
-1+/* Enforce qemu required alignment. */ if (unlikely (addr & (size -1 ))) {cpu_loop_exit_atomic (env_cpu (env), retaddr); } -void *ret =g2h (env_cpu (env), addr); + + ret =g2h (env_cpu (env), addr);set_helper_retaddr (retaddr);return ret;
Can't we simply do:
return g2h(env_cpu(env), addr);
?
Quoted 2 lines
accel/tcg/user-exec.c +0
-0}
Re: [PATCH v2 20/55] accel/tcg: Report unaligned atomics for user-only
Quoted 11 lines · Philippe Mathieu-Daudé
accel/tcg/user-exec.c static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, · line 1251
Quoted 5 lines
accel/tcg/user-exec.c +2
-1-void *ret =g2h (env_cpu (env), addr); + + ret =g2h (env_cpu (env), addr);set_helper_retaddr (retaddr);return ret;Can't we simply do:
return g2h(env_cpu(env), addr);?
I think the idea was to narrow the range of instructions in which helper_retaddr is set, because {set,clear}_helper_retaddr contain barriers. I didn't give it more thought this time around, just kept the ordering.
r~
PATCH v2 21/55 accel/tcg: Drop signness in tracing in cputlb.c
In reply to Richard HendersonWe are already inconsistent about whether or not MO_SIGN is set in trace_mem_get_info. Dropping it entirely allows some simplification.
--- accel/tcg/cputlb.c | 10 +++------- accel/tcg/user-exec.c | 45 ++++++------------------------------------- 2 files changed, 9 insertions(+), 46 deletions(-)
accel/tcg/cputlb.c +3 -7
@@ -2110,7 +2110,6 @@ static inline uint64_t cpu_load_helper(CPUArchState *env, abi_ptr addr, meminfo =trace_mem_get_info (op, mmu_idx, false);trace_guest_mem_before_exec (env_cpu (env), addr, meminfo); - op &= ~MO_SIGN ; oi =make_memop_idx (op, mmu_idx); ret =full_load (env, addr, oi, retaddr);
@@ -2128,8 +2127,7 @@ uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,int cpu_ldsb_mmuidx_ra (CPUArchState *env,abi_ptr addr,int mmu_idx,uintptr_t ra) { -return (int8_t )cpu_load_helper (env, addr, mmu_idx, ra,MO_SB , - full_ldub_mmu); +return (int8_t )cpu_ldub_mmuidx_ra (env, addr, mmu_idx, ra); } uint32_t cpu_lduw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr,
@@ -2141,8 +2139,7 @@ uint32_t cpu_lduw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr,int cpu_ldsw_be_mmuidx_ra (CPUArchState *env,abi_ptr addr,int mmu_idx,uintptr_t ra) { -return (int16_t )cpu_load_helper (env, addr, mmu_idx, ra,MO_BESW , - full_be_lduw_mmu); +return (int16_t )cpu_lduw_be_mmuidx_ra (env, addr, mmu_idx, ra); } uint32_t cpu_ldl_be_mmuidx_ra(CPUArchState *env, abi_ptr addr,
@@ -2166,8 +2163,7 @@ uint32_t cpu_lduw_le_mmuidx_ra(CPUArchState *env, abi_ptr addr,int cpu_ldsw_le_mmuidx_ra (CPUArchState *env,abi_ptr addr,int mmu_idx,uintptr_t ra) { -return (int16_t )cpu_load_helper (env, addr, mmu_idx, ra,MO_LESW , - full_le_lduw_mmu); +return (int16_t )cpu_lduw_le_mmuidx_ra (env, addr, mmu_idx, ra); } uint32_t cpu_ldl_le_mmuidx_ra(CPUArchState *env, abi_ptr addr,
accel/tcg/user-exec.c +6 -39
81 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v2 21/55] accel/tcg: Drop signness in tracing in cputlb.c
Quoted 3 lines · Richard Henderson
We are already inconsistent about whether or not
MO_SIGNis set intrace_mem_get_info. Dropping it entirely allows some simplification.
I think once 6.2 opens up we should just drop all the trace_mem stuff:
Subject: [PATCH v1 5/7] docs: mark intention to deprecate TCG tracing functionality
Date: Wed, 5 May 2021 10:22:57 +0100
Message-Id: <[email protected]>
Quoted 140 lines
Signed-off-by Richard Henderson <[email protected]>--- accel/tcg/cputlb.c | 10 +++------- accel/tcg/user-exec.c | 45 ++++++------------------------------------- 2 files changed, 9 insertions(+), 46 deletions(-)accel/tcg/cputlb.c +3
-7@@ -2110,7 +2110,6 @@ static inline uint64_t cpu_load_helper(CPUArchState *env, abi_ptr addr, meminfo =trace_mem_get_info (op, mmu_idx, false);trace_guest_mem_before_exec (env_cpu (env), addr, meminfo); - op &= ~MO_SIGN ; oi =make_memop_idx (op, mmu_idx); ret =full_load (env, addr, oi, retaddr);@@ -2128,8 +2127,7 @@ uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,int cpu_ldsb_mmuidx_ra (CPUArchState *env,abi_ptr addr,int mmu_idx,uintptr_t ra) { -return (int8_t )cpu_load_helper (env, addr, mmu_idx, ra,MO_SB , - full_ldub_mmu); +return (int8_t )cpu_ldub_mmuidx_ra (env, addr, mmu_idx, ra); } uint32_t cpu_lduw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr,@@ -2141,8 +2139,7 @@ uint32_t cpu_lduw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr,int cpu_ldsw_be_mmuidx_ra (CPUArchState *env,abi_ptr addr,int mmu_idx,uintptr_t ra) { -return (int16_t )cpu_load_helper (env, addr, mmu_idx, ra,MO_BESW , - full_be_lduw_mmu); +return (int16_t )cpu_lduw_be_mmuidx_ra (env, addr, mmu_idx, ra); } uint32_t cpu_ldl_be_mmuidx_ra(CPUArchState *env, abi_ptr addr,@@ -2166,8 +2163,7 @@ uint32_t cpu_lduw_le_mmuidx_ra(CPUArchState *env, abi_ptr addr,int cpu_ldsw_le_mmuidx_ra (CPUArchState *env,abi_ptr addr,int mmu_idx,uintptr_t ra) { -return (int16_t )cpu_load_helper (env, addr, mmu_idx, ra,MO_LESW , - full_le_lduw_mmu); +return (int16_t )cpu_lduw_le_mmuidx_ra (env, addr, mmu_idx, ra); } uint32_t cpu_ldl_le_mmuidx_ra(CPUArchState *env, abi_ptr addr,accel/tcg/user-exec.c +6
-39@@ -866,13 +866,7 @@ uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr)int cpu_ldsb_data (CPUArchState *env,abi_ptr ptr) { -int ret; -uint16_t meminfo =trace_mem_get_info (MO_SB ,MMU_USER_IDX , false); - -trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo); - ret =ldsb_p (g2h (env_cpu (env), ptr)); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); -return ret; +return (int8_t )cpu_ldub_data (env, ptr); }uint32_t cpu_lduw_be_data (CPUArchState *env,abi_ptr ptr)@@ -888,13 +882,7 @@ uint32_t cpu_lduw_be_data(CPUArchState *env, abi_ptr ptr)int cpu_ldsw_be_data (CPUArchState *env,abi_ptr ptr) { -int ret; -uint16_t meminfo =trace_mem_get_info (MO_BESW ,MMU_USER_IDX , false); - -trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo); - ret =ldsw_be_p (g2h (env_cpu (env), ptr)); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); -return ret; +return (int16_t )cpu_lduw_be_data (env, ptr); }uint32_t cpu_ldl_be_data (CPUArchState *env,abi_ptr ptr)@@ -932,13 +920,7 @@ uint32_t cpu_lduw_le_data(CPUArchState *env, abi_ptr ptr)int cpu_ldsw_le_data (CPUArchState *env,abi_ptr ptr) { -int ret; -uint16_t meminfo =trace_mem_get_info (MO_LESW ,MMU_USER_IDX , false); - -trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo); - ret =ldsw_le_p (g2h (env_cpu (env), ptr)); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); -return ret; +return (int16_t )cpu_lduw_le_data (env, ptr); }uint32_t cpu_ldl_le_data (CPUArchState *env,abi_ptr ptr)@@ -975,12 +957,7 @@ uint32_t cpu_ldub_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)int cpu_ldsb_data_ra (CPUArchState *env,abi_ptr ptr,uintptr_t retaddr) { -int ret; - -set_helper_retaddr (retaddr); - ret =cpu_ldsb_data (env, ptr); -clear_helper_retaddr (); -return ret; +return (int8_t )cpu_ldub_data_ra (env, ptr, retaddr); }uint32_t cpu_lduw_be_data_ra (CPUArchState *env,abi_ptr ptr,uintptr_t retaddr)@@ -995,12 +972,7 @@ uint32_t cpu_lduw_be_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)int cpu_ldsw_be_data_ra (CPUArchState *env,abi_ptr ptr,uintptr_t retaddr) { -int ret; - -set_helper_retaddr (retaddr); - ret =cpu_ldsw_be_data (env, ptr); -clear_helper_retaddr (); -return ret; +return (int16_t )cpu_lduw_be_data_ra (env, ptr, retaddr); }uint32_t cpu_ldl_be_data_ra (CPUArchState *env,abi_ptr ptr,uintptr_t retaddr)@@ -1035,12 +1007,7 @@ uint32_t cpu_lduw_le_data_ra(CPUArchState *env, abi_ptr ptr, uintptr_t retaddr)int cpu_ldsw_le_data_ra (CPUArchState *env,abi_ptr ptr,uintptr_t retaddr) { -int ret; - -set_helper_retaddr (retaddr); - ret =cpu_ldsw_le_data (env, ptr); -clear_helper_retaddr (); -return ret; +return (int16_t )cpu_lduw_le_data_ra (env, ptr, retaddr); }uint32_t cpu_ldl_le_data_ra (CPUArchState *env,abi_ptr ptr,uintptr_t retaddr)
Signature · 1 line
Alex Bennée
PATCH v2 22/55 tcg: Expand MO_SIZE to 3 bits
In reply to Richard HendersonWe have lacked expressive support for memory sizes larger than 64-bits for a while. Fixing that requires adjustment to several points where we used this for array indexing, and two places that develop -Wswitch warnings after the change.
--- include/exec/memop.h | 14 +++++++++----- target/arm/translate-a64.c | 2 +- tcg/tcg-op.c | 13 ++++++++----- target/s390x/tcg/translate_vx.c.inc | 2 +- tcg/aarch64/tcg-target.c.inc | 4 ++-- tcg/arm/tcg-target.c.inc | 4 ++-- tcg/i386/tcg-target.c.inc | 4 ++-- tcg/mips/tcg-target.c.inc | 4 ++-- tcg/ppc/tcg-target.c.inc | 8 ++++---- tcg/riscv/tcg-target.c.inc | 4 ++-- tcg/s390/tcg-target.c.inc | 4 ++-- tcg/sparc/tcg-target.c.inc | 16 ++++++++-------- 12 files changed, 43 insertions(+), 36 deletions(-)
include/exec/memop.h +9 -5
@@ -19,11 +19,15 @@ typedef enum MemOp {MO_16 =1 ,MO_32 =2 ,MO_64 =3 , -MO_SIZE =3 ,/* Mask for the above. */ +MO_128 =4 , +MO_256 =5 , +MO_512 =6 , +MO_1024 =7 , +MO_SIZE =0x07 ,/* Mask for the above. */ -MO_SIGN =4 ,/* Sign-extended, otherwise zero-extended. */ +MO_SIGN =0x08 ,/* Sign-extended, otherwise zero-extended. */ -MO_BSWAP =8 ,/* Host reverse endian. */ +MO_BSWAP =0x10 ,/* Host reverse endian. */ #ifdef HOST_WORDS_BIGENDIANMO_LE =MO_BSWAP , MO_BE = 0,
@@ -59,8 +63,8 @@ typedef enum MemOp {* - an alignment to a specified size, which may be more or less than * the access size (MO_ALIGN_x where 'x' is a size in bytes); */ - MO_ASHIFT = 4, - MO_AMASK = 7 << MO_ASHIFT, + MO_ASHIFT = 5, + MO_AMASK = 0x7 << MO_ASHIFT,#ifdef NEED_CPU_H #ifdef TARGET_ALIGNED_ONLY MO_ALIGN = 0,
target/arm/translate-a64.c +1 -1
@@ -1045,7 +1045,7 @@ static void read_vec_element(DisasContext *s, TCGv_i64 tcg_dest, int srcidx, int element, MemOp memop) { int vect_off = vec_reg_offset(s, srcidx, element, memop & MO_SIZE); -switch (memop) { +switch ((unsigned )memop) {case MO_8 :tcg_gen_ld8u_i64 (tcg_dest, cpu_env, vect_off);break ;
tcg/tcg-op.c +8 -5
@@ -2780,10 +2780,13 @@ static inline MemOp tcg_canonicalize_memop(MemOp op, bool is64, bool st) }break ;case MO_64 : -if (!is64) { -tcg_abort (); +if (is64) { + op &= ~MO_SIGN ; +break ; } -break ; +/* fall through */ +default : +g_assert_not_reached (); }if (st) { op &= ~MO_SIGN ;
@@ -3095,7 +3098,7 @@ typedef void (*gen_atomic_op_i64)(TCGv_i64, TCGv_env, TCGv,# define WITH_ATOMIC64 (X )#endif -static void *const table_cmpxchg[16 ] = { +static void *const table_cmpxchg[(MO_SIZE |MO_BSWAP ) +1 ] = { [MO_8 ] = gen_helper_atomic_cmpxchgb, [MO_16 |MO_LE ] = gen_helper_atomic_cmpxchgw_le, [MO_16 |MO_BE ] = gen_helper_atomic_cmpxchgw_be,
@@ -3297,7 +3300,7 @@ static void do_atomic_op_i64(TCGv_i64 ret, TCGv addr, TCGv_i64 val, }#define GEN_ATOMIC_HELPER (NAME ,OP ,NEW ) \ -static void * const table_##NAME[16] = { \ +static void * const table_##NAME[(MO_SIZE | MO_BSWAP) + 1] = { \ [MO_8] = gen_helper_atomic_##NAME##b, \ [MO_16 | MO_LE] = gen_helper_atomic_##NAME##w_le, \ [MO_16 | MO_BE] = gen_helper_atomic_##NAME##w_be, \
target/s390x/tcg/translate_vx.c.inc +1 -1
@@ -67,7 +67,7 @@ static void read_vec_element_i64(TCGv_i64 dst, uint8_t reg, uint8_t enr, { const int offs = vec_reg_offset(reg, enr, memop & MO_SIZE); - switch (memop) { + switch ((unsigned)memop) { case ES_8: tcg_gen_ld8u_i64(dst, cpu_env, offs); break;
tcg/aarch64/tcg-target.c.inc +2 -2
@@ -1547,7 +1547,7 @@ static void tcg_out_cltz(TCGContext *s, TCGType ext, TCGReg d, /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, * TCGMemOpIdx oi, uintptr_t ra) */ -static void * const qemu_ld_helpers[4] = { +static void * const qemu_ld_helpers[MO_SIZE + 1] = { [MO_8] = helper_ret_ldub_mmu, #ifdef HOST_WORDS_BIGENDIAN [MO_16] = helper_be_lduw_mmu,
@@ -1564,7 +1564,7 @@ static void * const qemu_ld_helpers[4] = { * uintxx_t val, TCGMemOpIdx oi, * uintptr_t ra) */ -static void * const qemu_st_helpers[4] = { +static void * const qemu_st_helpers[MO_SIZE + 1] = { [MO_8] = helper_ret_stb_mmu, #ifdef HOST_WORDS_BIGENDIAN [MO_16] = helper_be_stw_mmu,
tcg/arm/tcg-target.c.inc +2 -2
@@ -1393,7 +1393,7 @@ static void tcg_out_vldst(TCGContext *s, ARMInsn insn, /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, * int mmu_idx, uintptr_t ra) */ -static void * const qemu_ld_helpers[8] = { +static void * const qemu_ld_helpers[MO_SSIZE + 1] = { [MO_UB] = helper_ret_ldub_mmu, [MO_SB] = helper_ret_ldsb_mmu, #ifdef HOST_WORDS_BIGENDIAN
@@ -1414,7 +1414,7 @@ static void * const qemu_ld_helpers[8] = { /* helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr, * uintxx_t val, int mmu_idx, uintptr_t ra) */ -static void * const qemu_st_helpers[4] = { +static void * const qemu_st_helpers[MO_SIZE + 1] = { [MO_8] = helper_ret_stb_mmu, #ifdef HOST_WORDS_BIGENDIAN [MO_16] = helper_be_stw_mmu,
tcg/i386/tcg-target.c.inc +2 -2
@@ -1610,7 +1610,7 @@ static void tcg_out_nopn(TCGContext *s, int n) /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, * int mmu_idx, uintptr_t ra) */ -static void * const qemu_ld_helpers[16] = { +static void * const qemu_ld_helpers[(MO_SIZE | MO_BSWAP) + 1] = { [MO_UB] = helper_ret_ldub_mmu, [MO_LEUW] = helper_le_lduw_mmu, [MO_LEUL] = helper_le_ldul_mmu,
@@ -1623,7 +1623,7 @@ static void * const qemu_ld_helpers[16] = { /* helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr, * uintxx_t val, int mmu_idx, uintptr_t ra) */ -static void * const qemu_st_helpers[16] = { +static void * const qemu_st_helpers[(MO_SIZE | MO_BSWAP) + 1] = { [MO_UB] = helper_ret_stb_mmu, [MO_LEUW] = helper_le_stw_mmu, [MO_LEUL] = helper_le_stl_mmu,
tcg/mips/tcg-target.c.inc +2 -2
@@ -1037,7 +1037,7 @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) #if defined(CONFIG_SOFTMMU) #include "../tcg-ldst.c.inc" -static void * const qemu_ld_helpers[16] = { +static void * const qemu_ld_helpers[(MO_SSIZE | MO_BSWAP) + 1] = { [MO_UB] = helper_ret_ldub_mmu, [MO_SB] = helper_ret_ldsb_mmu, [MO_LEUW] = helper_le_lduw_mmu,
@@ -1054,7 +1054,7 @@ static void * const qemu_ld_helpers[16] = { #endif }; -static void * const qemu_st_helpers[16] = { +static void * const qemu_st_helpers[(MO_SIZE | MO_BSWAP) + 1] = { [MO_UB] = helper_ret_stb_mmu, [MO_LEUW] = helper_le_stw_mmu, [MO_LEUL] = helper_le_stl_mmu,
tcg/ppc/tcg-target.c.inc +4 -4
@@ -1916,7 +1916,7 @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) #endif } -static const uint32_t qemu_ldx_opc[16] = { +static const uint32_t qemu_ldx_opc[(MO_SSIZE + MO_BSWAP) + 1] = { [MO_UB] = LBZX, [MO_UW] = LHZX, [MO_UL] = LWZX,
@@ -1929,7 +1929,7 @@ static const uint32_t qemu_ldx_opc[16] = { [MO_BSWAP | MO_Q] = LDBRX, }; -static const uint32_t qemu_stx_opc[16] = { +static const uint32_t qemu_stx_opc[(MO_SIZE + MO_BSWAP) + 1] = { [MO_UB] = STBX, [MO_UW] = STHX, [MO_UL] = STWX,
@@ -1950,7 +1950,7 @@ static const uint32_t qemu_exts_opc[4] = { /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, * int mmu_idx, uintptr_t ra) */ -static void * const qemu_ld_helpers[16] = { +static void * const qemu_ld_helpers[(MO_SIZE | MO_BSWAP) + 1] = { [MO_UB] = helper_ret_ldub_mmu, [MO_LEUW] = helper_le_lduw_mmu, [MO_LEUL] = helper_le_ldul_mmu,
@@ -1963,7 +1963,7 @@ static void * const qemu_ld_helpers[16] = { /* helper signature: helper_st_mmu(CPUState *env, target_ulong addr, * uintxx_t val, int mmu_idx, uintptr_t ra) */ -static void * const qemu_st_helpers[16] = { +static void * const qemu_st_helpers[(MO_SIZE | MO_BSWAP) + 1] = { [MO_UB] = helper_ret_stb_mmu, [MO_LEUW] = helper_le_stw_mmu, [MO_LEUL] = helper_le_stl_mmu,
tcg/riscv/tcg-target.c.inc +2 -2
@@ -852,7 +852,7 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, * TCGMemOpIdx oi, uintptr_t ra) */ -static void * const qemu_ld_helpers[8] = { +static void * const qemu_ld_helpers[MO_SSIZE + 1] = { [MO_UB] = helper_ret_ldub_mmu, [MO_SB] = helper_ret_ldsb_mmu, #ifdef HOST_WORDS_BIGENDIAN
@@ -878,7 +878,7 @@ static void * const qemu_ld_helpers[8] = { * uintxx_t val, TCGMemOpIdx oi, * uintptr_t ra) */ -static void * const qemu_st_helpers[4] = { +static void * const qemu_st_helpers[MO_SIZE + 1] = { [MO_8] = helper_ret_stb_mmu, #ifdef HOST_WORDS_BIGENDIAN [MO_16] = helper_be_stw_mmu,
tcg/s390/tcg-target.c.inc +2 -2
@@ -350,7 +350,7 @@ static const uint8_t tcg_cond_to_ltr_cond[] = { }; #ifdef CONFIG_SOFTMMU -static void * const qemu_ld_helpers[16] = { +static void * const qemu_ld_helpers[(MO_SSIZE | MO_BSWAP) + 1] = { [MO_UB] = helper_ret_ldub_mmu, [MO_SB] = helper_ret_ldsb_mmu, [MO_LEUW] = helper_le_lduw_mmu,
@@ -365,7 +365,7 @@ static void * const qemu_ld_helpers[16] = { [MO_BEQ] = helper_be_ldq_mmu, }; -static void * const qemu_st_helpers[16] = { +static void * const qemu_st_helpers[(MO_SIZE | MO_BSWAP) + 1] = { [MO_UB] = helper_ret_stb_mmu, [MO_LEUW] = helper_le_stw_mmu, [MO_LEUL] = helper_le_stl_mmu,
tcg/sparc/tcg-target.c.inc +8 -8
@@ -847,8 +847,8 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) } #ifdef CONFIG_SOFTMMU -static const tcg_insn_unit *qemu_ld_trampoline[16]; -static const tcg_insn_unit *qemu_st_trampoline[16]; +static const tcg_insn_unit *qemu_ld_trampoline[(MO_SSIZE | MO_BSWAP) + 1]; +static const tcg_insn_unit *qemu_st_trampoline[(MO_SIZE | MO_BSWAP) + 1]; static void emit_extend(TCGContext *s, TCGReg r, int op) {
@@ -875,7 +875,7 @@ static void emit_extend(TCGContext *s, TCGReg r, int op) static void build_trampolines(TCGContext *s) { - static void * const qemu_ld_helpers[16] = { + static void * const qemu_ld_helpers[] = { [MO_UB] = helper_ret_ldub_mmu, [MO_SB] = helper_ret_ldsb_mmu, [MO_LEUW] = helper_le_lduw_mmu,
@@ -887,7 +887,7 @@ static void build_trampolines(TCGContext *s) [MO_BEUL] = helper_be_ldul_mmu, [MO_BEQ] = helper_be_ldq_mmu, }; - static void * const qemu_st_helpers[16] = { + static void * const qemu_st_helpers[] = { [MO_UB] = helper_ret_stb_mmu, [MO_LEUW] = helper_le_stw_mmu, [MO_LEUL] = helper_le_stl_mmu,
@@ -900,7 +900,7 @@ static void build_trampolines(TCGContext *s) int i; TCGReg ra; - for (i = 0; i < 16; ++i) { + for (i = 0; i < ARRAY_SIZE(qemu_ld_helpers); ++i) { if (qemu_ld_helpers[i] == NULL) { continue; }
@@ -928,7 +928,7 @@ static void build_trampolines(TCGContext *s) tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_O7, ra); } - for (i = 0; i < 16; ++i) { + for (i = 0; i < ARRAY_SIZE(qemu_st_helpers); ++i) { if (qemu_st_helpers[i] == NULL) { continue; }
@@ -1110,7 +1110,7 @@ static TCGReg tcg_out_tlb_load(TCGContext *s, TCGReg addr, int mem_index, } #endif /* CONFIG_SOFTMMU */ -static const int qemu_ld_opc[16] = { +static const int qemu_ld_opc[(MO_SSIZE | MO_BSWAP) + 1] = { [MO_UB] = LDUB, [MO_SB] = LDSB,
@@ -1127,7 +1127,7 @@ static const int qemu_ld_opc[16] = { [MO_LEQ] = LDX_LE, }; -static const int qemu_st_opc[16] = { +static const int qemu_st_opc[(MO_SIZE | MO_BSWAP) + 1] = { [MO_UB] = STB, [MO_BEUW] = STH,
Signature · 1 line
2.25.1
PATCH v2 23/55 tcg: Rename TCGMemOpIdx to MemOpIdx
In reply to Richard HendersonWe're about to move this out of tcg.h, so rename it as we did when moving MemOp.
--- accel/tcg/atomic_template.h | 24 +++++------ include/tcg/tcg.h | 74 ++++++++++++++++----------------- accel/tcg/cputlb.c | 78 +++++++++++++++++------------------ accel/tcg/user-exec.c | 2 +- target/arm/helper-a64.c | 16 +++---- target/arm/m_helper.c | 2 +- target/i386/tcg/mem_helper.c | 4 +- target/m68k/op_helper.c | 2 +- target/mips/tcg/msa_helper.c | 6 +-- target/s390x/tcg/mem_helper.c | 20 ++++----- target/sparc/ldst_helper.c | 2 +- tcg/optimize.c | 2 +- tcg/tcg-op.c | 12 +++--- tcg/tcg.c | 2 +- tcg/tci.c | 14 +++---- accel/tcg/atomic_common.c.inc | 6 +-- tcg/aarch64/tcg-target.c.inc | 14 +++---- tcg/arm/tcg-target.c.inc | 10 ++--- tcg/i386/tcg-target.c.inc | 10 ++--- tcg/mips/tcg-target.c.inc | 12 +++--- tcg/ppc/tcg-target.c.inc | 10 ++--- tcg/riscv/tcg-target.c.inc | 16 +++---- tcg/s390/tcg-target.c.inc | 10 ++--- tcg/sparc/tcg-target.c.inc | 4 +- tcg/tcg-ldst.c.inc | 2 +- 25 files changed, 177 insertions(+), 177 deletions(-)
accel/tcg/atomic_template.h +12 -12
@@ -72,7 +72,7 @@ABI_TYPE ATOMIC_NAME (cmpxchg )(CPUArchState *env,target_ulong addr,ABI_TYPE cmpv,ABI_TYPE newv, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_READ |PAGE_WRITE , retaddr);
@@ -92,7 +92,7 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr, #if DATA_SIZE >= 16 #if HAVE_ATOMIC128 ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr, - TCGMemOpIdx oi, uintptr_t retaddr) + MemOpIdx oi, uintptr_t retaddr) { DATA_TYPE *haddr = atomic_mmu_lookup(env, addr, oi, DATA_SIZE, PAGE_READ, retaddr);
@@ -106,7 +106,7 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr, }void ATOMIC_NAME (st )(CPUArchState *env,target_ulong addr,ABI_TYPE val, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_WRITE , retaddr);
@@ -119,7 +119,7 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, ABI_TYPE val,#endif #else ABI_TYPE ATOMIC_NAME (xchg )(CPUArchState *env,target_ulong addr,ABI_TYPE val, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_READ |PAGE_WRITE , retaddr);
@@ -134,7 +134,7 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ABI_TYPE val,#define GEN_ATOMIC_HELPER (X ) \ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ - ABI_TYPE val, TCGMemOpIdx oi, uintptr_t retaddr) \ + ABI_TYPE val, MemOpIdx oi, uintptr_t retaddr) \ { \ DATA_TYPE *haddr = atomic_mmu_lookup(env, addr, oi, DATA_SIZE, \ PAGE_READ | PAGE_WRITE, retaddr); \
@@ -167,7 +167,7 @@ GEN_ATOMIC_HELPER(xor_fetch)*/ #define GEN_ATOMIC_HELPER_FN (X ,FN ,XDATA_TYPE ,RET ) \ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ - ABI_TYPE xval, TCGMemOpIdx oi, uintptr_t retaddr) \ + ABI_TYPE xval, MemOpIdx oi, uintptr_t retaddr) \ { \ XDATA_TYPE *haddr = atomic_mmu_lookup(env, addr, oi, DATA_SIZE, \ PAGE_READ | PAGE_WRITE, retaddr); \
@@ -211,7 +211,7 @@ GEN_ATOMIC_HELPER_FN(umax_fetch, MAX, DATA_TYPE, new)ABI_TYPE ATOMIC_NAME (cmpxchg )(CPUArchState *env,target_ulong addr,ABI_TYPE cmpv,ABI_TYPE newv, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_READ |PAGE_WRITE , retaddr);
@@ -231,7 +231,7 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr, #if DATA_SIZE >= 16 #if HAVE_ATOMIC128 ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr, - TCGMemOpIdx oi, uintptr_t retaddr) + MemOpIdx oi, uintptr_t retaddr) { DATA_TYPE *haddr = atomic_mmu_lookup(env, addr, oi, DATA_SIZE, PAGE_READ, retaddr);
@@ -245,7 +245,7 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr, }void ATOMIC_NAME (st )(CPUArchState *env,target_ulong addr,ABI_TYPE val, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_WRITE , retaddr);
@@ -259,7 +259,7 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, ABI_TYPE val,#endif #else ABI_TYPE ATOMIC_NAME (xchg )(CPUArchState *env,target_ulong addr,ABI_TYPE val, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_READ |PAGE_WRITE , retaddr);
@@ -274,7 +274,7 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ABI_TYPE val,#define GEN_ATOMIC_HELPER (X ) \ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ - ABI_TYPE val, TCGMemOpIdx oi, uintptr_t retaddr) \ + ABI_TYPE val, MemOpIdx oi, uintptr_t retaddr) \ { \ DATA_TYPE *haddr = atomic_mmu_lookup(env, addr, oi, DATA_SIZE, \ PAGE_READ | PAGE_WRITE, retaddr); \
@@ -304,7 +304,7 @@ GEN_ATOMIC_HELPER(xor_fetch)*/ #define GEN_ATOMIC_HELPER_FN (X ,FN ,XDATA_TYPE ,RET ) \ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ - ABI_TYPE xval, TCGMemOpIdx oi, uintptr_t retaddr) \ + ABI_TYPE xval, MemOpIdx oi, uintptr_t retaddr) \ { \ XDATA_TYPE *haddr = atomic_mmu_lookup(env, addr, oi, DATA_SIZE, \ PAGE_READ | PAGE_WRITE, retaddr); \
include/tcg/tcg.h +37 -37
160 lines not on this page · raw message
accel/tcg/cputlb.c +39 -39
289 lines not on this page · raw message
accel/tcg/user-exec.c +1 -1
@@ -1195,7 +1195,7 @@ uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr ptr)* @prot may be PAGE_READ, PAGE_WRITE, or PAGE_READ|PAGE_WRITE. */ static void *atomic_mmu_lookup (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,int size,int prot, +MemOpIdx oi,int size,int prot,uintptr_t retaddr) {MemOp mop =get_memop (oi);
target/arm/helper-a64.c +8 -8
@@ -531,8 +531,8 @@ uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr,clear_helper_retaddr ();#else int mem_idx =cpu_mmu_index (env, false); -TCGMemOpIdx oi0 =make_memop_idx (MO_LEQ |MO_ALIGN_16 , mem_idx); -TCGMemOpIdx oi1 =make_memop_idx (MO_LEQ , mem_idx); +MemOpIdx oi0 =make_memop_idx (MO_LEQ |MO_ALIGN_16 , mem_idx); +MemOpIdx oi1 =make_memop_idx (MO_LEQ , mem_idx); o0 =helper_le_ldq_mmu (env, addr +0 , oi0, ra); o1 =helper_le_ldq_mmu (env, addr +8 , oi1, ra);
@@ -555,7 +555,7 @@ uint64_t HELPER(paired_cmpxchg64_le_parallel)(CPUARMState *env, uint64_t addr,uintptr_t ra =GETPC ();bool success;int mem_idx; -TCGMemOpIdx oi; +MemOpIdx oi;assert (HAVE_CMPXCHG128 );
@@ -601,8 +601,8 @@ uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr,clear_helper_retaddr ();#else int mem_idx =cpu_mmu_index (env, false); -TCGMemOpIdx oi0 =make_memop_idx (MO_BEQ |MO_ALIGN_16 , mem_idx); -TCGMemOpIdx oi1 =make_memop_idx (MO_BEQ , mem_idx); +MemOpIdx oi0 =make_memop_idx (MO_BEQ |MO_ALIGN_16 , mem_idx); +MemOpIdx oi1 =make_memop_idx (MO_BEQ , mem_idx); o1 =helper_be_ldq_mmu (env, addr +0 , oi0, ra); o0 =helper_be_ldq_mmu (env, addr +8 , oi1, ra);
@@ -625,7 +625,7 @@ uint64_t HELPER(paired_cmpxchg64_be_parallel)(CPUARMState *env, uint64_t addr,uintptr_t ra =GETPC ();bool success;int mem_idx; -TCGMemOpIdx oi; +MemOpIdx oi;assert (HAVE_CMPXCHG128 );
@@ -651,7 +651,7 @@ void HELPER(casp_le_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr,Int128 oldv, cmpv, newv;uintptr_t ra =GETPC ();int mem_idx; -TCGMemOpIdx oi; +MemOpIdx oi;assert (HAVE_CMPXCHG128 );
@@ -672,7 +672,7 @@ void HELPER(casp_be_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr,Int128 oldv, cmpv, newv;uintptr_t ra =GETPC ();int mem_idx; -TCGMemOpIdx oi; +MemOpIdx oi;assert (HAVE_CMPXCHG128 );
target/arm/m_helper.c +1 -1
@@ -1930,7 +1930,7 @@ static bool do_v7m_function_return(ARMCPU *cpu) {bool threadmode, spsel; -TCGMemOpIdx oi; +MemOpIdx oi;ARMMMUIdx mmu_idx;uint32_t *frame_sp_p;uint32_t frameptr;
target/i386/tcg/mem_helper.c +2 -2
@@ -67,7 +67,7 @@ void helper_cmpxchg8b(CPUX86State *env, target_ulong a0) {uintptr_t ra =GETPC ();int mem_idx =cpu_mmu_index (env, false); -TCGMemOpIdx oi =make_memop_idx (MO_TEQ , mem_idx); +MemOpIdx oi =make_memop_idx (MO_TEQ , mem_idx); oldv =cpu_atomic_cmpxchgq_le_mmu (env, a0, cmpv, newv, oi, ra); }
@@ -136,7 +136,7 @@ void helper_cmpxchg16b(CPUX86State *env, target_ulong a0)Int128 newv =int128_make128 (env->regs[R_EBX ], env->regs[R_ECX ]);int mem_idx =cpu_mmu_index (env, false); -TCGMemOpIdx oi =make_memop_idx (MO_TEQ |MO_ALIGN_16 , mem_idx); +MemOpIdx oi =make_memop_idx (MO_TEQ |MO_ALIGN_16 , mem_idx);Int128 oldv =cpu_atomic_cmpxchgo_le_mmu (env, a0, cmpv, newv, oi, ra);if (int128_eq (oldv, cmpv)) {
target/m68k/op_helper.c +1 -1
@@ -785,7 +785,7 @@ static void do_cas2l(CPUM68KState *env, uint32_t regs, uint32_t a1, uint32_t a2,uintptr_t ra =GETPC ();#if defined(CONFIG_ATOMIC64 )int mmu_idx =cpu_mmu_index (env,0 ); -TCGMemOpIdx oi =make_memop_idx (MO_BEQ , mmu_idx); +MemOpIdx oi =make_memop_idx (MO_BEQ , mmu_idx);#endif if (parallel) {
target/mips/tcg/msa_helper.c +3 -3
@@ -8211,9 +8211,9 @@ void helper_msa_ffint_u_df(CPUMIPSState *env, uint32_t df, uint32_t wd,#define DF_ELEMENTS (df) (MSA_WRLEN / DF_BITS(df))#if !defined(CONFIG_USER_ONLY ) -#define MEMOP_IDX (DF ) \ - TCGMemOpIdx oi = make_memop_idx(MO_TE | DF | MO_UNALN, \ - cpu_mmu_index(env, false)); +#define MEMOP_IDX (DF ) \ + MemOpIdx oi = make_memop_idx(MO_TE | DF | MO_UNALN, \ + cpu_mmu_index(env, false));#else #define MEMOP_IDX (DF )#endif
target/s390x/tcg/mem_helper.c +10 -10
@@ -238,7 +238,7 @@ static void do_access_memset(CPUS390XState *env, vaddr vaddr, char *haddr,g_assert (haddr);memset (haddr, byte, size);#else -TCGMemOpIdx oi =make_memop_idx (MO_UB , mmu_idx); +MemOpIdx oi =make_memop_idx (MO_UB , mmu_idx);int i;if (likely (haddr)) {
@@ -281,7 +281,7 @@ static uint8_t do_access_get_byte(CPUS390XState *env, vaddr vaddr, char **haddr,#ifdef CONFIG_USER_ONLY return ldub_p (*haddr + offset);#else -TCGMemOpIdx oi =make_memop_idx (MO_UB , mmu_idx); +MemOpIdx oi =make_memop_idx (MO_UB , mmu_idx);uint8_t byte;if (likely (*haddr)) {
@@ -315,7 +315,7 @@ static void do_access_set_byte(CPUS390XState *env, vaddr vaddr, char **haddr,#ifdef CONFIG_USER_ONLY stb_p (*haddr + offset, byte);#else -TCGMemOpIdx oi =make_memop_idx (MO_UB , mmu_idx); +MemOpIdx oi =make_memop_idx (MO_UB , mmu_idx);if (likely (*haddr)) {stb_p (*haddr + offset, byte);
@@ -1803,7 +1803,7 @@ void HELPER(cdsg_parallel)(CPUS390XState *env, uint64_t addr,Int128 cmpv =int128_make128 (env->regs[r1 +1 ], env->regs[r1]);Int128 newv =int128_make128 (env->regs[r3 +1 ], env->regs[r3]);int mem_idx; -TCGMemOpIdx oi; +MemOpIdx oi;Int128 oldv;bool fail;
@@ -1883,7 +1883,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1,uint32_t *haddr =g2h (env_cpu (env), a1); ov =qatomic_cmpxchg__nocheck (haddr, cv, nv);#else -TCGMemOpIdx oi =make_memop_idx (MO_TEUL |MO_ALIGN , mem_idx); +MemOpIdx oi =make_memop_idx (MO_TEUL |MO_ALIGN , mem_idx); ov =cpu_atomic_cmpxchgl_be_mmu (env, a1, cv, nv, oi, ra);#endif }else {
@@ -1903,7 +1903,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1,if (parallel) {#ifdef CONFIG_ATOMIC64 -TCGMemOpIdx oi =make_memop_idx (MO_TEQ |MO_ALIGN , mem_idx); +MemOpIdx oi =make_memop_idx (MO_TEQ |MO_ALIGN , mem_idx); ov =cpu_atomic_cmpxchgq_be_mmu (env, a1, cv, nv, oi, ra);#else /* Note that we asserted !parallel above. */
@@ -1939,7 +1939,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1,cpu_stq_data_ra (env, a1 +0 ,int128_gethi (nv), ra);cpu_stq_data_ra (env, a1 +8 ,int128_getlo (nv), ra); }else if (HAVE_CMPXCHG128 ) { -TCGMemOpIdx oi =make_memop_idx (MO_TEQ |MO_ALIGN_16 , mem_idx); +MemOpIdx oi =make_memop_idx (MO_TEQ |MO_ALIGN_16 , mem_idx); ov =cpu_atomic_cmpxchgo_be_mmu (env, a1, cv, nv, oi, ra); cc = !int128_eq (ov, cv); }else {
@@ -1978,7 +1978,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1,cpu_stq_data_ra (env, a2 +0 , svh, ra);cpu_stq_data_ra (env, a2 +8 , svl, ra); }else if (HAVE_ATOMIC128 ) { -TCGMemOpIdx oi =make_memop_idx (MO_TEQ |MO_ALIGN_16 , mem_idx); +MemOpIdx oi =make_memop_idx (MO_TEQ |MO_ALIGN_16 , mem_idx);Int128 sv =int128_make128 (svl, svh);cpu_atomic_sto_be_mmu (env, a2, sv, oi, ra); }else {
@@ -2474,7 +2474,7 @@ uint64_t HELPER(lpq_parallel)(CPUS390XState *env, uint64_t addr)uintptr_t ra =GETPC ();uint64_t hi, lo;int mem_idx; -TCGMemOpIdx oi; +MemOpIdx oi;Int128 v;assert (HAVE_ATOMIC128 );
@@ -2505,7 +2505,7 @@ void HELPER(stpq_parallel)(CPUS390XState *env, uint64_t addr, {uintptr_t ra =GETPC ();int mem_idx; -TCGMemOpIdx oi; +MemOpIdx oi;Int128 v;assert (HAVE_ATOMIC128 );
target/sparc/ldst_helper.c +1 -1
@@ -1313,7 +1313,7 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr,case ASI_SNF :case ASI_SNFL : { -TCGMemOpIdx oi; +MemOpIdx oi;int idx = (env->pstate &PS_PRIV ? (asi &1 ?MMU_KERNEL_SECONDARY_IDX :MMU_KERNEL_IDX ) : (asi &1 ?MMU_USER_SECONDARY_IDX :MMU_USER_IDX ));
tcg/optimize.c +1 -1
@@ -1023,7 +1023,7 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(qemu_ld): { -TCGMemOpIdx oi = op->args[nb_oargs + nb_iargs]; +MemOpIdx oi = op->args[nb_oargs + nb_iargs];MemOp mop =get_memop (oi);if (!(mop &MO_SIGN )) { mask = (2ULL << ((8 << (mop &MO_SIZE )) -1 )) -1 ;
tcg/tcg-op.c +6 -6
@@ -2797,7 +2797,7 @@ static inline MemOp tcg_canonicalize_memop(MemOp op, bool is64, bool st)static void gen_ldst_i32 (TCGOpcode opc,TCGv_i32 val,TCGv addr,MemOp memop,TCGArg idx) { -TCGMemOpIdx oi =make_memop_idx (memop, idx); +MemOpIdx oi =make_memop_idx (memop, idx);#if TARGET_LONG_BITS ==32 tcg_gen_op3i_i32 (opc, val, addr, oi);#else
@@ -2812,7 +2812,7 @@ static void gen_ldst_i32(TCGOpcode opc, TCGv_i32 val, TCGv addr,static void gen_ldst_i64 (TCGOpcode opc,TCGv_i64 val,TCGv addr,MemOp memop,TCGArg idx) { -TCGMemOpIdx oi =make_memop_idx (memop, idx); +MemOpIdx oi =make_memop_idx (memop, idx);#if TARGET_LONG_BITS ==32 if (TCG_TARGET_REG_BITS ==32 ) {tcg_gen_op4i_i32 (opc,TCGV_LOW (val),TCGV_HIGH (val), addr, oi);
@@ -3132,7 +3132,7 @@ void tcg_gen_atomic_cmpxchg_i32(TCGv_i32 retv, TCGv addr, TCGv_i32 cmpv,tcg_temp_free_i32 (t1); }else {gen_atomic_cx_i32 gen; -TCGMemOpIdx oi; +MemOpIdx oi; gen = table_cmpxchg[memop & (MO_SIZE |MO_BSWAP )];tcg_debug_assert (gen !=NULL );
@@ -3171,7 +3171,7 @@ void tcg_gen_atomic_cmpxchg_i64(TCGv_i64 retv, TCGv addr, TCGv_i64 cmpv, }else if ((memop &MO_SIZE ) ==MO_64 ) {#ifdef CONFIG_ATOMIC64 gen_atomic_cx_i64 gen; -TCGMemOpIdx oi; +MemOpIdx oi; gen = table_cmpxchg[memop & (MO_SIZE |MO_BSWAP )];tcg_debug_assert (gen !=NULL );
@@ -3227,7 +3227,7 @@ static void do_atomic_op_i32(TCGv_i32 ret, TCGv addr, TCGv_i32 val, TCGArg idx, MemOp memop, void * const table[]) { gen_atomic_op_i32 gen; -TCGMemOpIdx oi; +MemOpIdx oi; memop =tcg_canonicalize_memop (memop,0 ,0 );
@@ -3269,7 +3269,7 @@ static void do_atomic_op_i64(TCGv_i64 ret, TCGv addr, TCGv_i64 val,if ((memop &MO_SIZE ) ==MO_64 ) {#ifdef CONFIG_ATOMIC64 gen_atomic_op_i64 gen; -TCGMemOpIdx oi; +MemOpIdx oi; gen = table[memop & (MO_SIZE |MO_BSWAP )];tcg_debug_assert (gen !=NULL );
tcg/tcg.c +1 -1
@@ -1910,7 +1910,7 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs)case INDEX_op_qemu_ld_i64:case INDEX_op_qemu_st_i64: { -TCGMemOpIdx oi = op->args[k++]; +MemOpIdx oi = op->args[k++];MemOp op =get_memop (oi);unsigned ix =get_mmuidx (oi);
tcg/tci.c +7 -7
@@ -61,7 +61,7 @@ static uint64_t tci_uint64(uint32_t high, uint32_t low)* i = immediate (uint32_t) * I = immediate (tcg_target_ulong) * l = label or pointer -* m = immediate (TCGMemOpIdx) +* m = immediate (MemOpIdx) * n = immediate (call return length) * r = register * s = signed ldst offset
@@ -105,7 +105,7 @@ static void tci_args_ri(uint32_t insn, TCGReg *r0, tcg_target_ulong *i1) }static void tci_args_rrm (uint32_t insn,TCGReg *r0, -TCGReg *r1,TCGMemOpIdx *m2) +TCGReg *r1,MemOpIdx *m2) { *r0 =extract32 (insn,8 ,4 ); *r1 =extract32 (insn,12 ,4 );
@@ -145,7 +145,7 @@ static void tci_args_rrrc(uint32_t insn, }static void tci_args_rrrm (uint32_t insn, -TCGReg *r0,TCGReg *r1,TCGReg *r2,TCGMemOpIdx *m3) +TCGReg *r0,TCGReg *r1,TCGReg *r2,MemOpIdx *m3) { *r0 =extract32 (insn,8 ,4 ); *r1 =extract32 (insn,12 ,4 );
@@ -289,7 +289,7 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) }static uint64_t tci_qemu_ld (CPUArchState *env,target_ulong taddr, -TCGMemOpIdx oi,const void *tb_ptr) +MemOpIdx oi,const void *tb_ptr) {MemOp mop =get_memop (oi) & (MO_BSWAP |MO_SSIZE );uintptr_t ra = (uintptr_t )tb_ptr;
@@ -374,7 +374,7 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, }static void tci_qemu_st (CPUArchState *env,target_ulong taddr,uint64_t val, -TCGMemOpIdx oi,const void *tb_ptr) +MemOpIdx oi,const void *tb_ptr) {MemOp mop =get_memop (oi) & (MO_BSWAP |MO_SSIZE );uintptr_t ra = (uintptr_t )tb_ptr;
@@ -482,7 +482,7 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env,uint32_t tmp32;uint64_t tmp64;uint64_t T1 ,T2 ; -TCGMemOpIdx oi; +MemOpIdx oi;int32_t ofs;void *ptr;
@@ -1148,7 +1148,7 @@ int print_insn_tci(bfd_vma addr, disassemble_info *info)tcg_target_ulong i1;int32_t s2;TCGCond c; -TCGMemOpIdx oi; +MemOpIdx oi;uint8_t pos, len;void *ptr;
accel/tcg/atomic_common.c.inc +3 -3
@@ -14,7 +14,7 @@ */ static uint16_t atomic_trace_rmw_pre(CPUArchState *env, target_ulong addr, - TCGMemOpIdx oi) + MemOpIdx oi) { CPUState *cpu = env_cpu(env); uint16_t info = trace_mem_get_info(get_memop(oi), get_mmuidx(oi), false);
@@ -34,7 +34,7 @@ static void atomic_trace_rmw_post(CPUArchState *env, target_ulong addr, #if HAVE_ATOMIC128 static uint16_t atomic_trace_ld_pre(CPUArchState *env, target_ulong addr, - TCGMemOpIdx oi) + MemOpIdx oi) { uint16_t info = trace_mem_get_info(get_memop(oi), get_mmuidx(oi), false);
@@ -50,7 +50,7 @@ static void atomic_trace_ld_post(CPUArchState *env, target_ulong addr, } static uint16_t atomic_trace_st_pre(CPUArchState *env, target_ulong addr, - TCGMemOpIdx oi) + MemOpIdx oi) { uint16_t info = trace_mem_get_info(get_memop(oi), get_mmuidx(oi), true);
tcg/aarch64/tcg-target.c.inc +7 -7
@@ -1545,7 +1545,7 @@ static void tcg_out_cltz(TCGContext *s, TCGType ext, TCGReg d, #include "../tcg-ldst.c.inc" /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, - * TCGMemOpIdx oi, uintptr_t ra) + * MemOpIdx oi, uintptr_t ra) */ static void * const qemu_ld_helpers[MO_SIZE + 1] = { [MO_8] = helper_ret_ldub_mmu,
@@ -1561,7 +1561,7 @@ static void * const qemu_ld_helpers[MO_SIZE + 1] = { }; /* helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr, - * uintxx_t val, TCGMemOpIdx oi, + * uintxx_t val, MemOpIdx oi, * uintptr_t ra) */ static void * const qemu_st_helpers[MO_SIZE + 1] = {
@@ -1586,7 +1586,7 @@ static inline void tcg_out_adr(TCGContext *s, TCGReg rd, const void *target) static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) { - TCGMemOpIdx oi = lb->oi; + MemOpIdx oi = lb->oi; MemOp opc = get_memop(oi); MemOp size = opc & MO_SIZE;
@@ -1611,7 +1611,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) { - TCGMemOpIdx oi = lb->oi; + MemOpIdx oi = lb->oi; MemOp opc = get_memop(oi); MemOp size = opc & MO_SIZE;
@@ -1629,7 +1629,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) return true; } -static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, +static void add_qemu_ldst_label(TCGContext *s, bool is_ld, MemOpIdx oi, TCGType ext, TCGReg data_reg, TCGReg addr_reg, tcg_insn_unit *raddr, tcg_insn_unit *label_ptr) {
@@ -1778,7 +1778,7 @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp memop, } static void tcg_out_qemu_ld(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, - TCGMemOpIdx oi, TCGType ext) + MemOpIdx oi, TCGType ext) { MemOp memop = get_memop(oi); const TCGType otype = TARGET_LONG_BITS == 64 ? TCG_TYPE_I64 : TCG_TYPE_I32;
@@ -1803,7 +1803,7 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, } static void tcg_out_qemu_st(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, - TCGMemOpIdx oi) + MemOpIdx oi) { MemOp memop = get_memop(oi); const TCGType otype = TARGET_LONG_BITS == 64 ? TCG_TYPE_I64 : TCG_TYPE_I32;
tcg/arm/tcg-target.c.inc +5 -5
@@ -1588,7 +1588,7 @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addrlo, TCGReg addrhi, /* Record the context of a call to the out of line helper code for the slow path for a load or store, so that we can later generate the correct helper code. */ -static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, +static void add_qemu_ldst_label(TCGContext *s, bool is_ld, MemOpIdx oi, TCGReg datalo, TCGReg datahi, TCGReg addrlo, TCGReg addrhi, tcg_insn_unit *raddr, tcg_insn_unit *label_ptr)
@@ -1608,7 +1608,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) { TCGReg argreg, datalo, datahi; - TCGMemOpIdx oi = lb->oi; + MemOpIdx oi = lb->oi; MemOp opc = get_memop(oi); void *func;
@@ -1672,7 +1672,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) { TCGReg argreg, datalo, datahi; - TCGMemOpIdx oi = lb->oi; + MemOpIdx oi = lb->oi; MemOp opc = get_memop(oi); if (!reloc_pc24(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) {
@@ -1801,7 +1801,7 @@ static inline void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) { TCGReg addrlo, datalo, datahi, addrhi __attribute__((unused)); - TCGMemOpIdx oi; + MemOpIdx oi; MemOp opc; #ifdef CONFIG_SOFTMMU int mem_index;
@@ -1906,7 +1906,7 @@ static inline void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) { TCGReg addrlo, datalo, datahi, addrhi __attribute__((unused)); - TCGMemOpIdx oi; + MemOpIdx oi; MemOp opc; #ifdef CONFIG_SOFTMMU int mem_index;
tcg/i386/tcg-target.c.inc +5 -5
@@ -1740,7 +1740,7 @@ static inline void tcg_out_tlb_load(TCGContext *s, TCGReg addrlo, TCGReg addrhi, * for a load or store, so that we can later generate the correct helper code */ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, bool is_64, - TCGMemOpIdx oi, + MemOpIdx oi, TCGReg datalo, TCGReg datahi, TCGReg addrlo, TCGReg addrhi, tcg_insn_unit *raddr,
@@ -1767,7 +1767,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, bool is_64, */ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) { - TCGMemOpIdx oi = l->oi; + MemOpIdx oi = l->oi; MemOp opc = get_memop(oi); TCGReg data_reg; tcg_insn_unit **label_ptr = &l->label_ptr[0];
@@ -1852,7 +1852,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) */ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) { - TCGMemOpIdx oi = l->oi; + MemOpIdx oi = l->oi; MemOp opc = get_memop(oi); MemOp s_bits = opc & MO_SIZE; tcg_insn_unit **label_ptr = &l->label_ptr[0];
@@ -2053,7 +2053,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) { TCGReg datalo, datahi, addrlo; TCGReg addrhi __attribute__((unused)); - TCGMemOpIdx oi; + MemOpIdx oi; MemOp opc; #if defined(CONFIG_SOFTMMU) int mem_index;
@@ -2142,7 +2142,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is64) { TCGReg datalo, datahi, addrlo; TCGReg addrhi __attribute__((unused)); - TCGMemOpIdx oi; + MemOpIdx oi; MemOp opc; #if defined(CONFIG_SOFTMMU) int mem_index;
tcg/mips/tcg-target.c.inc +6 -6
@@ -1140,7 +1140,7 @@ QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) < -32768); * Clobbers TMP0, TMP1, TMP2, TMP3. */ static void tcg_out_tlb_load(TCGContext *s, TCGReg base, TCGReg addrl, - TCGReg addrh, TCGMemOpIdx oi, + TCGReg addrh, MemOpIdx oi, tcg_insn_unit *label_ptr[2], bool is_load) { MemOp opc = get_memop(oi);
@@ -1216,7 +1216,7 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg base, TCGReg addrl, tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_TMP2, addrl); } -static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, +static void add_qemu_ldst_label(TCGContext *s, int is_ld, MemOpIdx oi, TCGType ext, TCGReg datalo, TCGReg datahi, TCGReg addrlo, TCGReg addrhi,
@@ -1241,7 +1241,7 @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) { const tcg_insn_unit *tgt_rx = tcg_splitwx_to_rx(s->code_ptr); - TCGMemOpIdx oi = l->oi; + MemOpIdx oi = l->oi; MemOp opc = get_memop(oi); TCGReg v0; int i;
@@ -1295,7 +1295,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) { const tcg_insn_unit *tgt_rx = tcg_splitwx_to_rx(s->code_ptr); - TCGMemOpIdx oi = l->oi; + MemOpIdx oi = l->oi; MemOp opc = get_memop(oi); MemOp s_bits = opc & MO_SIZE; int i;
@@ -1454,7 +1454,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) { TCGReg addr_regl, addr_regh __attribute__((unused)); TCGReg data_regl, data_regh; - TCGMemOpIdx oi; + MemOpIdx oi; MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[2];
@@ -1556,7 +1556,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) { TCGReg addr_regl, addr_regh __attribute__((unused)); TCGReg data_regl, data_regh; - TCGMemOpIdx oi; + MemOpIdx oi; MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[2];
tcg/ppc/tcg-target.c.inc +5 -5
@@ -2088,7 +2088,7 @@ static TCGReg tcg_out_tlb_read(TCGContext *s, MemOp opc, /* Record the context of a call to the out of line helper code for the slow path for a load or store, so that we can later generate the correct helper code. */ -static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, +static void add_qemu_ldst_label(TCGContext *s, bool is_ld, MemOpIdx oi, TCGReg datalo_reg, TCGReg datahi_reg, TCGReg addrlo_reg, TCGReg addrhi_reg, tcg_insn_unit *raddr, tcg_insn_unit *lptr)
@@ -2107,7 +2107,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) { - TCGMemOpIdx oi = lb->oi; + MemOpIdx oi = lb->oi; MemOp opc = get_memop(oi); TCGReg hi, lo, arg = TCG_REG_R3;
@@ -2154,7 +2154,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) { - TCGMemOpIdx oi = lb->oi; + MemOpIdx oi = lb->oi; MemOp opc = get_memop(oi); MemOp s_bits = opc & MO_SIZE; TCGReg hi, lo, arg = TCG_REG_R3;
@@ -2218,7 +2218,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) { TCGReg datalo, datahi, addrlo, rbase; TCGReg addrhi __attribute__((unused)); - TCGMemOpIdx oi; + MemOpIdx oi; MemOp opc, s_bits; #ifdef CONFIG_SOFTMMU int mem_index;
@@ -2293,7 +2293,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) { TCGReg datalo, datahi, addrlo, rbase; TCGReg addrhi __attribute__((unused)); - TCGMemOpIdx oi; + MemOpIdx oi; MemOp opc, s_bits; #ifdef CONFIG_SOFTMMU int mem_index;
tcg/riscv/tcg-target.c.inc +8 -8
@@ -850,7 +850,7 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) #include "../tcg-ldst.c.inc" /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, - * TCGMemOpIdx oi, uintptr_t ra) + * MemOpIdx oi, uintptr_t ra) */ static void * const qemu_ld_helpers[MO_SSIZE + 1] = { [MO_UB] = helper_ret_ldub_mmu,
@@ -875,7 +875,7 @@ static void * const qemu_ld_helpers[MO_SSIZE + 1] = { }; /* helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr, - * uintxx_t val, TCGMemOpIdx oi, + * uintxx_t val, MemOpIdx oi, * uintptr_t ra) */ static void * const qemu_st_helpers[MO_SIZE + 1] = {
@@ -906,7 +906,7 @@ static void tcg_out_goto(TCGContext *s, const tcg_insn_unit *target) } static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl, - TCGReg addrh, TCGMemOpIdx oi, + TCGReg addrh, MemOpIdx oi, tcg_insn_unit **label_ptr, bool is_load) { MemOp opc = get_memop(oi);
@@ -959,7 +959,7 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl, tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, TCG_REG_TMP2, addrl); } -static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, +static void add_qemu_ldst_label(TCGContext *s, int is_ld, MemOpIdx oi, TCGType ext, TCGReg datalo, TCGReg datahi, TCGReg addrlo, TCGReg addrhi,
@@ -980,7 +980,7 @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) { - TCGMemOpIdx oi = l->oi; + MemOpIdx oi = l->oi; MemOp opc = get_memop(oi); TCGReg a0 = tcg_target_call_iarg_regs[0]; TCGReg a1 = tcg_target_call_iarg_regs[1];
@@ -1012,7 +1012,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) { - TCGMemOpIdx oi = l->oi; + MemOpIdx oi = l->oi; MemOp opc = get_memop(oi); MemOp s_bits = opc & MO_SIZE; TCGReg a0 = tcg_target_call_iarg_regs[0];
@@ -1104,7 +1104,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) { TCGReg addr_regl, addr_regh __attribute__((unused)); TCGReg data_regl, data_regh; - TCGMemOpIdx oi; + MemOpIdx oi; MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[1];
@@ -1173,7 +1173,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) { TCGReg addr_regl, addr_regh __attribute__((unused)); TCGReg data_regl, data_regh; - TCGMemOpIdx oi; + MemOpIdx oi; MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[1];
tcg/s390/tcg-target.c.inc +5 -5
@@ -1547,7 +1547,7 @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg addr_reg, MemOp opc, return addr_reg; } -static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, +static void add_qemu_ldst_label(TCGContext *s, bool is_ld, MemOpIdx oi, TCGReg data, TCGReg addr, tcg_insn_unit *raddr, tcg_insn_unit *label_ptr) {
@@ -1565,7 +1565,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) { TCGReg addr_reg = lb->addrlo_reg; TCGReg data_reg = lb->datalo_reg; - TCGMemOpIdx oi = lb->oi; + MemOpIdx oi = lb->oi; MemOp opc = get_memop(oi); if (!patch_reloc(lb->label_ptr[0], R_390_PC16DBL,
@@ -1590,7 +1590,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) { TCGReg addr_reg = lb->addrlo_reg; TCGReg data_reg = lb->datalo_reg; - TCGMemOpIdx oi = lb->oi; + MemOpIdx oi = lb->oi; MemOp opc = get_memop(oi); if (!patch_reloc(lb->label_ptr[0], R_390_PC16DBL,
@@ -1644,7 +1644,7 @@ static void tcg_prepare_user_ldst(TCGContext *s, TCGReg *addr_reg, #endif /* CONFIG_SOFTMMU */ static void tcg_out_qemu_ld(TCGContext* s, TCGReg data_reg, TCGReg addr_reg, - TCGMemOpIdx oi) + MemOpIdx oi) { MemOp opc = get_memop(oi); #ifdef CONFIG_SOFTMMU
@@ -1671,7 +1671,7 @@ static void tcg_out_qemu_ld(TCGContext* s, TCGReg data_reg, TCGReg addr_reg, } static void tcg_out_qemu_st(TCGContext* s, TCGReg data_reg, TCGReg addr_reg, - TCGMemOpIdx oi) + MemOpIdx oi) { MemOp opc = get_memop(oi); #ifdef CONFIG_SOFTMMU
tcg/sparc/tcg-target.c.inc +2 -2
@@ -1140,7 +1140,7 @@ static const int qemu_st_opc[(MO_SIZE | MO_BSWAP) + 1] = { }; static void tcg_out_qemu_ld(TCGContext *s, TCGReg data, TCGReg addr, - TCGMemOpIdx oi, bool is_64) + MemOpIdx oi, bool is_64) { MemOp memop = get_memop(oi); #ifdef CONFIG_SOFTMMU
@@ -1222,7 +1222,7 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg data, TCGReg addr, } static void tcg_out_qemu_st(TCGContext *s, TCGReg data, TCGReg addr, - TCGMemOpIdx oi) + MemOpIdx oi) { MemOp memop = get_memop(oi); #ifdef CONFIG_SOFTMMU
tcg/tcg-ldst.c.inc +1 -1
@@ -22,7 +22,7 @@ typedef struct TCGLabelQemuLdst { bool is_ld; /* qemu_ld: true, qemu_st: false */ - TCGMemOpIdx oi; + MemOpIdx oi; TCGType type; /* result type of a load */ TCGReg addrlo_reg; /* reg index for low word of guest virtual addr */ TCGReg addrhi_reg; /* reg index for high word of guest virtual addr */
Signature · 1 line
2.25.1
PATCH v2 24/55 tcg: Split out MemOpIdx to exec/memopidx.h
In reply to Richard HendersonMove this code from tcg/tcg.h to its own header.
--- include/exec/memopidx.h | 55 +++++++++++++++++++++++++++++++++++++++++ include/tcg/tcg.h | 39 +---------------------------- 2 files changed, 56 insertions(+), 38 deletions(-) create mode 100644 include/exec/memopidx.h
include/exec/memopidx.h new file +55 -0
@@ -0,0 +1,55 @@ +/* +* Combine the MemOp and mmu_idx parameters into a single value. +* +* Authors: +* Richard Henderson <[email protected]> +* +* 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 EXEC_MEMOPIDX_H +#define EXEC_MEMOPIDX_H 1 + +#include "exec/memop.h" + +typedef uint32_t MemOpIdx ; + +/** +* make_memop_idx +* @op: memory operation +* @idx: mmu index +* +* Encode these values into a single parameter. +*/ +static inline MemOpIdx make_memop_idx (MemOp op,unsigned idx) +{ +#ifdef CONFIG_DEBUG_TCG +assert (idx <=15 ); +#endif +return (op <<4 ) | idx; +} + +/** +* get_memop +* @oi: combined op/idx parameter +* +* Extract the memory operation from the combined value. +*/ +static inline MemOp get_memop (MemOpIdx oi) +{ +return oi >>4 ; +} + +/** +* get_mmuidx +* @oi: combined op/idx parameter +* +* Extract the mmu index from the combined value. +*/ +static inline unsigned get_mmuidx (MemOpIdx oi) +{ +return oi &15 ; +} + +#endif
include/tcg/tcg.h +1 -38
@@ -27,6 +27,7 @@#include "cpu.h" #include "exec/memop.h" +#include "exec/memopidx.h" #include "qemu/bitops.h" #include "qemu/plugin.h" #include "qemu/queue.h"
@@ -1147,44 +1148,6 @@ static inline size_t tcg_current_code_size(TCGContext *s)return tcg_ptr_byte_diff (s->code_ptr, s->code_buf); } -/* Combine the MemOp and mmu_idx parameters into a single value. */ -typedef uint32_t MemOpIdx ; - -/** -* make_memop_idx -* @op: memory operation -* @idx: mmu index -* -* Encode these values into a single parameter. -*/ -static inline MemOpIdx make_memop_idx (MemOp op,unsigned idx) -{ -tcg_debug_assert (idx <=15 ); -return (op <<4 ) | idx; -} - -/** -* get_memop -* @oi: combined op/idx parameter -* -* Extract the memory operation from the combined value. -*/ -static inline MemOp get_memop (MemOpIdx oi) -{ -return oi >>4 ; -} - -/** -* get_mmuidx -* @oi: combined op/idx parameter -* -* Extract the mmu index from the combined value. -*/ -static inline unsigned get_mmuidx (MemOpIdx oi) -{ -return oi &15 ; -} -/** * tcg_qemu_tb_exec: * @env: pointer to CPUArchState for the CPU
Signature · 1 line
2.25.1
PATCH v2 25/55 trace/mem: Pass MemOpIdx to trace_mem_get_info
In reply to Richard HendersonWe (will) often have the complete MemOpIdx handy, so use that.
--- trace/mem.h | 32 +++++++++----------------- accel/tcg/cputlb.c | 12 ++++------ accel/tcg/user-exec.c | 42 +++++++++++++++++++++++------------ tcg/tcg-op.c | 8 +++---- accel/tcg/atomic_common.c.inc | 6 ++--- 5 files changed, 49 insertions(+), 51 deletions(-)
trace/mem.h +10 -22
@@ -10,7 +10,7 @@#ifndef TRACE__MEM_H #define TRACE__MEM_H -#include "tcg/tcg.h" +#include "exec/memopidx.h" #define TRACE_MEM_SZ_SHIFT_MASK 0xf/* size shift mask */ #define TRACE_MEM_SE (1ULL << 4)/* sign extended (y/n) */
@@ -19,45 +19,33 @@#define TRACE_MEM_MMU_SHIFT 8/* mmu idx */ /** -* trace_mem_build_info: +* trace_mem_get_info: * * Return a value for the 'info' argument in guest memory access traces. */ -static inline uint16_t trace_mem_build_info (int size_shift,bool sign_extend, -MemOp endianness,bool store, -unsigned int mmu_idx) +static inline uint16_t trace_mem_get_info (MemOpIdx oi,bool store) { +MemOp op =get_memop (oi); +uint32_t size_shift = op &MO_SIZE ; +bool sign_extend = op &MO_SIGN ; +bool big_endian = (op &MO_BSWAP ) ==MO_BE ;uint16_t res; res = size_shift &TRACE_MEM_SZ_SHIFT_MASK ;if (sign_extend) { res |=TRACE_MEM_SE ; } -if (endianness ==MO_BE ) { +if (big_endian) { res |=TRACE_MEM_BE ; }if (store) { res |=TRACE_MEM_ST ; }#ifdef CONFIG_SOFTMMU - res |= mmu_idx <<TRACE_MEM_MMU_SHIFT ; + res |=get_mmuidx (oi) <<TRACE_MEM_MMU_SHIFT ;#endif +return res; } - -/** -* trace_mem_get_info: -* -* Return a value for the 'info' argument in guest memory access traces. -*/ -static inline uint16_t trace_mem_get_info (MemOp op, -unsigned int mmu_idx, -bool store) -{ -return trace_mem_build_info (op &MO_SIZE , !!(op &MO_SIGN ), - op &MO_BSWAP , store, - mmu_idx); -} -#endif /* TRACE__MEM_H */
accel/tcg/cputlb.c +4 -8
@@ -2103,14 +2103,12 @@ static inline uint64_t cpu_load_helper(CPUArchState *env, abi_ptr addr, int mmu_idx, uintptr_t retaddr, MemOp op, FullLoadHelper *full_load) { - uint16_t meminfo; -MemOpIdx oi; + MemOpIdx oi = make_memop_idx(op, mmu_idx); +uint16_t meminfo =trace_mem_get_info (oi, false);uint64_t ret; - meminfo =trace_mem_get_info (op, mmu_idx, false);trace_guest_mem_before_exec (env_cpu (env), addr, meminfo); - oi =make_memop_idx (op, mmu_idx); ret =full_load (env, addr, oi, retaddr);qemu_plugin_vcpu_mem_cb (env_cpu (env), addr, meminfo);
@@ -2542,13 +2540,11 @@ static inline void QEMU_ALWAYS_INLINE cpu_store_helper(CPUArchState *env, target_ulong addr, uint64_t val, int mmu_idx, uintptr_t retaddr, MemOp op) { -MemOpIdx oi; -uint16_t meminfo; +MemOpIdx oi =make_memop_idx (op, mmu_idx); +uint16_t meminfo =trace_mem_get_info (oi, true); - meminfo =trace_mem_get_info (op, mmu_idx, true);trace_guest_mem_before_exec (env_cpu (env), addr, meminfo); - oi =make_memop_idx (op, mmu_idx);store_helper (env, addr, val, oi, retaddr, op);qemu_plugin_vcpu_mem_cb (env_cpu (env), addr, meminfo);
accel/tcg/user-exec.c +28 -14
133 lines not on this page · raw message
tcg/tcg-op.c +4 -4
@@ -2866,7 +2866,7 @@ static inline void plugin_gen_mem_callbacks(TCGv vaddr, uint16_t info)void tcg_gen_qemu_ld_i32 (TCGv_i32 val,TCGv addr,TCGArg idx,MemOp memop) {MemOp orig_memop; -uint16_t info =trace_mem_get_info (memop, idx,0 ); +uint16_t info =trace_mem_get_info (make_memop_idx (memop, idx),0 );tcg_gen_req_mo (TCG_MO_LD_LD |TCG_MO_ST_LD ); memop =tcg_canonicalize_memop (memop,0 ,0 );
@@ -2904,7 +2904,7 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop)void tcg_gen_qemu_st_i32 (TCGv_i32 val,TCGv addr,TCGArg idx,MemOp memop) {TCGv_i32 swap =NULL ; -uint16_t info =trace_mem_get_info (memop, idx,1 ); +uint16_t info =trace_mem_get_info (make_memop_idx (memop, idx),1 );tcg_gen_req_mo (TCG_MO_LD_ST |TCG_MO_ST_ST ); memop =tcg_canonicalize_memop (memop,0 ,1 );
@@ -2956,7 +2956,7 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop)tcg_gen_req_mo (TCG_MO_LD_LD |TCG_MO_ST_LD ); memop =tcg_canonicalize_memop (memop,1 ,0 ); - info =trace_mem_get_info (memop, idx,0 ); + info =trace_mem_get_info (make_memop_idx (memop, idx),0 );trace_guest_mem_before_tcg (tcg_ctx->cpu, cpu_env, addr, info); orig_memop = memop;
@@ -3004,7 +3004,7 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop)tcg_gen_req_mo (TCG_MO_LD_ST |TCG_MO_ST_ST ); memop =tcg_canonicalize_memop (memop,1 ,1 ); - info =trace_mem_get_info (memop, idx,1 ); + info =trace_mem_get_info (make_memop_idx (memop, idx),1 );trace_guest_mem_before_tcg (tcg_ctx->cpu, cpu_env, addr, info);if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop &MO_BSWAP )) {
accel/tcg/atomic_common.c.inc +3 -3
@@ -17,7 +17,7 @@ static uint16_t atomic_trace_rmw_pre(CPUArchState *env, target_ulong addr, MemOpIdx oi) { CPUState *cpu = env_cpu(env); - uint16_t info = trace_mem_get_info(get_memop(oi), get_mmuidx(oi), false); + uint16_t info = trace_mem_get_info(oi, false); trace_guest_mem_before_exec(cpu, addr, info); trace_guest_mem_before_exec(cpu, addr, info | TRACE_MEM_ST);
@@ -36,7 +36,7 @@ static void atomic_trace_rmw_post(CPUArchState *env, target_ulong addr, static uint16_t atomic_trace_ld_pre(CPUArchState *env, target_ulong addr, MemOpIdx oi) { - uint16_t info = trace_mem_get_info(get_memop(oi), get_mmuidx(oi), false); + uint16_t info = trace_mem_get_info(oi, false); trace_guest_mem_before_exec(env_cpu(env), addr, info);
@@ -52,7 +52,7 @@ static void atomic_trace_ld_post(CPUArchState *env, target_ulong addr, static uint16_t atomic_trace_st_pre(CPUArchState *env, target_ulong addr, MemOpIdx oi) { - uint16_t info = trace_mem_get_info(get_memop(oi), get_mmuidx(oi), true); + uint16_t info = trace_mem_get_info(oi, true); trace_guest_mem_before_exec(env_cpu(env), addr, info);
Signature · 1 line
2.25.1
PATCH v2 26/55 accel/tcg: Pass MemOpIdx to atomic_trace_*_post
In reply to Richard HendersonWe will shortly use the MemOpIdx directly, but in the meantime re-compute the trace meminfo.
--- accel/tcg/atomic_template.h | 48 +++++++++++++++++------------------ accel/tcg/atomic_common.c.inc | 30 +++++++++++----------- 2 files changed, 39 insertions(+), 39 deletions(-)
accel/tcg/atomic_template.h +24 -24
@@ -77,15 +77,15 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_READ |PAGE_WRITE , retaddr);DATA_TYPE ret; -uint16_t info =atomic_trace_rmw_pre (env, addr, oi); +atomic_trace_rmw_pre (env, addr, oi);#if DATA_SIZE ==16 ret =atomic16_cmpxchg (haddr, cmpv, newv);#else ret =qatomic_cmpxchg__nocheck (haddr, cmpv, newv);#endif ATOMIC_MMU_CLEANUP ; -atomic_trace_rmw_post (env, addr, info); +atomic_trace_rmw_post (env, addr, oi);return ret; }
@@ -97,11 +97,11 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr,DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_READ , retaddr);DATA_TYPE val; -uint16_t info =atomic_trace_ld_pre (env, addr, oi); +atomic_trace_ld_pre (env, addr, oi); val =atomic16_read (haddr);ATOMIC_MMU_CLEANUP ; -atomic_trace_ld_post (env, addr, info); +atomic_trace_ld_post (env, addr, oi);return val; }
@@ -110,11 +110,11 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, ABI_TYPE val, {DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_WRITE , retaddr); -uint16_t info =atomic_trace_st_pre (env, addr, oi); +atomic_trace_st_pre (env, addr, oi);atomic16_set (haddr, val);ATOMIC_MMU_CLEANUP ; -atomic_trace_st_post (env, addr, info); +atomic_trace_st_post (env, addr, oi); }#endif #else
@@ -124,11 +124,11 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ABI_TYPE val,DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_READ |PAGE_WRITE , retaddr);DATA_TYPE ret; -uint16_t info =atomic_trace_rmw_pre (env, addr, oi); +atomic_trace_rmw_pre (env, addr, oi); ret =qatomic_xchg__nocheck (haddr, val);ATOMIC_MMU_CLEANUP ; -atomic_trace_rmw_post (env, addr, info); +atomic_trace_rmw_post (env, addr, oi);return ret; }
@@ -139,10 +139,10 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE , \PAGE_READ |PAGE_WRITE , retaddr); \DATA_TYPE ret; \ -uint16_t info =atomic_trace_rmw_pre (env, addr, oi); \ +atomic_trace_rmw_pre (env, addr, oi); \ ret = qatomic_##X(haddr, val); \ ATOMIC_MMU_CLEANUP; \ - atomic_trace_rmw_post(env, addr, info); \ + atomic_trace_rmw_post(env, addr, oi); \ return ret; \ }
@@ -172,7 +172,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \XDATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE , \PAGE_READ |PAGE_WRITE , retaddr); \XDATA_TYPE cmp, old, new, val = xval; \ -uint16_t info =atomic_trace_rmw_pre (env, addr, oi); \ +atomic_trace_rmw_pre (env, addr, oi); \smp_mb (); \ cmp =qatomic_read__nocheck (haddr); \ do { \
@@ -180,7 +180,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ cmp =qatomic_cmpxchg__nocheck (haddr, old, new); \ }while (cmp != old); \ATOMIC_MMU_CLEANUP ; \ -atomic_trace_rmw_post (env, addr, info); \ +atomic_trace_rmw_post (env, addr, oi); \return RET ; \ }
@@ -216,15 +216,15 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_READ |PAGE_WRITE , retaddr);DATA_TYPE ret; -uint16_t info =atomic_trace_rmw_pre (env, addr, oi); +atomic_trace_rmw_pre (env, addr, oi);#if DATA_SIZE ==16 ret =atomic16_cmpxchg (haddr,BSWAP (cmpv),BSWAP (newv));#else ret =qatomic_cmpxchg__nocheck (haddr,BSWAP (cmpv),BSWAP (newv));#endif ATOMIC_MMU_CLEANUP ; -atomic_trace_rmw_post (env, addr, info); +atomic_trace_rmw_post (env, addr, oi);return BSWAP (ret); }
@@ -236,11 +236,11 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr,DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_READ , retaddr);DATA_TYPE val; -uint16_t info =atomic_trace_ld_pre (env, addr, oi); +atomic_trace_ld_pre (env, addr, oi); val =atomic16_read (haddr);ATOMIC_MMU_CLEANUP ; -atomic_trace_ld_post (env, addr, info); +atomic_trace_ld_post (env, addr, oi);return BSWAP (val); }
@@ -249,12 +249,12 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, ABI_TYPE val, {DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_WRITE , retaddr); -uint16_t info =atomic_trace_st_pre (env, addr, oi); +atomic_trace_st_pre (env, addr, oi); val =BSWAP (val);atomic16_set (haddr, val);ATOMIC_MMU_CLEANUP ; -atomic_trace_st_post (env, addr, info); +atomic_trace_st_post (env, addr, oi); }#endif #else
@@ -264,11 +264,11 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ABI_TYPE val,DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE ,PAGE_READ |PAGE_WRITE , retaddr);ABI_TYPE ret; -uint16_t info =atomic_trace_rmw_pre (env, addr, oi); +atomic_trace_rmw_pre (env, addr, oi); ret =qatomic_xchg__nocheck (haddr,BSWAP (val));ATOMIC_MMU_CLEANUP ; -atomic_trace_rmw_post (env, addr, info); +atomic_trace_rmw_post (env, addr, oi);return BSWAP (ret); }
@@ -279,10 +279,10 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \DATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE , \PAGE_READ |PAGE_WRITE , retaddr); \DATA_TYPE ret; \ -uint16_t info =atomic_trace_rmw_pre (env, addr, oi); \ +atomic_trace_rmw_pre (env, addr, oi); \ ret = qatomic_##X(haddr, BSWAP(val)); \ ATOMIC_MMU_CLEANUP; \ - atomic_trace_rmw_post(env, addr, info); \ + atomic_trace_rmw_post(env, addr, oi); \ return BSWAP(ret); \ }
@@ -309,7 +309,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \XDATA_TYPE *haddr =atomic_mmu_lookup (env, addr, oi,DATA_SIZE , \PAGE_READ |PAGE_WRITE , retaddr); \XDATA_TYPE ldo, ldn, old, new, val = xval; \ -uint16_t info =atomic_trace_rmw_pre (env, addr, oi); \ +atomic_trace_rmw_pre (env, addr, oi); \smp_mb (); \ ldn =qatomic_read__nocheck (haddr); \ do { \
@@ -317,7 +317,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ ldn =qatomic_cmpxchg__nocheck (haddr, ldo,BSWAP (new)); \ }while (ldo != ldn); \ATOMIC_MMU_CLEANUP ; \ -atomic_trace_rmw_post (env, addr, info); \ +atomic_trace_rmw_post (env, addr, oi); \return RET ; \ }
accel/tcg/atomic_common.c.inc +15 -15
@@ -13,55 +13,55 @@ * See the COPYING file in the top-level directory. */ -static uint16_t atomic_trace_rmw_pre(CPUArchState *env, target_ulong addr, - MemOpIdx oi) +static void atomic_trace_rmw_pre(CPUArchState *env, target_ulong addr, + MemOpIdx oi) { CPUState *cpu = env_cpu(env); uint16_t info = trace_mem_get_info(oi, false); trace_guest_mem_before_exec(cpu, addr, info); trace_guest_mem_before_exec(cpu, addr, info | TRACE_MEM_ST); - - return info; } static void atomic_trace_rmw_post(CPUArchState *env, target_ulong addr, - uint16_t info) + MemOpIdx oi) { + uint16_t info = trace_mem_get_info(oi, false); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info); qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info | TRACE_MEM_ST); } #if HAVE_ATOMIC128 -static uint16_t atomic_trace_ld_pre(CPUArchState *env, target_ulong addr, - MemOpIdx oi) +static void atomic_trace_ld_pre(CPUArchState *env, target_ulong addr, + MemOpIdx oi) { uint16_t info = trace_mem_get_info(oi, false); trace_guest_mem_before_exec(env_cpu(env), addr, info); - - return info; } static void atomic_trace_ld_post(CPUArchState *env, target_ulong addr, - uint16_t info) + MemOpIdx oi) { + uint16_t info = trace_mem_get_info(oi, false); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info); } -static uint16_t atomic_trace_st_pre(CPUArchState *env, target_ulong addr, - MemOpIdx oi) +static void atomic_trace_st_pre(CPUArchState *env, target_ulong addr, + MemOpIdx oi) { uint16_t info = trace_mem_get_info(oi, true); trace_guest_mem_before_exec(env_cpu(env), addr, info); - - return info; } static void atomic_trace_st_post(CPUArchState *env, target_ulong addr, - uint16_t info) + MemOpIdx oi) { + uint16_t info = trace_mem_get_info(oi, false); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info); } #endif
Signature · 1 line
2.25.1
PATCH v2 27/55 plugins: Reorg arguments to qemu_plugin_vcpu_mem_cb
In reply to Richard HendersonUse the MemOpIdx directly, rather than the rearrangement of the same bits currently done by the trace infrastructure. Pass in enum qemu_plugin_mem_rw so that we are able to treat read-modify-write operations as a single operation.
--- include/qemu/plugin.h | 26 ++++++++++++++++++++++++-- accel/tcg/cputlb.c | 4 ++-- accel/tcg/plugin-gen.c | 5 ++--- accel/tcg/user-exec.c | 28 ++++++++++++++-------------- plugins/api.c | 19 +++++++++++-------- plugins/core.c | 10 +++++----- tcg/tcg-op.c | 30 +++++++++++++++++++++--------- accel/tcg/atomic_common.c.inc | 13 +++---------- 8 files changed, 82 insertions(+), 53 deletions(-)
include/qemu/plugin.h +24 -2
@@ -12,6 +12,7 @@#include "qemu/error-report.h" #include "qemu/queue.h" #include "qemu/option.h" +#include "exec/memopidx.h" /* * Events that plugins can subscribe to.
@@ -36,6 +37,25 @@ enum qemu_plugin_event {struct qemu_plugin_desc ; typedef QTAILQ_HEAD(, qemu_plugin_desc) QemuPluginList; +/* +* Construct a qemu_plugin_meminfo_t. +*/ +static inline qemu_plugin_meminfo_t +make_plugin_meminfo (MemOpIdx oi,enum qemu_plugin_mem_rw rw) +{ +return oi | (rw <<16 ); +} + +/* +* Extract the memory operation direction from a qemu_plugin_meminfo_t. +* Other portions may be extracted via get_memop and get_mmuidx. +*/ +static inline enum qemu_plugin_mem_rw +get_plugin_meminfo_rw (qemu_plugin_meminfo_t i) +{ +return i >>16 ; +} +#ifdef CONFIG_PLUGIN extern QemuOptsList qemu_plugin_opts;
@@ -180,7 +200,8 @@ qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, uint64_t a6, uint64_t a7, uint64_t a8);void qemu_plugin_vcpu_syscall_ret (CPUState *cpu,int64_t num,int64_t ret); -void qemu_plugin_vcpu_mem_cb (CPUState *cpu,uint64_t vaddr,uint32_t meminfo); +void qemu_plugin_vcpu_mem_cb (CPUState *cpu,uint64_t vaddr, +MemOpIdx oi,enum qemu_plugin_mem_rw rw);void qemu_plugin_flush_cb (void );
@@ -244,7 +265,8 @@ void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret) { }static inline void qemu_plugin_vcpu_mem_cb (CPUState *cpu,uint64_t vaddr, -uint32_t meminfo) +MemOpIdx oi, +enum qemu_plugin_mem_rw rw) { }static inline void qemu_plugin_flush_cb (void )
accel/tcg/cputlb.c +2 -2
@@ -2111,7 +2111,7 @@ static inline uint64_t cpu_load_helper(CPUArchState *env, abi_ptr addr, ret =full_load (env, addr, oi, retaddr); -qemu_plugin_vcpu_mem_cb (env_cpu (env), addr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), addr, oi,QEMU_PLUGIN_MEM_R );return ret; }
@@ -2547,7 +2547,7 @@ cpu_store_helper(CPUArchState *env, target_ulong addr, uint64_t val,store_helper (env, addr, val, oi, retaddr, op); -qemu_plugin_vcpu_mem_cb (env_cpu (env), addr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), addr, oi,QEMU_PLUGIN_MEM_W ); } void cpu_stb_mmuidx_ra(CPUArchState *env, target_ulong addr, uint32_t val,
accel/tcg/plugin-gen.c +2 -3
@@ -45,7 +45,6 @@#include "qemu/osdep.h" #include "tcg/tcg.h" #include "tcg/tcg-op.h" -#include "trace/mem.h" #include "exec/exec-all.h" #include "exec/plugin-gen.h" #include "exec/translator.h"
@@ -211,9 +210,9 @@ static void gen_mem_wrapped(enum plugin_gen_cb type, const union mem_gen_fn *f, TCGv addr, uint32_t info, bool is_mem) { - int wr = !!(info & TRACE_MEM_ST); + enum qemu_plugin_mem_rw rw = get_plugin_meminfo_rw(info); -gen_plugin_cb_start (PLUGIN_GEN_FROM_MEM , type, wr); +gen_plugin_cb_start (PLUGIN_GEN_FROM_MEM , type, rw);if (is_mem) { f->mem_fn (addr, info); }else {
accel/tcg/user-exec.c +14 -14
@@ -861,7 +861,7 @@ uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo); ret =ldub_p (g2h (env_cpu (env), ptr)); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_R );return ret; }
@@ -878,7 +878,7 @@ uint32_t cpu_lduw_be_data(CPUArchState *env, abi_ptr ptr)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo); ret =lduw_be_p (g2h (env_cpu (env), ptr)); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_R );return ret; }
@@ -895,7 +895,7 @@ uint32_t cpu_ldl_be_data(CPUArchState *env, abi_ptr ptr)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo); ret =ldl_be_p (g2h (env_cpu (env), ptr)); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_R );return ret; }
@@ -907,7 +907,7 @@ uint64_t cpu_ldq_be_data(CPUArchState *env, abi_ptr ptr)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo); ret =ldq_be_p (g2h (env_cpu (env), ptr)); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_R );return ret; }
@@ -919,7 +919,7 @@ uint32_t cpu_lduw_le_data(CPUArchState *env, abi_ptr ptr)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo); ret =lduw_le_p (g2h (env_cpu (env), ptr)); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_R );return ret; }
@@ -936,7 +936,7 @@ uint32_t cpu_ldl_le_data(CPUArchState *env, abi_ptr ptr)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo); ret =ldl_le_p (g2h (env_cpu (env), ptr)); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_R );return ret; }
@@ -948,7 +948,7 @@ uint64_t cpu_ldq_le_data(CPUArchState *env, abi_ptr ptr)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo); ret =ldq_le_p (g2h (env_cpu (env), ptr)); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_R );return ret; }
@@ -1044,7 +1044,7 @@ void cpu_stb_data(CPUArchState *env, abi_ptr ptr, uint32_t val)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo);stb_p (g2h (env_cpu (env), ptr), val); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_W ); }void cpu_stw_be_data (CPUArchState *env,abi_ptr ptr,uint32_t val)
@@ -1054,7 +1054,7 @@ void cpu_stw_be_data(CPUArchState *env, abi_ptr ptr, uint32_t val)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo);stw_be_p (g2h (env_cpu (env), ptr), val); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_W ); }void cpu_stl_be_data (CPUArchState *env,abi_ptr ptr,uint32_t val)
@@ -1064,7 +1064,7 @@ void cpu_stl_be_data(CPUArchState *env, abi_ptr ptr, uint32_t val)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo);stl_be_p (g2h (env_cpu (env), ptr), val); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_W ); }void cpu_stq_be_data (CPUArchState *env,abi_ptr ptr,uint64_t val)
@@ -1074,7 +1074,7 @@ void cpu_stq_be_data(CPUArchState *env, abi_ptr ptr, uint64_t val)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo);stq_be_p (g2h (env_cpu (env), ptr), val); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_W ); }void cpu_stw_le_data (CPUArchState *env,abi_ptr ptr,uint32_t val)
@@ -1084,7 +1084,7 @@ void cpu_stw_le_data(CPUArchState *env, abi_ptr ptr, uint32_t val)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo);stw_le_p (g2h (env_cpu (env), ptr), val); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_W ); }void cpu_stl_le_data (CPUArchState *env,abi_ptr ptr,uint32_t val)
@@ -1094,7 +1094,7 @@ void cpu_stl_le_data(CPUArchState *env, abi_ptr ptr, uint32_t val)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo);stl_le_p (g2h (env_cpu (env), ptr), val); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_W ); }void cpu_stq_le_data (CPUArchState *env,abi_ptr ptr,uint64_t val)
@@ -1104,7 +1104,7 @@ void cpu_stq_le_data(CPUArchState *env, abi_ptr ptr, uint64_t val)trace_guest_mem_before_exec (env_cpu (env), ptr, meminfo);stq_le_p (g2h (env_cpu (env), ptr), val); -qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, meminfo); +qemu_plugin_vcpu_mem_cb (env_cpu (env), ptr, oi,QEMU_PLUGIN_MEM_W ); } void cpu_stb_data_ra(CPUArchState *env, abi_ptr ptr,
plugins/api.c +11 -8
@@ -45,7 +45,6 @@#include "qemu/plugin-memory.h" #include "hw/boards.h" #endif -#include "trace/mem.h" /* Uninstall and Reset handlers */
@@ -246,22 +245,25 @@ const char *qemu_plugin_insn_symbol(const struct qemu_plugin_insn *insn)unsigned qemu_plugin_mem_size_shift (qemu_plugin_meminfo_t info) { -return info &TRACE_MEM_SZ_SHIFT_MASK ; +MemOp op =get_memop (info); +return op &MO_SIZE ; }bool qemu_plugin_mem_is_sign_extended (qemu_plugin_meminfo_t info) { -return !!(info &TRACE_MEM_SE ); +MemOp op =get_memop (info); +return op &MO_SIGN ; }bool qemu_plugin_mem_is_big_endian (qemu_plugin_meminfo_t info) { -return !!(info &TRACE_MEM_BE ); +MemOp op =get_memop (info); +return (op &MO_BSWAP ) ==MO_BE ; }bool qemu_plugin_mem_is_store (qemu_plugin_meminfo_t info) { -return !!(info &TRACE_MEM_ST ); +return get_plugin_meminfo_rw (info) &QEMU_PLUGIN_MEM_W ; }/*
@@ -277,11 +279,12 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, {#ifdef CONFIG_SOFTMMU CPUState *cpu = current_cpu; -unsigned int mmu_idx = info >>TRACE_MEM_MMU_SHIFT ; - hwaddr_info.is_store = info &TRACE_MEM_ST ; +unsigned int mmu_idx =get_mmuidx (info); +enum qemu_plugin_mem_rw rw =get_plugin_meminfo_rw (info); + hwaddr_info.is_store = (rw &QEMU_PLUGIN_MEM_W ) !=0 ;if (!tlb_plugin_lookup (cpu, vaddr, mmu_idx, - info &TRACE_MEM_ST , &hwaddr_info)) { + hwaddr_info.is_store, &hwaddr_info)) {error_report ("invalid use of qemu_plugin_get_hwaddr" );return NULL ; }
plugins/core.c +5 -5
@@ -27,7 +27,6 @@#include "exec/helper-proto.h" #include "tcg/tcg.h" #include "tcg/tcg-op.h" -#include "trace/mem.h" /* mem_info macros */ #include "plugin.h" #include "qemu/compiler.h"
@@ -446,7 +445,8 @@ void exec_inline_op(struct qemu_plugin_dyn_cb *cb) } } -void qemu_plugin_vcpu_mem_cb (CPUState *cpu,uint64_t vaddr,uint32_t info) +void qemu_plugin_vcpu_mem_cb (CPUState *cpu,uint64_t vaddr, +MemOpIdx oi,enum qemu_plugin_mem_rw rw) {GArray *arr = cpu->plugin_mem_cbs;size_t i;
@@ -457,14 +457,14 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, uint32_t info)for (i =0 ; i < arr->len; i++) {struct qemu_plugin_dyn_cb *cb = &g_array_index(arr, struct qemu_plugin_dyn_cb, i); -int w = !!(info &TRACE_MEM_ST ) +1 ; -if (!(w & cb->rw)) { +if (!(rw & cb->rw)) {break ; }switch (cb->type) {case PLUGIN_CB_REGULAR : - cb->f.vcpu_mem (cpu->cpu_index, info, vaddr, cb->userp); + cb->f.vcpu_mem (cpu->cpu_index,make_plugin_meminfo (oi, rw), + vaddr, cb->userp);break ;case PLUGIN_CB_INLINE :exec_inline_op (cb);
tcg/tcg-op.c +21 -9
@@ -2853,10 +2853,12 @@ static inline TCGv plugin_prep_mem_callbacks(TCGv vaddr)return vaddr; } -static inline void plugin_gen_mem_callbacks (TCGv vaddr,uint16_t info) +static void plugin_gen_mem_callbacks (TCGv vaddr,MemOpIdx oi, +enum qemu_plugin_mem_rw rw) {#ifdef CONFIG_PLUGIN if (tcg_ctx->plugin_insn !=NULL ) { +qemu_plugin_meminfo_t info =make_plugin_meminfo (oi, rw);plugin_gen_empty_mem_callback (vaddr, info);tcg_temp_free (vaddr); }
@@ -2866,10 +2868,13 @@ static inline void plugin_gen_mem_callbacks(TCGv vaddr, uint16_t info)void tcg_gen_qemu_ld_i32 (TCGv_i32 val,TCGv addr,TCGArg idx,MemOp memop) {MemOp orig_memop; -uint16_t info =trace_mem_get_info (make_memop_idx (memop, idx),0 ); +MemOpIdx oi; +uint16_t info;tcg_gen_req_mo (TCG_MO_LD_LD |TCG_MO_ST_LD ); memop =tcg_canonicalize_memop (memop,0 ,0 ); + oi =make_memop_idx (memop, idx); + info =trace_mem_get_info (oi,0 );trace_guest_mem_before_tcg (tcg_ctx->cpu, cpu_env, addr, info); orig_memop = memop;
@@ -2883,7 +2888,7 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) addr =plugin_prep_mem_callbacks (addr);gen_ldst_i32 (INDEX_op_qemu_ld_i32, val, addr, memop, idx); -plugin_gen_mem_callbacks (addr, info); +plugin_gen_mem_callbacks (addr, oi,QEMU_PLUGIN_MEM_R );if ((orig_memop ^ memop) &MO_BSWAP ) {switch (orig_memop &MO_SIZE ) {
@@ -2904,10 +2909,13 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop)void tcg_gen_qemu_st_i32 (TCGv_i32 val,TCGv addr,TCGArg idx,MemOp memop) {TCGv_i32 swap =NULL ; -uint16_t info =trace_mem_get_info (make_memop_idx (memop, idx),1 ); +MemOpIdx oi; +uint16_t info;tcg_gen_req_mo (TCG_MO_LD_ST |TCG_MO_ST_ST ); memop =tcg_canonicalize_memop (memop,0 ,1 ); + oi =make_memop_idx (memop, idx); + info =trace_mem_get_info (oi,1 );trace_guest_mem_before_tcg (tcg_ctx->cpu, cpu_env, addr, info);if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop &MO_BSWAP )) {
@@ -2932,7 +2940,7 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) }else {gen_ldst_i32 (INDEX_op_qemu_st_i32, val, addr, memop, idx); } -plugin_gen_mem_callbacks (addr, info); +plugin_gen_mem_callbacks (addr, oi,QEMU_PLUGIN_MEM_W );if (swap) {tcg_temp_free_i32 (swap);
@@ -2942,6 +2950,7 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop)void tcg_gen_qemu_ld_i64 (TCGv_i64 val,TCGv addr,TCGArg idx,MemOp memop) {MemOp orig_memop; +MemOpIdx oi;uint16_t info;if (TCG_TARGET_REG_BITS ==32 && (memop &MO_SIZE ) <MO_64 ) {
@@ -2956,7 +2965,8 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop)tcg_gen_req_mo (TCG_MO_LD_LD |TCG_MO_ST_LD ); memop =tcg_canonicalize_memop (memop,1 ,0 ); - info =trace_mem_get_info (make_memop_idx (memop, idx),0 ); + oi =make_memop_idx (memop, idx); + info =trace_mem_get_info (oi,0 );trace_guest_mem_before_tcg (tcg_ctx->cpu, cpu_env, addr, info); orig_memop = memop;
@@ -2970,7 +2980,7 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) addr =plugin_prep_mem_callbacks (addr);gen_ldst_i64 (INDEX_op_qemu_ld_i64, val, addr, memop, idx); -plugin_gen_mem_callbacks (addr, info); +plugin_gen_mem_callbacks (addr, oi,QEMU_PLUGIN_MEM_R );if ((orig_memop ^ memop) &MO_BSWAP ) { int flags = (orig_memop & MO_SIGN
@@ -2995,6 +3005,7 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop)void tcg_gen_qemu_st_i64 (TCGv_i64 val,TCGv addr,TCGArg idx,MemOp memop) {TCGv_i64 swap =NULL ; +MemOpIdx oi;uint16_t info;if (TCG_TARGET_REG_BITS ==32 && (memop &MO_SIZE ) <MO_64 ) {
@@ -3004,7 +3015,8 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop)tcg_gen_req_mo (TCG_MO_LD_ST |TCG_MO_ST_ST ); memop =tcg_canonicalize_memop (memop,1 ,1 ); - info =trace_mem_get_info (make_memop_idx (memop, idx),1 ); + oi =make_memop_idx (memop, idx); + info =trace_mem_get_info (oi,1 );trace_guest_mem_before_tcg (tcg_ctx->cpu, cpu_env, addr, info);if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop &MO_BSWAP )) {
@@ -3028,7 +3040,7 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) addr =plugin_prep_mem_callbacks (addr);gen_ldst_i64 (INDEX_op_qemu_st_i64, val, addr, memop, idx); -plugin_gen_mem_callbacks (addr, info); +plugin_gen_mem_callbacks (addr, oi,QEMU_PLUGIN_MEM_W );if (swap) {tcg_temp_free_i64 (swap);
accel/tcg/atomic_common.c.inc +3 -10
@@ -26,10 +26,7 @@ static void atomic_trace_rmw_pre(CPUArchState *env, target_ulong addr, static void atomic_trace_rmw_post(CPUArchState *env, target_ulong addr, MemOpIdx oi) { - uint16_t info = trace_mem_get_info(oi, false); - - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info); - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info | TRACE_MEM_ST); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_RW); } #if HAVE_ATOMIC128
@@ -44,9 +41,7 @@ static void atomic_trace_ld_pre(CPUArchState *env, target_ulong addr, static void atomic_trace_ld_post(CPUArchState *env, target_ulong addr, MemOpIdx oi) { - uint16_t info = trace_mem_get_info(oi, false); - - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R); } static void atomic_trace_st_pre(CPUArchState *env, target_ulong addr,
@@ -60,9 +55,7 @@ static void atomic_trace_st_pre(CPUArchState *env, target_ulong addr, static void atomic_trace_st_post(CPUArchState *env, target_ulong addr, MemOpIdx oi) { - uint16_t info = trace_mem_get_info(oi, false); - - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W); } #endif
Signature · 1 line
2.25.1
PATCH v2 28/55 trace: Split guest_mem_before
In reply to Richard HendersonThere is no point in encoding load/store within a bit of the memory trace info operand. Represent atomic operations as a single read-modify-write tracepoint. Use MemOpIdx instead of inventing a form specifically for traces.
--- accel/tcg/atomic_template.h | 1 - trace/mem.h | 51 ----------------------------------- accel/tcg/cputlb.c | 7 ++--- accel/tcg/user-exec.c | 43 ++++++++++------------------- tcg/tcg-op.c | 17 +++--------- accel/tcg/atomic_common.c.inc | 12 +++------ trace-events | 18 +++---------- 7 files changed, 27 insertions(+), 122 deletions(-) delete mode 100644 trace/mem.h
accel/tcg/atomic_template.h +0 -1
@@ -19,7 +19,6 @@*/ #include "qemu/plugin.h" -#include "trace/mem.h" #if DATA_SIZE ==16 # define SUFFIX o
trace/mem.h deleted +0 -51
51 lines not on this page · raw message
accel/tcg/cputlb.c +2 -5
@@ -34,7 +34,6 @@#include "qemu/atomic128.h" #include "exec/translate-all.h" #include "trace/trace-root.h" -#include "trace/mem.h" #include "tb-hash.h" #include "internal.h" #ifdef CONFIG_PLUGIN
@@ -2104,10 +2103,9 @@ static inline uint64_t cpu_load_helper(CPUArchState *env, abi_ptr addr, MemOp op, FullLoadHelper *full_load) { MemOpIdx oi = make_memop_idx(op, mmu_idx); -uint16_t meminfo =trace_mem_get_info (oi, false);uint64_t ret; -trace_guest_mem_before_exec (env_cpu (env), addr, meminfo); +trace_guest_ld_before_exec (env_cpu (env), addr, oi); ret =full_load (env, addr, oi, retaddr);
@@ -2541,9 +2539,8 @@ cpu_store_helper(CPUArchState *env, target_ulong addr, uint64_t val, int mmu_idx, uintptr_t retaddr, MemOp op) { MemOpIdx oi = make_memop_idx(op, mmu_idx); -uint16_t meminfo =trace_mem_get_info (oi, true); -trace_guest_mem_before_exec (env_cpu (env), addr, meminfo); +trace_guest_st_before_exec (env_cpu (env), addr, oi);store_helper (env, addr, val, oi, retaddr, op);
accel/tcg/user-exec.c +14 -29
154 lines not on this page · raw message
tcg/tcg-op.c +4 -13
@@ -28,7 +28,6 @@#include "tcg/tcg-op.h" #include "tcg/tcg-mo.h" #include "trace-tcg.h" -#include "trace/mem.h" #include "exec/plugin-gen.h" /* Reduce the number of ifdefs below. This assumes that all uses of
@@ -2869,13 +2868,11 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) {MemOp orig_memop;MemOpIdx oi; -uint16_t info;tcg_gen_req_mo (TCG_MO_LD_LD |TCG_MO_ST_LD ); memop =tcg_canonicalize_memop (memop,0 ,0 ); oi =make_memop_idx (memop, idx); - info =trace_mem_get_info (oi,0 ); -trace_guest_mem_before_tcg (tcg_ctx->cpu, cpu_env, addr, info); +trace_guest_ld_before_tcg (tcg_ctx->cpu, cpu_env, addr, oi); orig_memop = memop;if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop &MO_BSWAP )) {
@@ -2910,13 +2907,11 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) {TCGv_i32 swap =NULL ;MemOpIdx oi; -uint16_t info;tcg_gen_req_mo (TCG_MO_LD_ST |TCG_MO_ST_ST ); memop =tcg_canonicalize_memop (memop,0 ,1 ); oi =make_memop_idx (memop, idx); - info =trace_mem_get_info (oi,1 ); -trace_guest_mem_before_tcg (tcg_ctx->cpu, cpu_env, addr, info); +trace_guest_st_before_tcg (tcg_ctx->cpu, cpu_env, addr, oi);if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop &MO_BSWAP )) { swap =tcg_temp_new_i32 ();
@@ -2951,7 +2946,6 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) {MemOp orig_memop;MemOpIdx oi; -uint16_t info;if (TCG_TARGET_REG_BITS ==32 && (memop &MO_SIZE ) <MO_64 ) {tcg_gen_qemu_ld_i32 (TCGV_LOW (val), addr, idx, memop);
@@ -2966,8 +2960,7 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop)tcg_gen_req_mo (TCG_MO_LD_LD |TCG_MO_ST_LD ); memop =tcg_canonicalize_memop (memop,1 ,0 ); oi =make_memop_idx (memop, idx); - info =trace_mem_get_info (oi,0 ); -trace_guest_mem_before_tcg (tcg_ctx->cpu, cpu_env, addr, info); +trace_guest_ld_before_tcg (tcg_ctx->cpu, cpu_env, addr, oi); orig_memop = memop;if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop &MO_BSWAP )) {
@@ -3006,7 +2999,6 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) {TCGv_i64 swap =NULL ;MemOpIdx oi; -uint16_t info;if (TCG_TARGET_REG_BITS ==32 && (memop &MO_SIZE ) <MO_64 ) {tcg_gen_qemu_st_i32 (TCGV_LOW (val), addr, idx, memop);
@@ -3016,8 +3008,7 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop)tcg_gen_req_mo (TCG_MO_LD_ST |TCG_MO_ST_ST ); memop =tcg_canonicalize_memop (memop,1 ,1 ); oi =make_memop_idx (memop, idx); - info =trace_mem_get_info (oi,1 ); -trace_guest_mem_before_tcg (tcg_ctx->cpu, cpu_env, addr, info); +trace_guest_st_before_tcg (tcg_ctx->cpu, cpu_env, addr, oi);if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop &MO_BSWAP )) { swap =tcg_temp_new_i64 ();
accel/tcg/atomic_common.c.inc +3 -9
@@ -17,10 +17,8 @@ static void atomic_trace_rmw_pre(CPUArchState *env, target_ulong addr, MemOpIdx oi) { CPUState *cpu = env_cpu(env); - uint16_t info = trace_mem_get_info(oi, false); - trace_guest_mem_before_exec(cpu, addr, info); - trace_guest_mem_before_exec(cpu, addr, info | TRACE_MEM_ST); + trace_guest_rmw_before_exec(cpu, addr, oi); } static void atomic_trace_rmw_post(CPUArchState *env, target_ulong addr,
@@ -33,9 +31,7 @@ static void atomic_trace_rmw_post(CPUArchState *env, target_ulong addr, static void atomic_trace_ld_pre(CPUArchState *env, target_ulong addr, MemOpIdx oi) { - uint16_t info = trace_mem_get_info(oi, false); - - trace_guest_mem_before_exec(env_cpu(env), addr, info); + trace_guest_ld_before_exec(env_cpu(env), addr, oi); } static void atomic_trace_ld_post(CPUArchState *env, target_ulong addr,
@@ -47,9 +43,7 @@ static void atomic_trace_ld_post(CPUArchState *env, target_ulong addr, static void atomic_trace_st_pre(CPUArchState *env, target_ulong addr, MemOpIdx oi) { - uint16_t info = trace_mem_get_info(oi, true); - - trace_guest_mem_before_exec(env_cpu(env), addr, info); + trace_guest_st_before_exec(env_cpu(env), addr, oi); } static void atomic_trace_st_post(CPUArchState *env, target_ulong addr,
trace-events +4 -14
@@ -120,26 +120,16 @@ vcpu guest_cpu_reset(void) # tcg/tcg-op.c # @vaddr: Access' virtual address. -# @info : Access' information (see below). +# @memopidx: Access' information (see below). # # Start virtual memory access (before any potential access violation). -# # Does not include memory accesses performed by devices. # -# Access information can be parsed as: -# -# struct mem_info { -# uint8_t size_shift : 4; /* interpreted as "1 << size_shift" bytes */ -# bool sign_extend: 1; /* sign-extended */ -# uint8_t endianness : 1; /* 0: little, 1: big */ -# bool store : 1; /* whether it is a store operation */ -# pad : 1; -# uint8_t mmuidx : 4; /* mmuidx (softmmu only) */ -# }; -# # Mode: user, softmmu # Targets: TCG(all) -vcpu tcg guest_mem_before(TCGv vaddr, uint16_t info) "info=%d", "vaddr=0x%016"PRIx64" info=%d" +vcpu tcg guest_ld_before(TCGv vaddr, uint32_t memopidx) "info=%d", "vaddr=0x%016"PRIx64" memopidx=0x%x" +vcpu tcg guest_st_before(TCGv vaddr, uint32_t memopidx) "info=%d", "vaddr=0x%016"PRIx64" memopidx=0x%x" +vcpu tcg guest_rmw_before(TCGv vaddr, uint32_t memopidx) "info=%d", "vaddr=0x%016"PRIx64" memopidx=0x%x" # include/user/syscall-trace.h
Signature · 1 line
2.25.1
Re: [PATCH v2 28/55] trace: Split guest_mem_before
Quoted 107 lines · Richard Henderson
There is no point in encoding load/store within a bit of the memory trace info operand. Represent atomic operations as a single read-modify-write tracepoint. Use MemOpIdx instead of inventing a form specifically for traces.
Signed-off-by Richard Henderson <[email protected]>--- accel/tcg/atomic_template.h | 1 - trace/mem.h | 51 ----------------------------------- accel/tcg/cputlb.c | 7 ++--- accel/tcg/user-exec.c | 43 ++++++++++------------------- tcg/tcg-op.c | 17 +++--------- accel/tcg/atomic_common.c.inc | 12 +++------ trace-events | 18 +++---------- 7 files changed, 27 insertions(+), 122 deletions(-) delete mode 100644 trace/mem.haccel/tcg/atomic_template.h +0
-1@@ -19,7 +19,6 @@*/ #include "qemu/plugin.h" -#include "trace/mem.h" #if DATA_SIZE ==16 # define SUFFIX otrace/mem.h deleted +0
-49@@ -1,51 +0,0 @@ -/* -* Helper functions for guest memory tracing -* -* Copyright (C) 2016 Lluís Vilanova <[email protected]> -* -* 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 TRACE__MEM_H -#define TRACE__MEM_H - -#include "exec/memopidx.h" - -#define TRACE_MEM_SZ_SHIFT_MASK 0xf/* size shift mask */ -#define TRACE_MEM_SE (1ULL << 4)/* sign extended (y/n) */ -#define TRACE_MEM_BE (1ULL << 5)/* big endian (y/n) */ -#define TRACE_MEM_ST (1ULL << 6)/* store (y/n) */ -#define TRACE_MEM_MMU_SHIFT 8/* mmu idx */ - -/** -* trace_mem_get_info: -* -* Return a value for the 'info' argument in guest memory access traces. -*/ -static inline uint16_t trace_mem_get_info (MemOpIdx oi,bool store) -{ -MemOp op =get_memop (oi); -uint32_t size_shift = op &MO_SIZE ; -bool sign_extend = op &MO_SIGN ; -bool big_endian = (op &MO_BSWAP ) ==MO_BE ; -uint16_t res; - - res = size_shift &TRACE_MEM_SZ_SHIFT_MASK ; -if (sign_extend) { - res |=TRACE_MEM_SE ; - } -if (big_endian) { - res |=TRACE_MEM_BE ; - } -if (store) { - res |=TRACE_MEM_ST ; - } -#ifdef CONFIG_SOFTMMU - res |=get_mmuidx (oi) <<TRACE_MEM_MMU_SHIFT ; -#endif - -return res; -}trace-events +1
-9@@ -120,26 +120,16 @@ vcpu guest_cpu_reset(void) # tcg/tcg-op.c # @vaddr: Access' virtual address. -# @info : Access' information (see below). +# @memopidx: Access' information (see below). # # Start virtual memory access (before any potential access violation). -# # Does not include memory accesses performed by devices. # -# Access information can be parsed as: -# -# struct mem_info { -# uint8_t size_shift : 4; /* interpreted as "1 << size_shift" bytes */ -# bool sign_extend: 1; /* sign-extended */ -# uint8_t endianness : 1; /* 0: little, 1: big */ -# bool store : 1; /* whether it is a store operation */
trace-events vcpu guest_cpu_reset(void) · line 132
Quoted 10 lines
trace-events +3
-5-# pad : 1; -# uint8_t mmuidx : 4; /* mmuidx (softmmu only) */ -# }; -# # Mode: user, softmmu # Targets: TCG(all) -vcpu tcg guest_mem_before(TCGv vaddr, uint16_t info) "info=%d", "vaddr=0x%016"PRIx64" info=%d" +vcpu tcg guest_ld_before(TCGv vaddr, uint32_t memopidx) "info=%d", "vaddr=0x%016"PRIx64" memopidx=0x%x" +vcpu tcg guest_st_before(TCGv vaddr, uint32_t memopidx) "info=%d", "vaddr=0x%016"PRIx64" memopidx=0x%x" +vcpu tcg guest_rmw_before(TCGv vaddr, uint32_t memopidx) "info=%d", "vaddr=0x%016"PRIx64" memopidx=0x%x"
Alternatively we can implement:
const char *memopidx_name(MemOpIdx oi);
and have the trace events display the MemOpIdx name.
Anyway,
(also, maybe "trace/mem:" in subject).
PATCH v2 29/55 target/arm: Use MO_128 for 16 byte atomics
In reply to Richard Henderson--- target/arm/helper-a64.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/arm/helper-a64.c +4 -4
@@ -560,7 +560,7 @@ uint64_t HELPER(paired_cmpxchg64_le_parallel)(CPUARMState *env, uint64_t addr,assert (HAVE_CMPXCHG128 ); mem_idx =cpu_mmu_index (env, false); - oi =make_memop_idx (MO_LEQ |MO_ALIGN_16 , mem_idx); + oi =make_memop_idx (MO_LE |MO_128 |MO_ALIGN , mem_idx); cmpv =int128_make128 (env->exclusive_val, env->exclusive_high); newv =int128_make128 (new_lo, new_hi);
@@ -630,7 +630,7 @@ uint64_t HELPER(paired_cmpxchg64_be_parallel)(CPUARMState *env, uint64_t addr,assert (HAVE_CMPXCHG128 ); mem_idx =cpu_mmu_index (env, false); - oi =make_memop_idx (MO_BEQ |MO_ALIGN_16 , mem_idx); + oi =make_memop_idx (MO_BE |MO_128 |MO_ALIGN , mem_idx);/* * High and low need to be switched here because this is not actually a
@@ -656,7 +656,7 @@ void HELPER(casp_le_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr,assert (HAVE_CMPXCHG128 ); mem_idx =cpu_mmu_index (env, false); - oi =make_memop_idx (MO_LEQ |MO_ALIGN_16 , mem_idx); + oi =make_memop_idx (MO_LE |MO_128 |MO_ALIGN , mem_idx); cmpv =int128_make128 (env->xregs[rs], env->xregs[rs +1 ]); newv =int128_make128 (new_lo, new_hi);
@@ -677,7 +677,7 @@ void HELPER(casp_be_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr,assert (HAVE_CMPXCHG128 ); mem_idx =cpu_mmu_index (env, false); - oi =make_memop_idx (MO_LEQ |MO_ALIGN_16 , mem_idx); + oi =make_memop_idx (MO_LE |MO_128 |MO_ALIGN , mem_idx); cmpv =int128_make128 (env->xregs[rs +1 ], env->xregs[rs]); newv =int128_make128 (new_lo, new_hi);
Signature · 1 line
2.25.1
PATCH v2 30/55 target/i386: Use MO_128 for 16 byte atomics
In reply to Richard Henderson--- target/i386/tcg/mem_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/tcg/mem_helper.c +1 -1
@@ -136,7 +136,7 @@ void helper_cmpxchg16b(CPUX86State *env, target_ulong a0)Int128 newv =int128_make128 (env->regs[R_EBX ], env->regs[R_ECX ]);int mem_idx =cpu_mmu_index (env, false); -MemOpIdx oi =make_memop_idx (MO_TEQ |MO_ALIGN_16 , mem_idx); +MemOpIdx oi =make_memop_idx (MO_TE |MO_128 |MO_ALIGN , mem_idx);Int128 oldv =cpu_atomic_cmpxchgo_le_mmu (env, a0, cmpv, newv, oi, ra);if (int128_eq (oldv, cmpv)) {
Signature · 1 line
2.25.1
Re: [PATCH v2 30/55] target/i386: Use MO_128 for 16 byte atomics
Quoted 4 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- target/i386/tcg/mem_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH v2 31/55 target/ppc: Use MO_128 for 16 byte atomics
In reply to Richard Henderson--- target/ppc/translate.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
target/ppc/translate.c +7 -5
@@ -3461,10 +3461,12 @@ static void gen_std(DisasContext *ctx)if (HAVE_ATOMIC128 ) {TCGv_i32 oi =tcg_temp_new_i32 ();if (ctx->le_mode) { -tcg_gen_movi_i32 (oi,make_memop_idx (MO_LEQ , ctx->mem_idx)); +tcg_gen_movi_i32 (oi,make_memop_idx (MO_LE |MO_128 , + ctx->mem_idx));gen_helper_stq_le_parallel (cpu_env,EA , lo, hi, oi); }else { -tcg_gen_movi_i32 (oi,make_memop_idx (MO_BEQ , ctx->mem_idx)); +tcg_gen_movi_i32 (oi,make_memop_idx (MO_BE |MO_128 , + ctx->mem_idx));gen_helper_stq_be_parallel (cpu_env,EA , lo, hi, oi); }tcg_temp_free_i32 (oi);
@@ -4066,11 +4068,11 @@ static void gen_lqarx(DisasContext *ctx)if (HAVE_ATOMIC128 ) {TCGv_i32 oi =tcg_temp_new_i32 ();if (ctx->le_mode) { -tcg_gen_movi_i32 (oi,make_memop_idx (MO_LEQ |MO_ALIGN_16 , +tcg_gen_movi_i32 (oi,make_memop_idx (MO_LE |MO_128 |MO_ALIGN , ctx->mem_idx));gen_helper_lq_le_parallel (lo, cpu_env,EA , oi); }else { -tcg_gen_movi_i32 (oi,make_memop_idx (MO_BEQ |MO_ALIGN_16 , +tcg_gen_movi_i32 (oi,make_memop_idx (MO_BE |MO_128 |MO_ALIGN , ctx->mem_idx));gen_helper_lq_be_parallel (lo, cpu_env,EA , oi); }
@@ -4121,7 +4123,7 @@ static void gen_stqcx_(DisasContext *ctx)if (tb_cflags (ctx->base.tb) &CF_PARALLEL ) {if (HAVE_CMPXCHG128 ) { -TCGv_i32 oi =tcg_const_i32 (DEF_MEMOP (MO_Q ) |MO_ALIGN_16 ); +TCGv_i32 oi =tcg_const_i32 (DEF_MEMOP (MO_128 ) |MO_ALIGN );if (ctx->le_mode) {gen_helper_stqcx_le_parallel (cpu_crf[0 ], cpu_env,EA , lo, hi, oi);
Signature · 1 line
2.25.1
PATCH v2 32/55 target/s390x: Use MO_128 for 16 byte atomics
In reply to Richard Henderson--- target/s390x/tcg/mem_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/s390x/tcg/mem_helper.c +2 -2
@@ -1810,7 +1810,7 @@ void HELPER(cdsg_parallel)(CPUS390XState *env, uint64_t addr,assert (HAVE_CMPXCHG128 ); mem_idx =cpu_mmu_index (env, false); - oi =make_memop_idx (MO_TEQ |MO_ALIGN_16 , mem_idx); + oi =make_memop_idx (MO_TE |MO_128 |MO_ALIGN , mem_idx); oldv =cpu_atomic_cmpxchgo_be_mmu (env, addr, cmpv, newv, oi, ra); fail = !int128_eq (oldv, cmpv);
@@ -1939,7 +1939,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1,cpu_stq_data_ra (env, a1 +0 ,int128_gethi (nv), ra);cpu_stq_data_ra (env, a1 +8 ,int128_getlo (nv), ra); }else if (HAVE_CMPXCHG128 ) { -MemOpIdx oi =make_memop_idx (MO_TEQ |MO_ALIGN_16 , mem_idx); +MemOpIdx oi =make_memop_idx (MO_TE |MO_128 |MO_ALIGN , mem_idx); ov =cpu_atomic_cmpxchgo_be_mmu (env, a1, cv, nv, oi, ra); cc = !int128_eq (ov, cv); }else {
Signature · 1 line
2.25.1
PATCH v2 33/55 target/hexagon: Implement cpu_mmu_index
In reply to Richard HendersonThe function is trivial for user-only, but still must be present.
--- target/hexagon/cpu.h | 9 +++++++++ 1 file changed, 9 insertions(+)
target/hexagon/cpu.h +9 -0
@@ -144,6 +144,15 @@ static inline void cpu_get_tb_cpu_state(CPUHexagonState *env, target_ulong *pc,#endif } +static inline int cpu_mmu_index (CPUHexagonState *env,bool ifetch) +{ +#ifdef CONFIG_USER_ONLY +return MMU_USER_IDX ; +#else +#error System mode not supported on Hexagon yet +#endif +} +typedef struct CPUHexagonState CPUArchState ;typedef HexagonCPU ArchCPU ;
Signature · 1 line
2.25.1
PATCH v2 34/55 accel/tcg: Add cpu_{ld,st}*_mmu interfaces
In reply to Richard HendersonThese functions are much closer to the softmmu helper functions, in that they take the complete MemOpIdx, and from that they may enforce required alignment.
The previous cpu_ldst.h functions did not have alignment info, and so did not enforce it. Retain this by adding MO_UNALN to the MemOp that we create in calling the new functions.
--- docs/devel/loads-stores.rst | 52 ++++- include/exec/cpu_ldst.h | 245 ++++++++-------------- accel/tcg/cputlb.c | 392 ++++++++++++------------------------ accel/tcg/user-exec.c | 390 +++++++++++++++-------------------- accel/tcg/ldst_common.c.inc | 307 ++++++++++++++++++++++++++++ 5 files changed, 722 insertions(+), 664 deletions(-) create mode 100644 accel/tcg/ldst_common.c.inc
docs/devel/loads-stores.rst +43 -9
@@ -68,15 +68,19 @@ Regexes for git grep - ``\<ldn_\([hbl]e\)?_p\>`` - ``\<stn_\([hbl]e\)?_p\>`` -``cpu_{ld,st}*_mmuidx_ra`` -~~~~~~~~~~~~~~~~~~~~~~~~~~ +``cpu_{ld,st}*_mmu`` +~~~~~~~~~~~~~~~~~~~~ -These functions operate on a guest virtual address plus a context, -known as a "mmu index" or ``mmuidx``, which controls how that virtual -address is translated. The meaning of the indexes are target specific, -but specifying a particular index might be necessary if, for instance, -the helper requires an "always as non-privileged" access rather that -the default access for the current state of the guest CPU. +These functions operate on a guest virtual address, plus a context +known as a "mmu index" which controls how that virtual address is +translated, plus a ``MemOp`` which contains alignment requirements +among other things. The ``MemOp`` and mmu index are combined into +a single argument of type ``MemOpIdx``. + +The meaning of the indexes are target specific, but specifying a +particular index might be necessary if, for instance, the helper +requires a "always as non-privileged" access rather than the +default access for the current state of the guest CPU. These functions may cause a guest CPU exception to be taken (e.g. for an alignment fault or MMU fault) which will result in
@@ -99,6 +103,35 @@ function, which is a return address into the generated code [#gpc]_. Function names follow the pattern: +load: ``cpu_ld{size}{end}_mmu(env, ptr, oi, retaddr)`` + +store: ``cpu_st{size}{end}_mmu(env, ptr, val, oi, retaddr)`` + +``size`` + - ``b`` : 8 bits + - ``w`` : 16 bits + - ``l`` : 32 bits + - ``q`` : 64 bits + +``end`` + - (empty) : for target endian, or 8 bit sizes + - ``_be`` : big endian + - ``_le`` : little endian + +Regexes for git grep: + - ``\<cpu_ld[bwlq](_[bl]e)\?_mmu\>`` + - ``\<cpu_st[bwlq](_[bl]e)\?_mmu\>`` + + +``cpu_{ld,st}*_mmuidx_ra`` +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +These functions work like the ``cpu_{ld,st}_mmu`` functions except +that the ``mmuidx`` parameter is not combined with a ``MemOp``, +and therefore there is no required alignment supplied or enforced. + +Function names follow the pattern: + load: ``cpu_ld{sign}{size}{end}_mmuidx_ra(env, ptr, mmuidx, retaddr)`` store: ``cpu_st{size}{end}_mmuidx_ra(env, ptr, val, mmuidx, retaddr)``
@@ -132,7 +165,8 @@ of the guest CPU, as determined by ``cpu_mmu_index(env, false)``. These are generally the preferred way to do accesses by guest virtual address from helper functions, unless the access should -be performed with a context other than the default. +be performed with a context other than the default, or alignment +should be enforced for the access. Function names follow the pattern:
include/exec/cpu_ldst.h +84 -161
348 lines not on this page · raw message
accel/tcg/cputlb.c +126 -266
562 lines not on this page · raw message
accel/tcg/user-exec.c +162 -228
468 lines not on this page · raw message
accel/tcg/ldst_common.c.inc new file +307 -0
307 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v2 34/55] accel/tcg: Add cpu_{ld,st}*_mmu interfaces
Quoted 20 lines · Richard Henderson
These functions are much closer to the softmmu helper functions, in that they take the complete MemOpIdx, and from that they may enforce required alignment.
The previous
cpu_ldst.hfunctions did not have alignment info, and so did not enforce it. Retain this by addingMO_UNALNto the MemOp that we create in calling the new functions.Signed-off-by Richard Henderson <[email protected]>--- docs/devel/loads-stores.rst | 52 ++++- include/exec/cpu_ldst.h | 245 ++++++++-------------- accel/tcg/cputlb.c | 392 ++++++++++++------------------------ accel/tcg/user-exec.c | 390 +++++++++++++++-------------------- accel/tcg/ldst_common.c.inc | 307 ++++++++++++++++++++++++++++ 5 files changed, 722 insertions(+), 664 deletions(-) create mode 100644 accel/tcg/ldst_common.c.incFunction names follow the pattern:
docs/devel/loads-stores.rst function, which is a return address into the generated code [#gpc]_. · line 114
Quoted 9 lines
docs/devel/loads-stores.rst +9
-0+load: ``cpu_ld{size}{end}_mmu(env, ptr, oi, retaddr)`` + +store: ``cpu_st{size}{end}_mmu(env, ptr, val, oi, retaddr)`` + +``size`` + - ``b`` : 8 bits + - ``w`` : 16 bits + - ``l`` : 32 bits + - ``q`` : 64 bits
kinda unrelated to this patch, but what would be the pattern for 128 bits? ``o`` for octoword?
Quoted 9 lines
docs/devel/loads-stores.rst +9
-0+ +``end`` + - (empty) : for target endian, or 8 bit sizes + - ``_be`` : big endian + - ``_le`` : little endian + +Regexes for git grep: + - ``\<cpu_ld[bwlq](_[bl]e)\?_mmu\>`` + - ``\<cpu_st[bwlq](_[bl]e)\?_mmu\>``
Re: [PATCH v2 34/55] accel/tcg: Add cpu_{ld,st}*_mmu interfaces
Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 20 lines · Richard Henderson
These functions are much closer to the softmmu helper functions, in that they take the complete MemOpIdx, and from that they may enforce required alignment.
The previous
cpu_ldst.hfunctions did not have alignment info, and so did not enforce it. Retain this by addingMO_UNALNto the MemOp that we create in calling the new functions.Signed-off-by Richard Henderson <[email protected]>--- docs/devel/loads-stores.rst | 52 ++++- include/exec/cpu_ldst.h | 245 ++++++++-------------- accel/tcg/cputlb.c | 392 ++++++++++++------------------------ accel/tcg/user-exec.c | 390 +++++++++++++++-------------------- accel/tcg/ldst_common.c.inc | 307 ++++++++++++++++++++++++++++ 5 files changed, 722 insertions(+), 664 deletions(-)create mode 100644 accel/tcg/ldst_common.c.inc
Function names follow the pattern:
Quoted 12 lines
docs/devel/loads-stores.rst function, which is a return address into the generated code [#gpc]_. · line 114
Quoted 9 lines
docs/devel/loads-stores.rst +9
-0+load: ``cpu_ld{size}{end}_mmu(env, ptr, oi, retaddr)`` + +store: ``cpu_st{size}{end}_mmu(env, ptr, val, oi, retaddr)`` + +``size`` + - ``b`` : 8 bits + - ``w`` : 16 bits + - ``l`` : 32 bits + - ``q`` : 64 bitskinda unrelated to this patch, but what would be the pattern for 128 bits? ``o`` for octoword?
Yeah, that's what we've done for the 128-bit atomics.
r~
PATCH v2 35/55 accel/tcg: Move cpu_atomic decls to exec/cpu_ldst.h
In reply to Richard HendersonThe previous placement in tcg/tcg.h was not logical.
--- include/exec/cpu_ldst.h | 87 +++++++++++++++++++++++++++++++++++ include/tcg/tcg.h | 87 ----------------------------------- target/arm/helper-a64.c | 1 - target/m68k/op_helper.c | 1 - target/ppc/mem_helper.c | 1 - target/s390x/tcg/mem_helper.c | 1 - 6 files changed, 87 insertions(+), 91 deletions(-)
include/exec/cpu_ldst.h +87 -0
@@ -63,6 +63,7 @@#define CPU_LDST_H #include "exec/memopidx.h" +#include "qemu/int128.h" #if defined(CONFIG_USER_ONLY )/* sparc32plus has 64bit long but 32bit space address
@@ -233,6 +234,92 @@ void cpu_stl_le_mmu(CPUArchState *env, abi_ptr ptr, uint32_t val,void cpu_stq_le_mmu (CPUArchState *env,abi_ptr ptr,uint64_t val,MemOpIdx oi,uintptr_t ra); +uint32_t cpu_atomic_cmpxchgb_mmu (CPUArchState *env,target_ulong addr, +uint32_t cmpv,uint32_t newv, +MemOpIdx oi,uintptr_t retaddr); +uint32_t cpu_atomic_cmpxchgw_le_mmu (CPUArchState *env,target_ulong addr, +uint32_t cmpv,uint32_t newv, +MemOpIdx oi,uintptr_t retaddr); +uint32_t cpu_atomic_cmpxchgl_le_mmu (CPUArchState *env,target_ulong addr, +uint32_t cmpv,uint32_t newv, +MemOpIdx oi,uintptr_t retaddr); +uint64_t cpu_atomic_cmpxchgq_le_mmu (CPUArchState *env,target_ulong addr, +uint64_t cmpv,uint64_t newv, +MemOpIdx oi,uintptr_t retaddr); +uint32_t cpu_atomic_cmpxchgw_be_mmu (CPUArchState *env,target_ulong addr, +uint32_t cmpv,uint32_t newv, +MemOpIdx oi,uintptr_t retaddr); +uint32_t cpu_atomic_cmpxchgl_be_mmu (CPUArchState *env,target_ulong addr, +uint32_t cmpv,uint32_t newv, +MemOpIdx oi,uintptr_t retaddr); +uint64_t cpu_atomic_cmpxchgq_be_mmu (CPUArchState *env,target_ulong addr, +uint64_t cmpv,uint64_t newv, +MemOpIdx oi,uintptr_t retaddr); + +#define GEN_ATOMIC_HELPER (NAME ,TYPE ,SUFFIX ) \ +TYPE cpu_atomic_ ## NAME ## SUFFIX ## _mmu \ + (CPUArchState *env, target_ulong addr, TYPE val, \ + MemOpIdx oi, uintptr_t retaddr); + +#ifdef CONFIG_ATOMIC64 +#define GEN_ATOMIC_HELPER_ALL (NAME ) \ + GEN_ATOMIC_HELPER(NAME, uint32_t, b) \ + GEN_ATOMIC_HELPER(NAME, uint32_t, w_le) \ + GEN_ATOMIC_HELPER(NAME, uint32_t, w_be) \ + GEN_ATOMIC_HELPER(NAME, uint32_t, l_le) \ + GEN_ATOMIC_HELPER(NAME, uint32_t, l_be) \ + GEN_ATOMIC_HELPER(NAME, uint64_t, q_le) \ + GEN_ATOMIC_HELPER(NAME, uint64_t, q_be) +#else +#define GEN_ATOMIC_HELPER_ALL (NAME ) \ + GEN_ATOMIC_HELPER(NAME, uint32_t, b) \ + GEN_ATOMIC_HELPER(NAME, uint32_t, w_le) \ + GEN_ATOMIC_HELPER(NAME, uint32_t, w_be) \ + GEN_ATOMIC_HELPER(NAME, uint32_t, l_le) \ + GEN_ATOMIC_HELPER(NAME, uint32_t, l_be) +#endif + +GEN_ATOMIC_HELPER_ALL(fetch_add) +GEN_ATOMIC_HELPER_ALL(fetch_sub) +GEN_ATOMIC_HELPER_ALL(fetch_and) +GEN_ATOMIC_HELPER_ALL(fetch_or) +GEN_ATOMIC_HELPER_ALL(fetch_xor) +GEN_ATOMIC_HELPER_ALL(fetch_smin) +GEN_ATOMIC_HELPER_ALL(fetch_umin) +GEN_ATOMIC_HELPER_ALL(fetch_smax) +GEN_ATOMIC_HELPER_ALL(fetch_umax) + +GEN_ATOMIC_HELPER_ALL(add_fetch) +GEN_ATOMIC_HELPER_ALL(sub_fetch) +GEN_ATOMIC_HELPER_ALL(and_fetch) +GEN_ATOMIC_HELPER_ALL(or_fetch) +GEN_ATOMIC_HELPER_ALL(xor_fetch) +GEN_ATOMIC_HELPER_ALL(smin_fetch) +GEN_ATOMIC_HELPER_ALL(umin_fetch) +GEN_ATOMIC_HELPER_ALL(smax_fetch) +GEN_ATOMIC_HELPER_ALL(umax_fetch) + +GEN_ATOMIC_HELPER_ALL(xchg) + +#undef GEN_ATOMIC_HELPER_ALL +#undef GEN_ATOMIC_HELPER + +Int128 cpu_atomic_cmpxchgo_le_mmu(CPUArchState *env, target_ulong addr, + Int128 cmpv, Int128 newv, + MemOpIdx oi, uintptr_t retaddr); +Int128 cpu_atomic_cmpxchgo_be_mmu (CPUArchState *env,target_ulong addr, +Int128 cmpv,Int128 newv, +MemOpIdx oi,uintptr_t retaddr); + +Int128 cpu_atomic_ldo_le_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); +Int128 cpu_atomic_ldo_be_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); +void cpu_atomic_sto_le_mmu (CPUArchState *env,target_ulong addr,Int128 val, +MemOpIdx oi,uintptr_t retaddr); +void cpu_atomic_sto_be_mmu (CPUArchState *env,target_ulong addr,Int128 val, +MemOpIdx oi,uintptr_t retaddr); +#if defined(CONFIG_USER_ONLY )extern __threaduintptr_t helper_retaddr;
include/tcg/tcg.h +0 -87
99 lines not on this page · raw message
target/arm/helper-a64.c +0 -1
@@ -32,7 +32,6 @@#include "exec/cpu_ldst.h" #include "qemu/int128.h" #include "qemu/atomic128.h" -#include "tcg/tcg.h" #include "fpu/softfloat.h" #include <zlib.h> /* For crc32 */
target/m68k/op_helper.c +0 -1
@@ -22,7 +22,6 @@#include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "semihosting/semihost.h" -#include "tcg/tcg.h" #if defined(CONFIG_USER_ONLY )
target/ppc/mem_helper.c +0 -1
@@ -25,7 +25,6 @@#include "exec/helper-proto.h" #include "helper_regs.h" #include "exec/cpu_ldst.h" -#include "tcg/tcg.h" #include "internal.h" #include "qemu/atomic128.h"
target/s390x/tcg/mem_helper.c +0 -1
@@ -27,7 +27,6 @@#include "exec/cpu_ldst.h" #include "qemu/int128.h" #include "qemu/atomic128.h" -#include "tcg/tcg.h" #if !defined(CONFIG_USER_ONLY )#include "hw/s390x/storage-keys.h"
Signature · 1 line
2.25.1
PATCH v2 36/55 target/mips: Use cpu_*_data_ra for msa load/store
In reply to Richard HendersonWe should not have been using the helper_ret_* set of functions, as they are supposed to be private to tcg. Nor should we have been using the plain cpu_*_data set of functions, as they do not handle unwinding properly.
--- target/mips/tcg/msa_helper.c | 420 +++++++++++------------------------ 1 file changed, 135 insertions(+), 285 deletions(-)
target/mips/tcg/msa_helper.c +135 -285
@@ -8222,79 +8222,42 @@ void helper_msa_ld_b(CPUMIPSState *env, uint32_t wd, target_ulong addr) {wr_t *pwd = &(env->active_fpu.fpr[wd].wr); - MEMOP_IDX(DF_BYTE) -#if !defined(CONFIG_USER_ONLY ) +uintptr_t ra =GETPC (); +#if !defined(HOST_WORDS_BIGENDIAN ) - pwd->b[0 ] =helper_ret_ldub_mmu (env, addr + (0 <<DF_BYTE ), oi,GETPC ()); - pwd->b[1 ] =helper_ret_ldub_mmu (env, addr + (1 <<DF_BYTE ), oi,GETPC ()); - pwd->b[2 ] =helper_ret_ldub_mmu (env, addr + (2 <<DF_BYTE ), oi,GETPC ()); - pwd->b[3 ] =helper_ret_ldub_mmu (env, addr + (3 <<DF_BYTE ), oi,GETPC ()); - pwd->b[4 ] =helper_ret_ldub_mmu (env, addr + (4 <<DF_BYTE ), oi,GETPC ()); - pwd->b[5 ] =helper_ret_ldub_mmu (env, addr + (5 <<DF_BYTE ), oi,GETPC ()); - pwd->b[6 ] =helper_ret_ldub_mmu (env, addr + (6 <<DF_BYTE ), oi,GETPC ()); - pwd->b[7 ] =helper_ret_ldub_mmu (env, addr + (7 <<DF_BYTE ), oi,GETPC ()); - pwd->b[8 ] =helper_ret_ldub_mmu (env, addr + (8 <<DF_BYTE ), oi,GETPC ()); - pwd->b[9 ] =helper_ret_ldub_mmu (env, addr + (9 <<DF_BYTE ), oi,GETPC ()); - pwd->b[10 ] =helper_ret_ldub_mmu (env, addr + (10 <<DF_BYTE ), oi,GETPC ()); - pwd->b[11 ] =helper_ret_ldub_mmu (env, addr + (11 <<DF_BYTE ), oi,GETPC ()); - pwd->b[12 ] =helper_ret_ldub_mmu (env, addr + (12 <<DF_BYTE ), oi,GETPC ()); - pwd->b[13 ] =helper_ret_ldub_mmu (env, addr + (13 <<DF_BYTE ), oi,GETPC ()); - pwd->b[14 ] =helper_ret_ldub_mmu (env, addr + (14 <<DF_BYTE ), oi,GETPC ()); - pwd->b[15 ] =helper_ret_ldub_mmu (env, addr + (15 <<DF_BYTE ), oi,GETPC ()); + pwd->b[0 ] =cpu_ldub_data_ra (env, addr + (0 <<DF_BYTE ), ra); + pwd->b[1 ] =cpu_ldub_data_ra (env, addr + (1 <<DF_BYTE ), ra); + pwd->b[2 ] =cpu_ldub_data_ra (env, addr + (2 <<DF_BYTE ), ra); + pwd->b[3 ] =cpu_ldub_data_ra (env, addr + (3 <<DF_BYTE ), ra); + pwd->b[4 ] =cpu_ldub_data_ra (env, addr + (4 <<DF_BYTE ), ra); + pwd->b[5 ] =cpu_ldub_data_ra (env, addr + (5 <<DF_BYTE ), ra); + pwd->b[6 ] =cpu_ldub_data_ra (env, addr + (6 <<DF_BYTE ), ra); + pwd->b[7 ] =cpu_ldub_data_ra (env, addr + (7 <<DF_BYTE ), ra); + pwd->b[8 ] =cpu_ldub_data_ra (env, addr + (8 <<DF_BYTE ), ra); + pwd->b[9 ] =cpu_ldub_data_ra (env, addr + (9 <<DF_BYTE ), ra); + pwd->b[10 ] =cpu_ldub_data_ra (env, addr + (10 <<DF_BYTE ), ra); + pwd->b[11 ] =cpu_ldub_data_ra (env, addr + (11 <<DF_BYTE ), ra); + pwd->b[12 ] =cpu_ldub_data_ra (env, addr + (12 <<DF_BYTE ), ra); + pwd->b[13 ] =cpu_ldub_data_ra (env, addr + (13 <<DF_BYTE ), ra); + pwd->b[14 ] =cpu_ldub_data_ra (env, addr + (14 <<DF_BYTE ), ra); + pwd->b[15 ] =cpu_ldub_data_ra (env, addr + (15 <<DF_BYTE ), ra);#else - pwd->b[0 ] =helper_ret_ldub_mmu (env, addr + (7 <<DF_BYTE ), oi,GETPC ()); - pwd->b[1 ] =helper_ret_ldub_mmu (env, addr + (6 <<DF_BYTE ), oi,GETPC ()); - pwd->b[2 ] =helper_ret_ldub_mmu (env, addr + (5 <<DF_BYTE ), oi,GETPC ()); - pwd->b[3 ] =helper_ret_ldub_mmu (env, addr + (4 <<DF_BYTE ), oi,GETPC ()); - pwd->b[4 ] =helper_ret_ldub_mmu (env, addr + (3 <<DF_BYTE ), oi,GETPC ()); - pwd->b[5 ] =helper_ret_ldub_mmu (env, addr + (2 <<DF_BYTE ), oi,GETPC ()); - pwd->b[6 ] =helper_ret_ldub_mmu (env, addr + (1 <<DF_BYTE ), oi,GETPC ()); - pwd->b[7 ] =helper_ret_ldub_mmu (env, addr + (0 <<DF_BYTE ), oi,GETPC ()); - pwd->b[8 ] =helper_ret_ldub_mmu (env, addr + (15 <<DF_BYTE ), oi,GETPC ()); - pwd->b[9 ] =helper_ret_ldub_mmu (env, addr + (14 <<DF_BYTE ), oi,GETPC ()); - pwd->b[10 ] =helper_ret_ldub_mmu (env, addr + (13 <<DF_BYTE ), oi,GETPC ()); - pwd->b[11 ] =helper_ret_ldub_mmu (env, addr + (12 <<DF_BYTE ), oi,GETPC ()); - pwd->b[12 ] =helper_ret_ldub_mmu (env, addr + (11 <<DF_BYTE ), oi,GETPC ()); - pwd->b[13 ] =helper_ret_ldub_mmu (env, addr + (10 <<DF_BYTE ), oi,GETPC ()); - pwd->b[14 ] =helper_ret_ldub_mmu (env, addr + (9 <<DF_BYTE ), oi,GETPC ()); - pwd->b[15 ] =helper_ret_ldub_mmu (env, addr + (8 <<DF_BYTE ), oi,GETPC ()); -#endif -#else -#if !defined(HOST_WORDS_BIGENDIAN ) - pwd->b[0 ] =cpu_ldub_data (env, addr + (0 <<DF_BYTE )); - pwd->b[1 ] =cpu_ldub_data (env, addr + (1 <<DF_BYTE )); - pwd->b[2 ] =cpu_ldub_data (env, addr + (2 <<DF_BYTE )); - pwd->b[3 ] =cpu_ldub_data (env, addr + (3 <<DF_BYTE )); - pwd->b[4 ] =cpu_ldub_data (env, addr + (4 <<DF_BYTE )); - pwd->b[5 ] =cpu_ldub_data (env, addr + (5 <<DF_BYTE )); - pwd->b[6 ] =cpu_ldub_data (env, addr + (6 <<DF_BYTE )); - pwd->b[7 ] =cpu_ldub_data (env, addr + (7 <<DF_BYTE )); - pwd->b[8 ] =cpu_ldub_data (env, addr + (8 <<DF_BYTE )); - pwd->b[9 ] =cpu_ldub_data (env, addr + (9 <<DF_BYTE )); - pwd->b[10 ] =cpu_ldub_data (env, addr + (10 <<DF_BYTE )); - pwd->b[11 ] =cpu_ldub_data (env, addr + (11 <<DF_BYTE )); - pwd->b[12 ] =cpu_ldub_data (env, addr + (12 <<DF_BYTE )); - pwd->b[13 ] =cpu_ldub_data (env, addr + (13 <<DF_BYTE )); - pwd->b[14 ] =cpu_ldub_data (env, addr + (14 <<DF_BYTE )); - pwd->b[15 ] =cpu_ldub_data (env, addr + (15 <<DF_BYTE )); -#else - pwd->b[0 ] =cpu_ldub_data (env, addr + (7 <<DF_BYTE )); - pwd->b[1 ] =cpu_ldub_data (env, addr + (6 <<DF_BYTE )); - pwd->b[2 ] =cpu_ldub_data (env, addr + (5 <<DF_BYTE )); - pwd->b[3 ] =cpu_ldub_data (env, addr + (4 <<DF_BYTE )); - pwd->b[4 ] =cpu_ldub_data (env, addr + (3 <<DF_BYTE )); - pwd->b[5 ] =cpu_ldub_data (env, addr + (2 <<DF_BYTE )); - pwd->b[6 ] =cpu_ldub_data (env, addr + (1 <<DF_BYTE )); - pwd->b[7 ] =cpu_ldub_data (env, addr + (0 <<DF_BYTE )); - pwd->b[8 ] =cpu_ldub_data (env, addr + (15 <<DF_BYTE )); - pwd->b[9 ] =cpu_ldub_data (env, addr + (14 <<DF_BYTE )); - pwd->b[10 ] =cpu_ldub_data (env, addr + (13 <<DF_BYTE )); - pwd->b[11 ] =cpu_ldub_data (env, addr + (12 <<DF_BYTE )); - pwd->b[12 ] =cpu_ldub_data (env, addr + (11 <<DF_BYTE )); - pwd->b[13 ] =cpu_ldub_data (env, addr + (10 <<DF_BYTE )); - pwd->b[14 ] =cpu_ldub_data (env, addr + (9 <<DF_BYTE )); - pwd->b[15 ] =cpu_ldub_data (env, addr + (8 <<DF_BYTE )); -#endif + pwd->b[0 ] =cpu_ldub_data_ra (env, addr + (7 <<DF_BYTE ), ra); + pwd->b[1 ] =cpu_ldub_data_ra (env, addr + (6 <<DF_BYTE ), ra); + pwd->b[2 ] =cpu_ldub_data_ra (env, addr + (5 <<DF_BYTE ), ra); + pwd->b[3 ] =cpu_ldub_data_ra (env, addr + (4 <<DF_BYTE ), ra); + pwd->b[4 ] =cpu_ldub_data_ra (env, addr + (3 <<DF_BYTE ), ra); + pwd->b[5 ] =cpu_ldub_data_ra (env, addr + (2 <<DF_BYTE ), ra); + pwd->b[6 ] =cpu_ldub_data_ra (env, addr + (1 <<DF_BYTE ), ra); + pwd->b[7 ] =cpu_ldub_data_ra (env, addr + (0 <<DF_BYTE ), ra); + pwd->b[8 ] =cpu_ldub_data_ra (env, addr + (15 <<DF_BYTE ), ra); + pwd->b[9 ] =cpu_ldub_data_ra (env, addr + (14 <<DF_BYTE ), ra); + pwd->b[10 ] =cpu_ldub_data_ra (env, addr + (13 <<DF_BYTE ), ra); + pwd->b[11 ] =cpu_ldub_data_ra (env, addr + (12 <<DF_BYTE ), ra); + pwd->b[12 ] =cpu_ldub_data_ra (env, addr + (11 <<DF_BYTE ), ra); + pwd->b[13 ] =cpu_ldub_data_ra (env, addr + (10 <<DF_BYTE ), ra); + pwd->b[14 ] =cpu_ldub_data_ra (env, addr + (9 <<DF_BYTE ), ra); + pwd->b[15 ] =cpu_ldub_data_ra (env, addr + (8 <<DF_BYTE ), ra);#endif }
@@ -8302,47 +8265,26 @@ void helper_msa_ld_h(CPUMIPSState *env, uint32_t wd, target_ulong addr) {wr_t *pwd = &(env->active_fpu.fpr[wd].wr); - MEMOP_IDX(DF_HALF) -#if !defined(CONFIG_USER_ONLY ) +uintptr_t ra =GETPC (); +#if !defined(HOST_WORDS_BIGENDIAN ) - pwd->h[0 ] =helper_ret_lduw_mmu (env, addr + (0 <<DF_HALF ), oi,GETPC ()); - pwd->h[1 ] =helper_ret_lduw_mmu (env, addr + (1 <<DF_HALF ), oi,GETPC ()); - pwd->h[2 ] =helper_ret_lduw_mmu (env, addr + (2 <<DF_HALF ), oi,GETPC ()); - pwd->h[3 ] =helper_ret_lduw_mmu (env, addr + (3 <<DF_HALF ), oi,GETPC ()); - pwd->h[4 ] =helper_ret_lduw_mmu (env, addr + (4 <<DF_HALF ), oi,GETPC ()); - pwd->h[5 ] =helper_ret_lduw_mmu (env, addr + (5 <<DF_HALF ), oi,GETPC ()); - pwd->h[6 ] =helper_ret_lduw_mmu (env, addr + (6 <<DF_HALF ), oi,GETPC ()); - pwd->h[7 ] =helper_ret_lduw_mmu (env, addr + (7 <<DF_HALF ), oi,GETPC ()); + pwd->h[0 ] =cpu_lduw_data_ra (env, addr + (0 <<DF_HALF ), ra); + pwd->h[1 ] =cpu_lduw_data_ra (env, addr + (1 <<DF_HALF ), ra); + pwd->h[2 ] =cpu_lduw_data_ra (env, addr + (2 <<DF_HALF ), ra); + pwd->h[3 ] =cpu_lduw_data_ra (env, addr + (3 <<DF_HALF ), ra); + pwd->h[4 ] =cpu_lduw_data_ra (env, addr + (4 <<DF_HALF ), ra); + pwd->h[5 ] =cpu_lduw_data_ra (env, addr + (5 <<DF_HALF ), ra); + pwd->h[6 ] =cpu_lduw_data_ra (env, addr + (6 <<DF_HALF ), ra); + pwd->h[7 ] =cpu_lduw_data_ra (env, addr + (7 <<DF_HALF ), ra);#else - pwd->h[0 ] =helper_ret_lduw_mmu (env, addr + (3 <<DF_HALF ), oi,GETPC ()); - pwd->h[1 ] =helper_ret_lduw_mmu (env, addr + (2 <<DF_HALF ), oi,GETPC ()); - pwd->h[2 ] =helper_ret_lduw_mmu (env, addr + (1 <<DF_HALF ), oi,GETPC ()); - pwd->h[3 ] =helper_ret_lduw_mmu (env, addr + (0 <<DF_HALF ), oi,GETPC ()); - pwd->h[4 ] =helper_ret_lduw_mmu (env, addr + (7 <<DF_HALF ), oi,GETPC ()); - pwd->h[5 ] =helper_ret_lduw_mmu (env, addr + (6 <<DF_HALF ), oi,GETPC ()); - pwd->h[6 ] =helper_ret_lduw_mmu (env, addr + (5 <<DF_HALF ), oi,GETPC ()); - pwd->h[7 ] =helper_ret_lduw_mmu (env, addr + (4 <<DF_HALF ), oi,GETPC ()); -#endif -#else -#if !defined(HOST_WORDS_BIGENDIAN ) - pwd->h[0 ] =cpu_lduw_data (env, addr + (0 <<DF_HALF )); - pwd->h[1 ] =cpu_lduw_data (env, addr + (1 <<DF_HALF )); - pwd->h[2 ] =cpu_lduw_data (env, addr + (2 <<DF_HALF )); - pwd->h[3 ] =cpu_lduw_data (env, addr + (3 <<DF_HALF )); - pwd->h[4 ] =cpu_lduw_data (env, addr + (4 <<DF_HALF )); - pwd->h[5 ] =cpu_lduw_data (env, addr + (5 <<DF_HALF )); - pwd->h[6 ] =cpu_lduw_data (env, addr + (6 <<DF_HALF )); - pwd->h[7 ] =cpu_lduw_data (env, addr + (7 <<DF_HALF )); -#else - pwd->h[0 ] =cpu_lduw_data (env, addr + (3 <<DF_HALF )); - pwd->h[1 ] =cpu_lduw_data (env, addr + (2 <<DF_HALF )); - pwd->h[2 ] =cpu_lduw_data (env, addr + (1 <<DF_HALF )); - pwd->h[3 ] =cpu_lduw_data (env, addr + (0 <<DF_HALF )); - pwd->h[4 ] =cpu_lduw_data (env, addr + (7 <<DF_HALF )); - pwd->h[5 ] =cpu_lduw_data (env, addr + (6 <<DF_HALF )); - pwd->h[6 ] =cpu_lduw_data (env, addr + (5 <<DF_HALF )); - pwd->h[7 ] =cpu_lduw_data (env, addr + (4 <<DF_HALF )); -#endif + pwd->h[0 ] =cpu_lduw_data_ra (env, addr + (3 <<DF_HALF ), ra); + pwd->h[1 ] =cpu_lduw_data_ra (env, addr + (2 <<DF_HALF ), ra); + pwd->h[2 ] =cpu_lduw_data_ra (env, addr + (1 <<DF_HALF ), ra); + pwd->h[3 ] =cpu_lduw_data_ra (env, addr + (0 <<DF_HALF ), ra); + pwd->h[4 ] =cpu_lduw_data_ra (env, addr + (7 <<DF_HALF ), ra); + pwd->h[5 ] =cpu_lduw_data_ra (env, addr + (6 <<DF_HALF ), ra); + pwd->h[6 ] =cpu_lduw_data_ra (env, addr + (5 <<DF_HALF ), ra); + pwd->h[7 ] =cpu_lduw_data_ra (env, addr + (4 <<DF_HALF ), ra);#endif }
@@ -8350,31 +8292,18 @@ void helper_msa_ld_w(CPUMIPSState *env, uint32_t wd, target_ulong addr) {wr_t *pwd = &(env->active_fpu.fpr[wd].wr); - MEMOP_IDX(DF_WORD) -#if !defined(CONFIG_USER_ONLY ) +uintptr_t ra =GETPC (); +#if !defined(HOST_WORDS_BIGENDIAN ) - pwd->w[0 ] =helper_ret_ldul_mmu (env, addr + (0 <<DF_WORD ), oi,GETPC ()); - pwd->w[1 ] =helper_ret_ldul_mmu (env, addr + (1 <<DF_WORD ), oi,GETPC ()); - pwd->w[2 ] =helper_ret_ldul_mmu (env, addr + (2 <<DF_WORD ), oi,GETPC ()); - pwd->w[3 ] =helper_ret_ldul_mmu (env, addr + (3 <<DF_WORD ), oi,GETPC ()); + pwd->w[0 ] =cpu_ldl_data_ra (env, addr + (0 <<DF_WORD ), ra); + pwd->w[1 ] =cpu_ldl_data_ra (env, addr + (1 <<DF_WORD ), ra); + pwd->w[2 ] =cpu_ldl_data_ra (env, addr + (2 <<DF_WORD ), ra); + pwd->w[3 ] =cpu_ldl_data_ra (env, addr + (3 <<DF_WORD ), ra);#else - pwd->w[0 ] =helper_ret_ldul_mmu (env, addr + (1 <<DF_WORD ), oi,GETPC ()); - pwd->w[1 ] =helper_ret_ldul_mmu (env, addr + (0 <<DF_WORD ), oi,GETPC ()); - pwd->w[2 ] =helper_ret_ldul_mmu (env, addr + (3 <<DF_WORD ), oi,GETPC ()); - pwd->w[3 ] =helper_ret_ldul_mmu (env, addr + (2 <<DF_WORD ), oi,GETPC ()); -#endif -#else -#if !defined(HOST_WORDS_BIGENDIAN ) - pwd->w[0 ] =cpu_ldl_data (env, addr + (0 <<DF_WORD )); - pwd->w[1 ] =cpu_ldl_data (env, addr + (1 <<DF_WORD )); - pwd->w[2 ] =cpu_ldl_data (env, addr + (2 <<DF_WORD )); - pwd->w[3 ] =cpu_ldl_data (env, addr + (3 <<DF_WORD )); -#else - pwd->w[0 ] =cpu_ldl_data (env, addr + (1 <<DF_WORD )); - pwd->w[1 ] =cpu_ldl_data (env, addr + (0 <<DF_WORD )); - pwd->w[2 ] =cpu_ldl_data (env, addr + (3 <<DF_WORD )); - pwd->w[3 ] =cpu_ldl_data (env, addr + (2 <<DF_WORD )); -#endif + pwd->w[0 ] =cpu_ldl_data_ra (env, addr + (1 <<DF_WORD ), ra); + pwd->w[1 ] =cpu_ldl_data_ra (env, addr + (0 <<DF_WORD ), ra); + pwd->w[2 ] =cpu_ldl_data_ra (env, addr + (3 <<DF_WORD ), ra); + pwd->w[3 ] =cpu_ldl_data_ra (env, addr + (2 <<DF_WORD ), ra);#endif }
@@ -8382,14 +8311,10 @@ void helper_msa_ld_d(CPUMIPSState *env, uint32_t wd, target_ulong addr) {wr_t *pwd = &(env->active_fpu.fpr[wd].wr); - MEMOP_IDX(DF_DOUBLE) -#if !defined(CONFIG_USER_ONLY ) - pwd->d[0 ] =helper_ret_ldq_mmu (env, addr + (0 <<DF_DOUBLE ), oi,GETPC ()); - pwd->d[1 ] =helper_ret_ldq_mmu (env, addr + (1 <<DF_DOUBLE ), oi,GETPC ()); -#else - pwd->d[0 ] =cpu_ldq_data (env, addr + (0 <<DF_DOUBLE )); - pwd->d[1 ] =cpu_ldq_data (env, addr + (1 <<DF_DOUBLE )); -#endif +uintptr_t ra =GETPC (); + + pwd->d[0 ] =cpu_ldq_data_ra (env, addr + (0 <<DF_DOUBLE ), ra); + pwd->d[1 ] =cpu_ldq_data_ra (env, addr + (1 <<DF_DOUBLE ), ra); }#define MSA_PAGESPAN (x) \
@@ -8415,81 +8340,44 @@ void helper_msa_st_b(CPUMIPSState *env, uint32_t wd, {wr_t *pwd = &(env->active_fpu.fpr[wd].wr);int mmu_idx =cpu_mmu_index (env, false); +uintptr_t ra =GETPC (); + +ensure_writable_pages (env, addr, mmu_idx, ra); -MEMOP_IDX (DF_BYTE) -ensure_writable_pages (env, addr, mmu_idx, GETPC()); -#if !defined(CONFIG_USER_ONLY )#if !defined(HOST_WORDS_BIGENDIAN ) -helper_ret_stb_mmu (env, addr + (0 <<DF_BYTE ), pwd->b[0 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (1 <<DF_BYTE ), pwd->b[1 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (2 <<DF_BYTE ), pwd->b[2 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (3 <<DF_BYTE ), pwd->b[3 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (4 <<DF_BYTE ), pwd->b[4 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (5 <<DF_BYTE ), pwd->b[5 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (6 <<DF_BYTE ), pwd->b[6 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (7 <<DF_BYTE ), pwd->b[7 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (8 <<DF_BYTE ), pwd->b[8 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (9 <<DF_BYTE ), pwd->b[9 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (10 <<DF_BYTE ), pwd->b[10 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (11 <<DF_BYTE ), pwd->b[11 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (12 <<DF_BYTE ), pwd->b[12 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (13 <<DF_BYTE ), pwd->b[13 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (14 <<DF_BYTE ), pwd->b[14 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (15 <<DF_BYTE ), pwd->b[15 ], oi,GETPC ()); +cpu_stb_data_ra (env, addr + (0 <<DF_BYTE ), pwd->b[0 ], ra); +cpu_stb_data_ra (env, addr + (1 <<DF_BYTE ), pwd->b[1 ], ra); +cpu_stb_data_ra (env, addr + (2 <<DF_BYTE ), pwd->b[2 ], ra); +cpu_stb_data_ra (env, addr + (3 <<DF_BYTE ), pwd->b[3 ], ra); +cpu_stb_data_ra (env, addr + (4 <<DF_BYTE ), pwd->b[4 ], ra); +cpu_stb_data_ra (env, addr + (5 <<DF_BYTE ), pwd->b[5 ], ra); +cpu_stb_data_ra (env, addr + (6 <<DF_BYTE ), pwd->b[6 ], ra); +cpu_stb_data_ra (env, addr + (7 <<DF_BYTE ), pwd->b[7 ], ra); +cpu_stb_data_ra (env, addr + (8 <<DF_BYTE ), pwd->b[8 ], ra); +cpu_stb_data_ra (env, addr + (9 <<DF_BYTE ), pwd->b[9 ], ra); +cpu_stb_data_ra (env, addr + (10 <<DF_BYTE ), pwd->b[10 ], ra); +cpu_stb_data_ra (env, addr + (11 <<DF_BYTE ), pwd->b[11 ], ra); +cpu_stb_data_ra (env, addr + (12 <<DF_BYTE ), pwd->b[12 ], ra); +cpu_stb_data_ra (env, addr + (13 <<DF_BYTE ), pwd->b[13 ], ra); +cpu_stb_data_ra (env, addr + (14 <<DF_BYTE ), pwd->b[14 ], ra); +cpu_stb_data_ra (env, addr + (15 <<DF_BYTE ), pwd->b[15 ], ra);#else -helper_ret_stb_mmu (env, addr + (7 <<DF_BYTE ), pwd->b[0 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (6 <<DF_BYTE ), pwd->b[1 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (5 <<DF_BYTE ), pwd->b[2 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (4 <<DF_BYTE ), pwd->b[3 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (3 <<DF_BYTE ), pwd->b[4 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (2 <<DF_BYTE ), pwd->b[5 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (1 <<DF_BYTE ), pwd->b[6 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (0 <<DF_BYTE ), pwd->b[7 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (15 <<DF_BYTE ), pwd->b[8 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (14 <<DF_BYTE ), pwd->b[9 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (13 <<DF_BYTE ), pwd->b[10 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (12 <<DF_BYTE ), pwd->b[11 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (11 <<DF_BYTE ), pwd->b[12 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (10 <<DF_BYTE ), pwd->b[13 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (9 <<DF_BYTE ), pwd->b[14 ], oi,GETPC ()); -helper_ret_stb_mmu (env, addr + (8 <<DF_BYTE ), pwd->b[15 ], oi,GETPC ()); -#endif -#else -#if !defined(HOST_WORDS_BIGENDIAN ) -cpu_stb_data (env, addr + (0 <<DF_BYTE ), pwd->b[0 ]); -cpu_stb_data (env, addr + (1 <<DF_BYTE ), pwd->b[1 ]); -cpu_stb_data (env, addr + (2 <<DF_BYTE ), pwd->b[2 ]); -cpu_stb_data (env, addr + (3 <<DF_BYTE ), pwd->b[3 ]); -cpu_stb_data (env, addr + (4 <<DF_BYTE ), pwd->b[4 ]); -cpu_stb_data (env, addr + (5 <<DF_BYTE ), pwd->b[5 ]); -cpu_stb_data (env, addr + (6 <<DF_BYTE ), pwd->b[6 ]); -cpu_stb_data (env, addr + (7 <<DF_BYTE ), pwd->b[7 ]); -cpu_stb_data (env, addr + (8 <<DF_BYTE ), pwd->b[8 ]); -cpu_stb_data (env, addr + (9 <<DF_BYTE ), pwd->b[9 ]); -cpu_stb_data (env, addr + (10 <<DF_BYTE ), pwd->b[10 ]); -cpu_stb_data (env, addr + (11 <<DF_BYTE ), pwd->b[11 ]); -cpu_stb_data (env, addr + (12 <<DF_BYTE ), pwd->b[12 ]); -cpu_stb_data (env, addr + (13 <<DF_BYTE ), pwd->b[13 ]); -cpu_stb_data (env, addr + (14 <<DF_BYTE ), pwd->b[14 ]); -cpu_stb_data (env, addr + (15 <<DF_BYTE ), pwd->b[15 ]); -#else -cpu_stb_data (env, addr + (7 <<DF_BYTE ), pwd->b[0 ]); -cpu_stb_data (env, addr + (6 <<DF_BYTE ), pwd->b[1 ]); -cpu_stb_data (env, addr + (5 <<DF_BYTE ), pwd->b[2 ]); -cpu_stb_data (env, addr + (4 <<DF_BYTE ), pwd->b[3 ]); -cpu_stb_data (env, addr + (3 <<DF_BYTE ), pwd->b[4 ]); -cpu_stb_data (env, addr + (2 <<DF_BYTE ), pwd->b[5 ]); -cpu_stb_data (env, addr + (1 <<DF_BYTE ), pwd->b[6 ]); -cpu_stb_data (env, addr + (0 <<DF_BYTE ), pwd->b[7 ]); -cpu_stb_data (env, addr + (15 <<DF_BYTE ), pwd->b[8 ]); -cpu_stb_data (env, addr + (14 <<DF_BYTE ), pwd->b[9 ]); -cpu_stb_data (env, addr + (13 <<DF_BYTE ), pwd->b[10 ]); -cpu_stb_data (env, addr + (12 <<DF_BYTE ), pwd->b[11 ]); -cpu_stb_data (env, addr + (11 <<DF_BYTE ), pwd->b[12 ]); -cpu_stb_data (env, addr + (10 <<DF_BYTE ), pwd->b[13 ]); -cpu_stb_data (env, addr + (9 <<DF_BYTE ), pwd->b[14 ]); -cpu_stb_data (env, addr + (8 <<DF_BYTE ), pwd->b[15 ]); -#endif +cpu_stb_data_ra (env, addr + (7 <<DF_BYTE ), pwd->b[0 ], ra); +cpu_stb_data_ra (env, addr + (6 <<DF_BYTE ), pwd->b[1 ], ra); +cpu_stb_data_ra (env, addr + (5 <<DF_BYTE ), pwd->b[2 ], ra); +cpu_stb_data_ra (env, addr + (4 <<DF_BYTE ), pwd->b[3 ], ra); +cpu_stb_data_ra (env, addr + (3 <<DF_BYTE ), pwd->b[4 ], ra); +cpu_stb_data_ra (env, addr + (2 <<DF_BYTE ), pwd->b[5 ], ra); +cpu_stb_data_ra (env, addr + (1 <<DF_BYTE ), pwd->b[6 ], ra); +cpu_stb_data_ra (env, addr + (0 <<DF_BYTE ), pwd->b[7 ], ra); +cpu_stb_data_ra (env, addr + (15 <<DF_BYTE ), pwd->b[8 ], ra); +cpu_stb_data_ra (env, addr + (14 <<DF_BYTE ), pwd->b[9 ], ra); +cpu_stb_data_ra (env, addr + (13 <<DF_BYTE ), pwd->b[10 ], ra); +cpu_stb_data_ra (env, addr + (12 <<DF_BYTE ), pwd->b[11 ], ra); +cpu_stb_data_ra (env, addr + (11 <<DF_BYTE ), pwd->b[12 ], ra); +cpu_stb_data_ra (env, addr + (10 <<DF_BYTE ), pwd->b[13 ], ra); +cpu_stb_data_ra (env, addr + (9 <<DF_BYTE ), pwd->b[14 ], ra); +cpu_stb_data_ra (env, addr + (8 <<DF_BYTE ), pwd->b[15 ], ra);#endif }
@@ -8498,49 +8386,28 @@ void helper_msa_st_h(CPUMIPSState *env, uint32_t wd, {wr_t *pwd = &(env->active_fpu.fpr[wd].wr);int mmu_idx =cpu_mmu_index (env, false); +uintptr_t ra =GETPC (); + +ensure_writable_pages (env, addr, mmu_idx, ra); -MEMOP_IDX (DF_HALF) -ensure_writable_pages (env, addr, mmu_idx, GETPC()); -#if !defined(CONFIG_USER_ONLY )#if !defined(HOST_WORDS_BIGENDIAN ) -helper_ret_stw_mmu (env, addr + (0 <<DF_HALF ), pwd->h[0 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (1 <<DF_HALF ), pwd->h[1 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (2 <<DF_HALF ), pwd->h[2 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (3 <<DF_HALF ), pwd->h[3 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (4 <<DF_HALF ), pwd->h[4 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (5 <<DF_HALF ), pwd->h[5 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (6 <<DF_HALF ), pwd->h[6 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (7 <<DF_HALF ), pwd->h[7 ], oi,GETPC ()); +cpu_stw_data_ra (env, addr + (0 <<DF_HALF ), pwd->h[0 ], ra); +cpu_stw_data_ra (env, addr + (1 <<DF_HALF ), pwd->h[1 ], ra); +cpu_stw_data_ra (env, addr + (2 <<DF_HALF ), pwd->h[2 ], ra); +cpu_stw_data_ra (env, addr + (3 <<DF_HALF ), pwd->h[3 ], ra); +cpu_stw_data_ra (env, addr + (4 <<DF_HALF ), pwd->h[4 ], ra); +cpu_stw_data_ra (env, addr + (5 <<DF_HALF ), pwd->h[5 ], ra); +cpu_stw_data_ra (env, addr + (6 <<DF_HALF ), pwd->h[6 ], ra); +cpu_stw_data_ra (env, addr + (7 <<DF_HALF ), pwd->h[7 ], ra);#else -helper_ret_stw_mmu (env, addr + (3 <<DF_HALF ), pwd->h[0 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (2 <<DF_HALF ), pwd->h[1 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (1 <<DF_HALF ), pwd->h[2 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (0 <<DF_HALF ), pwd->h[3 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (7 <<DF_HALF ), pwd->h[4 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (6 <<DF_HALF ), pwd->h[5 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (5 <<DF_HALF ), pwd->h[6 ], oi,GETPC ()); -helper_ret_stw_mmu (env, addr + (4 <<DF_HALF ), pwd->h[7 ], oi,GETPC ()); -#endif -#else -#if !defined(HOST_WORDS_BIGENDIAN ) -cpu_stw_data (env, addr + (0 <<DF_HALF ), pwd->h[0 ]); -cpu_stw_data (env, addr + (1 <<DF_HALF ), pwd->h[1 ]); -cpu_stw_data (env, addr + (2 <<DF_HALF ), pwd->h[2 ]); -cpu_stw_data (env, addr + (3 <<DF_HALF ), pwd->h[3 ]); -cpu_stw_data (env, addr + (4 <<DF_HALF ), pwd->h[4 ]); -cpu_stw_data (env, addr + (5 <<DF_HALF ), pwd->h[5 ]); -cpu_stw_data (env, addr + (6 <<DF_HALF ), pwd->h[6 ]); -cpu_stw_data (env, addr + (7 <<DF_HALF ), pwd->h[7 ]); -#else -cpu_stw_data (env, addr + (3 <<DF_HALF ), pwd->h[0 ]); -cpu_stw_data (env, addr + (2 <<DF_HALF ), pwd->h[1 ]); -cpu_stw_data (env, addr + (1 <<DF_HALF ), pwd->h[2 ]); -cpu_stw_data (env, addr + (0 <<DF_HALF ), pwd->h[3 ]); -cpu_stw_data (env, addr + (7 <<DF_HALF ), pwd->h[4 ]); -cpu_stw_data (env, addr + (6 <<DF_HALF ), pwd->h[5 ]); -cpu_stw_data (env, addr + (5 <<DF_HALF ), pwd->h[6 ]); -cpu_stw_data (env, addr + (4 <<DF_HALF ), pwd->h[7 ]); -#endif +cpu_stw_data_ra (env, addr + (3 <<DF_HALF ), pwd->h[0 ], ra); +cpu_stw_data_ra (env, addr + (2 <<DF_HALF ), pwd->h[1 ], ra); +cpu_stw_data_ra (env, addr + (1 <<DF_HALF ), pwd->h[2 ], ra); +cpu_stw_data_ra (env, addr + (0 <<DF_HALF ), pwd->h[3 ], ra); +cpu_stw_data_ra (env, addr + (7 <<DF_HALF ), pwd->h[4 ], ra); +cpu_stw_data_ra (env, addr + (6 <<DF_HALF ), pwd->h[5 ], ra); +cpu_stw_data_ra (env, addr + (5 <<DF_HALF ), pwd->h[6 ], ra); +cpu_stw_data_ra (env, addr + (4 <<DF_HALF ), pwd->h[7 ], ra);#endif }
@@ -8549,33 +8416,20 @@ void helper_msa_st_w(CPUMIPSState *env, uint32_t wd, {wr_t *pwd = &(env->active_fpu.fpr[wd].wr);int mmu_idx =cpu_mmu_index (env, false); +uintptr_t ra =GETPC (); + +ensure_writable_pages (env, addr, mmu_idx, ra); -MEMOP_IDX (DF_WORD) -ensure_writable_pages (env, addr, mmu_idx, GETPC()); -#if !defined(CONFIG_USER_ONLY )#if !defined(HOST_WORDS_BIGENDIAN ) -helper_ret_stl_mmu (env, addr + (0 <<DF_WORD ), pwd->w[0 ], oi,GETPC ()); -helper_ret_stl_mmu (env, addr + (1 <<DF_WORD ), pwd->w[1 ], oi,GETPC ()); -helper_ret_stl_mmu (env, addr + (2 <<DF_WORD ), pwd->w[2 ], oi,GETPC ()); -helper_ret_stl_mmu (env, addr + (3 <<DF_WORD ), pwd->w[3 ], oi,GETPC ()); +cpu_stl_data_ra (env, addr + (0 <<DF_WORD ), pwd->w[0 ], ra); +cpu_stl_data_ra (env, addr + (1 <<DF_WORD ), pwd->w[1 ], ra); +cpu_stl_data_ra (env, addr + (2 <<DF_WORD ), pwd->w[2 ], ra); +cpu_stl_data_ra (env, addr + (3 <<DF_WORD ), pwd->w[3 ], ra);#else -helper_ret_stl_mmu (env, addr + (1 <<DF_WORD ), pwd->w[0 ], oi,GETPC ()); -helper_ret_stl_mmu (env, addr + (0 <<DF_WORD ), pwd->w[1 ], oi,GETPC ()); -helper_ret_stl_mmu (env, addr + (3 <<DF_WORD ), pwd->w[2 ], oi,GETPC ()); -helper_ret_stl_mmu (env, addr + (2 <<DF_WORD ), pwd->w[3 ], oi,GETPC ()); -#endif -#else -#if !defined(HOST_WORDS_BIGENDIAN ) -cpu_stl_data (env, addr + (0 <<DF_WORD ), pwd->w[0 ]); -cpu_stl_data (env, addr + (1 <<DF_WORD ), pwd->w[1 ]); -cpu_stl_data (env, addr + (2 <<DF_WORD ), pwd->w[2 ]); -cpu_stl_data (env, addr + (3 <<DF_WORD ), pwd->w[3 ]); -#else -cpu_stl_data (env, addr + (1 <<DF_WORD ), pwd->w[0 ]); -cpu_stl_data (env, addr + (0 <<DF_WORD ), pwd->w[1 ]); -cpu_stl_data (env, addr + (3 <<DF_WORD ), pwd->w[2 ]); -cpu_stl_data (env, addr + (2 <<DF_WORD ), pwd->w[3 ]); -#endif +cpu_stl_data_ra (env, addr + (1 <<DF_WORD ), pwd->w[0 ], ra); +cpu_stl_data_ra (env, addr + (0 <<DF_WORD ), pwd->w[1 ], ra); +cpu_stl_data_ra (env, addr + (3 <<DF_WORD ), pwd->w[2 ], ra); +cpu_stl_data_ra (env, addr + (2 <<DF_WORD ), pwd->w[3 ], ra);#endif }
@@ -8584,14 +8438,10 @@ void helper_msa_st_d(CPUMIPSState *env, uint32_t wd, {wr_t *pwd = &(env->active_fpu.fpr[wd].wr);int mmu_idx =cpu_mmu_index (env, false); +uintptr_t ra =GETPC (); -MEMOP_IDX (DF_DOUBLE)ensure_writable_pages (env, addr, mmu_idx,GETPC ()); -#if !defined(CONFIG_USER_ONLY ) -helper_ret_stq_mmu (env, addr + (0 <<DF_DOUBLE ), pwd->d[0 ], oi,GETPC ()); -helper_ret_stq_mmu (env, addr + (1 <<DF_DOUBLE ), pwd->d[1 ], oi,GETPC ()); -#else -cpu_stq_data (env, addr + (0 <<DF_DOUBLE ), pwd->d[0 ]); -cpu_stq_data (env, addr + (1 <<DF_DOUBLE ), pwd->d[1 ]); -#endif + +cpu_stq_data_ra (env, addr + (0 <<DF_DOUBLE ), pwd->d[0 ], ra); +cpu_stq_data_ra (env, addr + (1 <<DF_DOUBLE ), pwd->d[1 ], ra); }
Signature · 1 line
2.25.1
PATCH v2 37/55 target/mips: Use 8-byte memory ops for msa load/store
In reply to Richard HendersonRather than use 4-16 separate operations, use 2 operations plus some byte reordering as necessary.
--- target/mips/tcg/msa_helper.c | 201 +++++++++++++---------------------- 1 file changed, 71 insertions(+), 130 deletions(-)
target/mips/tcg/msa_helper.c +71 -130
@@ -8218,47 +8218,31 @@ void helper_msa_ffint_u_df(CPUMIPSState *env, uint32_t df, uint32_t wd,#define MEMOP_IDX (DF )#endif +#ifdef TARGET_WORDS_BIGENDIAN +static inline uint64_t bswap16x4 (uint64_t x) +{ +uint64_t m =0x00ff00ff00ff00ffull ; +return ((x & m) <<8 ) | ((x >>8 ) & m); +} + +static inline uint64_t bswap32x2 (uint64_t x) +{ +return ror64 (bswap64 (x),32 ); +} +#endif +void helper_msa_ld_b (CPUMIPSState *env,uint32_t wd,target_ulong addr) {wr_t *pwd = &(env->active_fpu.fpr[wd].wr);uintptr_t ra =GETPC (); +uint64_t d0, d1; -#if !defined(HOST_WORDS_BIGENDIAN ) - pwd->b[0 ] =cpu_ldub_data_ra (env, addr + (0 <<DF_BYTE ), ra); - pwd->b[1 ] =cpu_ldub_data_ra (env, addr + (1 <<DF_BYTE ), ra); - pwd->b[2 ] =cpu_ldub_data_ra (env, addr + (2 <<DF_BYTE ), ra); - pwd->b[3 ] =cpu_ldub_data_ra (env, addr + (3 <<DF_BYTE ), ra); - pwd->b[4 ] =cpu_ldub_data_ra (env, addr + (4 <<DF_BYTE ), ra); - pwd->b[5 ] =cpu_ldub_data_ra (env, addr + (5 <<DF_BYTE ), ra); - pwd->b[6 ] =cpu_ldub_data_ra (env, addr + (6 <<DF_BYTE ), ra); - pwd->b[7 ] =cpu_ldub_data_ra (env, addr + (7 <<DF_BYTE ), ra); - pwd->b[8 ] =cpu_ldub_data_ra (env, addr + (8 <<DF_BYTE ), ra); - pwd->b[9 ] =cpu_ldub_data_ra (env, addr + (9 <<DF_BYTE ), ra); - pwd->b[10 ] =cpu_ldub_data_ra (env, addr + (10 <<DF_BYTE ), ra); - pwd->b[11 ] =cpu_ldub_data_ra (env, addr + (11 <<DF_BYTE ), ra); - pwd->b[12 ] =cpu_ldub_data_ra (env, addr + (12 <<DF_BYTE ), ra); - pwd->b[13 ] =cpu_ldub_data_ra (env, addr + (13 <<DF_BYTE ), ra); - pwd->b[14 ] =cpu_ldub_data_ra (env, addr + (14 <<DF_BYTE ), ra); - pwd->b[15 ] =cpu_ldub_data_ra (env, addr + (15 <<DF_BYTE ), ra); -#else - pwd->b[0 ] =cpu_ldub_data_ra (env, addr + (7 <<DF_BYTE ), ra); - pwd->b[1 ] =cpu_ldub_data_ra (env, addr + (6 <<DF_BYTE ), ra); - pwd->b[2 ] =cpu_ldub_data_ra (env, addr + (5 <<DF_BYTE ), ra); - pwd->b[3 ] =cpu_ldub_data_ra (env, addr + (4 <<DF_BYTE ), ra); - pwd->b[4 ] =cpu_ldub_data_ra (env, addr + (3 <<DF_BYTE ), ra); - pwd->b[5 ] =cpu_ldub_data_ra (env, addr + (2 <<DF_BYTE ), ra); - pwd->b[6 ] =cpu_ldub_data_ra (env, addr + (1 <<DF_BYTE ), ra); - pwd->b[7 ] =cpu_ldub_data_ra (env, addr + (0 <<DF_BYTE ), ra); - pwd->b[8 ] =cpu_ldub_data_ra (env, addr + (15 <<DF_BYTE ), ra); - pwd->b[9 ] =cpu_ldub_data_ra (env, addr + (14 <<DF_BYTE ), ra); - pwd->b[10 ] =cpu_ldub_data_ra (env, addr + (13 <<DF_BYTE ), ra); - pwd->b[11 ] =cpu_ldub_data_ra (env, addr + (12 <<DF_BYTE ), ra); - pwd->b[12 ] =cpu_ldub_data_ra (env, addr + (11 <<DF_BYTE ), ra); - pwd->b[13 ] =cpu_ldub_data_ra (env, addr + (10 <<DF_BYTE ), ra); - pwd->b[14 ] =cpu_ldub_data_ra (env, addr + (9 <<DF_BYTE ), ra); - pwd->b[15 ] =cpu_ldub_data_ra (env, addr + (8 <<DF_BYTE ), ra); -#endif +/* Load 8 bytes at a time. Vector element ordering makes this LE. */ + d0 =cpu_ldq_le_data_ra (env, addr +0 , ra); + d1 =cpu_ldq_le_data_ra (env, addr +8 , ra); + pwd->d[0 ] = d0; + pwd->d[1 ] = d1; } void helper_msa_ld_h(CPUMIPSState *env, uint32_t wd,
@@ -8266,26 +8250,20 @@ void helper_msa_ld_h(CPUMIPSState *env, uint32_t wd, {wr_t *pwd = &(env->active_fpu.fpr[wd].wr);uintptr_t ra =GETPC (); +uint64_t d0, d1; -#if !defined(HOST_WORDS_BIGENDIAN ) - pwd->h[0 ] =cpu_lduw_data_ra (env, addr + (0 <<DF_HALF ), ra); - pwd->h[1 ] =cpu_lduw_data_ra (env, addr + (1 <<DF_HALF ), ra); - pwd->h[2 ] =cpu_lduw_data_ra (env, addr + (2 <<DF_HALF ), ra); - pwd->h[3 ] =cpu_lduw_data_ra (env, addr + (3 <<DF_HALF ), ra); - pwd->h[4 ] =cpu_lduw_data_ra (env, addr + (4 <<DF_HALF ), ra); - pwd->h[5 ] =cpu_lduw_data_ra (env, addr + (5 <<DF_HALF ), ra); - pwd->h[6 ] =cpu_lduw_data_ra (env, addr + (6 <<DF_HALF ), ra); - pwd->h[7 ] =cpu_lduw_data_ra (env, addr + (7 <<DF_HALF ), ra); -#else - pwd->h[0 ] =cpu_lduw_data_ra (env, addr + (3 <<DF_HALF ), ra); - pwd->h[1 ] =cpu_lduw_data_ra (env, addr + (2 <<DF_HALF ), ra); - pwd->h[2 ] =cpu_lduw_data_ra (env, addr + (1 <<DF_HALF ), ra); - pwd->h[3 ] =cpu_lduw_data_ra (env, addr + (0 <<DF_HALF ), ra); - pwd->h[4 ] =cpu_lduw_data_ra (env, addr + (7 <<DF_HALF ), ra); - pwd->h[5 ] =cpu_lduw_data_ra (env, addr + (6 <<DF_HALF ), ra); - pwd->h[6 ] =cpu_lduw_data_ra (env, addr + (5 <<DF_HALF ), ra); - pwd->h[7 ] =cpu_lduw_data_ra (env, addr + (4 <<DF_HALF ), ra); +/* +* Load 8 bytes at a time. Use little-endian load, then for +* big-endian target, we must then swap the four halfwords. +*/ + d0 =cpu_ldq_le_data_ra (env, addr +0 , ra); + d1 =cpu_ldq_le_data_ra (env, addr +8 , ra); +#ifdef TARGET_WORDS_BIGENDIAN + d0 =bswap16x4 (d0); + d1 =bswap16x4 (d1);#endif + pwd->d[0 ] = d0; + pwd->d[1 ] = d1; } void helper_msa_ld_w(CPUMIPSState *env, uint32_t wd,
@@ -8293,18 +8271,20 @@ void helper_msa_ld_w(CPUMIPSState *env, uint32_t wd, {wr_t *pwd = &(env->active_fpu.fpr[wd].wr);uintptr_t ra =GETPC (); +uint64_t d0, d1; -#if !defined(HOST_WORDS_BIGENDIAN ) - pwd->w[0 ] =cpu_ldl_data_ra (env, addr + (0 <<DF_WORD ), ra); - pwd->w[1 ] =cpu_ldl_data_ra (env, addr + (1 <<DF_WORD ), ra); - pwd->w[2 ] =cpu_ldl_data_ra (env, addr + (2 <<DF_WORD ), ra); - pwd->w[3 ] =cpu_ldl_data_ra (env, addr + (3 <<DF_WORD ), ra); -#else - pwd->w[0 ] =cpu_ldl_data_ra (env, addr + (1 <<DF_WORD ), ra); - pwd->w[1 ] =cpu_ldl_data_ra (env, addr + (0 <<DF_WORD ), ra); - pwd->w[2 ] =cpu_ldl_data_ra (env, addr + (3 <<DF_WORD ), ra); - pwd->w[3 ] =cpu_ldl_data_ra (env, addr + (2 <<DF_WORD ), ra); +/* +* Load 8 bytes at a time. Use little-endian load, then for +* big-endian target, we must then bswap the two words. +*/ + d0 =cpu_ldq_le_data_ra (env, addr +0 , ra); + d1 =cpu_ldq_le_data_ra (env, addr +8 , ra); +#ifdef TARGET_WORDS_BIGENDIAN + d0 =bswap32x2 (d0); + d1 =bswap32x2 (d1);#endif + pwd->d[0 ] = d0; + pwd->d[1 ] = d1; } void helper_msa_ld_d(CPUMIPSState *env, uint32_t wd,
@@ -8312,9 +8292,12 @@ void helper_msa_ld_d(CPUMIPSState *env, uint32_t wd, {wr_t *pwd = &(env->active_fpu.fpr[wd].wr);uintptr_t ra =GETPC (); +uint64_t d0, d1; - pwd->d[0 ] =cpu_ldq_data_ra (env, addr + (0 <<DF_DOUBLE ), ra); - pwd->d[1 ] =cpu_ldq_data_ra (env, addr + (1 <<DF_DOUBLE ), ra); + d0 =cpu_ldq_data_ra (env, addr +0 , ra); + d1 =cpu_ldq_data_ra (env, addr +8 , ra); + pwd->d[0 ] = d0; + pwd->d[1 ] = d1; }#define MSA_PAGESPAN (x) \
@@ -8344,41 +8327,9 @@ void helper_msa_st_b(CPUMIPSState *env, uint32_t wd,ensure_writable_pages (env, addr, mmu_idx, ra); -#if !defined(HOST_WORDS_BIGENDIAN ) -cpu_stb_data_ra (env, addr + (0 <<DF_BYTE ), pwd->b[0 ], ra); -cpu_stb_data_ra (env, addr + (1 <<DF_BYTE ), pwd->b[1 ], ra); -cpu_stb_data_ra (env, addr + (2 <<DF_BYTE ), pwd->b[2 ], ra); -cpu_stb_data_ra (env, addr + (3 <<DF_BYTE ), pwd->b[3 ], ra); -cpu_stb_data_ra (env, addr + (4 <<DF_BYTE ), pwd->b[4 ], ra); -cpu_stb_data_ra (env, addr + (5 <<DF_BYTE ), pwd->b[5 ], ra); -cpu_stb_data_ra (env, addr + (6 <<DF_BYTE ), pwd->b[6 ], ra); -cpu_stb_data_ra (env, addr + (7 <<DF_BYTE ), pwd->b[7 ], ra); -cpu_stb_data_ra (env, addr + (8 <<DF_BYTE ), pwd->b[8 ], ra); -cpu_stb_data_ra (env, addr + (9 <<DF_BYTE ), pwd->b[9 ], ra); -cpu_stb_data_ra (env, addr + (10 <<DF_BYTE ), pwd->b[10 ], ra); -cpu_stb_data_ra (env, addr + (11 <<DF_BYTE ), pwd->b[11 ], ra); -cpu_stb_data_ra (env, addr + (12 <<DF_BYTE ), pwd->b[12 ], ra); -cpu_stb_data_ra (env, addr + (13 <<DF_BYTE ), pwd->b[13 ], ra); -cpu_stb_data_ra (env, addr + (14 <<DF_BYTE ), pwd->b[14 ], ra); -cpu_stb_data_ra (env, addr + (15 <<DF_BYTE ), pwd->b[15 ], ra); -#else -cpu_stb_data_ra (env, addr + (7 <<DF_BYTE ), pwd->b[0 ], ra); -cpu_stb_data_ra (env, addr + (6 <<DF_BYTE ), pwd->b[1 ], ra); -cpu_stb_data_ra (env, addr + (5 <<DF_BYTE ), pwd->b[2 ], ra); -cpu_stb_data_ra (env, addr + (4 <<DF_BYTE ), pwd->b[3 ], ra); -cpu_stb_data_ra (env, addr + (3 <<DF_BYTE ), pwd->b[4 ], ra); -cpu_stb_data_ra (env, addr + (2 <<DF_BYTE ), pwd->b[5 ], ra); -cpu_stb_data_ra (env, addr + (1 <<DF_BYTE ), pwd->b[6 ], ra); -cpu_stb_data_ra (env, addr + (0 <<DF_BYTE ), pwd->b[7 ], ra); -cpu_stb_data_ra (env, addr + (15 <<DF_BYTE ), pwd->b[8 ], ra); -cpu_stb_data_ra (env, addr + (14 <<DF_BYTE ), pwd->b[9 ], ra); -cpu_stb_data_ra (env, addr + (13 <<DF_BYTE ), pwd->b[10 ], ra); -cpu_stb_data_ra (env, addr + (12 <<DF_BYTE ), pwd->b[11 ], ra); -cpu_stb_data_ra (env, addr + (11 <<DF_BYTE ), pwd->b[12 ], ra); -cpu_stb_data_ra (env, addr + (10 <<DF_BYTE ), pwd->b[13 ], ra); -cpu_stb_data_ra (env, addr + (9 <<DF_BYTE ), pwd->b[14 ], ra); -cpu_stb_data_ra (env, addr + (8 <<DF_BYTE ), pwd->b[15 ], ra); -#endif +/* Store 8 bytes at a time. Vector element ordering makes this LE. */ +cpu_stq_le_data_ra (env, addr +0 , pwd->d[0 ], ra); +cpu_stq_le_data_ra (env, addr +0 , pwd->d[1 ], ra); } void helper_msa_st_h(CPUMIPSState *env, uint32_t wd,
@@ -8387,28 +8338,19 @@ void helper_msa_st_h(CPUMIPSState *env, uint32_t wd,wr_t *pwd = &(env->active_fpu.fpr[wd].wr);int mmu_idx =cpu_mmu_index (env, false);uintptr_t ra =GETPC (); +uint64_t d0, d1;ensure_writable_pages (env, addr, mmu_idx, ra); -#if !defined(HOST_WORDS_BIGENDIAN ) -cpu_stw_data_ra (env, addr + (0 <<DF_HALF ), pwd->h[0 ], ra); -cpu_stw_data_ra (env, addr + (1 <<DF_HALF ), pwd->h[1 ], ra); -cpu_stw_data_ra (env, addr + (2 <<DF_HALF ), pwd->h[2 ], ra); -cpu_stw_data_ra (env, addr + (3 <<DF_HALF ), pwd->h[3 ], ra); -cpu_stw_data_ra (env, addr + (4 <<DF_HALF ), pwd->h[4 ], ra); -cpu_stw_data_ra (env, addr + (5 <<DF_HALF ), pwd->h[5 ], ra); -cpu_stw_data_ra (env, addr + (6 <<DF_HALF ), pwd->h[6 ], ra); -cpu_stw_data_ra (env, addr + (7 <<DF_HALF ), pwd->h[7 ], ra); -#else -cpu_stw_data_ra (env, addr + (3 <<DF_HALF ), pwd->h[0 ], ra); -cpu_stw_data_ra (env, addr + (2 <<DF_HALF ), pwd->h[1 ], ra); -cpu_stw_data_ra (env, addr + (1 <<DF_HALF ), pwd->h[2 ], ra); -cpu_stw_data_ra (env, addr + (0 <<DF_HALF ), pwd->h[3 ], ra); -cpu_stw_data_ra (env, addr + (7 <<DF_HALF ), pwd->h[4 ], ra); -cpu_stw_data_ra (env, addr + (6 <<DF_HALF ), pwd->h[5 ], ra); -cpu_stw_data_ra (env, addr + (5 <<DF_HALF ), pwd->h[6 ], ra); -cpu_stw_data_ra (env, addr + (4 <<DF_HALF ), pwd->h[7 ], ra); +/* Store 8 bytes at a time. See helper_msa_ld_h. */ + d0 = pwd->d[0 ]; + d1 = pwd->d[1 ]; +#ifdef TARGET_WORDS_BIGENDIAN + d0 =bswap16x4 (d0); + d1 =bswap16x4 (d1);#endif +cpu_stq_le_data_ra (env, addr +0 , d0, ra); +cpu_stq_le_data_ra (env, addr +8 , d1, ra); } void helper_msa_st_w(CPUMIPSState *env, uint32_t wd,
@@ -8417,20 +8359,19 @@ void helper_msa_st_w(CPUMIPSState *env, uint32_t wd,wr_t *pwd = &(env->active_fpu.fpr[wd].wr);int mmu_idx =cpu_mmu_index (env, false);uintptr_t ra =GETPC (); +uint64_t d0, d1;ensure_writable_pages (env, addr, mmu_idx, ra); -#if !defined(HOST_WORDS_BIGENDIAN ) -cpu_stl_data_ra (env, addr + (0 <<DF_WORD ), pwd->w[0 ], ra); -cpu_stl_data_ra (env, addr + (1 <<DF_WORD ), pwd->w[1 ], ra); -cpu_stl_data_ra (env, addr + (2 <<DF_WORD ), pwd->w[2 ], ra); -cpu_stl_data_ra (env, addr + (3 <<DF_WORD ), pwd->w[3 ], ra); -#else -cpu_stl_data_ra (env, addr + (1 <<DF_WORD ), pwd->w[0 ], ra); -cpu_stl_data_ra (env, addr + (0 <<DF_WORD ), pwd->w[1 ], ra); -cpu_stl_data_ra (env, addr + (3 <<DF_WORD ), pwd->w[2 ], ra); -cpu_stl_data_ra (env, addr + (2 <<DF_WORD ), pwd->w[3 ], ra); +/* Store 8 bytes at a time. See helper_msa_ld_w. */ + d0 = pwd->d[0 ]; + d1 = pwd->d[1 ]; +#ifdef TARGET_WORDS_BIGENDIAN + d0 =bswap32x2 (d0); + d1 =bswap32x2 (d1);#endif +cpu_stq_le_data_ra (env, addr +0 , d0, ra); +cpu_stq_le_data_ra (env, addr +8 , d1, ra); } void helper_msa_st_d(CPUMIPSState *env, uint32_t wd,
@@ -8442,6 +8383,6 @@ void helper_msa_st_d(CPUMIPSState *env, uint32_t wd,ensure_writable_pages (env, addr, mmu_idx,GETPC ()); -cpu_stq_data_ra (env, addr + (0 <<DF_DOUBLE ), pwd->d[0 ], ra); -cpu_stq_data_ra (env, addr + (1 <<DF_DOUBLE ), pwd->d[1 ], ra); +cpu_stq_data_ra (env, addr +0 , pwd->d[0 ], ra); +cpu_stq_data_ra (env, addr +8 , pwd->d[1 ], ra); }
Signature · 1 line
2.25.1
Re: [PATCH v2 37/55] target/mips: Use 8-byte memory ops for msa load/store
Quoted 19 lines · Richard Henderson
Rather than use 4-16 separate operations, use 2 operations plus some byte reordering as necessary.
Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/mips/tcg/msa_helper.c | 201 +++++++++++++---------------------- 1 file changed, 71 insertions(+), 130 deletions(-)target/mips/tcg/msa_helper.c +2
-0@@ -8218,47 +8218,31 @@ void helper_msa_ffint_u_df(CPUMIPSState *env, uint32_t df, uint32_t wd,#define MEMOP_IDX (DF )#endif +#ifdef TARGET_WORDS_BIGENDIAN +static inline uint64_t bswap16x4 (uint64_t x)
target/mips/tcg/msa_helper.c void helper_msa_ffint_u_df(CPUMIPSState *env, uint32_t df, uint32_t wd, · line 8232
Quoted 10 lines
target/mips/tcg/msa_helper.c +10
-0+{ +uint64_t m =0x00ff00ff00ff00ffull ; +return ((x & m) <<8 ) | ((x >>8 ) & m); +} + +static inline uint64_t bswap32x2 (uint64_t x) +{ +return ror64 (bswap64 (x),32 ); +} +#endif
I'm trying to remove TARGET_WORDS_BIGENDIAN uses,
so this would become:
static inline bool is_cpu_bigendian(CPUMIPSState *)
{
return extract32(env->CP0_Config0, CP0C0_BE, 1);
}static inline uint64_t bswap16x4(CPUMIPSState *env, uint64_t x)
{
if (is_cpu_bigendian(env)) {
uint64_t m = 0x00ff00ff00ff00ffull;
return ((x & m) << 8) | ((x >> 8) & m);
} else {
return x;
}
}static inline uint64_t bswap32x2(CPUMIPSState *env, uint64_t x)
{
if (is_cpu_bigendian(env)) {
return ror64(bswap64(x), 32);
} else {
return x;
}
}And we can remove the other TARGET_WORDS_BIGENDIAN uses:
Quoted 20 lines
target/mips/tcg/msa_helper.c +4
-10void helper_msa_ld_w(CPUMIPSState *env, uint32_t wd,@@ -8293,18 +8271,20 @@ void helper_msa_ld_w(CPUMIPSState *env, uint32_t wd, {wr_t *pwd = &(env->active_fpu.fpr[wd].wr);uintptr_t ra =GETPC (); +uint64_t d0, d1; -#if !defined(HOST_WORDS_BIGENDIAN ) - pwd->w[0 ] =cpu_ldl_data_ra (env, addr + (0 <<DF_WORD ), ra); - pwd->w[1 ] =cpu_ldl_data_ra (env, addr + (1 <<DF_WORD ), ra); - pwd->w[2 ] =cpu_ldl_data_ra (env, addr + (2 <<DF_WORD ), ra); - pwd->w[3 ] =cpu_ldl_data_ra (env, addr + (3 <<DF_WORD ), ra); -#else - pwd->w[0 ] =cpu_ldl_data_ra (env, addr + (1 <<DF_WORD ), ra); - pwd->w[1 ] =cpu_ldl_data_ra (env, addr + (0 <<DF_WORD ), ra); - pwd->w[2 ] =cpu_ldl_data_ra (env, addr + (3 <<DF_WORD ), ra); - pwd->w[3 ] =cpu_ldl_data_ra (env, addr + (2 <<DF_WORD ), ra); +/* +* Load 8 bytes at a time. Use little-endian load, then for +* big-endian target, we must then bswap the two words.
target/mips/tcg/msa_helper.c void helper_msa_ld_w(CPUMIPSState *env, uint32_t wd, · line 8288
Quoted 10 lines
target/mips/tcg/msa_helper.c +8
-0+*/ + d0 =cpu_ldq_le_data_ra (env, addr +0 , ra); + d1 =cpu_ldq_le_data_ra (env, addr +8 , ra); +#ifdef TARGET_WORDS_BIGENDIAN + d0 =bswap32x2 (d0); + d1 =bswap32x2 (d1);#endif + pwd->d[0 ] = d0; + pwd->d[1 ] = d1; }
But can be done later, so:
(nice simplification BTW!).
Re: [PATCH v2 37/55] target/mips: Use 8-byte memory ops for msa load/store
Quoted 31 lines · Philippe Mathieu-Daudé
target/mips/tcg/msa_helper.c void helper_msa_ffint_u_df(CPUMIPSState *env, uint32_t df, uint32_t wd, · line 8232
Quoted 12 lines
target/mips/tcg/msa_helper.c +12
-0+#ifdef TARGET_WORDS_BIGENDIAN +static inline uint64_t bswap16x4 (uint64_t x) +{ +uint64_t m =0x00ff00ff00ff00ffull ; +return ((x & m) <<8 ) | ((x >>8 ) & m); +} + +static inline uint64_t bswap32x2 (uint64_t x) +{ +return ror64 (bswap64 (x),32 ); +} +#endif I'm trying to remove
TARGET_WORDS_BIGENDIANuses,
so this would become:static inline bool
is_cpu_bigendian(CPUMIPSState *){ return extract32(env->CP0_Config0, CP0C0_BE, 1); }static inline
uint64_tbswap16x4(CPUMIPSState *env, uint64_t x){ if (is_cpu_bigendian(env)) { uint64_t m = 0x00ff00ff00ff00ffull; return ((x & m) << 8) | ((x >> 8) & m); } else { return x; } }
Quoted 8 lines
static inline
uint64_tbswap32x2(CPUMIPSState *env, uint64_t x){ if (is_cpu_bigendian(env)) { return ror64(bswap64(x), 32); } else { return x; } }
I would not put the bigendian test in here...
Quoted 22 lines
And we can remove the other
TARGET_WORDS_BIGENDIANuses:Quoted 19 lines
void helper_msa_ld_w(CPUMIPSState *env,
uint32_twd,target/mips/tcg/msa_helper.c +3
-10@@ -8293,18 +8271,20 @@ void helper_msa_ld_w(CPUMIPSState *env, uint32_t wd, {wr_t *pwd = &(env->active_fpu.fpr[wd].wr);uintptr_t ra =GETPC (); +uint64_t d0, d1; -#if !defined(HOST_WORDS_BIGENDIAN ) - pwd->w[0 ] =cpu_ldl_data_ra (env, addr + (0 <<DF_WORD ), ra); - pwd->w[1 ] =cpu_ldl_data_ra (env, addr + (1 <<DF_WORD ), ra); - pwd->w[2 ] =cpu_ldl_data_ra (env, addr + (2 <<DF_WORD ), ra); - pwd->w[3 ] =cpu_ldl_data_ra (env, addr + (3 <<DF_WORD ), ra); -#else - pwd->w[0 ] =cpu_ldl_data_ra (env, addr + (1 <<DF_WORD ), ra); - pwd->w[1 ] =cpu_ldl_data_ra (env, addr + (0 <<DF_WORD ), ra); - pwd->w[2 ] =cpu_ldl_data_ra (env, addr + (3 <<DF_WORD ), ra); - pwd->w[3 ] =cpu_ldl_data_ra (env, addr + (2 <<DF_WORD ), ra); +/* +* Load 8 bytes at a time. Use little-endian load, then for
Quoted 8 lines
target/mips/tcg/msa_helper.c void helper_msa_ld_w(CPUMIPSState *env, uint32_t wd, · line 8285
Quoted 8 lines
target/mips/tcg/msa_helper.c +7
-0+* big-endian target, we must then bswap the two words. +*/ + d0 =cpu_ldq_le_data_ra (env, addr +0 , ra); + d1 =cpu_ldq_le_data_ra (env, addr +8 , ra); +#ifdef TARGET_WORDS_BIGENDIAN + d0 =bswap32x2 (d0); + d1 =bswap32x2 (d1);#endif
... I would leave it here.
r~
PATCH v2 38/55 target/s390x: Use cpu_*_mmu instead of helper_*_mmu
In reply to Richard HendersonThe helper_*_mmu functions were the only thing available when this code was written. This could have been adjusted when we added cpu_*_mmuidx_ra, but now we can most easily use the newest set of interfaces.
--- target/s390x/tcg/mem_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/s390x/tcg/mem_helper.c +4 -4
@@ -248,13 +248,13 @@ static void do_access_memset(CPUS390XState *env, vaddr vaddr, char *haddr,* page. This is especially relevant to speed up TLB_NOTDIRTY. */ g_assert (size >0 ); -helper_ret_stb_mmu (env, vaddr, byte, oi, ra); +cpu_stb_mmu (env, vaddr, byte, oi, ra); haddr =tlb_vaddr_to_host (env, vaddr,MMU_DATA_STORE , mmu_idx);if (likely (haddr)) {memset (haddr +1 , byte, size -1 ); }else {for (i =1 ; i < size; i++) { -helper_ret_stb_mmu (env, vaddr + i, byte, oi, ra); +cpu_stb_mmu (env, vaddr + i, byte, oi, ra); } } }
@@ -290,7 +290,7 @@ static uint8_t do_access_get_byte(CPUS390XState *env, vaddr vaddr, char **haddr,* Do a single access and test if we can then get access to the * page. This is especially relevant to speed up TLB_NOTDIRTY. */ - byte =helper_ret_ldub_mmu (env, vaddr + offset, oi, ra); + byte =cpu_ldb_mmu (env, vaddr + offset, oi, ra); *haddr =tlb_vaddr_to_host (env, vaddr,MMU_DATA_LOAD , mmu_idx);return byte;#endif
@@ -324,7 +324,7 @@ static void do_access_set_byte(CPUS390XState *env, vaddr vaddr, char **haddr,* Do a single access and test if we can then get access to the * page. This is especially relevant to speed up TLB_NOTDIRTY. */ -helper_ret_stb_mmu (env, vaddr + offset, byte, oi, ra); +cpu_stb_mmu (env, vaddr + offset, byte, oi, ra); *haddr =tlb_vaddr_to_host (env, vaddr,MMU_DATA_STORE , mmu_idx);#endif }
Signature · 1 line
2.25.1
Re: [PATCH v2 38/55] target/s390x: Use cpu_*_mmu instead of helper_*_mmu
Quoted 9 lines · Richard Henderson
The helper_*_mmu functions were the only thing available when this code was written. This could have been adjusted when we added cpu_*_mmuidx_ra, but now we can most easily use the newest set of interfaces.
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Richard Henderson <[email protected]>---
Signature · 3 lines
Thanks, David / dhildenb
PATCH v2 39/55 target/sparc: Use cpu_*_mmu instead of helper_*_mmu
In reply to Richard HendersonThe helper_*_mmu functions were the only thing available when this code was written. This could have been adjusted when we added cpu_*_mmuidx_ra, but now we can most easily use the newest set of interfaces.
--- target/sparc/ldst_helper.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
target/sparc/ldst_helper.c +7 -7
@@ -1328,27 +1328,27 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, oi =make_memop_idx (memop, idx);switch (size) {case 1 : - ret =helper_ret_ldub_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldb_mmu (env, addr, oi,GETPC ());break ;case 2 :if (asi &8 ) { - ret =helper_le_lduw_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldw_le_mmu (env, addr, oi,GETPC ()); }else { - ret =helper_be_lduw_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldw_be_mmu (env, addr, oi,GETPC ()); }break ;case 4 :if (asi &8 ) { - ret =helper_le_ldul_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldl_le_mmu (env, addr, oi,GETPC ()); }else { - ret =helper_be_ldul_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldl_be_mmu (env, addr, oi,GETPC ()); }break ;case 8 :if (asi &8 ) { - ret =helper_le_ldq_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldq_le_mmu (env, addr, oi,GETPC ()); }else { - ret =helper_be_ldq_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldq_be_mmu (env, addr, oi,GETPC ()); }break ;default :
Signature · 1 line
2.25.1
Re: [PATCH v2 39/55] target/sparc: Use cpu_*_mmu instead of helper_*_mmu
Quoted 10 lines · Richard Henderson
The helper_*_mmu functions were the only thing available when this code was written. This could have been adjusted when we added cpu_*_mmuidx_ra, but now we can most easily use the newest set of interfaces.
Cc Mark Cave-Ayland <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/sparc/ldst_helper.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
Re: [PATCH v2 39/55] target/sparc: Use cpu_*_mmu instead of helper_*_mmu
In reply to Richard HendersonQuoted 40 lines · Richard Henderson
The helper_*_mmu functions were the only thing available when this code was written. This could have been adjusted when we added cpu_*_mmuidx_ra, but now we can most easily use the newest set of interfaces.
Cc Mark Cave-Ayland <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/sparc/ldst_helper.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)target/sparc/ldst_helper.c +5
-5@@ -1328,27 +1328,27 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, oi =make_memop_idx (memop, idx);switch (size) {case 1 : - ret =helper_ret_ldub_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldb_mmu (env, addr, oi,GETPC ());break ;case 2 :if (asi &8 ) { - ret =helper_le_lduw_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldw_le_mmu (env, addr, oi,GETPC ()); }else { - ret =helper_be_lduw_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldw_be_mmu (env, addr, oi,GETPC ()); }break ;case 4 :if (asi &8 ) { - ret =helper_le_ldul_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldl_le_mmu (env, addr, oi,GETPC ()); }else { - ret =helper_be_ldul_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldl_be_mmu (env, addr, oi,GETPC ()); }break ;
target/sparc/ldst_helper.c uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, · line 1354
Quoted 10 lines
target/sparc/ldst_helper.c +2
-2case 8 :if (asi &8 ) { - ret =helper_le_ldq_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldq_le_mmu (env, addr, oi,GETPC ()); }else { - ret =helper_be_ldq_mmu (env, addr, oi,GETPC ()); + ret =cpu_ldq_be_mmu (env, addr, oi,GETPC ()); }break ;default :
ATB,
Mark.
PATCH v2 40/55 target/arm: Use cpu_*_mmu instead of helper_*_mmu
In reply to Richard HendersonThe helper_*_mmu functions were the only thing available when this code was written. This could have been adjusted when we added cpu_*_mmuidx_ra, but now we can most easily use the newest set of interfaces.
--- target/arm/helper-a64.c | 52 +++++++---------------------------------- target/arm/m_helper.c | 6 ++--- 2 files changed, 11 insertions(+), 47 deletions(-)
target/arm/helper-a64.c +8 -44
@@ -512,37 +512,19 @@ uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr,uintptr_t ra =GETPC ();uint64_t o0, o1;bool success; - -#ifdef CONFIG_USER_ONLY -/* ??? Enforce alignment. */ -uint64_t *haddr =g2h (env_cpu (env), addr); - -set_helper_retaddr (ra); - o0 =ldq_le_p (haddr +0 ); - o1 =ldq_le_p (haddr +1 ); - oldv =int128_make128 (o0, o1); - - success =int128_eq (oldv, cmpv); -if (success) { -stq_le_p (haddr +0 ,int128_getlo (newv)); -stq_le_p (haddr +1 ,int128_gethi (newv)); - } -clear_helper_retaddr (); -#else int mem_idx =cpu_mmu_index (env, false);MemOpIdx oi0 =make_memop_idx (MO_LEQ |MO_ALIGN_16 , mem_idx);MemOpIdx oi1 =make_memop_idx (MO_LEQ , mem_idx); - o0 =helper_le_ldq_mmu (env, addr +0 , oi0, ra); - o1 =helper_le_ldq_mmu (env, addr +8 , oi1, ra); + o0 =cpu_ldq_le_mmu (env, addr +0 , oi0, ra); + o1 =cpu_ldq_le_mmu (env, addr +8 , oi1, ra); oldv =int128_make128 (o0, o1); success =int128_eq (oldv, cmpv);if (success) { -helper_le_stq_mmu (env, addr +0 ,int128_getlo (newv), oi1, ra); -helper_le_stq_mmu (env, addr +8 ,int128_gethi (newv), oi1, ra); +cpu_stq_le_mmu (env, addr +0 ,int128_getlo (newv), oi1, ra); +cpu_stq_le_mmu (env, addr +8 ,int128_gethi (newv), oi1, ra); } -#endif return !success; }
@@ -582,37 +564,19 @@ uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr,uintptr_t ra =GETPC ();uint64_t o0, o1;bool success; - -#ifdef CONFIG_USER_ONLY -/* ??? Enforce alignment. */ -uint64_t *haddr =g2h (env_cpu (env), addr); - -set_helper_retaddr (ra); - o1 =ldq_be_p (haddr +0 ); - o0 =ldq_be_p (haddr +1 ); - oldv =int128_make128 (o0, o1); - - success =int128_eq (oldv, cmpv); -if (success) { -stq_be_p (haddr +0 ,int128_gethi (newv)); -stq_be_p (haddr +1 ,int128_getlo (newv)); - } -clear_helper_retaddr (); -#else int mem_idx =cpu_mmu_index (env, false);MemOpIdx oi0 =make_memop_idx (MO_BEQ |MO_ALIGN_16 , mem_idx);MemOpIdx oi1 =make_memop_idx (MO_BEQ , mem_idx); - o1 =helper_be_ldq_mmu (env, addr +0 , oi0, ra); - o0 =helper_be_ldq_mmu (env, addr +8 , oi1, ra); + o1 =cpu_ldq_be_mmu (env, addr +0 , oi0, ra); + o0 =cpu_ldq_be_mmu (env, addr +8 , oi1, ra); oldv =int128_make128 (o0, o1); success =int128_eq (oldv, cmpv);if (success) { -helper_be_stq_mmu (env, addr +0 ,int128_gethi (newv), oi1, ra); -helper_be_stq_mmu (env, addr +8 ,int128_getlo (newv), oi1, ra); +cpu_stq_be_mmu (env, addr +0 ,int128_gethi (newv), oi1, ra); +cpu_stq_be_mmu (env, addr +8 ,int128_getlo (newv), oi1, ra); } -#endif return !success; }
target/arm/m_helper.c +3 -3
@@ -1947,9 +1947,9 @@ static bool do_v7m_function_return(ARMCPU *cpu)* do them as secure, so work out what MMU index that is. */ mmu_idx =arm_v7m_mmu_idx_for_secstate (env, true); - oi =make_memop_idx (MO_LE ,arm_to_core_mmu_idx (mmu_idx)); - newpc =helper_le_ldul_mmu (env, frameptr, oi,0 ); - newpsr =helper_le_ldul_mmu (env, frameptr +4 , oi,0 ); + oi =make_memop_idx (MO_LEUL ,arm_to_core_mmu_idx (mmu_idx)); + newpc =cpu_ldl_le_mmu (env, frameptr, oi,0 ); + newpsr =cpu_ldl_le_mmu (env, frameptr +4 , oi,0 );/* Consistency checks on new IPSR */ newpsr_exc = newpsr &XPSR_EXCP ;
Signature · 1 line
2.25.1
PATCH v2 41/55 tcg: Move helper_*_mmu decls to tcg/tcg-ldst.h
In reply to Richard HendersonThese functions have been replaced by cpu_*_mmu as the most proper interface to use from target code.
Hide these declarations from code that should not use them.
--- include/tcg/tcg-ldst.h | 74 ++++++++++++++++++++++++++++++++++++++++++ include/tcg/tcg.h | 71 ---------------------------------------- accel/tcg/cputlb.c | 1 + tcg/tcg.c | 1 + tcg/tci.c | 1 + 5 files changed, 77 insertions(+), 71 deletions(-) create mode 100644 include/tcg/tcg-ldst.h
include/tcg/tcg-ldst.h new file +74 -0
@@ -0,0 +1,74 @@ +/* +* Memory helpers that will be used by TCG generated code. +* +* Copyright (c) 2008 Fabrice Bellard +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#ifndef TCG_LDST_H +#define TCG_LDST_H 1 + +#ifdef CONFIG_SOFTMMU + +/* Value zero-extended to tcg register size. */ +tcg_target_ulong helper_ret_ldub_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); +tcg_target_ulong helper_le_lduw_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); +tcg_target_ulong helper_le_ldul_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); +uint64_t helper_le_ldq_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); +tcg_target_ulong helper_be_lduw_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); +tcg_target_ulong helper_be_ldul_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); +uint64_t helper_be_ldq_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); + +/* Value sign-extended to tcg register size. */ +tcg_target_ulong helper_ret_ldsb_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); +tcg_target_ulong helper_le_ldsw_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); +tcg_target_ulong helper_le_ldsl_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); +tcg_target_ulong helper_be_ldsw_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); +tcg_target_ulong helper_be_ldsl_mmu (CPUArchState *env,target_ulong addr, +MemOpIdx oi,uintptr_t retaddr); + +void helper_ret_stb_mmu (CPUArchState *env,target_ulong addr,uint8_t val, +MemOpIdx oi,uintptr_t retaddr); +void helper_le_stw_mmu (CPUArchState *env,target_ulong addr,uint16_t val, +MemOpIdx oi,uintptr_t retaddr); +void helper_le_stl_mmu (CPUArchState *env,target_ulong addr,uint32_t val, +MemOpIdx oi,uintptr_t retaddr); +void helper_le_stq_mmu (CPUArchState *env,target_ulong addr,uint64_t val, +MemOpIdx oi,uintptr_t retaddr); +void helper_be_stw_mmu (CPUArchState *env,target_ulong addr,uint16_t val, +MemOpIdx oi,uintptr_t retaddr); +void helper_be_stl_mmu (CPUArchState *env,target_ulong addr,uint32_t val, +MemOpIdx oi,uintptr_t retaddr); +void helper_be_stq_mmu (CPUArchState *env,target_ulong addr,uint64_t val, +MemOpIdx oi,uintptr_t retaddr); + +#endif /* CONFIG_SOFTMMU */ +#endif /* TCG_LDST_H */
include/tcg/tcg.h +0 -71
77 lines not on this page · raw message
accel/tcg/cputlb.c +1 -0
@@ -39,6 +39,7 @@#ifdef CONFIG_PLUGIN #include "qemu/plugin-memory.h" #endif +#include "tcg/tcg-ldst.h" /* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */ /* #define DEBUG_TLB */
tcg/tcg.c +1 -0
@@ -58,6 +58,7 @@#include "elf.h" #include "exec/log.h" +#include "tcg/tcg-ldst.h" #include "tcg-internal.h" #ifdef CONFIG_TCG_INTERPRETER
tcg/tci.c +1 -0
@@ -22,6 +22,7 @@#include "tcg/tcg.h" /* MAX_OPC_PARAM_IARGS */ #include "exec/cpu_ldst.h" #include "tcg/tcg-op.h" +#include "tcg/tcg-ldst.h" #include "qemu/compiler.h" #include <ffi.h>
Signature · 1 line
2.25.1
PATCH v2 42/55 tcg: Add helper_unaligned_mmu for user-only sigbus
In reply to Richard HendersonTo be called from tcg generated code on hosts that support unaligned accesses natively, in response to an access that is supposed to be aligned.
--- include/tcg/tcg-ldst.h | 5 +++++ accel/tcg/user-exec.c | 7 +++++++ 2 files changed, 12 insertions(+)
include/tcg/tcg-ldst.h +5 -0
@@ -70,5 +70,10 @@ void helper_be_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val,void helper_be_stq_mmu (CPUArchState *env,target_ulong addr,uint64_t val,MemOpIdx oi,uintptr_t retaddr); +#else + +void QEMU_NORETURN helper_unaligned_mmu(CPUArchState *env, target_ulong addr, +uint32_t type,uintptr_t ra); +#endif /* CONFIG_SOFTMMU */ #endif /* TCG_LDST_H */
accel/tcg/user-exec.c +7 -0
@@ -27,6 +27,7 @@#include "exec/helper-proto.h" #include "qemu/atomic128.h" #include "trace/trace-root.h" +#include "tcg/tcg-ldst.h" #include "internal.h" #undef EAX
@@ -867,6 +868,12 @@ static void validate_memop(MemOpIdx oi, MemOp expected)#endif } +void helper_unaligned_mmu (CPUArchState *env,target_ulong addr, +uint32_t access_type,uintptr_t ra) +{ +cpu_unaligned_access (env_cpu (env), addr, access_type,MMU_USER_IDX , ra); +} +static void *cpu_mmu_lookup (CPUArchState *env,target_ulong addr,MemOpIdx oi,uintptr_t ra,MMUAccessType type) {
Signature · 1 line
2.25.1
PATCH v2 43/55 tcg/i386: Support raising sigbus for user-only
In reply to Richard Henderson--- tcg/i386/tcg-target.h | 2 - tcg/i386/tcg-target.c.inc | 114 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 110 insertions(+), 6 deletions(-)
tcg/i386/tcg-target.h +0 -2
@@ -232,9 +232,7 @@ static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx,#define TCG_TARGET_HAS_MEMORY_BSWAP have_movbe -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif #define TCG_TARGET_NEED_POOL_LABELS #endif
tcg/i386/tcg-target.c.inc +110 -4
170 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 44/55 tests/tcg/multiarch: Add sigbus.c
In reply to Richard HendersonA mostly generic test for unaligned access raising SIGBUS.
--- tests/tcg/multiarch/sigbus.c | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tests/tcg/multiarch/sigbus.c
tests/tcg/multiarch/sigbus.c new file +68 -0
@@ -0,0 +1,68 @@ +#define _GNU_SOURCE 1 + +#include <assert.h> +#include <stdlib.h> +#include <signal.h> +#include <endian.h> + + +unsigned long long x =0x8877665544332211ull ; +void *volatile p = (void *)&x +1 ; + +void sigbus (int sig,siginfo_t *info,void *uc) +{ +assert (sig ==SIGBUS ); +assert (info->si_signo ==SIGBUS ); +#ifdef BUS_ADRALN +assert (info->si_code ==BUS_ADRALN ); +#endif +assert (info->si_addr == p); +exit (EXIT_SUCCESS ); +} + +int main () +{ +struct sigaction sa = { + .sa_sigaction = sigbus, + .sa_flags =SA_SIGINFO + }; +int allow_fail =0 ; +int tmp; + + tmp =sigaction (SIGBUS , &sa,NULL ); +assert (tmp ==0 ); + +/* +* Select an operation that's likely to enforce alignment. +* On many guests that support unaligned accesses by default, +* this is often an atomic operation. +*/ +#if defined(__aarch64__) + asmvolatile ("ldxr %w0,[%1]" :"=r" (tmp) :"r" (p) :"memory" ); +#elif defined(__alpha__) + asmvolatile ("ldl_l %0,0(%1)" :"=r" (tmp) :"r" (p) :"memory" ); +#elif defined(__arm__) + asmvolatile ("ldrex %0,[%1]" :"=r" (tmp) :"r" (p) :"memory" ); +#elif defined(__powerpc__) + asmvolatile ("lwarx %0,0,%1" :"=r" (tmp) :"r" (p) :"memory" ); +#elif defined(__riscv_atomic) + asmvolatile ("lr.w %0,(%1)" :"=r" (tmp) :"r" (p) :"memory" ); +#else +/* No insn known to fault unaligned -- try for a straight load. */ + allow_fail =1 ; + tmp = *(volatile int *)p; +#endif + +assert (allow_fail); + +/* +* We didn't see a signal. +* We might as well validate the unaligned load worked. +*/ +if (BYTE_ORDER ==LITTLE_ENDIAN ) { +assert (tmp ==0x55443322 ); + }else { +assert (tmp ==0x77665544 ); + } +return EXIT_SUCCESS ; +}
Signature · 1 line
2.25.1
PATCH v2 45/55 linux-user: Split out do_prctl and subroutines
In reply to Richard HendersonSince the prctl constants are supposed to be generic, supply any that are not provided by the host.
Split out subroutines for PR_GET_FP_MODE, PR_SET_FP_MODE, PR_GET_VL, PR_SET_VL, PR_RESET_KEYS, PR_SET_TAGGED_ADDR_CTRL, PR_GET_TAGGED_ADDR_CTRL. Return EINVAL for guests that do not support these options rather than pass them on to the host.
--- linux-user/aarch64/target_syscall.h | 23 - linux-user/mips/target_syscall.h | 6 - linux-user/mips64/target_syscall.h | 6 - linux-user/syscall.c | 644 ++++++++++++++++------------ 4 files changed, 359 insertions(+), 320 deletions(-)
linux-user/aarch64/target_syscall.h +0 -23
@@ -20,27 +20,4 @@ struct target_pt_regs {#define TARGET_MCL_FUTURE 2#define TARGET_MCL_ONFAULT 4 -#define TARGET_PR_SVE_SET_VL 50 -#define TARGET_PR_SVE_GET_VL 51 - -#define TARGET_PR_PAC_RESET_KEYS 54 -# define TARGET_PR_PAC_APIAKEY (1 << 0) -# define TARGET_PR_PAC_APIBKEY (1 << 1) -# define TARGET_PR_PAC_APDAKEY (1 << 2) -# define TARGET_PR_PAC_APDBKEY (1 << 3) -# define TARGET_PR_PAC_APGAKEY (1 << 4) - -#define TARGET_PR_SET_TAGGED_ADDR_CTRL 55 -#define TARGET_PR_GET_TAGGED_ADDR_CTRL 56 -# define TARGET_PR_TAGGED_ADDR_ENABLE (1UL << 0) -/* MTE tag check fault modes */ -# define TARGET_PR_MTE_TCF_SHIFT 1 -# define TARGET_PR_MTE_TCF_NONE (0UL << TARGET_PR_MTE_TCF_SHIFT) -# define TARGET_PR_MTE_TCF_SYNC (1UL << TARGET_PR_MTE_TCF_SHIFT) -# define TARGET_PR_MTE_TCF_ASYNC (2UL << TARGET_PR_MTE_TCF_SHIFT) -# define TARGET_PR_MTE_TCF_MASK (3UL << TARGET_PR_MTE_TCF_SHIFT) -/* MTE tag inclusion mask */ -# define TARGET_PR_MTE_TAG_SHIFT 3 -# define TARGET_PR_MTE_TAG_MASK (0xffffUL << TARGET_PR_MTE_TAG_SHIFT) -#endif /* AARCH64_TARGET_SYSCALL_H */
linux-user/mips/target_syscall.h +0 -6
@@ -36,10 +36,4 @@ static inline abi_ulong target_shmlba(CPUMIPSState *env) return 0x40000; } -/* MIPS-specific prctl() options */ -#define TARGET_PR_SET_FP_MODE 45 -#define TARGET_PR_GET_FP_MODE 46 -#define TARGET_PR_FP_MODE_FR (1 << 0) -#define TARGET_PR_FP_MODE_FRE (1 << 1) -#endif /* MIPS_TARGET_SYSCALL_H */
linux-user/mips64/target_syscall.h +0 -6
@@ -33,10 +33,4 @@ static inline abi_ulong target_shmlba(CPUMIPSState *env) return 0x40000; } -/* MIPS-specific prctl() options */ -#define TARGET_PR_SET_FP_MODE 45 -#define TARGET_PR_GET_FP_MODE 46 -#define TARGET_PR_FP_MODE_FR (1 << 0) -#define TARGET_PR_FP_MODE_FRE (1 << 1) -#endif /* MIPS64_TARGET_SYSCALL_H */
linux-user/syscall.c +359 -285
658 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 46/55 linux-user: Disable more prctl subcodes
In reply to Richard HendersonCreate a list of subcodes that we want to pass on, a list of subcodes that should not be passed on because they would affect the running qemu itself, and a list that probably could be implemented but require extra work. Do not pass on unknown subcodes.
--- linux-user/syscall.c | 56 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-)
linux-user/syscall.c +52 -4
@@ -6325,6 +6325,13 @@ abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr)# define PR_MTE_TAG_SHIFT 3# define PR_MTE_TAG_MASK (0xffffUL << PR_MTE_TAG_SHIFT)#endif +#ifndef PR_SET_IO_FLUSHER +# define PR_SET_IO_FLUSHER 57 +# define PR_GET_IO_FLUSHER 58 +#endif +#ifndef PR_SET_SYSCALL_USER_DISPATCH +# define PR_SET_SYSCALL_USER_DISPATCH 59 +#endif static abi_long do_prctl_get_fp_mode (CPUArchState *env) {
@@ -6632,13 +6639,54 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,return -TARGET_EINVAL ; }return do_prctl_get_tagged_addr_ctrl (env); + +case PR_GET_DUMPABLE : +case PR_SET_DUMPABLE : +case PR_GET_KEEPCAPS : +case PR_SET_KEEPCAPS : +case PR_GET_TIMING : +case PR_SET_TIMING : +case PR_GET_TIMERSLACK : +case PR_SET_TIMERSLACK : +case PR_MCE_KILL : +case PR_MCE_KILL_GET : +case PR_GET_NO_NEW_PRIVS : +case PR_SET_NO_NEW_PRIVS : +case PR_GET_IO_FLUSHER : +case PR_SET_IO_FLUSHER : +/* Some prctl options have no pointer arguments and we can pass on. */ +return get_errno (prctl (option, arg2, arg3, arg4, arg5)); + +case PR_GET_CHILD_SUBREAPER : +case PR_SET_CHILD_SUBREAPER : +case PR_GET_SPECULATION_CTRL : +case PR_SET_SPECULATION_CTRL : +case PR_GET_TID_ADDRESS : +/* TODO */ +return -TARGET_EINVAL ; + +case PR_GET_FPEXC : +case PR_SET_FPEXC : +/* Was used for SPE on PowerPC. */ +return -TARGET_EINVAL ; + +case PR_GET_ENDIAN : +case PR_SET_ENDIAN : +case PR_GET_FPEMU : +case PR_SET_FPEMU : +case PR_SET_MM :case PR_GET_SECCOMP :case PR_SET_SECCOMP : -/* Disable seccomp to prevent the target disabling syscalls we need. */ -return -TARGET_EINVAL ; +case PR_SET_SYSCALL_USER_DISPATCH : +case PR_GET_THP_DISABLE : +case PR_SET_THP_DISABLE : +case PR_GET_TSC : +case PR_SET_TSC : +case PR_GET_UNALIGN : +case PR_SET_UNALIGN :default : -/* Most prctl options have no pointer arguments */ -return get_errno (prctl (option, arg2, arg3, arg4, arg5)); +/* Disable to prevent the target disabling stuff we need. */ +return -TARGET_EINVAL ; } }
Signature · 1 line
2.25.1
PATCH v2 47/55 hw/core/cpu: Re-sort the non-pointers to the end of CPUClass
In reply to Richard HendersonDespite the comment, the members were not kept at the end.
--- include/hw/core/cpu.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
include/hw/core/cpu.h +7 -4
@@ -131,7 +131,6 @@ struct CPUClass {ObjectClass *(*class_by_name)(const char *cpu_model);void (*parse_features)(const char *typename,char *str,Error **errp); -int reset_dump_flags;bool (*has_work)(CPUState *cpu);int (*memory_rw_debug)(CPUState *cpu,vaddr addr,uint8_t *buf,int len,bool is_write);
@@ -149,9 +148,6 @@ struct CPUClass {void (*disas_set_info)(CPUState *cpu,disassemble_info *info);const char *deprecation_note; -/* Keep non-pointer data at the end to minimize holes. */ -int gdb_num_core_regs; -bool gdb_stop_before_watchpoint;struct AccelCPUClass *accel_cpu;/* when system emulation is not available, this pointer is NULL */
@@ -165,6 +161,13 @@ struct CPUClass {* class data that depends on the accelerator, see accel/accel-common.c. */ void (*init_accel_cpu)(struct AccelCPUClass *accel_cpu,CPUClass *cc); + +/* +* Keep non-pointer data at the end to minimize holes. +*/ +int reset_dump_flags; +int gdb_num_core_regs; +bool gdb_stop_before_watchpoint; };/*
Signature · 1 line
2.25.1
PATCH v2 48/55 linux-user: Add code for PR_GET/SET_UNALIGN
In reply to Richard HendersonThis requires extra work for each target, but adds the common syscall code, and the necessary flag in CPUState.
--- include/hw/core/cpu.h | 3 +++ linux-user/syscall.c | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-)
include/hw/core/cpu.h +3 -0
@@ -412,6 +412,9 @@ struct CPUState {bool ignore_memory_transaction_failures; +/* Used for user-only emulation of prctl(PR_SET_UNALIGN). */ +bool prctl_unalign_sigbus; +struct hax_vcpu_state *hax_vcpu;struct hvf_vcpu_state *hvf;
linux-user/syscall.c +19 -2
@@ -6640,6 +6640,25 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, }return do_prctl_get_tagged_addr_ctrl (env); +/* +* We only implement PR_UNALIGN_SIGBUS, and only for those targets +* who have had their translator updated to insert MO_ALIGN. +*/ +#if 0 +case PR_GET_UNALIGN : + { +CPUState *cs =env_cpu (env); +uint32_t res =PR_UNALIGN_NOPRINT ; +if (cs->prctl_unalign_sigbus) { + res |=PR_UNALIGN_SIGBUS ; + } +return put_user_u32 (res, arg2); + } +case PR_SET_UNALIGN : +env_cpu (env)->prctl_unalign_sigbus = arg2 &PR_UNALIGN_SIGBUS ; +return 0 ; +#endif +case PR_GET_DUMPABLE :case PR_SET_DUMPABLE :case PR_GET_KEEPCAPS :
@@ -6682,8 +6701,6 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,case PR_SET_THP_DISABLE :case PR_GET_TSC :case PR_SET_TSC : -case PR_GET_UNALIGN : -case PR_SET_UNALIGN :default :/* Disable to prevent the target disabling stuff we need. */ return -TARGET_EINVAL ;
Signature · 1 line
2.25.1
PATCH v2 49/55 hw/core/cpu: Move cpu properties to cpu-sysemu.c
In reply to Richard HendersonThe comment in cpu-common.c is absolutely correct, we can't rely on the ifdef in a file built once. This was only "working" because we used ifndef.
--- hw/core/cpu-common.h | 17 +++++++++++++++++ hw/core/cpu-common.c | 18 ++---------------- hw/core/cpu-sysemu.c | 24 ++++++++++++++++++++++++ hw/core/cpu-user.c | 22 ++++++++++++++++++++++ hw/core/meson.build | 4 ++++ 5 files changed, 69 insertions(+), 16 deletions(-) create mode 100644 hw/core/cpu-common.h create mode 100644 hw/core/cpu-user.c
hw/core/cpu-common.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* QEMU CPU model +* +* Copyright (c) 2014 SUSE LINUX Products GmbH +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* 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 HW_CORE_CPU_COMMON_H +#define HW_CORE_CPU_COMMON_H + +void cpu_class_init_props (DeviceClass *dc); + +#endif
hw/core/cpu-common.c +2 -16
@@ -34,6 +34,7 @@#include "hw/qdev-properties.h" #include "trace/trace-root.h" #include "qemu/plugin.h" +#include "cpu-common.h" CPUState *cpu_by_arch_id (int64_t id) {
@@ -257,21 +258,6 @@ static int64_t cpu_common_get_arch_id(CPUState *cpu)return cpu->cpu_index; } -static Property cpu_common_props[] = { -#ifndef CONFIG_USER_ONLY -/* Create a memory property for softmmu CPU object, -* so users can wire up its memory. (This can't go in hw/core/cpu.c -* because that file is compiled only once for both user-mode -* and system builds.) The default if no link is set up is to use -* the system address space. -*/ -DEFINE_PROP_LINK ("memory" , CPUState, memory,TYPE_MEMORY_REGION , - MemoryRegion *), -#endif -DEFINE_PROP_BOOL ("start-powered-off" , CPUState, start_powered_off, false), -DEFINE_PROP_END_OF_LIST (), -}; -static void cpu_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -286,7 +272,7 @@ static void cpu_class_init(ObjectClass *klass, void *data) dc->realize = cpu_common_realizefn; dc->unrealize = cpu_common_unrealizefn; dc->reset = cpu_common_reset; -device_class_set_props (dc, cpu_common_props); +cpu_class_init_props (dc);/* * Reason: CPUs still need special care by board code: wiring up * IRQs, adding reset handlers, halting non-first CPUs, ...
hw/core/cpu-sysemu.c +24 -0
@@ -20,8 +20,11 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "exec/memory.h" #include "hw/core/cpu.h" #include "hw/core/sysemu-cpu-ops.h" +#include "hw/qdev-properties.h" +#include "cpu-common.h" bool cpu_paging_enabled (const CPUState *cpu) {
@@ -143,3 +146,24 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cpu) }return res; } + +/* +* This can't go in hw/core/cpu-common.c because that file is compiled only +* once for both user-mode and system builds. +*/ +static Property cpu_sysemu_props[] = { +/* +* Create a memory property for softmmu CPU object, so users can wire +* up its memory. The default if no link is set up is to use the +* system address space. +*/ +DEFINE_PROP_LINK ("memory" , CPUState, memory,TYPE_MEMORY_REGION , + MemoryRegion *), +DEFINE_PROP_BOOL ("start-powered-off" , CPUState, start_powered_off, false), +DEFINE_PROP_END_OF_LIST (), +}; + +void cpu_class_init_props (DeviceClass *dc) +{ +device_class_set_props (dc, cpu_sysemu_props); +}
hw/core/cpu-user.c new file +22 -0
@@ -0,0 +1,22 @@ +/* +* QEMU CPU model (user-only emulation specific) +* +* Copyright (c) 2021 Linaro, Ltd. +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "hw/core/cpu.h" +#include "cpu-common.h" + +/* +* This can't go in hw/core/cpu-common.c because that file is compiled only +* once for both user-mode and system builds. +*/ +void cpu_class_init_props (DeviceClass *dc) +{ +}
hw/core/meson.build +4 -0
@@ -43,3 +43,7 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: files( 'machine-qmp-cmds.c', 'numa.c', )) + +specific_ss.add(when: 'CONFIG_USER_ONLY', if_true: files( + 'cpu-user.c' +))
Signature · 1 line
2.25.1
PATCH v2 50/55 hw/core/cpu: Add prctl-unalign-sigbus property for user-only
In reply to Richard HendersonActually disabled for now. Will enable for each cpu that supports the feature.
--- hw/core/cpu-user.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
hw/core/cpu-user.c +15 -0
@@ -11,12 +11,27 @@#include "qemu/osdep.h" #include "hw/core/cpu.h" +#include "hw/qdev-properties.h" #include "cpu-common.h" /* * This can't go in hw/core/cpu-common.c because that file is compiled only * once for both user-mode and system builds. */ +static Property cpu_useronly_props[] = { +/* +* Create a memory property for softmmu CPU object, so users can wire +* up its memory. The default if no link is set up is to use the +* system address space. +*/ +#if 0 +DEFINE_PROP_BOOL ("prctl-unalign-sigbus" , CPUState, + prctl_unalign_sigbus, false), +#endif + DEFINE_PROP_END_OF_LIST(), +}; +void cpu_class_init_props (DeviceClass *dc) { +device_class_set_props (dc, cpu_useronly_props); }
Signature · 1 line
2.25.1
PATCH v2 51/55 target/alpha: Reorg fp memory operations
In reply to Richard HendersonPass in the context to each mini-helper, instead of an incorrectly named "flags". Separate gen_load_fp and gen_store_fp, away from the integer helpers.
--- target/alpha/translate.c | 83 +++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 26 deletions(-)
target/alpha/translate.c +57 -26
@@ -267,30 +267,47 @@ static inline DisasJumpType gen_invalid(DisasContext *ctx)return gen_excp (ctx,EXCP_OPCDEC ,0 ); } -static inline void gen_qemu_ldf (TCGv t0,TCGv t1,int flags) +static void gen_ldf (DisasContext *ctx,TCGv dest,TCGv addr) {TCGv_i32 tmp32 =tcg_temp_new_i32 (); -tcg_gen_qemu_ld_i32 (tmp32, t1, flags,MO_LEUL ); -gen_helper_memory_to_f (t0, tmp32); +tcg_gen_qemu_ld_i32 (tmp32, addr, ctx->mem_idx,MO_LEUL ); +gen_helper_memory_to_f (dest, tmp32);tcg_temp_free_i32 (tmp32); } -static inline void gen_qemu_ldg (TCGv t0,TCGv t1,int flags) +static void gen_ldg (DisasContext *ctx,TCGv dest,TCGv addr) {TCGv tmp =tcg_temp_new (); -tcg_gen_qemu_ld_i64 (tmp, t1, flags,MO_LEQ ); -gen_helper_memory_to_g (t0, tmp); +tcg_gen_qemu_ld_i64 (tmp, addr, ctx->mem_idx,MO_LEQ ); +gen_helper_memory_to_g (dest, tmp);tcg_temp_free (tmp); } -static inline void gen_qemu_lds (TCGv t0,TCGv t1,int flags) +static void gen_lds (DisasContext *ctx,TCGv dest,TCGv addr) {TCGv_i32 tmp32 =tcg_temp_new_i32 (); -tcg_gen_qemu_ld_i32 (tmp32, t1, flags,MO_LEUL ); -gen_helper_memory_to_s (t0, tmp32); +tcg_gen_qemu_ld_i32 (tmp32, addr, ctx->mem_idx,MO_LEUL ); +gen_helper_memory_to_s (dest, tmp32);tcg_temp_free_i32 (tmp32); } +static void gen_ldt (DisasContext *ctx,TCGv dest,TCGv addr) +{ +tcg_gen_qemu_ld_i64 (dest, addr, ctx->mem_idx,MO_LEQ ); +} + +static void gen_load_fp (DisasContext *ctx,int ra,int rb,int32_t disp16, +void (*func)(DisasContext *,TCGv ,TCGv )) +{ +/* Loads to $f31 are prefetches, which we can treat as nops. */ +if (likely (ra !=31 )) { +TCGv addr =tcg_temp_new (); +tcg_gen_addi_i64 (addr,load_gpr (ctx, rb), disp16); +func (ctx, cpu_fir[ra], addr); +tcg_temp_free (addr); + } +} +static inline void gen_qemu_ldl_l (TCGv t0,TCGv t1,int flags) {tcg_gen_qemu_ld_i64 (t0, t1, flags,MO_LESL );
@@ -338,30 +355,44 @@ static inline void gen_load_mem(DisasContext *ctx,tcg_temp_free (tmp); } -static inline void gen_qemu_stf (TCGv t0,TCGv t1,int flags) +static void gen_stf (DisasContext *ctx,TCGv src,TCGv addr) {TCGv_i32 tmp32 =tcg_temp_new_i32 (); -gen_helper_f_to_memory (tmp32, t0); -tcg_gen_qemu_st_i32 (tmp32, t1, flags,MO_LEUL ); +gen_helper_f_to_memory (tmp32, addr); +tcg_gen_qemu_st_i32 (tmp32, addr, ctx->mem_idx,MO_LEUL );tcg_temp_free_i32 (tmp32); } -static inline void gen_qemu_stg (TCGv t0,TCGv t1,int flags) +static void gen_stg (DisasContext *ctx,TCGv src,TCGv addr) {TCGv tmp =tcg_temp_new (); -gen_helper_g_to_memory (tmp, t0); -tcg_gen_qemu_st_i64 (tmp, t1, flags,MO_LEQ ); +gen_helper_g_to_memory (tmp, src); +tcg_gen_qemu_st_i64 (tmp, addr, ctx->mem_idx,MO_LEQ );tcg_temp_free (tmp); } -static inline void gen_qemu_sts (TCGv t0,TCGv t1,int flags) +static void gen_sts (DisasContext *ctx,TCGv src,TCGv addr) {TCGv_i32 tmp32 =tcg_temp_new_i32 (); -gen_helper_s_to_memory (tmp32, t0); -tcg_gen_qemu_st_i32 (tmp32, t1, flags,MO_LEUL ); +gen_helper_s_to_memory (tmp32, src); +tcg_gen_qemu_st_i32 (tmp32, addr, ctx->mem_idx,MO_LEUL );tcg_temp_free_i32 (tmp32); } +static void gen_stt (DisasContext *ctx,TCGv src,TCGv addr) +{ +tcg_gen_qemu_st_i64 (src, addr, ctx->mem_idx,MO_LEQ ); +} + +static void gen_store_fp (DisasContext *ctx,int ra,int rb,int32_t disp16, +void (*func)(DisasContext *,TCGv ,TCGv )) +{ +TCGv addr =tcg_temp_new (); +tcg_gen_addi_i64 (addr,load_gpr (ctx, rb), disp16); +func (ctx,load_fpr (ctx, ra), addr); +tcg_temp_free (addr); +} + static inline void gen_store_mem(DisasContext *ctx, void (*tcg_gen_qemu_store)(TCGv t0, TCGv t1, int flags),
@@ -2776,42 +2807,42 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)case 0x20 :/* LDF */ REQUIRE_FEN ; -gen_load_mem (ctx, &gen_qemu_ldf, ra, rb, disp16,1 ,0 ); +gen_load_fp (ctx, ra, rb, disp16, gen_ldf);break ;case 0x21 :/* LDG */ REQUIRE_FEN ; -gen_load_mem (ctx, &gen_qemu_ldg, ra, rb, disp16,1 ,0 ); +gen_load_fp (ctx, ra, rb, disp16, gen_ldg);break ;case 0x22 :/* LDS */ REQUIRE_FEN ; -gen_load_mem (ctx, &gen_qemu_lds, ra, rb, disp16,1 ,0 ); +gen_load_fp (ctx, ra, rb, disp16, gen_lds);break ;case 0x23 :/* LDT */ REQUIRE_FEN ; -gen_load_mem (ctx, &tcg_gen_qemu_ld64, ra, rb, disp16,1 ,0 ); +gen_load_fp (ctx, ra, rb, disp16, gen_ldt);break ;case 0x24 :/* STF */ REQUIRE_FEN ; -gen_store_mem (ctx, &gen_qemu_stf, ra, rb, disp16,1 ,0 ); +gen_store_fp (ctx, ra, rb, disp16, gen_stf);break ;case 0x25 :/* STG */ REQUIRE_FEN ; -gen_store_mem (ctx, &gen_qemu_stg, ra, rb, disp16,1 ,0 ); +gen_store_fp (ctx, ra, rb, disp16, gen_stg);break ;case 0x26 :/* STS */ REQUIRE_FEN ; -gen_store_mem (ctx, &gen_qemu_sts, ra, rb, disp16,1 ,0 ); +gen_store_fp (ctx, ra, rb, disp16, gen_sts);break ;case 0x27 :/* STT */ REQUIRE_FEN ; -gen_store_mem (ctx, &tcg_gen_qemu_st64, ra, rb, disp16,1 ,0 ); +gen_store_fp (ctx, ra, rb, disp16, gen_stt);break ;case 0x28 :/* LDL */
Signature · 1 line
2.25.1
PATCH v2 52/55 target/alpha: Reorg integer memory operations
In reply to Richard HendersonPass in the MemOp instead of a callback.
Drop the fp argument; add a locked argument.
--- target/alpha/translate.c | 104 +++++++++++++++------------------------ 1 file changed, 40 insertions(+), 64 deletions(-)
target/alpha/translate.c +40 -64
@@ -308,27 +308,10 @@ static void gen_load_fp(DisasContext *ctx, int ra, int rb, int32_t disp16, } } -static inline void gen_qemu_ldl_l (TCGv t0,TCGv t1,int flags) +static void gen_load_int (DisasContext *ctx,int ra,int rb,int32_t disp16, +MemOp op,bool clear,bool locked) { -tcg_gen_qemu_ld_i64 (t0, t1, flags,MO_LESL ); -tcg_gen_mov_i64 (cpu_lock_addr, t1); -tcg_gen_mov_i64 (cpu_lock_value, t0); -} - -static inline void gen_qemu_ldq_l (TCGv t0,TCGv t1,int flags) -{ -tcg_gen_qemu_ld_i64 (t0, t1, flags,MO_LEQ ); -tcg_gen_mov_i64 (cpu_lock_addr, t1); -tcg_gen_mov_i64 (cpu_lock_value, t0); -} - -static inline void gen_load_mem (DisasContext *ctx, -void (*tcg_gen_qemu_load)(TCGv t0,TCGv t1, -int flags), -int ra,int rb,int32_t disp16,bool fp, -bool clear) -{ -TCGv tmp, addr, va; +TCGv addr, dest;/* LDQ_U with ra $31 is UNOP. Other various loads are forms of prefetches, which we can treat as nops. No worries about
@@ -337,22 +320,20 @@ static inline void gen_load_mem(DisasContext *ctx,return ; } - tmp =tcg_temp_new (); - addr =load_gpr (ctx, rb); - -if (disp16) { -tcg_gen_addi_i64 (tmp, addr, disp16); - addr = tmp; - } + addr =tcg_temp_new (); +tcg_gen_addi_i64 (addr,load_gpr (ctx, rb), disp16);if (clear) { -tcg_gen_andi_i64 (tmp, addr, ~0x7 ); - addr = tmp; +tcg_gen_andi_i64 (addr, addr, ~0x7 ); } - va = (fp ? cpu_fir[ra] : ctx->ir[ra]); -tcg_gen_qemu_load (va, addr, ctx->mem_idx); + dest = ctx->ir[ra]; +tcg_gen_qemu_ld_i64 (dest, addr, ctx->mem_idx, op); -tcg_temp_free (tmp); +if (locked) { +tcg_gen_mov_i64 (cpu_lock_addr, addr); +tcg_gen_mov_i64 (cpu_lock_value, dest); + } +tcg_temp_free (addr); }static void gen_stf (DisasContext *ctx,TCGv src,TCGv addr)
@@ -393,30 +374,21 @@ static void gen_store_fp(DisasContext *ctx, int ra, int rb, int32_t disp16,tcg_temp_free (addr); } -static inline void gen_store_mem (DisasContext *ctx, -void (*tcg_gen_qemu_store)(TCGv t0,TCGv t1, -int flags), -int ra,int rb,int32_t disp16,bool fp, -bool clear) +static void gen_store_int (DisasContext *ctx,int ra,int rb,int32_t disp16, +MemOp op,bool clear) { -TCGv tmp, addr, va; +TCGv addr, src; - tmp =tcg_temp_new (); - addr =load_gpr (ctx, rb); - -if (disp16) { -tcg_gen_addi_i64 (tmp, addr, disp16); - addr = tmp; - } + addr =tcg_temp_new (); +tcg_gen_addi_i64 (addr,load_gpr (ctx, rb), disp16);if (clear) { -tcg_gen_andi_i64 (tmp, addr, ~0x7 ); - addr = tmp; +tcg_gen_andi_i64 (addr, addr, ~0x7 ); } - va = (fp ?load_fpr (ctx, ra) :load_gpr (ctx, ra)); -tcg_gen_qemu_store (va, addr, ctx->mem_idx); + src =load_gpr (ctx, ra); +tcg_gen_qemu_st_i64 (src, addr, ctx->mem_idx, op); -tcg_temp_free (tmp); +tcg_temp_free (addr); } static DisasJumpType gen_store_conditional(DisasContext *ctx, int ra, int rb,
@@ -1511,30 +1483,30 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)case 0x0A :/* LDBU */ REQUIRE_AMASK (BWX ); -gen_load_mem (ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16,0 ,0 ); +gen_load_int (ctx, ra, rb, disp16,MO_UB ,0 ,0 );break ;case 0x0B :/* LDQ_U */ -gen_load_mem (ctx, &tcg_gen_qemu_ld64, ra, rb, disp16,0 ,1 ); +gen_load_int (ctx, ra, rb, disp16,MO_LEQ ,1 ,0 );break ;case 0x0C :/* LDWU */ REQUIRE_AMASK (BWX ); -gen_load_mem (ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16,0 ,0 ); +gen_load_int (ctx, ra, rb, disp16,MO_LEUW ,0 ,0 );break ;case 0x0D :/* STW */ REQUIRE_AMASK (BWX ); -gen_store_mem (ctx, &tcg_gen_qemu_st16, ra, rb, disp16,0 ,0 ); +gen_store_int (ctx, ra, rb, disp16,MO_LEUW ,0 );break ;case 0x0E :/* STB */ REQUIRE_AMASK (BWX ); -gen_store_mem (ctx, &tcg_gen_qemu_st8, ra, rb, disp16,0 ,0 ); +gen_store_int (ctx, ra, rb, disp16,MO_UB ,0 );break ;case 0x0F :/* STQ_U */ -gen_store_mem (ctx, &tcg_gen_qemu_st64, ra, rb, disp16,0 ,1 ); +gen_store_int (ctx, ra, rb, disp16,MO_LEQ ,1 );break ;case 0x10 :
@@ -2489,11 +2461,15 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x2 :/* Longword physical access with lock (hw_ldl_l/p) */ -gen_qemu_ldl_l (va, addr,MMU_PHYS_IDX ); +tcg_gen_qemu_ld_i64 (va, addr,MMU_PHYS_IDX ,MO_LESL ); +tcg_gen_mov_i64 (cpu_lock_addr, addr); +tcg_gen_mov_i64 (cpu_lock_value, va);break ;case 0x3 :/* Quadword physical access with lock (hw_ldq_l/p) */ -gen_qemu_ldq_l (va, addr,MMU_PHYS_IDX ); +tcg_gen_qemu_ld_i64 (va, addr,MMU_PHYS_IDX ,MO_LEQ ); +tcg_gen_mov_i64 (cpu_lock_addr, addr); +tcg_gen_mov_i64 (cpu_lock_value, va);break ;case 0x4 :/* Longword virtual PTE fetch (hw_ldl/v) */
@@ -2846,27 +2822,27 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x28 :/* LDL */ -gen_load_mem (ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16,0 ,0 ); +gen_load_int (ctx, ra, rb, disp16,MO_LESL ,0 ,0 );break ;case 0x29 :/* LDQ */ -gen_load_mem (ctx, &tcg_gen_qemu_ld64, ra, rb, disp16,0 ,0 ); +gen_load_int (ctx, ra, rb, disp16,MO_LEQ ,0 ,0 );break ;case 0x2A :/* LDL_L */ -gen_load_mem (ctx, &gen_qemu_ldl_l, ra, rb, disp16,0 ,0 ); +gen_load_int (ctx, ra, rb, disp16,MO_LESL ,0 ,1 );break ;case 0x2B :/* LDQ_L */ -gen_load_mem (ctx, &gen_qemu_ldq_l, ra, rb, disp16,0 ,0 ); +gen_load_int (ctx, ra, rb, disp16,MO_LEQ ,0 ,1 );break ;case 0x2C :/* STL */ -gen_store_mem (ctx, &tcg_gen_qemu_st32, ra, rb, disp16,0 ,0 ); +gen_store_int (ctx, ra, rb, disp16,MO_LEUL ,0 );break ;case 0x2D :/* STQ */ -gen_store_mem (ctx, &tcg_gen_qemu_st64, ra, rb, disp16,0 ,0 ); +gen_store_int (ctx, ra, rb, disp16,MO_LEQ ,0 );break ;case 0x2E :/* STL_C */
Signature · 1 line
2.25.1
PATCH v2 53/55 target/alpha: Implement prctl_unalign_sigbus
In reply to Richard HendersonLeave TARGET_ALIGNED_ONLY set, but use the new CPUState flag to set MO_UNALN for the instructions that the kernel handles in the unaligned trap.
--- target/alpha/cpu.h | 5 +++++ hw/core/cpu-user.c | 2 +- linux-user/syscall.c | 2 +- target/alpha/translate.c | 31 ++++++++++++++++++++++--------- 4 files changed, 29 insertions(+), 11 deletions(-)
target/alpha/cpu.h +5 -0
@@ -387,6 +387,8 @@ enum {#define ENV_FLAG_TB_MASK \ (ENV_FLAG_PAL_MODE | ENV_FLAG_PS_USER | ENV_FLAG_FEN) +#define TB_FLAG_UNALIGN (1u << 1) +static inline int cpu_mmu_index (CPUAlphaState *env,bool ifetch) {int ret = env->flags &ENV_FLAG_PS_USER ?MMU_USER_IDX :MMU_KERNEL_IDX ;
@@ -469,6 +471,9 @@ static inline void cpu_get_tb_cpu_state(CPUAlphaState *env, target_ulong *pc, *pc = env->pc; *cs_base =0 ; *pflags = env->flags &ENV_FLAG_TB_MASK ; +#ifdef CONFIG_USER_ONLY + *pflags |=TB_FLAG_UNALIGN * !env_cpu (env)->prctl_unalign_sigbus; +#endif }#ifdef CONFIG_USER_ONLY
hw/core/cpu-user.c +1 -1
@@ -24,7 +24,7 @@ static Property cpu_useronly_props[] = {* up its memory. The default if no link is set up is to use the * system address space. */ -#if 0 +#if defined(TARGET_ALPHA ) DEFINE_PROP_BOOL("prctl-unalign-sigbus", CPUState, prctl_unalign_sigbus, false),#endif
linux-user/syscall.c +1 -1
@@ -6644,7 +6644,7 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,* We only implement PR_UNALIGN_SIGBUS, and only for those targets * who have had their translator updated to insert MO_ALIGN. */ -#if 0 +#if defined(TARGET_ALPHA )case PR_GET_UNALIGN : {CPUState *cs =env_cpu (env);
target/alpha/translate.c +22 -9
@@ -45,7 +45,9 @@ typedef struct DisasContext DisasContext;struct DisasContext {DisasContextBase base; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY +MemOp unalign; +#else uint64_t palbr;#endif uint32_t tbflags;
@@ -68,6 +70,12 @@ struct DisasContext {TCGv sink; }; +#ifdef CONFIG_USER_ONLY +#define UNALIGN (C ) (C)->unalign +#else +#define UNALIGN (C ) 0 +#endif +/* Target-specific return values from translate_one, indicating the state of the TB. Note that DISAS_NEXT indicates that we are not exiting the TB. */
@@ -270,7 +278,7 @@ static inline DisasJumpType gen_invalid(DisasContext *ctx)static void gen_ldf (DisasContext *ctx,TCGv dest,TCGv addr) {TCGv_i32 tmp32 =tcg_temp_new_i32 (); -tcg_gen_qemu_ld_i32 (tmp32, addr, ctx->mem_idx,MO_LEUL ); +tcg_gen_qemu_ld_i32 (tmp32, addr, ctx->mem_idx,MO_LEUL |UNALIGN (ctx));gen_helper_memory_to_f (dest, tmp32);tcg_temp_free_i32 (tmp32); }
@@ -278,7 +286,7 @@ static void gen_ldf(DisasContext *ctx, TCGv dest, TCGv addr)static void gen_ldg (DisasContext *ctx,TCGv dest,TCGv addr) {TCGv tmp =tcg_temp_new (); -tcg_gen_qemu_ld_i64 (tmp, addr, ctx->mem_idx,MO_LEQ ); +tcg_gen_qemu_ld_i64 (tmp, addr, ctx->mem_idx,MO_LEQ |UNALIGN (ctx));gen_helper_memory_to_g (dest, tmp);tcg_temp_free (tmp); }
@@ -286,14 +294,14 @@ static void gen_ldg(DisasContext *ctx, TCGv dest, TCGv addr)static void gen_lds (DisasContext *ctx,TCGv dest,TCGv addr) {TCGv_i32 tmp32 =tcg_temp_new_i32 (); -tcg_gen_qemu_ld_i32 (tmp32, addr, ctx->mem_idx,MO_LEUL ); +tcg_gen_qemu_ld_i32 (tmp32, addr, ctx->mem_idx,MO_LEUL |UNALIGN (ctx));gen_helper_memory_to_s (dest, tmp32);tcg_temp_free_i32 (tmp32); }static void gen_ldt (DisasContext *ctx,TCGv dest,TCGv addr) { -tcg_gen_qemu_ld_i64 (dest, addr, ctx->mem_idx,MO_LEQ ); +tcg_gen_qemu_ld_i64 (dest, addr, ctx->mem_idx,MO_LEQ |UNALIGN (ctx)); } static void gen_load_fp(DisasContext *ctx, int ra, int rb, int32_t disp16,
@@ -324,6 +332,8 @@ static void gen_load_int(DisasContext *ctx, int ra, int rb, int32_t disp16,tcg_gen_addi_i64 (addr,load_gpr (ctx, rb), disp16);if (clear) {tcg_gen_andi_i64 (addr, addr, ~0x7 ); + }else if (!locked) { + op |=UNALIGN (ctx); } dest = ctx->ir[ra];
@@ -340,7 +350,7 @@ static void gen_stf(DisasContext *ctx, TCGv src, TCGv addr) {TCGv_i32 tmp32 =tcg_temp_new_i32 ();gen_helper_f_to_memory (tmp32, addr); -tcg_gen_qemu_st_i32 (tmp32, addr, ctx->mem_idx,MO_LEUL ); +tcg_gen_qemu_st_i32 (tmp32, addr, ctx->mem_idx,MO_LEUL |UNALIGN (ctx));tcg_temp_free_i32 (tmp32); }
@@ -348,7 +358,7 @@ static void gen_stg(DisasContext *ctx, TCGv src, TCGv addr) {TCGv tmp =tcg_temp_new ();gen_helper_g_to_memory (tmp, src); -tcg_gen_qemu_st_i64 (tmp, addr, ctx->mem_idx,MO_LEQ ); +tcg_gen_qemu_st_i64 (tmp, addr, ctx->mem_idx,MO_LEQ |UNALIGN (ctx));tcg_temp_free (tmp); }
@@ -356,13 +366,13 @@ static void gen_sts(DisasContext *ctx, TCGv src, TCGv addr) {TCGv_i32 tmp32 =tcg_temp_new_i32 ();gen_helper_s_to_memory (tmp32, src); -tcg_gen_qemu_st_i32 (tmp32, addr, ctx->mem_idx,MO_LEUL ); +tcg_gen_qemu_st_i32 (tmp32, addr, ctx->mem_idx,MO_LEUL |UNALIGN (ctx));tcg_temp_free_i32 (tmp32); }static void gen_stt (DisasContext *ctx,TCGv src,TCGv addr) { -tcg_gen_qemu_st_i64 (src, addr, ctx->mem_idx,MO_LEQ ); +tcg_gen_qemu_st_i64 (src, addr, ctx->mem_idx,MO_LEQ |UNALIGN (ctx)); } static void gen_store_fp(DisasContext *ctx, int ra, int rb, int32_t disp16,
@@ -383,6 +393,8 @@ static void gen_store_int(DisasContext *ctx, int ra, int rb, int32_t disp16,tcg_gen_addi_i64 (addr,load_gpr (ctx, rb), disp16);if (clear) {tcg_gen_andi_i64 (addr, addr, ~0x7 ); + }else { + op |=UNALIGN (ctx); } src =load_gpr (ctx, ra);
@@ -2942,6 +2954,7 @@ static void alpha_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu)#ifdef CONFIG_USER_ONLY ctx->ir = cpu_std_ir; + ctx->unalign = (ctx->tbflags &TB_FLAG_UNALIGN ?MO_UNALN :MO_ALIGN );#else ctx->palbr = env->palbr; ctx->ir = (ctx->tbflags &ENV_FLAG_PAL_MODE ? cpu_pal_ir : cpu_std_ir);
Signature · 1 line
2.25.1
PATCH v2 54/55 target/hppa: Implement prctl_unalign_sigbus
In reply to Richard HendersonLeave TARGET_ALIGNED_ONLY set, but use the new CPUState flag to set MO_UNALN for the instructions that the kernel handles in the unaligned trap.
--- target/hppa/cpu.h | 5 ++++- hw/core/cpu-user.c | 2 +- linux-user/syscall.c | 2 +- target/hppa/translate.c | 19 +++++++++++++++---- 4 files changed, 21 insertions(+), 7 deletions(-)
target/hppa/cpu.h +4 -1
@@ -259,12 +259,14 @@ static inline target_ulong hppa_form_gva(CPUHPPAState *env, uint64_t spc,return hppa_form_gva_psw (env->psw, spc, off); } -/* Since PSW_{I,CB} will never need to be in tb->flags, reuse them. +/* +* Since PSW_{I,CB} will never need to be in tb->flags, reuse them. * TB_FLAG_SR_SAME indicates that SR4 through SR7 all contain the * same value. */ #define TB_FLAG_SR_SAME PSW_I#define TB_FLAG_PRIV_SHIFT 8 +#define TB_FLAG_UNALIGN 0x400 static inline void cpu_get_tb_cpu_state(CPUHPPAState *env, target_ulong *pc, target_ulong *cs_base,
@@ -279,6 +281,7 @@ static inline void cpu_get_tb_cpu_state(CPUHPPAState *env, target_ulong *pc,#ifdef CONFIG_USER_ONLY *pc = env->iaoq_f &-4 ; *cs_base = env->iaoq_b &-4 ; + flags |=TB_FLAG_UNALIGN * !env_cpu (env)->prctl_unalign_sigbus;#else /* ??? E, T, H, L, B, P bits need to be here, when implemented. */ flags |= env->psw & (PSW_W |PSW_C |PSW_D );
hw/core/cpu-user.c +1 -1
@@ -24,7 +24,7 @@ static Property cpu_useronly_props[] = {* up its memory. The default if no link is set up is to use the * system address space. */ -#if defined(TARGET_ALPHA ) +#if defined(TARGET_ALPHA ) || defined(TARGET_HPPA ) DEFINE_PROP_BOOL("prctl-unalign-sigbus", CPUState, prctl_unalign_sigbus, false),#endif
linux-user/syscall.c +1 -1
@@ -6644,7 +6644,7 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,* We only implement PR_UNALIGN_SIGBUS, and only for those targets * who have had their translator updated to insert MO_ALIGN. */ -#if defined(TARGET_ALPHA ) +#if defined(TARGET_ALPHA ) || defined(TARGET_HPPA )case PR_GET_UNALIGN : {CPUState *cs =env_cpu (env);
target/hppa/translate.c +15 -4
@@ -275,8 +275,18 @@ typedef struct DisasContext {int mmu_idx;int privilege;bool psw_n_nonzero; + +#ifdef CONFIG_USER_ONLY +MemOp unalign; +#endif } DisasContext; +#ifdef CONFIG_USER_ONLY +#define UNALIGN (C ) (C)->unalign +#else +#define UNALIGN (C ) 0 +#endif +/* Note that ssm/rsm instructions number PSW_W and PSW_E differently. */ static int expand_sm_imm (DisasContext *ctx,int val) {
@@ -1480,7 +1490,7 @@ static void do_load_32(DisasContext *ctx, TCGv_i32 dest, unsigned rb,form_gva (ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify, ctx->mmu_idx ==MMU_PHYS_IDX ); -tcg_gen_qemu_ld_reg (dest, addr, ctx->mmu_idx, mop); +tcg_gen_qemu_ld_reg (dest, addr, ctx->mmu_idx, mop |UNALIGN (ctx));if (modify) {save_gpr (ctx, rb, ofs); }
@@ -1498,7 +1508,7 @@ static void do_load_64(DisasContext *ctx, TCGv_i64 dest, unsigned rb,form_gva (ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify, ctx->mmu_idx ==MMU_PHYS_IDX ); -tcg_gen_qemu_ld_i64 (dest, addr, ctx->mmu_idx, mop); +tcg_gen_qemu_ld_i64 (dest, addr, ctx->mmu_idx, mop |UNALIGN (ctx));if (modify) {save_gpr (ctx, rb, ofs); }
@@ -1516,7 +1526,7 @@ static void do_store_32(DisasContext *ctx, TCGv_i32 src, unsigned rb,form_gva (ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify, ctx->mmu_idx ==MMU_PHYS_IDX ); -tcg_gen_qemu_st_i32 (src, addr, ctx->mmu_idx, mop); +tcg_gen_qemu_st_i32 (src, addr, ctx->mmu_idx, mop |UNALIGN (ctx));if (modify) {save_gpr (ctx, rb, ofs); }
@@ -1534,7 +1544,7 @@ static void do_store_64(DisasContext *ctx, TCGv_i64 src, unsigned rb,form_gva (ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify, ctx->mmu_idx ==MMU_PHYS_IDX ); -tcg_gen_qemu_st_i64 (src, addr, ctx->mmu_idx, mop); +tcg_gen_qemu_st_i64 (src, addr, ctx->mmu_idx, mop |UNALIGN (ctx));if (modify) {save_gpr (ctx, rb, ofs); }
@@ -4113,6 +4123,7 @@ static void hppa_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->mmu_idx =MMU_USER_IDX ; ctx->iaoq_f = ctx->base.pc_first |MMU_USER_IDX ; ctx->iaoq_b = ctx->base.tb->cs_base |MMU_USER_IDX ; + ctx->unalign = (ctx->tb_flags &TB_FLAG_UNALIGN ?MO_UNALN :MO_ALIGN );#else ctx->privilege = (ctx->tb_flags >>TB_FLAG_PRIV_SHIFT ) &3 ; ctx->mmu_idx = (ctx->tb_flags &PSW_D ? ctx->privilege :MMU_PHYS_IDX );
Signature · 1 line
2.25.1
PATCH v2 55/55 target/sh4: Implement prctl_unalign_sigbus
In reply to Richard HendersonLeave TARGET_ALIGNED_ONLY set, but use the new CPUState flag to set MO_UNALN for the instructions that the kernel handles in the unaligned trap.
The Linux kernel does not handle all memory operations: no floating-point and no MAC.
--- target/sh4/cpu.h | 4 ++++ hw/core/cpu-user.c | 2 +- linux-user/syscall.c | 2 +- target/sh4/translate.c | 50 ++++++++++++++++++++++++++++-------------- 4 files changed, 40 insertions(+), 18 deletions(-)
target/sh4/cpu.h +4 -0
@@ -83,6 +83,7 @@#define DELAY_SLOT_RTE (1 << 2)#define TB_FLAG_PENDING_MOVCA (1 << 3) +#define TB_FLAG_UNALIGN (1 << 4)#define GUSA_SHIFT 4#ifdef CONFIG_USER_ONLY
@@ -376,6 +377,9 @@ static inline void cpu_get_tb_cpu_state(CPUSH4State *env, target_ulong *pc, | (env->sr & ((1u << SR_MD) | (1u << SR_RB))) /* Bits 29-30 */ | (env->sr & (1u <<SR_FD ))/* Bit 15 */ | (env->movcal_backup ?TB_FLAG_PENDING_MOVCA :0 );/* Bit 3 */ +#ifdef CONFIG_USER_ONLY + *flags |=TB_FLAG_UNALIGN * !env_cpu (env)->prctl_unalign_sigbus; +#endif }#endif /* SH4_CPU_H */
hw/core/cpu-user.c +1 -1
@@ -24,7 +24,7 @@ static Property cpu_useronly_props[] = {* up its memory. The default if no link is set up is to use the * system address space. */ -#if defined(TARGET_ALPHA ) || defined(TARGET_HPPA ) +#if defined(TARGET_ALPHA ) || defined(TARGET_HPPA ) || defined(TARGET_SH4 ) DEFINE_PROP_BOOL("prctl-unalign-sigbus", CPUState, prctl_unalign_sigbus, false),#endif
linux-user/syscall.c +1 -1
@@ -6644,7 +6644,7 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,* We only implement PR_UNALIGN_SIGBUS, and only for those targets * who have had their translator updated to insert MO_ALIGN. */ -#if defined(TARGET_ALPHA ) || defined(TARGET_HPPA ) +#if defined(TARGET_ALPHA ) || defined(TARGET_HPPA ) || defined(TARGET_SH4 )case PR_GET_UNALIGN : {CPUState *cs =env_cpu (env);
target/sh4/translate.c +34 -16
143 lines not on this page · raw message
Signature · 1 line
2.25.1