From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPCCe-0000i0-KP for qemu-devel@nongnu.org; Fri, 29 Jan 2016 11:47:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPCCd-0001Ij-NS for qemu-devel@nongnu.org; Fri, 29 Jan 2016 11:47:20 -0500 References: <1452796451-2946-1-git-send-email-peter.maydell@linaro.org> <1452796451-2946-6-git-send-email-peter.maydell@linaro.org> From: Sergey Fedorov Message-ID: <56AB9792.8080302@gmail.com> Date: Fri, 29 Jan 2016 19:47:14 +0300 MIME-Version: 1.0 In-Reply-To: <1452796451-2946-6-git-send-email-peter.maydell@linaro.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 5/8] target-arm: Fix wrong AArch64 entry offset for EL2/EL3 target List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?Q?Alex_Benn=c3=a9e?= , patches@linaro.org, "Edgar E. Iglesias" On 14.01.2016 21:34, Peter Maydell wrote: > The entry offset when taking an exception to AArch64 from a lower > exception level may be 0x400 or 0x600. 0x400 is used if the > implemented exception level immediately lower than the target level > is using AArch64, and 0x600 if it is using AArch32. We were > incorrectly implementing this as checking the exception level > that the exception was taken from. (The two can be different if > for example we take an exception from EL0 to AArch64 EL3; we should > in this case be checking EL2 if EL2 is implemented, and EL1 if > EL2 is not implemented.) Reviewed-by: Sergey Fedorov > Signed-off-by: Peter Maydell > --- > target-arm/helper.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > diff --git a/target-arm/helper.c b/target-arm/helper.c > index d37c82c..196c111 100644 > --- a/target-arm/helper.c > +++ b/target-arm/helper.c > @@ -5866,7 +5866,26 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) > unsigned int new_mode = aarch64_pstate_mode(new_el, true); > > if (arm_current_el(env) < new_el) { > - if (env->aarch64) { > + /* Entry vector offset depends on whether the implemented EL > + * immediately lower than the target level is using AArch32 or AArch64 > + */ > + bool is_aa64; > + > + switch (new_el) { > + case 3: > + is_aa64 = (env->cp15.scr_el3 & SCR_RW) != 0; > + break; > + case 2: > + is_aa64 = (env->cp15.hcr_el2 & HCR_RW) != 0; > + break; > + case 1: > + is_aa64 = is_a64(env); > + break; > + default: > + g_assert_not_reached(); > + } > + > + if (is_aa64) { > addr += 0x400; > } else { > addr += 0x600;