From f85f30131665e76e84902f79d4d093c06901c9f6 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sun, 4 Mar 2018 12:46:32 -0500 Subject: [PATCH] target/arm: Don't trap WFI/WFE for M profile M profile cores can never trap on WFI or WFE instructions. Check for M profile in check_wfx_trap() to ensure this. The existing code will do the right thing for v7M cores because the hcr_el2 and scr_el3 registers will be all-zeroes and so we won't attempt to trap, but when we start setting ARM_FEATURE_V8 for v8M cores the v8A handling of SCTLR.nTWE and .nTWI will not give the right results. Backports commit 0e2845689ebdb4ea7174f96f6797e2d8942bd114 from qemu --- qemu/target/arm/op_helper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qemu/target/arm/op_helper.c b/qemu/target/arm/op_helper.c index d99f9f9b..cb1fb2a3 100644 --- a/qemu/target/arm/op_helper.c +++ b/qemu/target/arm/op_helper.c @@ -369,6 +369,11 @@ static inline int check_wfx_trap(CPUARMState *env, bool is_wfe) int cur_el = arm_current_el(env); uint64_t mask; + if (arm_feature(env, ARM_FEATURE_M)) { + /* M profile cores can never trap WFI/WFE. */ + return 0; + } + /* If we are currently in EL0 then we need to check if SCTLR is set up for * WFx instructions being trapped to EL1. These trap bits don't exist in v7. */