Skip to contentSkip to conversation

linux-user/arm: Reset CPSR_E when entering a signal handler

PATCH Applied Amanieu d'Antras 2 participants 3 messages May 11, 2020 – May 21, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 linux-user/arm: Reset CPSR_E when entering a signal handler

This fixes signal handlers running with the wrong endianness if the interrupted code used SETEND to dynamically switch endianness.

---
 linux-user/arm/signal.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
linux-user/arm/signal.c +7 -1
index d96fc27ce1..a475a103e9 100644
@@ -244,6 +244,11 @@ setup_return(CPUARMState *env, struct target_sigaction *ka,
     } else {
         cpsr &= ~CPSR_T;
     }
+    if (env->cp15.sctlr_el[1] & SCTLR_E0E) {
+        cpsr |= CPSR_E;
+    } else {
+        cpsr &= ~CPSR_E;
+    }
 
     if (ka->sa_flags & TARGET_SA_RESTORER) {
         if (is_fdpic) {
@@ -287,7 +292,8 @@ setup_return(CPUARMState *env, struct target_sigaction *ka,
     env->regs[13] = frame_addr;
     env->regs[14] = retcode;
     env->regs[15] = handler & (thumb ? ~1 : ~3);
-    cpsr_write(env, cpsr, CPSR_IT | CPSR_T, CPSRWriteByInstr);
+    cpsr_write(env, cpsr, CPSR_IT | CPSR_T | CPSR_E, CPSRWriteByInstr);
+    arm_rebuild_hflags(env);
 
     return 0;
 }
Signature · 1 line
2.26.2
#2 lore raw
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Amanieu d'Antras

This fixes signal handlers running with the wrong endianness if the interrupted code used SETEND to dynamically switch endianness.

Quoted 7 lines
Quoted 5 lines
---
 linux-user/arm/signal.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Applied to target-arm.next, thanks.

-- PMM