Skip to contentSkip to conversation

target/xtensa: clean up unaligned access

PATCH Superseded Max Filippov 1 participant 1 message May 17, 2021

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 target/xtensa: clean up unaligned access

Xtensa cores may or may not have hardware support for unaligned memory access. On cores with such support pass MO_UNALN in memory access flags for all operations that would not raise an exception. Drop condition from xtensa_cpu_do_unaligned_access and replace it with assertions. Add a test.

---
Changes v1->v2:
- correctly handle case of !XCHAL_UNALIGNED_*_EXCEPTION in the test

 target/xtensa/helper.c             |  14 +--
 target/xtensa/translate.c          | 108 ++++++++--------
 tests/tcg/xtensa/test_load_store.S | 195 +++++++++++++++++++++++++++++
 3 files changed, 256 insertions(+), 61 deletions(-)
 create mode 100644 tests/tcg/xtensa/test_load_store.S
target/xtensa/helper.c +7 -7
index eeffee297d15..eceb2958caab 100644
@@ -270,13 +270,13 @@ 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));
+    assert(!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);
 }
 
 bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
target/xtensa/translate.c +54 -54

275 lines not on this page · raw message

tests/tcg/xtensa/test_load_store.S new file +195 -0

195 lines not on this page · raw message

Signature · 1 line
2.20.1