target-arm: Implement new HLT trap for semihosting
PATCH 1/1 target-arm: Implement new HLT trap for semihosting
Version 2.0 of the semihosting specification introduces new trap instructions for AArch32: HLT 0xF000 for A32 and HLT 0x3C for T32. Implement these (in the same way we implement the existing HLT semihosting trap for A64).
The old traps via SVC and BKPT are unaffected.
---
The public doc for the new spec is not quite done yet, but I wanted to get support for the new trap insns into QEMU 2.8 (they're the only thing where a semihosting user can't probe to see whether the new-in-2.0 feature they want is present).
I've added support for testing these trap instructions to the not-very-comprehensive semihosting tests at
https://git.linaro.org/people/peter.maydell/semihosting-tests.git
linux-user/main.c | 3 +++ target-arm/cpu.h | 2 +- target-arm/helper.c | 11 ++++++++-- target-arm/translate.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 63 insertions(+), 7 deletions(-)
linux-user/main.c +3 -0
@@ -806,6 +806,9 @@ void cpu_loop(CPUARMState *env) } }break ; +case EXCP_SEMIHOST : + env->regs[0 ] =do_arm_semihosting (env); +break ;case EXCP_INTERRUPT :/* just indicate that signals should be handled asap */ break ;
target-arm/cpu.h +1 -1
@@ -52,7 +52,7 @@#define EXCP_SMC 13/* Secure Monitor Call */ #define EXCP_VIRQ 14#define EXCP_VFIQ 15 -#define EXCP_SEMIHOST 16/* semihosting call (A64 only) */ +#define EXCP_SEMIHOST 16/* semihosting call */ #define ARMV7M_EXCP_RESET 1#define ARMV7M_EXCP_NMI 2
target-arm/helper.c +9 -2
@@ -6573,12 +6573,19 @@ static inline bool check_for_semihosting(CPUState *cs)/* Only intercept calls from privileged modes, to provide some * semblance of security. */ -if (!semihosting_enabled () || - ((env->uncached_cpsr &CPSR_M ) ==ARM_CPU_MODE_USR )) { +if (cs->exception_index !=EXCP_SEMIHOST && + (!semihosting_enabled () || + ((env->uncached_cpsr &CPSR_M ) ==ARM_CPU_MODE_USR ))) {return false; }switch (cs->exception_index) { +case EXCP_SEMIHOST : +/* This is always a semihosting call; the "is this usermode" +* and "is semihosting enabled" checks have been done at +* translate time. +*/ +break ;case EXCP_SWI :/* Check for semihosting interrupt. */ if (env->thumb) {
target-arm/translate.c +50 -4
94 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 5 lines · Peter Maydell
Version 2.0 of the semihosting specification introduces new trap instructions for AArch32: HLT
0xF000for A32 and HLT0x3Cfor T32. Implement these (in the same way we implement the existing HLT semihosting trap for A64).
Quoted 8 lines
The old traps via SVC and BKPT are unaffected.
Signed-off-by Peter Maydell <[email protected]>---
The public doc for the new spec is not quite done yet, but I wanted to get support for the new trap insns into QEMU 2.8 (they're the only thing where a semihosting user can't probe to see whether the new-in-2.0 feature they want is present).
Just for the record, the public doc is now up:
https://developer.arm.com/docs/100863/latest/
thanks
-- PMM