Unaligned access for user-only
Subsystems (2)
v3 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.
I have now updated all of the tcg backends, but arm, sparc and mips are rather larger cleanups and I'll post them separately.
Changes for v3:
* Updated tcg/{aarch64,ppc,s390,riscv,tci}.
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 (66):
util: Suppress -Wstringop-overflow in qemu_thread_start 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_{ld,st} 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 accel/tcg/user-exec: Convert DEBUG_SIGNAL to tracepoint include/exec: Move cpu_signal_handler declaration accel/tcg: Handle SIGBUS in handle_cpu_signal tcg/aarch64: Support raising sigbus for user-only tcg/ppc: Support raising sigbus for user-only tcg/s390: Support raising sigbus for user-only tcg/tci: Support raising sigbus for user-only
tcg: Canonicalize alignment flags in MemOp
tcg/riscv: Support raising sigbus for user-only tcg/riscv: Remove add with zero on user-only memory access
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/exec-all.h | 13 + 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 | 15 +- target/arm/cpu.h | 7 - target/arm/internals.h | 2 +- target/avr/cpu.h | 2 - target/cris/cpu.h | 8 - target/hexagon/cpu.h | 12 +- target/hppa/cpu.h | 8 +- target/i386/cpu.h | 7 - target/m68k/cpu.h | 8 - target/microblaze/cpu.h | 9 +- target/mips/cpu.h | 3 - target/mips/internal.h | 2 - target/mips/tcg/tcg-internal.h | 4 +- target/nios2/cpu.h | 6 +- target/openrisc/cpu.h | 2 - target/ppc/cpu.h | 7 - target/ppc/internal.h | 4 +- target/riscv/cpu.h | 4 +- target/rx/cpu.h | 4 - target/s390x/cpu.h | 7 - target/s390x/s390x-internal.h | 4 +- target/sh4/cpu.h | 11 +- target/sparc/cpu.h | 2 - target/tricore/cpu.h | 2 - target/xtensa/cpu.h | 6 +- tcg/aarch64/tcg-target.h | 2 - tcg/i386/tcg-target.h | 2 - tcg/ppc/tcg-target.h | 2 - tcg/riscv/tcg-target.h | 2 - tcg/s390/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 | 634 ++++++++++++------------- 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/signal.c | 36 +- 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 | 67 +-- tcg/tcg.c | 3 +- tcg/tci.c | 33 +- tests/tcg/multiarch/sigbus.c | 68 +++ util/qemu-thread-posix.c | 19 + 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 | 192 +++++++- tcg/arm/tcg-target.c.inc | 14 +- tcg/i386/tcg-target.c.inc | 121 ++++- tcg/mips/tcg-target.c.inc | 16 +- tcg/ppc/tcg-target.c.inc | 120 ++++- tcg/riscv/tcg-target.c.inc | 92 +++- tcg/s390/tcg-target.c.inc | 77 ++- tcg/sparc/tcg-target.c.inc | 20 +- tcg/tcg-ldst.c.inc | 2 +- accel/tcg/trace-events | 4 + hw/core/meson.build | 4 + trace-events | 18 +- 121 files changed, 3126 insertions(+), 2454 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 v3 1/66 util: Suppress -Wstringop-overflow in qemu_thread_start
This seems to be either a glibc or gcc bug, but the code appears to be fine with the warning suppressed.
--- util/qemu-thread-posix.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
util/qemu-thread-posix.c +19 -0
@@ -537,9 +537,28 @@ static void *qemu_thread_start(void *args)QEMU_TSAN_ANNOTATE_THREAD_NAME (qemu_thread_args->name);g_free (qemu_thread_args->name);g_free (qemu_thread_args); + +/* +* GCC 11 with glibc 2.17 on PowerPC reports +* +* qemu-thread-posix.c:540:5: error: ‘__sigsetjmp’ accessing 656 bytes +* in a region of size 528 [-Werror=stringop-overflow=] +* 540 | pthread_cleanup_push(qemu_thread_atexit_notify, NULL); +* | ^~~~~~~~~~~~~~~~~~~~ +* +* which is clearly nonsense. +*/ +#pragma GCC diagnostic push +#ifndef __clang__ +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif +pthread_cleanup_push (qemu_thread_atexit_notify,NULL ); r =start_routine (arg);pthread_cleanup_pop (1 ); + +#pragma GCC diagnostic pop +return r; }
Signature · 1 line
2.25.1
Re: [PATCH v3 01/66] util: Suppress -Wstringop-overflow in qemu_thread_start
Quoted 24 lines · Richard Henderson
This seems to be either a glibc or gcc bug, but the code appears to be fine with the warning suppressed.
Signed-off-by Richard Henderson <[email protected]>--- util/qemu-thread-posix.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)util/qemu-thread-posix.c +7
-0@@ -537,9 +537,28 @@ static void *qemu_thread_start(void *args)QEMU_TSAN_ANNOTATE_THREAD_NAME (qemu_thread_args->name);g_free (qemu_thread_args->name);g_free (qemu_thread_args); + +/* +* GCC 11 with glibc 2.17 on PowerPC reports +* +* qemu-thread-posix.c:540:5: error: ‘__sigsetjmp’ accessing 656 bytes +* in a region of size 528 [-Werror=stringop-overflow=] +* 540 | pthread_cleanup_push(qemu_thread_atexit_notify, NULL);
util/qemu-thread-posix.c static void *qemu_thread_start(void *args) · line 556
Quoted 10 lines
util/qemu-thread-posix.c +9
-0+* | ^~~~~~~~~~~~~~~~~~~~ +* +* which is clearly nonsense. +*/ +#pragma GCC diagnostic push +#ifndef __clang__ +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif +pthread_cleanup_push (qemu_thread_atexit_notify,NULL );
Fixed in glibc in commit
https://sourceware.org/git/?p=glibc.git;a=commit;h=548f467fa14ffe7d955beeb31b30e2aeae4467e0
I think.
I found this mailing list thread:
https://www.mail-archive.com/[email protected]/msg20144.html
which suggests that another workaround would be to include pthread.h before setjmp.h. For us that would mean we'd have to pull pthread.h in in osdep.h, though...
util/qemu-thread-posix.c static void *qemu_thread_start(void *args) · line 563
Quoted 7 lines
util/qemu-thread-posix.c +3
-0r =start_routine (arg);pthread_cleanup_pop (1 ); + +#pragma GCC diagnostic pop +return r; }
With a link to the glibc commit in the comment,
thanks
-- PMM
PATCH v3 2/66 hw/core: Make do_unaligned_access noreturn
In reply to Richard HendersonWhile 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 | 2 +- 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, 23 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 +1 -1
@@ -594,7 +594,7 @@ 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 v3 02/66] hw/core: Make do_unaligned_access noreturn
Quoted 7 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.
Reviewed-by Alex Bennée <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Richard Henderson <[email protected]>
Alistair
Quoted 198 lines
--- include/hw/core/tcg-cpu-ops.h | 3 ++- target/alpha/cpu.h | 4 ++-- target/arm/internals.h | 2 +- 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, 23 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_handlertarget/arm/internals.h +1
-1@@ -594,7 +594,7 @@ 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_listtarget/hppa/cpu.c +4
-4@@ -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; --2.25.1
PATCH v3 3/66 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
PATCH v3 4/66 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
PATCH v3 5/66 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 v3 6/66 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 v3 06/66] target/hppa: Implement do_unaligned_access for user-only
Quoted 6 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(-)
thanks
-- PMM
PATCH v3 7/66 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
PATCH v3 8/66 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 v3 08/66] target/mips: Implement do_unaligned_access for user-only
Quoted 9 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(-)
thanks
-- PMM
PATCH v3 9/66 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
Re: [PATCH v3 09/66] target/ppc: Move SPR_DSISR setting to powerpc_excp
Quoted 42 lines · Richard Henderson
By doing this while sending the exception, we will have already done the unwinding, which makes the
ppc_cpu_do_unaligned_accesscode a bit cleaner.Update the comment about the expected instruction format.
Signed-off-by Richard Henderson <[email protected]>--- target/ppc/excp_helper.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)target/ppc/excp_helper.c +7
-6@@ -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;
target/ppc/excp_helper.c void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, · line 1509
Quoted 10 lines
target/ppc/excp_helper.c +2
-6- -/* 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);
cpu_ldl_code() in the unaligned-access handler is strictly speaking bogus, because the page might have been unmapped after translation but before we got round to actually running it. Better would be to stash the relevant bits of info from the insn in the insn_start param, the way Arm does with the syndrome info.
But it's the way we currently implement this, so
thanks
-- PMM
Re: [PATCH v3 09/66] target/ppc: Move SPR_DSISR setting to powerpc_excp
Quoted 5 lines · Peter Maydell
cpu_ldl_code()in the unaligned-access handler is strictly speaking bogus, because the page might have been unmapped after translation but before we got round to actually running it. Better would be to stash the relevant bits of info from the insn in theinsn_startparam, the way Arm does with the syndrome info.
Yep. That was more than I was prepared to do here.
r~
PATCH v3 10/66 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
Re: [PATCH v3 10/66] target/ppc: Set fault address in ppc_cpu_do_unaligned_access
Quoted 26 lines · Richard Henderson
We ought to have been recording the virtual address for reporting to the guest trap handler.
Signed-off-by Richard Henderson <[email protected]>--- target/ppc/excp_helper.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)target/ppc/excp_helper.c +8
-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;
target/ppc/excp_helper.c void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
Quoted 10 lines
target/ppc/excp_helper.c +6
-1+break ; +default : + env->spr[SPR_DAR ] = vaddr; +break ; + } + cs->exception_index =POWERPC_EXCP_ALIGN ; env->error_code =0 ;cpu_loop_exit_restore (cs, retaddr); --
thanks
-- PMM
PATCH v3 11/66 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
Re: [PATCH v3 11/66] target/ppc: Implement do_unaligned_access for user-only
Quoted 47 lines · Richard Henderson
For simplicity on the linux-user side, always use
SPR_DAR.Signed-off-by Richard Henderson <[email protected]>--- 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 +0
-0
target/ppc/excp_helper.c void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, · line 1507
Quoted 3 lines
target/ppc/excp_helper.c +0
-0@@ -1505,6 +1505,7 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,CPUPPCState *env = cs->env_ptr;switch (env->mmu_model) {
If you add a comment giving the same info the commit message has, eg:
/*
* In user-only mode we always set SPR_DAR regardless of CPU type
* so that the linux-user/ppc code only needs to look in one place */
then
thanks
-- PMM
PATCH v3 12/66 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 v3 13/66 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
PATCH v3 14/66 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 v3 15/66 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
Re: [PATCH v3 15/66] target/sh4: Implement do_unaligned_access for user-only
Quoted 18 lines · Richard Henderson
Cc Yoshinori Sato <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- 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 +1
-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 :
linux-user/sh4/cpu_loop.c void cpu_loop(CPUSH4State *env) · line 84
Quoted 10 lines
linux-user/sh4/cpu_loop.c +7
-0+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;
Doesn't this have to wait until after the later patches in the series that implement the "actually don't worry about alignment on most sh4 load/stores" ?
-- PMM
Re: [PATCH v3 15/66] target/sh4: Implement do_unaligned_access for user-only
Quoted 26 lines · Peter Maydell
Quoted 24 lines · Richard Henderson
Cc Yoshinori Sato <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- 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 +7
-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);
Quoted 8 lines
linux-user/sh4/cpu_loop.c void cpu_loop(CPUSH4State *env) · line 84
Quoted 4 lines
linux-user/sh4/cpu_loop.c +1
-0+break ;case EXCP_ATOMIC :cpu_exec_step_atomic (cs); arch_interrupt = false;Doesn't this have to wait until after the later patches in the series that implement the "actually don't worry about alignment on most sh4 load/stores" ?
Hmm. I don't think that helps. The only thing that delaying this patch would do is hit the assert in cpu_unaligned_access() due to an alignment fault occurring but not having the do_unaligned_access hook set.
I think the real requirement is that the tcg/i386 patch that enforces the alignment is delayed until after all of the prctl patches.
r~
PATCH v3 16/66 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
PATCH v3 17/66 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
PATCH v3 18/66 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
PATCH v3 19/66 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
PATCH v3 20/66 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
PATCH v3 21/66 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
PATCH v3 22/66 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 v3 22/66] accel/tcg: Drop signness in tracing in cputlb.c
Quoted 9 lines · Richard Henderson
We are already inconsistent about whether or not
MO_SIGNis set intrace_mem_get_info. Dropping it entirely allows some simplification.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(-)
PATCH v3 23/66 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
Re: [PATCH v3 23/66] tcg: Expand MO_SIZE to 3 bits
Quoted 8 lines · Richard Henderson
We 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.
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Richard Henderson <[email protected]>
Alistair
Quoted 359 lines
--- 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
-9@@ -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, --2.25.1
PATCH v3 24/66 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
Re: [PATCH v3 24/66] tcg: Rename TCGMemOpIdx to MemOpIdx
Quoted 6 lines · Richard Henderson
We're about to move this out of
tcg.h, so rename it as we did when moving MemOp.Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Richard Henderson <[email protected]>
Alistair
Quoted 1,480 lines
--- 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@@ -1148,7 +1148,7 @@ static inline size_t tcg_current_code_size(TCGContext *s) }/* Combine the MemOp and mmu_idx parameters into a single value. */ -typedef uint32_t TCGMemOpIdx ; +typedef uint32_t MemOpIdx ;/** * make_memop_idx @@ -1157,7 +1157,7 @@ typedef uint32_t TCGMemOpIdx;* * Encode these values into a single parameter. */ -static inline TCGMemOpIdx make_memop_idx (MemOp op,unsigned idx) +static inline MemOpIdx make_memop_idx (MemOp op,unsigned idx) {tcg_debug_assert (idx <=15 );return (op <<4 ) | idx;@@ -1169,7 +1169,7 @@ static inline TCGMemOpIdx make_memop_idx(MemOp op, unsigned idx)* * Extract the memory operation from the combined value. */ -static inline MemOp get_memop (TCGMemOpIdx oi) +static inline MemOp get_memop (MemOpIdx oi) {return oi >>4 ; }@@ -1180,7 +1180,7 @@ static inline MemOp get_memop(TCGMemOpIdx oi)* * Extract the mmu index from the combined value. */ -static inline unsigned get_mmuidx (TCGMemOpIdx oi) +static inline unsigned get_mmuidx (MemOpIdx oi) {return oi &15 ; }@@ -1278,46 +1278,46 @@ uint64_t dup_const(unsigned vece, uint64_t c);#ifdef CONFIG_SOFTMMU /* Value zero-extended to tcg register size. */ tcg_target_ulong helper_ret_ldub_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);tcg_target_ulong helper_le_lduw_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);tcg_target_ulong helper_le_ldul_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);uint64_t helper_le_ldq_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);tcg_target_ulong helper_be_lduw_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);tcg_target_ulong helper_be_ldul_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);uint64_t helper_be_ldq_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);/* Value sign-extended to tcg register size. */ tcg_target_ulong helper_ret_ldsb_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);tcg_target_ulong helper_le_ldsw_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);tcg_target_ulong helper_le_ldsl_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);tcg_target_ulong helper_be_ldsw_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);tcg_target_ulong helper_be_ldsl_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);void helper_ret_stb_mmu (CPUArchState *env,target_ulong addr,uint8_t val, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);void helper_le_stw_mmu (CPUArchState *env,target_ulong addr,uint16_t val, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);void helper_le_stl_mmu (CPUArchState *env,target_ulong addr,uint32_t val, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);void helper_le_stq_mmu (CPUArchState *env,target_ulong addr,uint64_t val, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);void helper_be_stw_mmu (CPUArchState *env,target_ulong addr,uint16_t val, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);void helper_be_stl_mmu (CPUArchState *env,target_ulong addr,uint32_t val, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);void helper_be_stq_mmu (CPUArchState *env,target_ulong addr,uint64_t val, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);/* Temporary aliases until backends are converted. */ #ifdef TARGET_WORDS_BIGENDIAN @@ -1345,30 +1345,30 @@ void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val,uint32_t cpu_atomic_cmpxchgb_mmu (CPUArchState *env,target_ulong addr,uint32_t cmpv,uint32_t newv, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);uint32_t cpu_atomic_cmpxchgw_le_mmu (CPUArchState *env,target_ulong addr,uint32_t cmpv,uint32_t newv, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);uint32_t cpu_atomic_cmpxchgl_le_mmu (CPUArchState *env,target_ulong addr,uint32_t cmpv,uint32_t newv, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);uint64_t cpu_atomic_cmpxchgq_le_mmu (CPUArchState *env,target_ulong addr,uint64_t cmpv,uint64_t newv, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);uint32_t cpu_atomic_cmpxchgw_be_mmu (CPUArchState *env,target_ulong addr,uint32_t cmpv,uint32_t newv, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);uint32_t cpu_atomic_cmpxchgl_be_mmu (CPUArchState *env,target_ulong addr,uint32_t cmpv,uint32_t newv, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);uint64_t cpu_atomic_cmpxchgq_be_mmu (CPUArchState *env,target_ulong addr,uint64_t cmpv,uint64_t newv, -TCGMemOpIdx oi,uintptr_t retaddr); +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, \ - TCGMemOpIdx oi, uintptr_t retaddr); + MemOpIdx oi, uintptr_t retaddr);#ifdef CONFIG_ATOMIC64 #define GEN_ATOMIC_HELPER_ALL (NAME ) \@@ -1415,19 +1415,19 @@ GEN_ATOMIC_HELPER_ALL(xchg)Int128 cpu_atomic_cmpxchgo_le_mmu (CPUArchState *env,target_ulong addr,Int128 cmpv,Int128 newv, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);Int128 cpu_atomic_cmpxchgo_be_mmu (CPUArchState *env,target_ulong addr,Int128 cmpv,Int128 newv, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);Int128 cpu_atomic_ldo_le_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);Int128 cpu_atomic_ldo_be_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);void cpu_atomic_sto_le_mmu (CPUArchState *env,target_ulong addr,Int128 val, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);void cpu_atomic_sto_be_mmu (CPUArchState *env,target_ulong addr,Int128 val, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr);#ifdef CONFIG_DEBUG_TCG void tcg_assert_listed_vecop (TCGOpcode );accel/tcg/cputlb.c +39
-39@@ -1740,7 +1740,7 @@ bool tlb_plugin_lookup(CPUState *cpu, target_ulong addr, int mmu_idx,* @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) {size_t mmu_idx =get_mmuidx (oi);@@ -1841,7 +1841,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,*/ typedef uint64_t FullLoadHelper (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr); +MemOpIdx oi,uintptr_t retaddr); static inline uint64_t QEMU_ALWAYS_INLINEload_memop (const void *haddr,MemOp op)@@ -1867,7 +1867,7 @@ load_memop(const void *haddr, MemOp op) } static inline uint64_t QEMU_ALWAYS_INLINE -load_helper (CPUArchState *env,target_ulong addr,TCGMemOpIdx oi, +load_helper (CPUArchState *env,target_ulong addr,MemOpIdx oi,uintptr_t retaddr,MemOp op,bool code_read,FullLoadHelper *full_load) {@@ -1982,78 +1982,78 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi,*/ static uint64_t full_ldub_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return load_helper (env, addr, oi, retaddr,MO_UB , false, full_ldub_mmu); }tcg_target_ulong helper_ret_ldub_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return full_ldub_mmu (env, addr, oi, retaddr); }static uint64_t full_le_lduw_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return load_helper (env, addr, oi, retaddr,MO_LEUW , false, full_le_lduw_mmu); }tcg_target_ulong helper_le_lduw_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return full_le_lduw_mmu (env, addr, oi, retaddr); }static uint64_t full_be_lduw_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return load_helper (env, addr, oi, retaddr,MO_BEUW , false, full_be_lduw_mmu); }tcg_target_ulong helper_be_lduw_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return full_be_lduw_mmu (env, addr, oi, retaddr); }static uint64_t full_le_ldul_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return load_helper (env, addr, oi, retaddr,MO_LEUL , false, full_le_ldul_mmu); }tcg_target_ulong helper_le_ldul_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return full_le_ldul_mmu (env, addr, oi, retaddr); }static uint64_t full_be_ldul_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return load_helper (env, addr, oi, retaddr,MO_BEUL , false, full_be_ldul_mmu); }tcg_target_ulong helper_be_ldul_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return full_be_ldul_mmu (env, addr, oi, retaddr); }uint64_t helper_le_ldq_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return load_helper (env, addr, oi, retaddr,MO_LEQ , false, helper_le_ldq_mmu); }uint64_t helper_be_ldq_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return load_helper (env, addr, oi, retaddr,MO_BEQ , false, helper_be_ldq_mmu);@@ -2066,31 +2066,31 @@ uint64_t helper_be_ldq_mmu(CPUArchState *env, target_ulong addr,tcg_target_ulong helper_ret_ldsb_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return (int8_t )helper_ret_ldub_mmu (env, addr, oi, retaddr); }tcg_target_ulong helper_le_ldsw_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return (int16_t )helper_le_lduw_mmu (env, addr, oi, retaddr); }tcg_target_ulong helper_be_ldsw_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return (int16_t )helper_be_lduw_mmu (env, addr, oi, retaddr); }tcg_target_ulong helper_le_ldsl_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return (int32_t )helper_le_ldul_mmu (env, addr, oi, retaddr); }tcg_target_ulong helper_be_ldsl_mmu (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return (int32_t )helper_be_ldul_mmu (env, addr, oi, retaddr); }@@ -2104,7 +2104,7 @@ static inline uint64_t cpu_load_helper(CPUArchState *env, abi_ptr addr, MemOp op, FullLoadHelper *full_load) { uint16_t meminfo; -TCGMemOpIdx oi; +MemOpIdx oi;uint64_t ret; meminfo =trace_mem_get_info (op, mmu_idx, false);@@ -2328,7 +2328,7 @@ store_helper_unaligned(CPUArchState *env, target_ulong addr, uint64_t val,uintptr_t index, index2;CPUTLBEntry *entry, *entry2;target_ulong page2, tlb_addr, tlb_addr2; -TCGMemOpIdx oi; +MemOpIdx oi;size_t size2;int i;@@ -2395,7 +2395,7 @@ store_helper_unaligned(CPUArchState *env, target_ulong addr, uint64_t val, static inline void QEMU_ALWAYS_INLINEstore_helper (CPUArchState *env,target_ulong addr,uint64_t val, -TCGMemOpIdx oi,uintptr_t retaddr,MemOp op) +MemOpIdx oi,uintptr_t retaddr,MemOp op) {uintptr_t mmu_idx =get_mmuidx (oi);uintptr_t index =tlb_index (env, mmu_idx, addr);@@ -2493,43 +2493,43 @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val,void __attribute__((noinline))helper_ret_stb_mmu (CPUArchState *env,target_ulong addr,uint8_t val, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {store_helper (env, addr, val, oi, retaddr,MO_UB ); }void helper_le_stw_mmu (CPUArchState *env,target_ulong addr,uint16_t val, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {store_helper (env, addr, val, oi, retaddr,MO_LEUW ); }void helper_be_stw_mmu (CPUArchState *env,target_ulong addr,uint16_t val, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {store_helper (env, addr, val, oi, retaddr,MO_BEUW ); }void helper_le_stl_mmu (CPUArchState *env,target_ulong addr,uint32_t val, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {store_helper (env, addr, val, oi, retaddr,MO_LEUL ); }void helper_be_stl_mmu (CPUArchState *env,target_ulong addr,uint32_t val, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {store_helper (env, addr, val, oi, retaddr,MO_BEUL ); }void helper_le_stq_mmu (CPUArchState *env,target_ulong addr,uint64_t val, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {store_helper (env, addr, val, oi, retaddr,MO_LEQ ); }void helper_be_stq_mmu (CPUArchState *env,target_ulong addr,uint64_t val, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {store_helper (env, addr, val, oi, retaddr,MO_BEQ ); }@@ -2542,7 +2542,7 @@ 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) { -TCGMemOpIdx oi; +MemOpIdx oi;uint16_t meminfo; meminfo =trace_mem_get_info (op, mmu_idx, true);@@ -2708,49 +2708,49 @@ void cpu_stq_le_data(CPUArchState *env, target_ulong ptr, uint64_t val)/* Code access functions. */ static uint64_t full_ldub_code (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return load_helper (env, addr, oi, retaddr,MO_8 , true, full_ldub_code); }uint32_t cpu_ldub_code (CPUArchState *env,abi_ptr addr) { -TCGMemOpIdx oi =make_memop_idx (MO_UB ,cpu_mmu_index (env, true)); +MemOpIdx oi =make_memop_idx (MO_UB ,cpu_mmu_index (env, true));return full_ldub_code (env, addr, oi,0 ); }static uint64_t full_lduw_code (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return load_helper (env, addr, oi, retaddr,MO_TEUW , true, full_lduw_code); }uint32_t cpu_lduw_code (CPUArchState *env,abi_ptr addr) { -TCGMemOpIdx oi =make_memop_idx (MO_TEUW ,cpu_mmu_index (env, true)); +MemOpIdx oi =make_memop_idx (MO_TEUW ,cpu_mmu_index (env, true));return full_lduw_code (env, addr, oi,0 ); }static uint64_t full_ldl_code (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return load_helper (env, addr, oi, retaddr,MO_TEUL , true, full_ldl_code); }uint32_t cpu_ldl_code (CPUArchState *env,abi_ptr addr) { -TCGMemOpIdx oi =make_memop_idx (MO_TEUL ,cpu_mmu_index (env, true)); +MemOpIdx oi =make_memop_idx (MO_TEUL ,cpu_mmu_index (env, true));return full_ldl_code (env, addr, oi,0 ); }static uint64_t full_ldq_code (CPUArchState *env,target_ulong addr, -TCGMemOpIdx oi,uintptr_t retaddr) +MemOpIdx oi,uintptr_t retaddr) {return load_helper (env, addr, oi, retaddr,MO_TEQ , true, full_ldq_code); }uint64_t cpu_ldq_code (CPUArchState *env,abi_ptr addr) { -TCGMemOpIdx oi =make_memop_idx (MO_TEQ ,cpu_mmu_index (env, true)); +MemOpIdx oi =make_memop_idx (MO_TEQ ,cpu_mmu_index (env, true));return full_ldq_code (env, addr, oi,0 ); }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_SOFTMMUtcg/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_SOFTMMUtcg/tcg-ldst.c.inc +1
-2@@ -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 */ --2.25.1
PATCH v3 25/66 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 v3 26/66 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
Re: [PATCH v3 26/66] trace/mem: Pass MemOpIdx to trace_mem_get_info
Quoted 4 lines · Richard Henderson
We (will) often have the complete MemOpIdx handy, so use that.
Signed-off-by Richard Henderson <[email protected]>
thanks
-- PMM
PATCH v3 27/66 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 v3 28/66 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
Re: [PATCH v3 28/66] plugins: Reorg arguments to qemu_plugin_vcpu_mem_cb
Quoted 6 lines · Richard Henderson
Use the MemOpIdx directly, rather than the rearrangement of the same bits currently done by the trace infrastructure. Pass in enum
qemu_plugin_mem_rwso that we are able to treat read-modify-write operations as a single operation.Signed-off-by Richard Henderson <[email protected]>
Quoted 10 lines
--- 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(-)
(now v3)
PATCH v3 29/66 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
PATCH v3 30/66 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 v3 31/66 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
PATCH v3 32/66 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 v3 33/66 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 v3 34/66 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 v3 35/66 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 v3 35/66] accel/tcg: Add cpu_{ld,st}*_mmu interfaces
Quoted 10 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]>
thanks
-- PMM
PATCH v3 36/66 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 v3 37/66 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 v3 38/66 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
PATCH v3 39/66 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
PATCH v3 40/66 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
PATCH v3 41/66 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 v3 42/66 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 v3 43/66 tcg: Add helper_unaligned_{ld, st} 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 | 13 +++++++++++++ 2 files changed, 18 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_ld(CPUArchState *env, target_ulong addr); +void QEMU_NORETURN helper_unaligned_st(CPUArchState *env, target_ulong addr); +#endif /* CONFIG_SOFTMMU */ #endif /* TCG_LDST_H */
accel/tcg/user-exec.c +13 -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,18 @@ static void validate_memop(MemOpIdx oi, MemOp expected)#endif } +void helper_unaligned_ld (CPUArchState *env,target_ulong addr) +{ +cpu_unaligned_access (env_cpu (env), addr,MMU_DATA_LOAD , +MMU_USER_IDX ,GETPC ()); +} + +void helper_unaligned_st (CPUArchState *env,target_ulong addr) +{ +cpu_unaligned_access (env_cpu (env), addr,MMU_DATA_STORE , +MMU_USER_IDX ,GETPC ()); +} +static void *cpu_mmu_lookup (CPUArchState *env,target_ulong addr,MemOpIdx oi,uintptr_t ra,MMUAccessType type) {
Signature · 1 line
2.25.1
Re: [PATCH v3 43/66] tcg: Add helper_unaligned_{ld, st} for user-only sigbus
Quoted 6 lines · Richard Henderson
To be called from tcg generated code on hosts that support unaligned accesses natively, in response to an access that is supposed to be aligned.
Signed-off-by Richard Henderson <[email protected]>
thanks
-- PMM
PATCH v3 44/66 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 | 107 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 102 insertions(+), 7 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 +102 -5
167 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v3 44/66] tcg/i386: Support raising sigbus for user-only
Quoted 6 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- tcg/i386/tcg-target.h | 2 - tcg/i386/tcg-target.c.inc | 107 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 102 insertions(+), 7 deletions(-)
thanks
-- PMM
PATCH v3 45/66 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
Re: [PATCH v3 45/66] tests/tcg/multiarch: Add sigbus.c
Quoted 7 lines · Richard Henderson
A mostly generic test for unaligned access raising SIGBUS.
Signed-off-by Richard Henderson <[email protected]>--- tests/tcg/multiarch/sigbus.c | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
thanks
-- PMM
PATCH v3 46/66 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
Re: [PATCH v3 46/66] linux-user: Split out do_prctl and subroutines
Quoted 22 lines · Richard Henderson
Since 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.Signed-off-by Richard Henderson <[email protected]>--- 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 ++++++++++++++++------------linux-user/syscall.c +6
-0+static abi_long do_prctl_get_fp_mode (CPUArchState *env) +{ +#ifdef TARGET_MIPS +abi_long ret =0 ; + +if (env->CP0_Status & (1 << CP0St_FR)) {
linux-user/syscall.c abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr) · line 6344
Quoted 10 lines
linux-user/syscall.c +10
-0+ ret |= PR_FP_MODE_FR; + } +if (env->CP0_Config5 & (1 <<CP0C5_FRE )) { + ret |=PR_FP_MODE_FRE ; + } +return ret; +#else +return -TARGET_EINVAL ; +#endif +}
If we're going to refactor the prctl code, I think it would be better to have architecture-specific prctl handling in linux-user/$ARCH/prctl.c files rather than lots of target ifdefs in syscall.c...
thanks
-- PMM
Re: [PATCH v3 46/66] linux-user: Split out do_prctl and subroutines
Quoted 31 lines · Peter Maydell
Quoted 29 lines · Richard Henderson
Since 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.Signed-off-by Richard Henderson <[email protected]>--- 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 ++++++++++++++++------------linux-user/syscall.c +13
-0+static abi_long do_prctl_get_fp_mode (CPUArchState *env) +{ +#ifdef TARGET_MIPS +abi_long ret =0 ; + +if (env->CP0_Status & (1 << CP0St_FR)) { + ret |=PR_FP_MODE_FR ; + } +if (env->CP0_Config5 & (1 <<CP0C5_FRE )) { + ret |=PR_FP_MODE_FRE ; + } +return ret; +#else
Quoted 8 lines
linux-user/syscall.c abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr) · line 6344
Quoted 3 lines
linux-user/syscall.c +3
-0+return -TARGET_EINVAL ; +#endif +}If we're going to refactor the prctl code, I think it would be better to have architecture-specific prctl handling in
linux-user/$ARCH/prctl.cfiles rather than lots of target ifdefs insyscall.c...
Ok, I'll give it some more thought.
r~
PATCH v3 47/66 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 v3 48/66 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
Re: [PATCH v3 48/66] hw/core/cpu: Re-sort the non-pointers to the end of CPUClass
Quoted 6 lines · Richard Henderson
Despite the comment, the members were not kept at the end.
Signed-off-by Richard Henderson <[email protected]>--- include/hw/core/cpu.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
PATCH v3 49/66 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 v3 50/66 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
Re: [PATCH v3 50/66] hw/core/cpu: Move cpu properties to cpu-sysemu.c
Quoted 6 lines · Richard Henderson
The comment in
cpu-common.cis absolutely correct, we can't rely on the ifdef in a file built once. This was only "working" because we used ifndef.Signed-off-by Richard Henderson <[email protected]>
which moved the properties out of cpu.c and into cpu-common.c with the remark "There's no reason to keep the property list separate from the CPU class code" despite there being a big fat warning comment saying why it can't go in a compiled-once source file !
Is there a reason to prefer this patch over just reverting 1b36e4f5a5de585 ?
thanks
-- PMM
(patch below for context)
Quoted 158 lines
--- 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.chw/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
-1@@ -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' +)) --
Re: [PATCH v3 50/66] hw/core/cpu: Move cpu properties to cpu-sysemu.c
Quoted 9 lines · Peter Maydell
Quoted 6 lines · Richard Henderson
The comment in
cpu-common.cis absolutely correct, we can't rely on the ifdef in a file built once. This was only "working" because we used ifndef.Signed-off-by Richard Henderson <[email protected]>
Quoted 7 lines
Fixes 1b36e4f5a5de585which moved the properties out of
cpu.cand intocpu-common.cwith the remark "There's no reason to keep the property list separate from the CPU class code" despite there being a big fat warning comment saying why it can't go in a compiled-once source file !
Ouch. Sorry about that. :(
Quoted 3 lines
Is there a reason to prefer this patch over just reverting
1b36e4f5a5de585?
I agree with reverting the commit.
Signature · 1 line
Eduardo
PATCH v3 51/66 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 v3 52/66 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
Re: [PATCH v3 52/66] target/alpha: Reorg fp memory operations
Quoted 8 lines · Richard Henderson
Pass in the context to each mini-helper, instead of an incorrectly named "flags". Separate
gen_load_fpandgen_store_fp, away from the integer helpers.Signed-off-by Richard Henderson <[email protected]>--- target/alpha/translate.c | 83 +++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 26 deletions(-)
PATCH v3 53/66 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
Re: [PATCH v3 53/66] target/alpha: Reorg integer memory operations
Quoted 8 lines · Richard Henderson
Pass in the MemOp instead of a callback.
Drop the fp argument; add a locked argument.Signed-off-by Richard Henderson <[email protected]>--- target/alpha/translate.c | 104 +++++++++++++++------------------------ 1 file changed, 40 insertions(+), 64 deletions(-)
(One of those patches where diff has made an incomprehensible mess of the change and it's easier to look separately at the "before" and "after" files, at least for the first half of the patch...)
thanks
-- PMM
PATCH v3 54/66 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 v3 55/66 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 v3 56/66 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
PATCH v3 57/66 accel/tcg/user-exec: Convert DEBUG_SIGNAL to tracepoint
In reply to Richard Henderson--- accel/tcg/user-exec.c | 9 +++------ accel/tcg/trace-events | 3 +++ 2 files changed, 6 insertions(+), 6 deletions(-)
accel/tcg/user-exec.c +3 -6
@@ -27,6 +27,7 @@#include "exec/helper-proto.h" #include "qemu/atomic128.h" #include "trace/trace-root.h" +#include "trace.h" #include "tcg/tcg-ldst.h" #include "internal.h"
@@ -45,8 +46,6 @@ __threaduintptr_t helper_retaddr; -//#define DEBUG_SIGNAL -/* exit the current TB from a signal handler. The host registers are restored in a state compatible with the CPU emulator */
@@ -133,10 +132,8 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info,abort (); } -#if defined(DEBUG_SIGNAL ) -printf ("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n" , - pc, address, is_write, *(unsigned long *)old_set); -#endif +trace_sigsegv (pc, address, is_write, *(unsigned long *)old_set); +/* XXX: locking issue */ /* Note that it is important that we don't call page_unprotect() unless * this is really a "write to nonwriteable page" fault, because
accel/tcg/trace-events +3 -0
@@ -8,3 +8,6 @@ exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=0x%x" # translate-all.c translate_block(void *tb, uintptr_t pc, const void *tb_code) "tb:%p, pc:0x%"PRIxPTR", tb_code:%p" + +# user-exec.c +sigsegv(uintptr_t pc, uintptr_t addr, int is_write, unsigned long old_set) "pc:0x%"PRIxPTR", addr:0x%"PRIxPTR", w:%d, oldset:0x%lx"
Signature · 1 line
2.25.1
Re: [PATCH v3 57/66] accel/tcg/user-exec: Convert DEBUG_SIGNAL to tracepoint
Quoted 5 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- accel/tcg/user-exec.c | 9 +++------ accel/tcg/trace-events | 3 +++ 2 files changed, 6 insertions(+), 6 deletions(-)
PATCH v3 58/66 include/exec: Move cpu_signal_handler declaration
In reply to Richard HendersonThere is nothing target specific about this. The implementation is host specific, but the declaration is 100% common.
--- include/exec/exec-all.h | 13 +++++++++++++ target/alpha/cpu.h | 6 ------ target/arm/cpu.h | 7 ------- target/avr/cpu.h | 2 -- target/cris/cpu.h | 8 -------- target/hexagon/cpu.h | 3 --- target/hppa/cpu.h | 3 --- target/i386/cpu.h | 7 ------- target/m68k/cpu.h | 8 -------- target/microblaze/cpu.h | 7 ------- target/mips/cpu.h | 3 --- target/mips/internal.h | 2 -- target/nios2/cpu.h | 2 -- target/openrisc/cpu.h | 2 -- target/ppc/cpu.h | 7 ------- target/riscv/cpu.h | 2 -- target/rx/cpu.h | 4 ---- target/s390x/cpu.h | 7 ------- target/sh4/cpu.h | 3 --- target/sparc/cpu.h | 2 -- target/tricore/cpu.h | 2 -- target/xtensa/cpu.h | 2 -- 22 files changed, 13 insertions(+), 89 deletions(-)
include/exec/exec-all.h +13 -0
@@ -662,6 +662,19 @@ static inline tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, }return addr; } + +/** +* cpu_signal_handler +* @signum: host signal number +* @pinfo: host siginfo_t +* @puc: host ucontext_t +* +* To be called from the SIGBUS and SIGSEGV signal handler to inform the +* virtual cpu of exceptions. Returns true if the signal was handled by +* the virtual CPU. +*/ +int cpu_signal_handler (int signum,void *pinfo,void *puc); +#else static inline void mmap_lock (void ) {}static inline void mmap_unlock (void ) {}
target/alpha/cpu.h +0 -6
@@ -287,7 +287,6 @@ void alpha_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, uintptr_t retaddr) QEMU_NORETURN;#define cpu_list alpha_cpu_list -#define cpu_signal_handler cpu_alpha_signal_handlertypedef CPUAlphaState CPUArchState ;typedef AlphaCPU ArchCPU ;
@@ -442,11 +441,6 @@ void alpha_translate_init(void);#define CPU_RESOLVING_TYPE TYPE_ALPHA_CPUvoid alpha_cpu_list (void ); -/* you can call this signal handler from your SIGBUS and SIGSEGV -signal handlers to inform the virtual CPU of exceptions. non zero -is returned if the signal was handled by the virtual CPU. */ -int cpu_alpha_signal_handler (int host_signum,void *pinfo, -void *puc);bool alpha_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr);
target/arm/cpu.h +0 -7
@@ -1117,12 +1117,6 @@ static inline bool is_a64(CPUARMState *env)return env->aarch64; } -/* you can call this signal handler from your SIGBUS and SIGSEGV -signal handlers to inform the virtual CPU of exceptions. non zero -is returned if the signal was handled by the virtual CPU. */ -int cpu_arm_signal_handler (int host_signum,void *pinfo, -void *puc); -/** * pmu_op_start/finish * @env: CPUARMState
@@ -3002,7 +2996,6 @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);#define ARM_CPU_TYPE_NAME (name) (name ARM_CPU_TYPE_SUFFIX)#define CPU_RESOLVING_TYPE TYPE_ARM_CPU -#define cpu_signal_handler cpu_arm_signal_handler#define cpu_list arm_cpu_list/* ARM has the following "translation regimes" (as the ARM ARM calls them):
target/avr/cpu.h +0 -2
@@ -175,7 +175,6 @@ static inline void set_avr_feature(CPUAVRState *env, int feature) }#define cpu_list avr_cpu_list -#define cpu_signal_handler cpu_avr_signal_handler#define cpu_mmu_index avr_cpu_mmu_indexstatic inline int avr_cpu_mmu_index (CPUAVRState *env,bool ifetch)
@@ -187,7 +186,6 @@ void avr_cpu_tcg_init(void);void avr_cpu_list (void );int cpu_avr_exec (CPUState *cpu); -int cpu_avr_signal_handler (int host_signum,void *pinfo,void *puc);int avr_cpu_memory_rw_debug (CPUState *cs,vaddr address,uint8_t *buf,int len,bool is_write);
target/cris/cpu.h +0 -8
@@ -199,12 +199,6 @@ int crisv10_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);int cris_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int cris_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); -/* you can call this signal handler from your SIGBUS and SIGSEGV -signal handlers to inform the virtual CPU of exceptions. non zero -is returned if the signal was handled by the virtual CPU. */ -int cpu_cris_signal_handler (int host_signum,void *pinfo, -void *puc); -void cris_initialize_tcg (void );void cris_initialize_crisv10_tcg (void );
@@ -250,8 +244,6 @@ enum {#define CRIS_CPU_TYPE_NAME (name) (name CRIS_CPU_TYPE_SUFFIX)#define CPU_RESOLVING_TYPE TYPE_CRIS_CPU -#define cpu_signal_handler cpu_cris_signal_handler -/* MMU modes definitions */ #define MMU_USER_IDX 1static inline int cpu_mmu_index (CPUCRISState *env,bool ifetch)
target/hexagon/cpu.h +0 -3
@@ -129,9 +129,6 @@ typedef struct HexagonCPU {#include "cpu_bits.h" -#define cpu_signal_handler cpu_hexagon_signal_handler -int cpu_hexagon_signal_handler (int host_signum,void *pinfo,void *puc); -static inline void cpu_get_tb_cpu_state (CPUHexagonState *env,target_ulong *pc,target_ulong *cs_base,uint32_t *flags) {
target/hppa/cpu.h +0 -3
@@ -322,9 +322,6 @@ static inline void cpu_hppa_change_prot_id(CPUHPPAState *env) { }void cpu_hppa_change_prot_id (CPUHPPAState *env);#endif -#define cpu_signal_handler cpu_hppa_signal_handler - -int cpu_hppa_signal_handler (int host_signum,void *pinfo,void *puc);hwaddr hppa_cpu_get_phys_page_debug (CPUState *cs,vaddr addr);int hppa_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int hppa_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/i386/cpu.h +0 -7
@@ -1940,12 +1940,6 @@ void cpu_x86_frstor(CPUX86State *s, target_ulong ptr, int data32);void cpu_x86_fxsave (CPUX86State *s,target_ulong ptr);void cpu_x86_fxrstor (CPUX86State *s,target_ulong ptr); -/* you can call this signal handler from your SIGBUS and SIGSEGV -signal handlers to inform the virtual CPU of exceptions. non zero -is returned if the signal was handled by the virtual CPU. */ -int cpu_x86_signal_handler (int host_signum,void *pinfo, -void *puc); -/* cpu.c */ void x86_cpu_vendor_words2str (char *dst,uint32_t vendor1,uint32_t vendor2,uint32_t vendor3);
@@ -2011,7 +2005,6 @@ uint64_t cpu_get_tsc(CPUX86State *env);#define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu32")#endif -#define cpu_signal_handler cpu_x86_signal_handler#define cpu_list x86_cpu_list/* MMU modes definitions */
target/m68k/cpu.h +0 -8
@@ -175,13 +175,6 @@ int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);void m68k_tcg_init (void );void m68k_cpu_init_gdb (M68kCPU *cpu); -/* -* you can call this signal handler from your SIGBUS and SIGSEGV -* signal handlers to inform the virtual CPU of exceptions. non zero -* is returned if the signal was handled by the virtual CPU. -*/ -int cpu_m68k_signal_handler (int host_signum,void *pinfo, -void *puc);uint32_t cpu_m68k_get_ccr (CPUM68KState *env);void cpu_m68k_set_ccr (CPUM68KState *env,uint32_t );void cpu_m68k_set_sr (CPUM68KState *env,uint32_t );
@@ -561,7 +554,6 @@ enum {#define M68K_CPU_TYPE_NAME (model) model M68K_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_M68K_CPU -#define cpu_signal_handler cpu_m68k_signal_handler#define cpu_list m68k_cpu_list/* MMU modes definitions */
target/microblaze/cpu.h +0 -7
@@ -383,16 +383,9 @@ static inline void mb_cpu_write_msr(CPUMBState *env, uint32_t val) }void mb_tcg_init (void ); -/* you can call this signal handler from your SIGBUS and SIGSEGV -signal handlers to inform the virtual CPU of exceptions. non zero -is returned if the signal was handled by the virtual CPU. */ -int cpu_mb_signal_handler (int host_signum,void *pinfo, -void *puc);#define CPU_RESOLVING_TYPE TYPE_MICROBLAZE_CPU -#define cpu_signal_handler cpu_mb_signal_handler -/* MMU modes definitions */ #define MMU_NOMMU_IDX 0#define MMU_KERNEL_IDX 1
target/mips/cpu.h +0 -3
@@ -1193,7 +1193,6 @@ struct MIPSCPU {void mips_cpu_list (void ); -#define cpu_signal_handler cpu_mips_signal_handler#define cpu_list mips_cpu_listextern void cpu_wrdsp (uint32_t rs,uint32_t mask_num,CPUMIPSState *env);
@@ -1277,8 +1276,6 @@ enum {*/ #define CPU_INTERRUPT_WAKE CPU_INTERRUPT_TGT_INT_0 -int cpu_mips_signal_handler (int host_signum,void *pinfo,void *puc); -#define MIPS_CPU_TYPE_SUFFIX "-" TYPE_MIPS_CPU#define MIPS_CPU_TYPE_NAME (model) model MIPS_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_MIPS_CPU
target/mips/internal.h +0 -2
@@ -156,8 +156,6 @@ extern const VMStateDescription vmstate_mips_cpu;#endif /* !CONFIG_USER_ONLY */ -#define cpu_signal_handler cpu_mips_signal_handler -static inline bool cpu_mips_hw_interrupts_enabled (CPUMIPSState *env) { return (env->CP0_Status & (1 << CP0St_IE)) &&
target/nios2/cpu.h +0 -2
@@ -193,7 +193,6 @@ struct Nios2CPU {void nios2_tcg_init (void );void nios2_cpu_do_interrupt (CPUState *cs); -int cpu_nios2_signal_handler (int host_signum,void *pinfo,void *puc);void dump_mmu (CPUNios2State *env);void nios2_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr nios2_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);
@@ -206,7 +205,6 @@ void do_nios2_semihosting(CPUNios2State *env);#define CPU_RESOLVING_TYPE TYPE_NIOS2_CPU#define cpu_gen_code cpu_nios2_gen_code -#define cpu_signal_handler cpu_nios2_signal_handler#define CPU_SAVE_VERSION 1
target/openrisc/cpu.h +0 -2
@@ -322,11 +322,9 @@ void openrisc_translate_init(void);bool openrisc_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr); -int cpu_openrisc_signal_handler (int host_signum,void *pinfo,void *puc);int print_insn_or1k (bfd_vma addr,disassemble_info *info);#define cpu_list cpu_openrisc_list -#define cpu_signal_handler cpu_openrisc_signal_handler#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_openrisc_cpu;
target/ppc/cpu.h +0 -7
@@ -1278,12 +1278,6 @@ extern const VMStateDescription vmstate_ppc_cpu;/*****************************************************************************/ void ppc_translate_init (void ); -/* -* you can call this signal handler from your SIGBUS and SIGSEGV -* signal handlers to inform the virtual CPU of exceptions. non zero -* is returned if the signal was handled by the virtual CPU. -*/ -int cpu_ppc_signal_handler (int host_signum,void *pinfo,void *puc);bool ppc_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr);
@@ -1362,7 +1356,6 @@ int ppc_dcr_write(ppc_dcr_t *dcr_env, int dcrn, uint32_t val);#define POWERPC_CPU_TYPE_NAME (model) model POWERPC_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU -#define cpu_signal_handler cpu_ppc_signal_handler#define cpu_list ppc_cpu_list/* MMU modes definitions */
target/riscv/cpu.h +0 -2
@@ -357,7 +357,6 @@ void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,char *riscv_isa_string (RISCVCPU *cpu);void riscv_cpu_list (void ); -#define cpu_signal_handler riscv_cpu_signal_handler#define cpu_list riscv_cpu_list#define cpu_mmu_index riscv_cpu_mmu_index
@@ -372,7 +371,6 @@ void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(uint32_t),void riscv_cpu_set_mode (CPURISCVState *env,target_ulong newpriv);void riscv_translate_init (void ); -int riscv_cpu_signal_handler (int host_signum,void *pinfo,void *puc); void QEMU_NORETURN riscv_raise_exception(CPURISCVState *env,uint32_t exception,uintptr_t pc);
target/rx/cpu.h +0 -4
@@ -132,13 +132,9 @@ int rx_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);hwaddr rx_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);void rx_translate_init (void ); -int cpu_rx_signal_handler (int host_signum,void *pinfo, -void *puc); -void rx_cpu_list (void );void rx_cpu_unpack_psw (CPURXState *env,uint32_t psw,int rte); -#define cpu_signal_handler cpu_rx_signal_handler#define cpu_list rx_cpu_list#include "exec/cpu-all.h"
target/s390x/cpu.h +0 -7
@@ -809,13 +809,6 @@ void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,#define S390_CPU_TYPE_NAME (name) (name S390_CPU_TYPE_SUFFIX)#define CPU_RESOLVING_TYPE TYPE_S390_CPU -/* you can call this signal handler from your SIGBUS and SIGSEGV -signal handlers to inform the virtual CPU of exceptions. non zero -is returned if the signal was handled by the virtual CPU. */ -int cpu_s390x_signal_handler (int host_signum,void *pinfo,void *puc); -#define cpu_signal_handler cpu_s390x_signal_handler - -/* interrupt.c */ #define RA_IGNORED 0void s390_program_interrupt (CPUS390XState *env,uint32_t code,uintptr_t ra);
target/sh4/cpu.h +0 -3
@@ -216,8 +216,6 @@ void superh_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, uintptr_t retaddr) QEMU_NORETURN;void sh4_translate_init (void ); -int cpu_sh4_signal_handler (int host_signum,void *pinfo, -void *puc);bool superh_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr);
@@ -251,7 +249,6 @@ void cpu_load_tlb(CPUSH4State * env);#define SUPERH_CPU_TYPE_NAME (model) model SUPERH_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_SUPERH_CPU -#define cpu_signal_handler cpu_sh4_signal_handler#define cpu_list sh4_cpu_list/* MMU modes definitions */
target/sparc/cpu.h +0 -2
@@ -649,13 +649,11 @@ hwaddr cpu_get_phys_page_nofault(CPUSPARCState *env, target_ulong addr, int mmu_idx);#endif #endif -int cpu_sparc_signal_handler (int host_signum,void *pinfo,void *puc);#define SPARC_CPU_TYPE_SUFFIX "-" TYPE_SPARC_CPU#define SPARC_CPU_TYPE_NAME (model) model SPARC_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_SPARC_CPU -#define cpu_signal_handler cpu_sparc_signal_handler#define cpu_list sparc_cpu_list/* MMU modes definitions */
target/tricore/cpu.h +0 -2
@@ -362,7 +362,6 @@ void fpu_set_state(CPUTriCoreState *env);void tricore_cpu_list (void ); -#define cpu_signal_handler cpu_tricore_signal_handler#define cpu_list tricore_cpu_liststatic inline int cpu_mmu_index (CPUTriCoreState *env,bool ifetch)
@@ -377,7 +376,6 @@ typedef TriCoreCPU ArchCPU;void cpu_state_reset (CPUTriCoreState *s);void tricore_tcg_init (void ); -int cpu_tricore_signal_handler (int host_signum,void *pinfo,void *puc);static inline void cpu_get_tb_cpu_state (CPUTriCoreState *env,target_ulong *pc,target_ulong *cs_base,uint32_t *flags)
target/xtensa/cpu.h +0 -2
@@ -582,7 +582,6 @@ void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, 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#define XTENSA_CPU_TYPE_SUFFIX "-" TYPE_XTENSA_CPU
@@ -611,7 +610,6 @@ void check_interrupts(CPUXtensaState *s);void xtensa_irq_init (CPUXtensaState *env);qemu_irq *xtensa_get_extints (CPUXtensaState *env);qemu_irq xtensa_get_runstall (CPUXtensaState *env); -int cpu_xtensa_signal_handler (int host_signum,void *pinfo,void *puc);void xtensa_cpu_list (void );void xtensa_sync_window_from_phys (CPUXtensaState *env);void xtensa_sync_phys_from_window (CPUXtensaState *env);
Signature · 1 line
2.25.1
Re: [PATCH v3 58/66] include/exec: Move cpu_signal_handler declaration
Quoted 20 lines · Richard Henderson
There is nothing target specific about this. The implementation is host specific, but the declaration is 100% common.
Signed-off-by Richard Henderson <[email protected]>--- include/exec/exec-all.h | 13 +++++++++++++ target/alpha/cpu.h | 6 ------ target/arm/cpu.h | 7 ------- target/avr/cpu.h | 2 -- target/cris/cpu.h | 8 -------- target/hexagon/cpu.h | 3 --- target/hppa/cpu.h | 3 --- target/i386/cpu.h | 7 ------- target/m68k/cpu.h | 8 -------- target/microblaze/cpu.h | 7 ------- target/mips/cpu.h | 3 --- target/mips/internal.h | 2 -- target/nios2/cpu.h | 2 -- target/openrisc/cpu.h | 2 -- target/ppc/cpu.h | 7 -------
Quoted 8 lines
target/riscv/cpu.h | 2 -- target/rx/cpu.h | 4 ---- target/s390x/cpu.h | 7 ------- target/sh4/cpu.h | 3 --- target/sparc/cpu.h | 2 -- target/tricore/cpu.h | 2 -- target/xtensa/cpu.h | 2 -- 22 files changed, 13 insertions(+), 89 deletions(-)
Re: [PATCH v3 58/66] include/exec: Move cpu_signal_handler declaration
In reply to Richard HendersonQuoted 5 lines · Richard Henderson
There is nothing target specific about this. The implementation is host specific, but the declaration is 100% common.
Signed-off-by Richard Henderson <[email protected]>
Alistair
Quoted 478 lines
--- include/exec/exec-all.h | 13 +++++++++++++ target/alpha/cpu.h | 6 ------ target/arm/cpu.h | 7 ------- target/avr/cpu.h | 2 -- target/cris/cpu.h | 8 -------- target/hexagon/cpu.h | 3 --- target/hppa/cpu.h | 3 --- target/i386/cpu.h | 7 ------- target/m68k/cpu.h | 8 -------- target/microblaze/cpu.h | 7 ------- target/mips/cpu.h | 3 --- target/mips/internal.h | 2 -- target/nios2/cpu.h | 2 -- target/openrisc/cpu.h | 2 -- target/ppc/cpu.h | 7 ------- target/riscv/cpu.h | 2 -- target/rx/cpu.h | 4 ---- target/s390x/cpu.h | 7 ------- target/sh4/cpu.h | 3 --- target/sparc/cpu.h | 2 -- target/tricore/cpu.h | 2 -- target/xtensa/cpu.h | 2 -- 22 files changed, 13 insertions(+), 89 deletions(-)include/exec/exec-all.h +13
-0@@ -662,6 +662,19 @@ static inline tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, }return addr; } + +/** +* cpu_signal_handler +* @signum: host signal number +* @pinfo: host siginfo_t +* @puc: host ucontext_t +* +* To be called from the SIGBUS and SIGSEGV signal handler to inform the +* virtual cpu of exceptions. Returns true if the signal was handled by +* the virtual CPU. +*/ +int cpu_signal_handler (int signum,void *pinfo,void *puc); +#else static inline void mmap_lock (void ) {}static inline void mmap_unlock (void ) {}target/alpha/cpu.h +0
-6@@ -287,7 +287,6 @@ void alpha_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, uintptr_t retaddr) QEMU_NORETURN;#define cpu_list alpha_cpu_list -#define cpu_signal_handler cpu_alpha_signal_handlertypedef CPUAlphaState CPUArchState ;typedef AlphaCPU ArchCPU ;@@ -442,11 +441,6 @@ void alpha_translate_init(void);#define CPU_RESOLVING_TYPE TYPE_ALPHA_CPUvoid alpha_cpu_list (void ); -/* you can call this signal handler from your SIGBUS and SIGSEGV -signal handlers to inform the virtual CPU of exceptions. non zero -is returned if the signal was handled by the virtual CPU. */ -int cpu_alpha_signal_handler (int host_signum,void *pinfo, -void *puc);bool alpha_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr);target/arm/cpu.h +0
-7@@ -1117,12 +1117,6 @@ static inline bool is_a64(CPUARMState *env)return env->aarch64; } -/* you can call this signal handler from your SIGBUS and SIGSEGV -signal handlers to inform the virtual CPU of exceptions. non zero -is returned if the signal was handled by the virtual CPU. */ -int cpu_arm_signal_handler (int host_signum,void *pinfo, -void *puc); -/** * pmu_op_start/finish * @env: CPUARMState @@ -3002,7 +2996,6 @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);#define ARM_CPU_TYPE_NAME (name) (name ARM_CPU_TYPE_SUFFIX)#define CPU_RESOLVING_TYPE TYPE_ARM_CPU -#define cpu_signal_handler cpu_arm_signal_handler#define cpu_list arm_cpu_list/* ARM has the following "translation regimes" (as the ARM ARM calls them): target/avr/cpu.h +0
-2@@ -175,7 +175,6 @@ static inline void set_avr_feature(CPUAVRState *env, int feature) }#define cpu_list avr_cpu_list -#define cpu_signal_handler cpu_avr_signal_handler#define cpu_mmu_index avr_cpu_mmu_indexstatic inline int avr_cpu_mmu_index (CPUAVRState *env,bool ifetch)@@ -187,7 +186,6 @@ void avr_cpu_tcg_init(void);void avr_cpu_list (void );int cpu_avr_exec (CPUState *cpu); -int cpu_avr_signal_handler (int host_signum,void *pinfo,void *puc);int avr_cpu_memory_rw_debug (CPUState *cs,vaddr address,uint8_t *buf,int len,bool is_write);target/cris/cpu.h +0
-8@@ -199,12 +199,6 @@ int crisv10_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);int cris_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int cris_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); -/* you can call this signal handler from your SIGBUS and SIGSEGV -signal handlers to inform the virtual CPU of exceptions. non zero -is returned if the signal was handled by the virtual CPU. */ -int cpu_cris_signal_handler (int host_signum,void *pinfo, -void *puc); -void cris_initialize_tcg (void );void cris_initialize_crisv10_tcg (void );@@ -250,8 +244,6 @@ enum {#define CRIS_CPU_TYPE_NAME (name) (name CRIS_CPU_TYPE_SUFFIX)#define CPU_RESOLVING_TYPE TYPE_CRIS_CPU -#define cpu_signal_handler cpu_cris_signal_handler -/* MMU modes definitions */ #define MMU_USER_IDX 1static inline int cpu_mmu_index (CPUCRISState *env,bool ifetch)target/hexagon/cpu.h +0
-3@@ -129,9 +129,6 @@ typedef struct HexagonCPU {#include "cpu_bits.h" -#define cpu_signal_handler cpu_hexagon_signal_handler -int cpu_hexagon_signal_handler (int host_signum,void *pinfo,void *puc); -static inline void cpu_get_tb_cpu_state (CPUHexagonState *env,target_ulong *pc,target_ulong *cs_base,uint32_t *flags) {target/hppa/cpu.h +0
-3@@ -322,9 +322,6 @@ static inline void cpu_hppa_change_prot_id(CPUHPPAState *env) { }void cpu_hppa_change_prot_id (CPUHPPAState *env);#endif -#define cpu_signal_handler cpu_hppa_signal_handler - -int cpu_hppa_signal_handler (int host_signum,void *pinfo,void *puc);hwaddr hppa_cpu_get_phys_page_debug (CPUState *cs,vaddr addr);int hppa_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int hppa_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);target/i386/cpu.h +0
-7@@ -1940,12 +1940,6 @@ void cpu_x86_frstor(CPUX86State *s, target_ulong ptr, int data32);void cpu_x86_fxsave (CPUX86State *s,target_ulong ptr);void cpu_x86_fxrstor (CPUX86State *s,target_ulong ptr); -/* you can call this signal handler from your SIGBUS and SIGSEGV -signal handlers to inform the virtual CPU of exceptions. non zero -is returned if the signal was handled by the virtual CPU. */ -int cpu_x86_signal_handler (int host_signum,void *pinfo, -void *puc); -/* cpu.c */ void x86_cpu_vendor_words2str (char *dst,uint32_t vendor1,uint32_t vendor2,uint32_t vendor3);@@ -2011,7 +2005,6 @@ uint64_t cpu_get_tsc(CPUX86State *env);#define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu32")#endif -#define cpu_signal_handler cpu_x86_signal_handler#define cpu_list x86_cpu_list/* MMU modes definitions */ target/m68k/cpu.h +0
-8@@ -175,13 +175,6 @@ int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);void m68k_tcg_init (void );void m68k_cpu_init_gdb (M68kCPU *cpu); -/* -* you can call this signal handler from your SIGBUS and SIGSEGV -* signal handlers to inform the virtual CPU of exceptions. non zero -* is returned if the signal was handled by the virtual CPU. -*/ -int cpu_m68k_signal_handler (int host_signum,void *pinfo, -void *puc);uint32_t cpu_m68k_get_ccr (CPUM68KState *env);void cpu_m68k_set_ccr (CPUM68KState *env,uint32_t );void cpu_m68k_set_sr (CPUM68KState *env,uint32_t );@@ -561,7 +554,6 @@ enum {#define M68K_CPU_TYPE_NAME (model) model M68K_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_M68K_CPU -#define cpu_signal_handler cpu_m68k_signal_handler#define cpu_list m68k_cpu_list/* MMU modes definitions */ target/microblaze/cpu.h +0
-7@@ -383,16 +383,9 @@ static inline void mb_cpu_write_msr(CPUMBState *env, uint32_t val) }void mb_tcg_init (void ); -/* you can call this signal handler from your SIGBUS and SIGSEGV -signal handlers to inform the virtual CPU of exceptions. non zero -is returned if the signal was handled by the virtual CPU. */ -int cpu_mb_signal_handler (int host_signum,void *pinfo, -void *puc);#define CPU_RESOLVING_TYPE TYPE_MICROBLAZE_CPU -#define cpu_signal_handler cpu_mb_signal_handler -/* MMU modes definitions */ #define MMU_NOMMU_IDX 0#define MMU_KERNEL_IDX 1target/mips/cpu.h +0
-3@@ -1193,7 +1193,6 @@ struct MIPSCPU {void mips_cpu_list (void ); -#define cpu_signal_handler cpu_mips_signal_handler#define cpu_list mips_cpu_listextern void cpu_wrdsp (uint32_t rs,uint32_t mask_num,CPUMIPSState *env);@@ -1277,8 +1276,6 @@ enum {*/ #define CPU_INTERRUPT_WAKE CPU_INTERRUPT_TGT_INT_0 -int cpu_mips_signal_handler (int host_signum,void *pinfo,void *puc); -#define MIPS_CPU_TYPE_SUFFIX "-" TYPE_MIPS_CPU#define MIPS_CPU_TYPE_NAME (model) model MIPS_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_MIPS_CPUtarget/mips/internal.h +0
-2@@ -156,8 +156,6 @@ extern const VMStateDescription vmstate_mips_cpu;#endif /* !CONFIG_USER_ONLY */ -#define cpu_signal_handler cpu_mips_signal_handler -static inline bool cpu_mips_hw_interrupts_enabled (CPUMIPSState *env) { return (env->CP0_Status & (1 << CP0St_IE)) &&target/nios2/cpu.h +0
-2@@ -193,7 +193,6 @@ struct Nios2CPU {void nios2_tcg_init (void );void nios2_cpu_do_interrupt (CPUState *cs); -int cpu_nios2_signal_handler (int host_signum,void *pinfo,void *puc);void dump_mmu (CPUNios2State *env);void nios2_cpu_dump_state (CPUState *cpu,FILE *f,int flags);hwaddr nios2_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);@@ -206,7 +205,6 @@ void do_nios2_semihosting(CPUNios2State *env);#define CPU_RESOLVING_TYPE TYPE_NIOS2_CPU#define cpu_gen_code cpu_nios2_gen_code -#define cpu_signal_handler cpu_nios2_signal_handler#define CPU_SAVE_VERSION 1target/openrisc/cpu.h +0
-2@@ -322,11 +322,9 @@ void openrisc_translate_init(void);bool openrisc_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr); -int cpu_openrisc_signal_handler (int host_signum,void *pinfo,void *puc);int print_insn_or1k (bfd_vma addr,disassemble_info *info);#define cpu_list cpu_openrisc_list -#define cpu_signal_handler cpu_openrisc_signal_handler#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_openrisc_cpu;target/ppc/cpu.h +0
-7@@ -1278,12 +1278,6 @@ extern const VMStateDescription vmstate_ppc_cpu;/*****************************************************************************/ void ppc_translate_init (void ); -/* -* you can call this signal handler from your SIGBUS and SIGSEGV -* signal handlers to inform the virtual CPU of exceptions. non zero -* is returned if the signal was handled by the virtual CPU. -*/ -int cpu_ppc_signal_handler (int host_signum,void *pinfo,void *puc);bool ppc_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr);@@ -1362,7 +1356,6 @@ int ppc_dcr_write(ppc_dcr_t *dcr_env, int dcrn, uint32_t val);#define POWERPC_CPU_TYPE_NAME (model) model POWERPC_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU -#define cpu_signal_handler cpu_ppc_signal_handler#define cpu_list ppc_cpu_list/* MMU modes definitions */ target/riscv/cpu.h +0
-2@@ -357,7 +357,6 @@ void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,char *riscv_isa_string (RISCVCPU *cpu);void riscv_cpu_list (void ); -#define cpu_signal_handler riscv_cpu_signal_handler#define cpu_list riscv_cpu_list#define cpu_mmu_index riscv_cpu_mmu_index@@ -372,7 +371,6 @@ void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(uint32_t),void riscv_cpu_set_mode (CPURISCVState *env,target_ulong newpriv);void riscv_translate_init (void ); -int riscv_cpu_signal_handler (int host_signum,void *pinfo,void *puc); void QEMU_NORETURN riscv_raise_exception(CPURISCVState *env,uint32_t exception,uintptr_t pc);target/rx/cpu.h +0
-4@@ -132,13 +132,9 @@ int rx_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);hwaddr rx_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);void rx_translate_init (void ); -int cpu_rx_signal_handler (int host_signum,void *pinfo, -void *puc); -void rx_cpu_list (void );void rx_cpu_unpack_psw (CPURXState *env,uint32_t psw,int rte); -#define cpu_signal_handler cpu_rx_signal_handler#define cpu_list rx_cpu_list#include "exec/cpu-all.h" target/s390x/cpu.h +0
-7@@ -809,13 +809,6 @@ void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,#define S390_CPU_TYPE_NAME (name) (name S390_CPU_TYPE_SUFFIX)#define CPU_RESOLVING_TYPE TYPE_S390_CPU -/* you can call this signal handler from your SIGBUS and SIGSEGV -signal handlers to inform the virtual CPU of exceptions. non zero -is returned if the signal was handled by the virtual CPU. */ -int cpu_s390x_signal_handler (int host_signum,void *pinfo,void *puc); -#define cpu_signal_handler cpu_s390x_signal_handler - -/* interrupt.c */ #define RA_IGNORED 0void s390_program_interrupt (CPUS390XState *env,uint32_t code,uintptr_t ra);target/sh4/cpu.h +0
-3@@ -216,8 +216,6 @@ void superh_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, uintptr_t retaddr) QEMU_NORETURN;void sh4_translate_init (void ); -int cpu_sh4_signal_handler (int host_signum,void *pinfo, -void *puc);bool superh_cpu_tlb_fill (CPUState *cs,vaddr address,int size,MMUAccessType access_type,int mmu_idx,bool probe,uintptr_t retaddr);@@ -251,7 +249,6 @@ void cpu_load_tlb(CPUSH4State * env);#define SUPERH_CPU_TYPE_NAME (model) model SUPERH_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_SUPERH_CPU -#define cpu_signal_handler cpu_sh4_signal_handler#define cpu_list sh4_cpu_list/* MMU modes definitions */ target/sparc/cpu.h +0
-2@@ -649,13 +649,11 @@ hwaddr cpu_get_phys_page_nofault(CPUSPARCState *env, target_ulong addr, int mmu_idx);#endif #endif -int cpu_sparc_signal_handler (int host_signum,void *pinfo,void *puc);#define SPARC_CPU_TYPE_SUFFIX "-" TYPE_SPARC_CPU#define SPARC_CPU_TYPE_NAME (model) model SPARC_CPU_TYPE_SUFFIX#define CPU_RESOLVING_TYPE TYPE_SPARC_CPU -#define cpu_signal_handler cpu_sparc_signal_handler#define cpu_list sparc_cpu_list/* MMU modes definitions */ target/tricore/cpu.h +0
-2@@ -362,7 +362,6 @@ void fpu_set_state(CPUTriCoreState *env);void tricore_cpu_list (void ); -#define cpu_signal_handler cpu_tricore_signal_handler#define cpu_list tricore_cpu_liststatic inline int cpu_mmu_index (CPUTriCoreState *env,bool ifetch)@@ -377,7 +376,6 @@ typedef TriCoreCPU ArchCPU;void cpu_state_reset (CPUTriCoreState *s);void tricore_tcg_init (void ); -int cpu_tricore_signal_handler (int host_signum,void *pinfo,void *puc);static inline void cpu_get_tb_cpu_state (CPUTriCoreState *env,target_ulong *pc,target_ulong *cs_base,uint32_t *flags)target/xtensa/cpu.h +0
-3@@ -582,7 +582,6 @@ void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, 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#define XTENSA_CPU_TYPE_SUFFIX "-" TYPE_XTENSA_CPU@@ -611,7 +610,6 @@ void check_interrupts(CPUXtensaState *s);void xtensa_irq_init (CPUXtensaState *env);qemu_irq *xtensa_get_extints (CPUXtensaState *env);qemu_irq xtensa_get_runstall (CPUXtensaState *env); -int cpu_xtensa_signal_handler (int host_signum,void *pinfo,void *puc);void xtensa_cpu_list (void );void xtensa_sync_window_from_phys (CPUXtensaState *env);void xtensa_sync_phys_from_window (CPUXtensaState *env); --2.25.1
PATCH v3 59/66 accel/tcg: Handle SIGBUS in handle_cpu_signal
In reply to Richard HendersonWe've been registering host SIGBUS, but then treating it exactly like SIGSEGV.
Handle BUS_ADRALN via cpu_unaligned_access, but allow other SIGBUS si_codes to continue into the host-to-guest signal coversion code in host_signal_handler. Unwind the guest state so that we report the correct guest PC for the fault.
--- accel/tcg/user-exec.c | 188 +++++++++++++++++++++++++++-------------- linux-user/signal.c | 36 +++++--- accel/tcg/trace-events | 3 +- 3 files changed, 152 insertions(+), 75 deletions(-)
accel/tcg/user-exec.c +124 -64
@@ -57,17 +57,123 @@ static void QEMU_NORETURN cpu_exit_tb_from_sighandler(CPUState *cpu,cpu_loop_exit_noexc (cpu); } -/* 'pc' is the host PC at which the exception was raised. 'address' is -the effective address of the memory exception. 'is_write' is 1 if a -write caused the exception and otherwise 0'. 'old_set' is the -signal set which should be restored */ -static inline int handle_cpu_signal (uintptr_t pc,siginfo_t *info, -int is_write,sigset_t *old_set) +static bool handle_cpu_sigsegv (CPUState *cpu,uintptr_t pc,uintptr_t addr, +int si_code,MMUAccessType access_type, +sigset_t *old_set) +{ +trace_sigsegv (pc, addr, access_type, *(unsigned long *)old_set); + +/* XXX: locking issue */ +/* +* Note that it is important that we don't call page_unprotect() unless +* this is really a "write to nonwriteable page" fault, because +* page_unprotect() assumes that if it is called for an access to +* a page that's writeable this means we had two threads racing and +* another thread got there first and already made the page writeable; +* so we will retry the access. If we were to call page_unprotect() +* for some other kind of fault that should really be passed to the +* guest, we'd end up in an infinite loop of retrying the faulting +* access. +*/ +if (access_type ==MMU_DATA_STORE + && si_code ==SEGV_ACCERR + &&h2g_valid (addr)) { +switch (page_unprotect (h2g_nocheck (addr), pc)) { +case 0 : +/* +* Fault not caused by a page marked unwritable to protect +* cached translations, must be the guest binary's problem. +*/ +break ; +case 1 : +/* +* Fault caused by protection of cached translation; TBs +* invalidated, so resume execution. Retain helper_retaddr +* for a possible second fault. +*/ +return true; +case 2 : +/* +* Fault caused by protection of cached translation, and the +* currently executing TB was modified and must be exited +* immediately. Clear helper_retaddr for next execution. +*/ +clear_helper_retaddr (); +cpu_exit_tb_from_sighandler (cpu, old_set); +/* NORETURN */ +default : +g_assert_not_reached (); + } + } + +/* +* Convert forcefully to guest address space, invalid addresses +* are still valid segv ones. +*/ + addr =h2g_nocheck (addr); + +/* +* There is no way the target can handle this other than raising +* an exception. Undo signal and retaddr state prior to longjmp. +*/ +sigprocmask (SIG_SETMASK , old_set,NULL ); +clear_helper_retaddr (); + +CPUClass *cc =CPU_GET_CLASS (cpu); + cc->tcg_ops->tlb_fill (cpu, addr,0 , access_type,MMU_USER_IDX , false, pc); +g_assert_not_reached (); +} + +static bool handle_cpu_sigbus (CPUState *cpu,uintptr_t pc,uintptr_t addr, +int si_code,MMUAccessType access_type, +sigset_t *old_set) +{ +trace_sigbus (pc, addr, access_type, *(unsigned long *)old_set); + +if (si_code ==BUS_ADRALN ) { +/* +* We're expecting host alignment faults to correspond +* directly to guest alignment faults, and thus the host +* address must correspond to a guest address. +*/ + addr =h2g (addr); + +/* Undo signal and retaddr state prior to longjmp. */ +sigprocmask (SIG_SETMASK , old_set,NULL ); +clear_helper_retaddr (); + +cpu_unaligned_access (cpu, addr, access_type,MMU_USER_IDX , pc); + } + +/* +* Otherwise this is probably BUS_ADRERR or suchlike, which +* can be easily triggered by the guest playing with mmap +* and accessing past the end of the file. +* +* Use PC to unwind to the current guest address and then +* return false to pass on the host signal to the guest. +*/ +cpu_restore_state (cpu, pc, true); +return false; +} + +/** +* handle_cpu_signal: +* @pc: the host PC at which the exception was raised, +* @address: the effective address of the memory exception, +* @is_write: true if a write caused the exception, +* @old_set: signal set which should be restored. +* +* Return true if the signal has been handled by the vcpu, +* false if the signal should be sent on to the guest. +*/ +static bool handle_cpu_signal (uintptr_t pc,siginfo_t *info, +bool is_write,sigset_t *old_set) {CPUState *cpu = current_cpu; -CPUClass *cc; -unsigned long address = (unsigned long )info->si_addr; +uintptr_t addr = (uintptr_t )info->si_addr;MMUAccessType access_type = is_write ?MMU_DATA_STORE :MMU_DATA_LOAD ; +int code;switch (helper_retaddr) {default :
@@ -119,7 +225,8 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info,break ; } -/* For synchronous signals we expect to be coming from the vCPU +/* +* For synchronous signals we expect to be coming from the vCPU * thread (so current_cpu should be valid) and either from running * code or during translation which can fault as we cross pages. *
@@ -132,62 +239,15 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info,abort (); } -trace_sigsegv (pc, address, is_write, *(unsigned long *)old_set); - -/* XXX: locking issue */ -/* Note that it is important that we don't call page_unprotect() unless -* this is really a "write to nonwriteable page" fault, because -* page_unprotect() assumes that if it is called for an access to -* a page that's writeable this means we had two threads racing and -* another thread got there first and already made the page writeable; -* so we will retry the access. If we were to call page_unprotect() -* for some other kind of fault that should really be passed to the -* guest, we'd end up in an infinite loop of retrying the faulting -* access. -*/ -if (is_write && info->si_signo ==SIGSEGV && info->si_code ==SEGV_ACCERR && -h2g_valid (address)) { -switch (page_unprotect (h2g (address), pc)) { -case 0 : -/* Fault not caused by a page marked unwritable to protect -* cached translations, must be the guest binary's problem. -*/ -break ; -case 1 : -/* Fault caused by protection of cached translation; TBs -* invalidated, so resume execution. Retain helper_retaddr -* for a possible second fault. -*/ -return 1 ; -case 2 : -/* Fault caused by protection of cached translation, and the -* currently executing TB was modified and must be exited -* immediately. Clear helper_retaddr for next execution. -*/ -clear_helper_retaddr (); -cpu_exit_tb_from_sighandler (cpu, old_set); -/* NORETURN */ - -default : -g_assert_not_reached (); - } + code = info->si_code; +switch (info->si_signo) { +case SIGSEGV : +return handle_cpu_sigsegv (cpu, pc, addr, code, access_type, old_set); +case SIGBUS : +return handle_cpu_sigbus (cpu, pc, addr, code, access_type, old_set); +default : +g_assert_not_reached (); } - -/* Convert forcefully to guest address space, invalid addresses -are still valid segv ones */ - address =h2g_nocheck (address); - -/* -* There is no way the target can handle this other than raising -* an exception. Undo signal and retaddr state prior to longjmp. -*/ -sigprocmask (SIG_SETMASK , old_set,NULL ); -clear_helper_retaddr (); - - cc =CPU_GET_CLASS (cpu); - cc->tcg_ops->tlb_fill (cpu, address,0 , access_type, -MMU_USER_IDX , false, pc); -g_assert_not_reached (); } static int probe_access_internal(CPUArchState *env, target_ulong addr,
linux-user/signal.c +26 -10
@@ -747,27 +747,37 @@ static inline void rewind_if_in_safe_syscall(void *puc)static void host_signal_handler (int host_signum,siginfo_t *info,void *puc) { -CPUArchState *env = thread_cpu->env_ptr; -CPUState *cpu =env_cpu (env); +CPUState *cpu = thread_cpu; +CPUArchState *env = cpu->env_ptr;TaskState *ts = cpu->opaque; -int sig;target_siginfo_t tinfo;ucontext_t *uc = puc;struct emulated_sigtable *k; +bool must_exit = false; -/* the CPU emulator uses some host signals to detect exceptions, -we forward to it some signals */ +/* +* The CPU emulator uses some host signals to detect exceptions, +* we forward to it some signals. +*/ if ((host_signum ==SIGSEGV || host_signum ==SIGBUS ) && info->si_code >0 ) { -if (cpu_signal_handler (host_signum, info, puc)) +if (cpu_signal_handler (host_signum, info, puc)) {return ; + } +/* +* E.g. SIGBUS, without BUS_ADRALN, which we want to pass on. +* We have unwound the TB to PC, so must use cpu_loop_exit below. +*/ + must_exit = true; }/* get target signal number */ sig =host_to_target_signal (host_signum); -if (sig <1 || sig >TARGET_NSIG ) +if (sig <1 || sig >TARGET_NSIG ) { +assert (!must_exit);return ; + }trace_user_host_signal (env, host_signum, sig);rewind_if_in_safe_syscall (puc);
@@ -778,7 +788,8 @@ static void host_signal_handler(int host_signum, siginfo_t *info, k->pending = sig; ts->signal_pending =1 ; -/* Block host signals until target signal handler entered. We +/* +* Block host signals until target signal handler entered. We * can't block SIGSEGV or SIGBUS while we're executing guest * code in case the guest code provokes one in the window between * now and it getting out to the main loop. Signals will be
@@ -796,8 +807,13 @@ static void host_signal_handler(int host_signum, siginfo_t *info,sigdelset (&uc->uc_sigmask,SIGSEGV );sigdelset (&uc->uc_sigmask,SIGBUS ); -/* interrupt the virtual CPU as soon as possible */ -cpu_exit (thread_cpu); +/* Interrupt the virtual CPU as soon as possible. */ +if (must_exit) { + cpu->exception_index =EXCP_INTERRUPT ; +cpu_loop_exit (cpu); + }else { +cpu_exit (cpu); + } }/* do_sigaltstack() returns target values and errnos. */
accel/tcg/trace-events +2 -1
@@ -10,4 +10,5 @@ exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=0x%x" translate_block(void *tb, uintptr_t pc, const void *tb_code) "tb:%p, pc:0x%"PRIxPTR", tb_code:%p" # user-exec.c -sigsegv(uintptr_t pc, uintptr_t addr, int is_write, unsigned long old_set) "pc:0x%"PRIxPTR", addr:0x%"PRIxPTR", w:%d, oldset:0x%lx" +sigsegv(uintptr_t pc, uintptr_t addr, int access_type, unsigned long old_set) "pc:0x%"PRIxPTR", addr:0x%"PRIxPTR", at:%d, oldset:0x%lx" +sigbus(uintptr_t pc, uintptr_t addr, int access_type, unsigned long old_set) "pc:0x%"PRIxPTR", addr:0x%"PRIxPTR", at:%d, oldset:0x%lx"
Signature · 1 line
2.25.1
Re: [PATCH v3 59/66] accel/tcg: Handle SIGBUS in handle_cpu_signal
Quoted 8 lines · Richard Henderson
We've been registering host SIGBUS, but then treating it exactly like SIGSEGV.
Handle
BUS_ADRALNviacpu_unaligned_access, but allow other SIGBUSsi_codesto continue into the host-to-guest signal coversion code inhost_signal_handler. Unwind the guest state so that we report the correct guest PC for the fault.
You can't rely on alignment faults being marked by BUS_ADRALN:
eg MIPS doesn't give you that si_code. How much does that matter for our use of it here ?
-- PMM
Re: [PATCH v3 59/66] accel/tcg: Handle SIGBUS in handle_cpu_signal
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Richard Henderson
We've been registering host SIGBUS, but then treating it exactly like SIGSEGV.
Quoted 8 lines
Quoted 4 lines
Handle
BUS_ADRALNviacpu_unaligned_access, but allow other SIGBUSsi_codesto continue into the host-to-guest signal coversion code inhost_signal_handler. Unwind the guest state so that we report the correct guest PC for the fault.You can't rely on alignment faults being marked by
BUS_ADRALN:
eg MIPS doesn't give you thatsi_code. How much does that matter for our use of it here ?
Aside from whatever tcg/foo relies upon, it doesn't matter.
But: silly mips. I was going to rely on it there -- oh well, I'll undo that section of the follow-on tcg/mips patch set. And it's got a different syscall for disabling the unaligned fixup.
r~
PATCH v3 60/66 tcg/aarch64: Support raising sigbus for user-only
In reply to Richard HendersonUse load-acquire / store-release for the normal case of alignment matching the access size. Otherwise, emit a test + branch sequence invoking helper_unaligned_mmu.
--- tcg/aarch64/tcg-target.h | 2 - tcg/aarch64/tcg-target.c.inc | 174 +++++++++++++++++++++++++++++++---- 2 files changed, 157 insertions(+), 19 deletions(-)
tcg/aarch64/tcg-target.h +0 -2
@@ -151,9 +151,7 @@ typedef enum {void tb_target_set_jmp_target (uintptr_t ,uintptr_t ,uintptr_t ,uintptr_t ); -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif #define TCG_TARGET_NEED_POOL_LABELS #endif /* AARCH64_TCG_TARGET_H */
tcg/aarch64/tcg-target.c.inc +157 -17
271 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v3 60/66] tcg/aarch64: Support raising sigbus for user-only
Quoted 4 lines · Richard Henderson
Use load-acquire / store-release for the normal case of alignment matching the access size. Otherwise, emit a test + branch sequence invoking
helper_unaligned_mmu.
I don't think this trick will work for a CPU that implements the FEAT_LSE2 feature -- section B2.5.2 in the Arm ARM DDI0487G.b says that if LSE2 is implemented then the CPU either must or can make them just work and do the unaligned access.
thanks
-- PMM
PATCH v3 61/66 tcg/ppc: Support raising sigbus for user-only
In reply to Richard Henderson--- tcg/ppc/tcg-target.h | 2 - tcg/ppc/tcg-target.c.inc | 102 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 94 insertions(+), 10 deletions(-)
tcg/ppc/tcg-target.h +0 -2
@@ -182,9 +182,7 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t);#define TCG_TARGET_DEFAULT_MO (0)#define TCG_TARGET_HAS_MEMORY_BSWAP 1 -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif #define TCG_TARGET_NEED_POOL_LABELS #endif
tcg/ppc/tcg-target.c.inc +94 -8
175 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v3 61/66] tcg/ppc: Support raising sigbus for user-only
Quoted 7 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- tcg/ppc/tcg-target.h | 2 - tcg/ppc/tcg-target.c.inc | 102 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 94 insertions(+), 10 deletions(-)
thanks
-- PMM
PATCH v3 62/66 tcg/s390: Support raising sigbus for user-only
In reply to Richard Henderson--- tcg/s390/tcg-target.h | 2 -- tcg/s390/tcg-target.c.inc | 63 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-)
tcg/s390/tcg-target.h +0 -2
@@ -157,9 +157,7 @@ static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, /* no need to flush icache explicitly */ } -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif #define TCG_TARGET_NEED_POOL_LABELS #endif
tcg/s390/tcg-target.c.inc +61 -2
101 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v3 62/66] tcg/s390: Support raising sigbus for user-only
Quoted 6 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- tcg/s390/tcg-target.h | 2 -- tcg/s390/tcg-target.c.inc | 63 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-)
thanks
-- PMM
PATCH v3 63/66 tcg/tci: Support raising sigbus for user-only
In reply to Richard Henderson--- tcg/tci.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
tcg/tci.c +13 -5
@@ -296,7 +296,7 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr,uintptr_t ra = (uintptr_t )tb_ptr;#ifdef CONFIG_SOFTMMU -switch (mop) { +switch (mop & (MO_BSWAP |MO_SSIZE )) {case MO_UB :return helper_ret_ldub_mmu (env, taddr, oi, ra);case MO_SB :
@@ -326,10 +326,14 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, }#else void *haddr =g2h (env_cpu (env), taddr); +unsigned a_mask = (1u <<get_alignment_bits (mop)) -1 ;uint64_t ret;set_helper_retaddr (ra); -switch (mop) { +if (taddr & a_mask) { +helper_unaligned_ld (env, taddr); + } +switch (mop & (MO_BSWAP |MO_SSIZE )) {case MO_UB : ret =ldub_p (haddr);break ;
@@ -377,11 +381,11 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr,static void tci_qemu_st (CPUArchState *env,target_ulong taddr,uint64_t val,MemOpIdx oi,const void *tb_ptr) { -MemOp mop =get_memop (oi) & (MO_BSWAP |MO_SSIZE ); +MemOp mop =get_memop (oi);uintptr_t ra = (uintptr_t )tb_ptr;#ifdef CONFIG_SOFTMMU -switch (mop) { +switch (mop & (MO_BSWAP |MO_SIZE )) {case MO_UB :helper_ret_stb_mmu (env, taddr, val, oi, ra);break ;
@@ -408,9 +412,13 @@ static void tci_qemu_st(CPUArchState *env, target_ulong taddr, uint64_t val, }#else void *haddr =g2h (env_cpu (env), taddr); +unsigned a_mask = (1u <<get_alignment_bits (mop)) -1 ;set_helper_retaddr (ra); -switch (mop) { +if (taddr & a_mask) { +helper_unaligned_st (env, taddr); + } +switch (mop & (MO_BSWAP |MO_SIZE )) {case MO_UB :stb_p (haddr, val);break ;
Signature · 1 line
2.25.1
Re: [PATCH v3 63/66] tcg/tci: Support raising sigbus for user-only
Quoted 36 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- tcg/tci.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)tcg/tci.c +6
-2@@ -296,7 +296,7 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr,uintptr_t ra = (uintptr_t )tb_ptr;#ifdef CONFIG_SOFTMMU -switch (mop) { +switch (mop & (MO_BSWAP |MO_SSIZE )) {case MO_UB :return helper_ret_ldub_mmu (env, taddr, oi, ra);case MO_SB :@@ -326,10 +326,14 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, }#else void *haddr =g2h (env_cpu (env), taddr); +unsigned a_mask = (1u <<get_alignment_bits (mop)) -1 ;uint64_t ret;set_helper_retaddr (ra); -switch (mop) { +if (taddr & a_mask) { +helper_unaligned_ld (env, taddr); + } +switch (mop & (MO_BSWAP |MO_SSIZE )) {case MO_UB : ret =ldub_p (haddr);break ;
tcg/tci.c static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, · line 385
Quoted 6 lines
tcg/tci.c +1
-1@@ -377,11 +381,11 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr,static void tci_qemu_st (CPUArchState *env,target_ulong taddr,uint64_t val,MemOpIdx oi,const void *tb_ptr) { -MemOp mop =get_memop (oi) & (MO_BSWAP |MO_SSIZE ); +MemOp mop =get_memop (oi);uintptr_t ra = (uintptr_t )tb_ptr;
Don't you need this bit in tci_qemu_st() as well ?
-- PMM
Re: [PATCH v3 63/66] tcg/tci: Support raising sigbus for user-only
Quoted 26 lines · Peter Maydell
Quoted 26 lines
tcg/tci.c +6
-2@@ -296,7 +296,7 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr,uintptr_t ra = (uintptr_t )tb_ptr;#ifdef CONFIG_SOFTMMU -switch (mop) { +switch (mop & (MO_BSWAP |MO_SSIZE )) {case MO_UB :return helper_ret_ldub_mmu (env, taddr, oi, ra);case MO_SB :@@ -326,10 +326,14 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, }#else void *haddr =g2h (env_cpu (env), taddr); +unsigned a_mask = (1u <<get_alignment_bits (mop)) -1 ;uint64_t ret;set_helper_retaddr (ra); -switch (mop) { +if (taddr & a_mask) { +helper_unaligned_ld (env, taddr); + } +switch (mop & (MO_BSWAP |MO_SSIZE )) {case MO_UB : ret =ldub_p (haddr);break ;@@ -377,11 +381,11 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr,
Quoted 8 lines
tcg/tci.c static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, · line 385
Quoted 6 lines
tcg/tci.c +1
-1static void tci_qemu_st (CPUArchState *env,target_ulong taddr,uint64_t val,MemOpIdx oi,const void *tb_ptr) { -MemOp mop =get_memop (oi) & (MO_BSWAP |MO_SSIZE ); +MemOp mop =get_memop (oi);uintptr_t ra = (uintptr_t )tb_ptr;Don't you need this bit in
tci_qemu_st()as well ?
Which bit isn't present in st as well?
There's missing hunks in your reply, but afaics they're the same.
r~
Re: [PATCH v3 63/66] tcg/tci: Support raising sigbus for user-only
Quoted 12 lines · Richard Henderson
Quoted 9 lines · Peter Maydell
tcg/tci.c static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, · line 385
Quoted 7 lines
tcg/tci.c +1
-1@@ -377,11 +381,11 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr,static void tci_qemu_st (CPUArchState *env,target_ulong taddr,uint64_t val,MemOpIdx oi,const void *tb_ptr) { -MemOp mop =get_memop (oi) & (MO_BSWAP |MO_SSIZE ); +MemOp mop =get_memop (oi);uintptr_t ra = (uintptr_t )tb_ptr;Don't you need this bit in
tci_qemu_st()as well ?
Quoted 2 lines
Which bit isn't present in st as well?
There's missing hunks in your reply, but afaics they're the same.
https://patchew.org/QEMU/[email protected]/[email protected]/
I had the function name wrong, but only the tci_qemu_st() change has this bit:
- MemOp mop = get_memop(oi) & (MO_BSWAP | MO_SSIZE);
+ MemOp mop = get_memop(oi);
-- PMM
Re: [PATCH v3 63/66] tcg/tci: Support raising sigbus for user-only
Quoted 22 lines · Peter Maydell
Quoted 12 lines · Richard Henderson
Quoted 9 lines · Peter Maydell
tcg/tci.c static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, · line 385
Quoted 7 lines
tcg/tci.c +1
-1@@ -377,11 +381,11 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr,static void tci_qemu_st (CPUArchState *env,target_ulong taddr,uint64_t val,MemOpIdx oi,const void *tb_ptr) { -MemOp mop =get_memop (oi) & (MO_BSWAP |MO_SSIZE ); +MemOp mop =get_memop (oi);uintptr_t ra = (uintptr_t )tb_ptr;Don't you need this bit in
tci_qemu_st()as well ?Quoted 2 lines
Which bit isn't present in st as well?
There's missing hunks in your reply, but afaics they're the same.https://patchew.org/QEMU/[email protected]/[email protected]/
I had the function name wrong, but only the
tci_qemu_st()change has this bit:
tcg/tci.c static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, · line 384
Quoted 2 lines
tcg/tci.c +1
-1-MemOp mop =get_memop (oi) & (MO_BSWAP |MO_SSIZE ); +MemOp mop =get_memop (oi);
Ah yes, thanks.
r~
PATCH v3 64/66 tcg: Canonicalize alignment flags in MemOp
In reply to Richard HendersonHaving observed e.g. al8+leq in dumps, canonicalize to al+leq.
--- tcg/tcg-op.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tcg/tcg-op.c +6 -1
@@ -2765,7 +2765,12 @@ void tcg_gen_lookup_and_goto_ptr(void)static inline MemOp tcg_canonicalize_memop (MemOp op,bool is64,bool st) {/* Trigger the asserts within as early as possible. */ - (void )get_alignment_bits (op); +unsigned a_bits =get_alignment_bits (op); + +/* Prefer MO_ALIGN+MO_XX over MO_ALIGN_XX+MO_XX */ +if (a_bits == (op &MO_SIZE )) { + op = (op & ~MO_AMASK ) |MO_ALIGN ; + }switch (op &MO_SIZE ) {case MO_8 :
Signature · 1 line
2.25.1
Re: [PATCH v3 64/66] tcg: Canonicalize alignment flags in MemOp
Quoted 6 lines · Richard Henderson
Having observed e.g. al8+leq in dumps, canonicalize to al+leq.
Signed-off-by Richard Henderson <[email protected]>--- tcg/tcg-op.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Nice.
PATCH v3 65/66 tcg/riscv: Support raising sigbus for user-only
In reply to Richard Henderson--- tcg/riscv/tcg-target.h | 2 -- tcg/riscv/tcg-target.c.inc | 64 +++++++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 6 deletions(-)
tcg/riscv/tcg-target.h +0 -2
@@ -165,9 +165,7 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t);#define TCG_TARGET_DEFAULT_MO (0) -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif #define TCG_TARGET_NEED_POOL_LABELS #define TCG_TARGET_HAS_MEMORY_BSWAP 0
tcg/riscv/tcg-target.c.inc +60 -4
106 lines not on this page · raw message
Signature · 1 line
2.25.1