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

Alex Bennée posted 1 patch 1 year, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230105114304.2017493-1-alex.bennee@linaro.org
Maintainers: Peter Maydell <peter.maydell@linaro.org>
target/arm/translate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[RFC PATCH] target/arm: fix handling of HLT semihosting in system mode
Posted by Alex Bennée 1 year, 3 months ago
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)
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 target/arm/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/arm/translate.c b/target/arm/translate.c
index 74a903072f..1dcaefb8e7 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -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;
-- 
2.34.1


Re: [RFC PATCH] target/arm: fix handling of HLT semihosting in system mode
Posted by Peter Maydell 1 year, 3 months ago
On Thu, 5 Jan 2023 at 11:43, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> 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)
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

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

Cc: qemu-stable@nongnu.org

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

and applied to target-arm.next.

-- PMM