target/xtensa: clean up unaligned access
PATCH v4 1/1 target/xtensa: clean up unaligned access
Xtensa cores may or may not have hardware support for unaligned memory access. Remove TARGET_ALIGNED_ONLY=y from all xtensa configurations and pass MO_ALIGN in memory access flags for all operations that would raise an exception.
Simplify use of gen_load_store_alignment by passing access size and alignment requirements in single parameter.
Drop condition from xtensa_cpu_do_unaligned_access and replace it with assertion.
Add a test.
---
Changes v3->v4:
- do additional cleanup in gen_load_store_alignment parameters as suggested by Richard.
Changes v2->v3:
- drop assertion for !XTENSA_OPTION_HW_ALIGNMENT from xtensa_cpu_do_unaligned_access to correctly handle acquire/release intsructions;
- add tests for acquire/release instructions.
Changes v1->v2:
- correctly handle case of !XCHAL_UNALIGNED_*_EXCEPTION in the test
default-configs/targets/xtensa-linux-user.mak | 1 - default-configs/targets/xtensa-softmmu.mak | 1 - .../targets/xtensaeb-linux-user.mak | 1 - default-configs/targets/xtensaeb-softmmu.mak | 1 - target/xtensa/helper.c | 13 +- target/xtensa/translate.c | 120 +++++----- tests/tcg/xtensa/test_load_store.S | 221 ++++++++++++++++++ 7 files changed, 288 insertions(+), 70 deletions(-) create mode 100644 tests/tcg/xtensa/test_load_store.S
default-configs/targets/xtensa-linux-user.mak +0 -1
@@ -1,5 +1,4 @@ TARGET_ARCH=xtensa TARGET_SYSTBL_ABI=common TARGET_SYSTBL=syscall.tbl -TARGET_ALIGNED_ONLY=y TARGET_HAS_BFLT=y
default-configs/targets/xtensa-softmmu.mak +0 -1
@@ -1,3 +1,2 @@ TARGET_ARCH=xtensa -TARGET_ALIGNED_ONLY=y TARGET_SUPPORTS_MTTCG=y
default-configs/targets/xtensaeb-linux-user.mak +0 -1
@@ -1,6 +1,5 @@ TARGET_ARCH=xtensa TARGET_SYSTBL_ABI=common TARGET_SYSTBL=syscall.tbl -TARGET_ALIGNED_ONLY=y TARGET_WORDS_BIGENDIAN=y TARGET_HAS_BFLT=y
default-configs/targets/xtensaeb-softmmu.mak +0 -1
@@ -1,4 +1,3 @@ TARGET_ARCH=xtensa -TARGET_ALIGNED_ONLY=y TARGET_WORDS_BIGENDIAN=y TARGET_SUPPORTS_MTTCG=y
target/xtensa/helper.c +6 -7
@@ -270,13 +270,12 @@ void xtensa_cpu_do_unaligned_access(CPUState *cs,XtensaCPU *cpu =XTENSA_CPU (cs);CPUXtensaState *env = &cpu->env; -if (xtensa_option_enabled (env->config,XTENSA_OPTION_UNALIGNED_EXCEPTION ) && - !xtensa_option_enabled (env->config,XTENSA_OPTION_HW_ALIGNMENT )) { -cpu_restore_state (CPU (cpu), retaddr, true); -HELPER (exception_cause_vaddr)(env, - env->pc,LOAD_STORE_ALIGNMENT_CAUSE , - addr); - } +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,
target/xtensa/translate.c +61 -59
297 lines not on this page · raw message
tests/tcg/xtensa/test_load_store.S new file +221 -0
221 lines not on this page · raw message
Signature · 1 line
2.20.1
Quoted 10 lines · Max Filippov
Xtensa cores may or may not have hardware support for unaligned memory access. Remove TARGET_ALIGNED_ONLY=y from all xtensa configurations and pass
MO_ALIGNin memory access flags for all operations that would raise an exception.
Simplify use ofgen_load_store_alignmentby passing access size and alignment requirements in single parameter.
Drop condition fromxtensa_cpu_do_unaligned_accessand replace it with assertion.
Add a test.
Quoted 4 lines
Suggested-by Philippe Mathieu-Daudé<[email protected]>Suggested-by Richard Henderson<[email protected]>Signed-off-by Max Filippov<[email protected]>---
r~
Quoted 10 lines · Max Filippov
Xtensa cores may or may not have hardware support for unaligned memory access. Remove TARGET_ALIGNED_ONLY=y from all xtensa configurations and pass
MO_ALIGNin memory access flags for all operations that would raise an exception.
Simplify use ofgen_load_store_alignmentby passing access size and alignment requirements in single parameter.
Drop condition fromxtensa_cpu_do_unaligned_accessand replace it with assertion.
Add a test.
Quoted 4 lines
Suggested-by Philippe Mathieu-Daudé <[email protected]>Suggested-by Richard Henderson <[email protected]>Signed-off-by Max Filippov <[email protected]>---
Based-on: <[email protected]>
Quoted 1 line
create mode 100644 tests/tcg/xtensa/test_load_store.S
Except this asm file,
Thanks!