From nobody Sat May 10 00:37:18 2025
Delivered-To: importer@patchew.org
Received-SPF: pass (zohomail.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=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass(p=none dis=none)  header.from=linaro.org
ARC-Seal: i=1; a=rsa-sha256; t=1574777652; cv=none;
	d=zohomail.com; s=zohoarc;
	b=Gd7fzZXLW5P1FWCTrrputtjCEg1x8aASVWpjn5vbMOlql1H0Dd3V2F7CPrM2riB80zG8fNXIcN+DkuriJtgXD7JPd+ovR776BwEX1F705w9mABRNlTgMrwUPqy1gKH40RGrsrayVfamgnyIWocti19RHdJnM0skcuj0x4b9zvIQ=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1574777652;
 h=Content-Type: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;
	bh=Er5f9rC8C8GOvtgbGPLP84tJvHsrIKrKDE2TS/iWzsk=;
	b=PXzAzR3Q0JsOd9PbVhTLxJn2GN+OrzNnYV5Go3TGSvM6DvKsppxzhFuWFUN70jn+rKGLXzv6Cz6QkDWCEHYe5TbS5UflYK6uLFnFQdXugG2LKQJHa9sjNN9CVviqBj/3wYz2WWAFgd+2PuBU2oEXDirYHT7bxvh0/puwNbL9SnM=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass header.from=<peter.maydell@linaro.org> (p=none dis=none)
 header.from=<peter.maydell@linaro.org>
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 15747776528271008.2405758295756;
 Tue, 26 Nov 2019 06:14:12 -0800 (PST)
Received: from localhost ([::1]:55616 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1iZbbW-0008Oo-U8
	for importer@patchew.org; Tue, 26 Nov 2019 09:14:10 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:47101)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <peter.maydell@linaro.org>) id 1iZbaA-00078t-7W
 for qemu-devel@nongnu.org; Tue, 26 Nov 2019 09:12:47 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <peter.maydell@linaro.org>) id 1iZba9-0005kz-0o
 for qemu-devel@nongnu.org; Tue, 26 Nov 2019 09:12:45 -0500
Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:51943)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <peter.maydell@linaro.org>)
 id 1iZba8-0005kO-Qs
 for qemu-devel@nongnu.org; Tue, 26 Nov 2019 09:12:44 -0500
Received: by mail-wm1-x342.google.com with SMTP id g206so3393114wme.1
 for <qemu-devel@nongnu.org>; Tue, 26 Nov 2019 06:12:44 -0800 (PST)
Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148])
 by smtp.gmail.com with ESMTPSA id i127sm3364581wma.35.2019.11.26.06.12.42
 for <qemu-devel@nongnu.org>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 26 Nov 2019 06:12:42 -0800 (PST)
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=Er5f9rC8C8GOvtgbGPLP84tJvHsrIKrKDE2TS/iWzsk=;
 b=l4Vw1Mu7s5FmEufBZTSgO2m0KdYjVROitAgPcLcUO19ujTQtQqRc5NGrl/Yl7KNKZd
 T9LKB+cU5A9g1+af80BZtPTPz+/x3r+LYt7CoGNWolzQMS/KrZiZ2cBXCK2AUNuQjr7m
 iCkH5P/IGVD7TPd5DqbPaRM9ZJ/T5wP3ukXMj+AJ2SlqU0TiRzxJbH7XmWFF/EhfAmsB
 ee57Fd5YAH9pe1xGqscJ6yOs//cMNUFr92+XCr16ecct99xyd2LbMdx3eY4pMPaqFIq8
 dWWnfZwXw5xAPVvtdDnVsZbi432pz0dmZN797UIt0CV/wa4VgMk48CnfC4gvcJG4VPzA
 1WGA==
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=Er5f9rC8C8GOvtgbGPLP84tJvHsrIKrKDE2TS/iWzsk=;
 b=BsEQlxWPGSaVtN4giRmFy+PJ/N0jth4nDHWIcWAAtwyoGKwv2x8UGET7NyG0xyQLu2
 FaX+ARx3bRmRdDx9Oa/yCUxpDrAHnP+B9VUHpUchw1f5LrgGGKB5shg6nngRlB/F9P9H
 UA5Y1peiCr3jsOeHLVgKstsA0wAQi5OlXky+1+Q3igLMtuf+vLBueQB3ta8eAjVG1cAM
 TH3gSsGni2gWxynaLlyymirSsNUxKdi0xYVRUmY5VSkSR+yRrYZp7p/xLlqoIZzKuSP+
 oje98y/Ueiv8Y/wupX6b47CHheRQXe8FKJMXOO3F1x2rbWu2CKHL0dXlHymXP6oB66ju
 amHA==
X-Gm-Message-State: APjAAAVysibkUcAYLnjoU+lKAyY61nwKu2tj6FKTqpDcTt3VXPN0W2W9
 /Of/A0xpI4+KmYwRD+icaBGCsyRHEj4=
X-Google-Smtp-Source: 
 APXvYqz5wSSeUsoOdGmQmfpLpuwrHBEIqwb38Hwd8nSaM80vIY3fnX1qDixh6aRknK0+zRTt9T3Z6w==
X-Received: by 2002:a05:600c:218e:: with SMTP id
 e14mr4268611wme.22.1574777563506;
 Tue, 26 Nov 2019 06:12:43 -0800 (PST)
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 1/4] target/arm: Fix handling of cortex-m FTYPE flag in EXCRET
Date: Tue, 26 Nov 2019 14:12:36 +0000
Message-Id: <20191126141239.8219-2-peter.maydell@linaro.org>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20191126141239.8219-1-peter.maydell@linaro.org>
References: <20191126141239.8219-1-peter.maydell@linaro.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
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::342
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: pass (identity @linaro.org)

From: Jean-Hugues Desch=C3=AAnes <Jean-Hugues.Deschenes@ossiaco.com>

According to the PushStack() pseudocode in the armv7m RM,
bit 4 of the LR should be set to NOT(CONTROL.PFCA) when
an FPU is present. Current implementation is doing it for
armv8, but not for armv7. This patch makes the existing
logic applicable to both code paths.

Signed-off-by: Jean-Hugues Deschenes <jean-hugues.deschenes@ossiaco.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target/arm/m_helper.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
index 4a48b792520..76de317e6af 100644
--- a/target/arm/m_helper.c
+++ b/target/arm/m_helper.c
@@ -2233,19 +2233,18 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
         if (env->v7m.secure) {
             lr |=3D R_V7M_EXCRET_S_MASK;
         }
-        if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) {
-            lr |=3D R_V7M_EXCRET_FTYPE_MASK;
-        }
     } else {
         lr =3D R_V7M_EXCRET_RES1_MASK |
             R_V7M_EXCRET_S_MASK |
             R_V7M_EXCRET_DCRS_MASK |
-            R_V7M_EXCRET_FTYPE_MASK |
             R_V7M_EXCRET_ES_MASK;
         if (env->v7m.control[M_REG_NS] & R_V7M_CONTROL_SPSEL_MASK) {
             lr |=3D R_V7M_EXCRET_SPSEL_MASK;
         }
     }
+    if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) {
+        lr |=3D R_V7M_EXCRET_FTYPE_MASK;
+    }
     if (!arm_v7m_is_handler_mode(env)) {
         lr |=3D R_V7M_EXCRET_MODE_MASK;
     }
--=20
2.20.1