From nobody Thu May 2 08:33:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524148460073379.07547563869775; Thu, 19 Apr 2018 07:34:20 -0700 (PDT) Received: from localhost ([::1]:50919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9AdX-0004PF-4t for importer@patchew.org; Thu, 19 Apr 2018 10:34:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9AR7-0002XL-Pm for qemu-devel@nongnu.org; Thu, 19 Apr 2018 10:21:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9AR1-0002AX-Rp for qemu-devel@nongnu.org; Thu, 19 Apr 2018 10:21:21 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:40920) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9AQv-00026j-M7; Thu, 19 Apr 2018 10:21:09 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1f9AQt-0003FQ-CG; Thu, 19 Apr 2018 15:21:07 +0100 From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Thu, 19 Apr 2018 15:21:06 +0100 Message-Id: <20180419142106.9694-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH] target/arm: Use v7m_stack_read() for reading the frame signature X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: patches@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In commit 95695effe8caa552b8f2 we changed the v7M/v8M stack pop code to use a new v7m_stack_read() function that checks whether the read should fail due to an MPU or bus abort. We missed one call though, the one which reads the signature word for the callee-saved register part of the frame. Correct the omission. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/arm/helper.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index b14fdab140..2ebd086ef2 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6913,7 +6913,6 @@ static bool v7m_push_stack(ARMCPU *cpu) static void do_v7m_exception_exit(ARMCPU *cpu) { CPUARMState *env =3D &cpu->env; - CPUState *cs =3D CPU(cpu); uint32_t excret; uint32_t xpsr; bool ufault =3D false; @@ -7112,9 +7111,11 @@ static void do_v7m_exception_exit(ARMCPU *cpu) ((excret & R_V7M_EXCRET_ES_MASK) =3D=3D 0 || (excret & R_V7M_EXCRET_DCRS_MASK) =3D=3D 0)) { uint32_t expected_sig =3D 0xfefa125b; - uint32_t actual_sig =3D ldl_phys(cs->as, frameptr); + uint32_t actual_sig; =20 - if (expected_sig !=3D actual_sig) { + pop_ok =3D v7m_stack_read(cpu, &actual_sig, frameptr, mmu_idx); + + if (pop_ok && expected_sig !=3D actual_sig) { /* Take a SecureFault on the current stack */ env->v7m.sfsr |=3D R_V7M_SFSR_INVIS_MASK; armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, fal= se); @@ -7125,7 +7126,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu) return; } =20 - pop_ok =3D + pop_ok =3D pop_ok && v7m_stack_read(cpu, &env->regs[4], frameptr + 0x8, mmu_idx= ) && v7m_stack_read(cpu, &env->regs[4], frameptr + 0x8, mmu_idx= ) && v7m_stack_read(cpu, &env->regs[5], frameptr + 0xc, mmu_idx= ) && --=20 2.17.0