From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxwMm-0006Td-La for qemu-devel@nongnu.org; Thu, 28 May 2015 07:52:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxwMi-0005Zp-Ev for qemu-devel@nongnu.org; Thu, 28 May 2015 07:52:52 -0400 Received: from mail-bl2on0070.outbound.protection.outlook.com ([65.55.169.70]:8256 helo=na01-bl2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxwMi-0005Zl-82 for qemu-devel@nongnu.org; Thu, 28 May 2015 07:52:48 -0400 Date: Thu, 28 May 2015 21:48:51 +1000 From: "Edgar E. Iglesias" Message-ID: <20150528114851.GJ27042@toto> References: <1432060414-5195-1-git-send-email-peter.maydell@linaro.org> <1432060414-5195-9-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1432060414-5195-9-git-send-email-peter.maydell@linaro.org> Subject: Re: [Qemu-devel] [PATCH 08/14] target-arm: Allow cp access functions to indicate traps to EL2 or EL3 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: agraf@suse.de, serge.fdrv@gmail.com, alex.bennee@linaro.org, qemu-devel@nongnu.org, patches@linaro.org On Tue, May 19, 2015 at 07:33:28PM +0100, Peter Maydell wrote: > Some coprocessor access functions will need to indicate that the > instruction should trap to EL2 or EL3 rather than the default > target exception level; add corresponding CPAccessResult enum > entries and handling code. > > Signed-off-by: Peter Maydell > --- > target-arm/cpu.h | 6 +++++- > target-arm/op_helper.c | 14 +++++++++++++- > 2 files changed, 18 insertions(+), 2 deletions(-) > > diff --git a/target-arm/cpu.h b/target-arm/cpu.h > index 9119a94..e431372 100644 > --- a/target-arm/cpu.h > +++ b/target-arm/cpu.h > @@ -1252,7 +1252,8 @@ typedef enum CPAccessResult { > /* Access fails due to a configurable trap or enable which would > * result in a categorized exception syndrome giving information about > * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, > - * 0xc or 0x18). > + * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or > + * PL1 if in EL0, otherwise to the current EL). > */ > CP_ACCESS_TRAP = 1, > /* Access fails and results in an exception syndrome 0x0 ("uncategorized"). > @@ -1260,6 +1261,9 @@ typedef enum CPAccessResult { > * result in this failure is specifically defined by the architecture. > */ > CP_ACCESS_TRAP_UNCATEGORIZED = 2, > + /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ > + CP_ACCESS_TRAP_EL2 = 3, > + CP_ACCESS_TRAP_EL3 = 4, > } CPAccessResult; > > /* Access functions for coprocessor registers. These cannot fail and > diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c > index d693b01..5963f3b 100644 > --- a/target-arm/op_helper.c > +++ b/target-arm/op_helper.c > @@ -335,6 +335,7 @@ void HELPER(set_user_reg)(CPUARMState *env, uint32_t regno, uint32_t val) > void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome) > { > const ARMCPRegInfo *ri = rip; > + int target_el; > > if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14 > && extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) { > @@ -349,6 +350,17 @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome) > case CP_ACCESS_OK: > return; > case CP_ACCESS_TRAP: > + target_el = exception_target_el(env); > + break; > + case CP_ACCESS_TRAP_EL2: > + /* Requesting a trap to EL2 when we're in EL3 or S-EL0/1 is > + * a bug in the access function. > + */ > + assert(!arm_is_secure(env) && !arm_current_el(env) == 3); > + target_el = 2; > + break; > + case CP_ACCESS_TRAP_EL3: > + target_el = 3; > break; > case CP_ACCESS_TRAP_UNCATEGORIZED: > syndrome = syn_uncategorized(); Here it was, this needs target_el = exception_target_el(env); With that change: Reviewed-by: Edgar E. Iglesias Cheers, Edgar > @@ -357,7 +369,7 @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome) > g_assert_not_reached(); > } > > - raise_exception(env, EXCP_UDEF, syndrome, exception_target_el(env)); > + raise_exception(env, EXCP_UDEF, syndrome, target_el); > } > > void HELPER(set_cp_reg)(CPUARMState *env, void *rip, uint32_t value) > -- > 1.9.1 >