From patchwork Mon Apr 29 17:00:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 163051 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp2139038ill; Mon, 29 Apr 2019 10:08:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0clTCqlr5/n2Htj+JnUwAOGj9ZmFqKl/5fjqoz/Iym/kQxEXpsSsT/3us2hCKhXd0I9lQ X-Received: by 2002:adf:f749:: with SMTP id z9mr25908315wrp.218.1556557717820; Mon, 29 Apr 2019 10:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556557717; cv=none; d=google.com; s=arc-20160816; b=deLkl32TdpRKd9XPbyTSvXPQbIvqiyhKJQvZYlnK3RDof84BI1suUxFnx3nJsU45k8 o0veb2EJmQK/W6QHS9qwUxditMywrlCVwFa75FLCjTUCItvW6/p+NxYaacY/aSD0cOH+ A91ZYdRssznrNL9cNdus3x/rlTPkqX+G6iNR5vE5uJD8oshq3PuoRqCKWsj+N9XMTgQX 6vcAZSD0T3tc8xI2huXbt6gPuFyx4CnFWUC9eKlAQLf1Xa8nF4q+XM6gOVL1dKkjuIGs wwWo4FYD+Wm24exlfK4ZEB5xo0l+Mm/N/UH5bNl6ot0EpIIhbqxyhk8xvMyMfQArv3XT d6lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=LNk5BgsGn2MS4PJAKvZ63GneIJcCBb8awXqH/62zPxI=; b=jiNt0sSaGWgCoYnZ/bl+r/yyWjTWBjL/YE6xS6wLs9qNIqr0TtwjvOZ3WmcD/yPc3d 3Kw7sYz/9iEDGuuGckUumq8q3AUeNKLbq4J3Y1l2UynMIQUx66eXhq+IugSeASl00P+o Lz1n3CL4WL0xQIWE2LdT4TofclYR7iryDIT3h8+F5U10IMBj8CziEr19KMrUpBBrXKcI IkXFIauu3Orclf99uopYK1rPN/lNCZSZysPhFu77AS3KD+u0p+i0eC8TO73baJ6UNuxL 1Hv60/3b2llK7qrFQc5W6xCO57HibezaWKKGZ8hpCRQn4OfdTXdgGGT1i4Vt6cH1eH/A Rw/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lLskodHS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x7si655357wrw.342.2019.04.29.10.08.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 29 Apr 2019 10:08:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lLskodHS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:60687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hL9lc-000201-NF for patch@linaro.org; Mon, 29 Apr 2019 13:08:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hL9eV-0004Wh-N8 for qemu-devel@nongnu.org; Mon, 29 Apr 2019 13:01:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hL9eS-0006aN-4K for qemu-devel@nongnu.org; Mon, 29 Apr 2019 13:01:14 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:51173) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hL9eK-0006RW-GN for qemu-devel@nongnu.org; Mon, 29 Apr 2019 13:01:06 -0400 Received: by mail-wm1-x32b.google.com with SMTP id p21so186918wmc.0 for ; Mon, 29 Apr 2019 10:00:55 -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=LNk5BgsGn2MS4PJAKvZ63GneIJcCBb8awXqH/62zPxI=; b=lLskodHS+aoOfkWKD38C0roDblJkHi/RdukuFq2vlmfq48r2N40TwKRZgnclcoN3ID 6HVMqwg4pGY4e73ceQ+FERdAiyzF4S5M7lboW5YqC4W/ikeEtl674k1jJfLRVqrUA+Mg XDkHWm9z6nMaZOcmFz9X3j6GVF8ihFiX3PvE4V6YlxfUxcC70A+/qEb7QIe1+gAl43zI QhkQW4RR7qtBLwUNd+3D8oDtvasDV49QpLUq5GbpC8UEYblOei/h1tc5rwDOHYcUXSSn E4hoCsEFmJSD7OFmj8M9Xz1rSx0s5NcvVjPUkyB8lI2lNG+OUb2KJ7fhVrN3L8RZBkzq sJUg== 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=LNk5BgsGn2MS4PJAKvZ63GneIJcCBb8awXqH/62zPxI=; b=Mn5v2g+oWkYhVAUeKD+H7m0v12c6CeYE5AYLIQ+Yro1p9INg6+gqYgj8IoVy/3h2Rk CS0xOU8pVV5+r+HUwBmzzfB5/pS+Gg62HI3dO2h70XgNu8qHtGDWVas0nfAIxUueYb9L iSeIw3RmdNDsrTDD0WLE/V3NMTvygDpwvDa6dll9qIlNWNsaIc9I8Wzeitkz5UId+7WO UCxpOhZXJD8rEs+m+qH5cSns0pWf2L7K0+Bhi3xyxfsARdPM86/ZyyFOVPRYVp4dZ0Uo LXzwTy0/uwqSLsu3lvaU7W7N6U/kAodAW4IS3zN1SSEzdUvLULhR6II9Xzr4426E+suN 6D6Q== X-Gm-Message-State: APjAAAWJM5uTJ8Ojx4EiutzknGxX6yguzfqvn9a7FTLUhcV3/pXJZpYr QBhBpk6Ok6JPeKMff7xVnVcRv5MgMW0= X-Received: by 2002:a1c:4d04:: with SMTP id o4mr44261wmh.126.1556557254084; Mon, 29 Apr 2019 10:00:54 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a13sm36896wmj.39.2019.04.29.10.00.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 10:00:53 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 29 Apr 2019 18:00:05 +0100 Message-Id: <20190429170030.11323-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429170030.11323-1-peter.maydell@linaro.org> References: <20190429170030.11323-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32b Subject: [Qemu-devel] [PULL 17/42] target/arm: Allow for floating point in callee stack integrity check 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The magic value pushed onto the callee stack as an integrity check is different if floating point is present. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20190416125744.27770-15-peter.maydell@linaro.org --- target/arm/helper.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index da0b6202400..c7b1a8d231d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7979,6 +7979,21 @@ load_fail: return false; } +static uint32_t v7m_integrity_sig(CPUARMState *env, uint32_t lr) +{ + /* + * Return the integrity signature value for the callee-saves + * stack frame section. @lr is the exception return payload/LR value + * whose FType bit forms bit 0 of the signature if FP is present. + */ + uint32_t sig = 0xfefa125a; + + if (!arm_feature(env, ARM_FEATURE_VFP) || (lr & R_V7M_EXCRET_FTYPE_MASK)) { + sig |= 1; + } + return sig; +} + static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, bool ignore_faults) { @@ -7993,6 +8008,7 @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, bool stacked_ok; uint32_t limit; bool want_psp; + uint32_t sig; if (dotailchain) { bool mode = lr & R_V7M_EXCRET_MODE_MASK; @@ -8034,8 +8050,9 @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, /* Write as much of the stack frame as we can. A write failure may * cause us to pend a derived exception. */ + sig = v7m_integrity_sig(env, lr); stacked_ok = - v7m_stack_write(cpu, frameptr, 0xfefa125b, mmu_idx, ignore_faults) && + v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) && v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx, ignore_faults) && v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx, @@ -8640,12 +8657,11 @@ static void do_v7m_exception_exit(ARMCPU *cpu) if (return_to_secure && ((excret & R_V7M_EXCRET_ES_MASK) == 0 || (excret & R_V7M_EXCRET_DCRS_MASK) == 0)) { - uint32_t expected_sig = 0xfefa125b; uint32_t actual_sig; pop_ok = v7m_stack_read(cpu, &actual_sig, frameptr, mmu_idx); - if (pop_ok && expected_sig != actual_sig) { + if (pop_ok && v7m_integrity_sig(env, excret) != actual_sig) { /* Take a SecureFault on the current stack */ env->v7m.sfsr |= R_V7M_SFSR_INVIS_MASK; armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);