Skip to contentSkip to conversation

target/arm: fix handling of HLT semihosting in system mode

RFC PATCH In review Alex Bennée 2 participants 2 messages Jan 5, 2023

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 target/arm: fix handling of HLT semihosting in system mode

The check semihosting_enabled() wants to know if the guest is currently in user mode. Unlike the other cases the test was inverted causing us to block semihosting calls in non-EL0 modes.

Fixes 19b26317e9 (target/arm: Honour -semihosting-config userspace=on)
---
 target/arm/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/translate.c +1 -1
index 74a903072f..1dcaefb8e7 100644
@@ -1184,7 +1184,7 @@ static inline void gen_hlt(DisasContext *s, int imm)
      * semihosting, to provide some semblance of security
      * (and for consistency with our 32-bit semihosting).
      */
-    if (semihosting_enabled(s->current_el != 0) &&
+    if (semihosting_enabled(s->current_el == 0) &&
         (imm == (s->thumb ? 0x3c : 0xf000))) {
         gen_exception_internal_insn(s, EXCP_SEMIHOST);
         return;
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Alex Bennée

The check semihosting_enabled() wants to know if the guest is currently in user mode. Unlike the other cases the test was inverted causing us to block semihosting calls in non-EL0 modes.

Fixes 19b26317e9 (target/arm: Honour -semihosting-config userspace=on)

Whoops. I guess I must have only tested SVC AA32 semihosting or something. We should

and applied to target-arm.next.

-- PMM