From nobody Mon Feb 9 07:22:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1555419772; cv=none; d=zoho.com; s=zohoarc; b=X7Qyem+EpOT2hNiJDMIzQvotnSDDTaEf+NXxPJKfHQ+Biw15Pa7f5IFithTenEmI4gpA6sXgUvr53OqgC7m6/L/qrcrmDL81DOVFTANpHvxPfcyrCn8DE+LuHqt9C7hHiHHqNlhCb0pOH3eyPkVpJKlpCgSEdHoDnMMaEDDxO/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555419772; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=BFL/4mmLnGxA0smTiBCKZfrdKeTsfE6ZtDY8NLO49os=; b=mFJHlAkKoGn6pbk7fcagGo7f+tHEIJY9sBtcP7VDZjLIEzXXtQ3Wcl7uWMOCsNDjDa1ixt0kay+UTZgbmItJajd6BrYcQn9TIC3qzMCy5HWSj3X/jgfEk5582t4iWoPKUaPBKiA2+0ZoshgaCC7Xnk1o9Z6d1fd6XVkiCQt4vgc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555419772286913.7675326642238; Tue, 16 Apr 2019 06:02:52 -0700 (PDT) Received: from localhost ([127.0.0.1]:36324 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGNjV-000863-0t for importer@patchew.org; Tue, 16 Apr 2019 09:02:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGNf8-0004cf-IM for qemu-devel@nongnu.org; Tue, 16 Apr 2019 08:58:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGNf6-0001Bt-VT for qemu-devel@nongnu.org; Tue, 16 Apr 2019 08:58:10 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:36135) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hGNf6-00019V-KM for qemu-devel@nongnu.org; Tue, 16 Apr 2019 08:58:08 -0400 Received: by mail-wm1-x329.google.com with SMTP id h18so25326435wml.1 for ; Tue, 16 Apr 2019 05:58:06 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v184sm39476572wma.6.2019.04.16.05.58.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Apr 2019 05:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BFL/4mmLnGxA0smTiBCKZfrdKeTsfE6ZtDY8NLO49os=; b=e0Ilpe1NU8SWZ4EcFHTIQOONo+Vj7nYG75Oum+SzAr3zQfR5WwR9fkNbHE7r29s+pH oNnXCH/bHBS95C5VsCeXYTYVT7RAnRjDTQXdry0QwixKSit9jHCpKt0Chh97TY+16MqV kSz54y2buvyI5iR6cWQ4rG7Ff5yaoMz1dHzZKak0zzUVic+ku0oFv32ku53zzUfc+BfE MoKzbmfbtDnA7q4uoxTURYsz9Yj+EJEquh2dSosSK8K2J/JfZ5GGCiJVYV8WYeNCQAzO jiWvAQCAwTNib5RK9ADU8hbWniprDy7KzXyGzKbSjz/NKMyWITE9SD9Rg8tAmKDsBHrf clQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BFL/4mmLnGxA0smTiBCKZfrdKeTsfE6ZtDY8NLO49os=; b=dDvsKX18/oVOwLg+rQTMLsZo2HQIThsO9Ep8TlEDw/AR8AnNlNGQtIRnynclAM99UM b58hrZyx+IzZFThiIdT94aitYDGZZEtJ0nNiBM8e5dnH6/AXop1ayGwqW19AgMm2q+lD dn2JK/hmCaU9Sc7t29k6yD3fmWOq7pPUg0yFV+5BJieOsPergksYUp0qaPZwXzAZBjqi cOzf0gOGyB81dpv/LrHVDjve+4+7jZp3m94U2qolpB+3E+beBBuRfiSWgvSpxHnxVxa5 TkwCEPeO8KEbFYR7N3DV8Vh4lh6ae+uC9zAiuR/dltX7VIgcK650m5mgvvJdUGqf/ey0 drQw== X-Gm-Message-State: APjAAAWRUFl5WyspKHpIA7Rj+iAG9Im3NDe6SXDcX8ceTP7z3N0acm4D GSQvVDDIdLzQGw2QYG54yOfQtg== X-Google-Smtp-Source: APXvYqxSUXTBSAtxr7EyxlwJXcDSCBKJw/Gw/OU8s7s/Hcte2ShcoY/EwYvSyhFdzthzFWm5cHrnlQ== X-Received: by 2002:a1c:cfcb:: with SMTP id f194mr25672482wmg.51.1555419485136; Tue, 16 Apr 2019 05:58:05 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Tue, 16 Apr 2019 13:57:27 +0100 Message-Id: <20190416125744.27770-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190416125744.27770-1-peter.maydell@linaro.org> References: <20190416125744.27770-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 Subject: [Qemu-devel] [PATCH 09/26] target/arm/helper: don't return early for STKOF faults during stacking 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Currently the code in v7m_push_stack() which detects a violation of the v8M stack limit simply returns early if it does so. This is OK for the current integer-only code, but won't work for the floating point handling we're about to add. We need to continue executing the rest of the function so that we check for other exceptions like not having permission to use the FPU and so that we correctly set the FPCCR state if we are doing lazy stacking. Refactor to avoid the early return. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/helper.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 297eb38fef0..a2222f84803 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8187,7 +8187,7 @@ static bool v7m_push_stack(ARMCPU *cpu) * should ignore further stack faults trying to process * that derived exception.) */ - bool stacked_ok; + bool stacked_ok =3D true, limitviol =3D false; CPUARMState *env =3D &cpu->env; uint32_t xpsr =3D xpsr_read(env); uint32_t frameptr =3D env->regs[13]; @@ -8218,7 +8218,14 @@ static bool v7m_push_stack(ARMCPU *cpu) armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); env->regs[13] =3D limit; - return true; + /* + * We won't try to perform any further memory accesses but + * we must continue through the following code to check for + * permission faults during FPU state preservation, and we + * must update FPCCR if lazy stacking is enabled. + */ + limitviol =3D true; + stacked_ok =3D false; } } =20 @@ -8227,7 +8234,7 @@ static bool v7m_push_stack(ARMCPU *cpu) * (which may be taken in preference to the one we started with * if it has higher priority). */ - stacked_ok =3D + stacked_ok =3D stacked_ok && v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) && v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) && v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) && @@ -8237,8 +8244,14 @@ static bool v7m_push_stack(ARMCPU *cpu) v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false)= && v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false); =20 - /* Update SP regardless of whether any of the stack accesses failed. */ - env->regs[13] =3D frameptr; + /* + * If we broke a stack limit then SP was already updated earlier; + * otherwise we update SP regardless of whether any of the stack + * accesses failed or we took some other kind of fault. + */ + if (!limitviol) { + env->regs[13] =3D frameptr; + } =20 return !stacked_ok; } --=20 2.20.1