From nobody Tue Feb 10 09:27:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664114114144730.7292896800282; Sun, 25 Sep 2022 06:55:14 -0700 (PDT) Received: from localhost ([::1]:41208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocS6C-00084M-PL for importer@patchew.org; Sun, 25 Sep 2022 09:55:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocRzZ-0002YK-Ih for qemu-devel@nongnu.org; Sun, 25 Sep 2022 09:48:22 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:59892) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocRzX-0001FE-Uq for qemu-devel@nongnu.org; Sun, 25 Sep 2022 09:48:21 -0400 Received: from [2a00:23c4:8ba7:8700:f0a2:2ba9:489e:6915] (helo=kentang.home) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ocRxm-0008Ik-O9; Sun, 25 Sep 2022 14:46:34 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=sLNk4fhMeQpFG+J5nKFN3DS77fn3aanljfTSgAMGm/w=; b=YxWAUf3W+NdhCIzNAuNtmJaDbp mKA9FBj3xgyQuwCF4FFxrVbIJzH6yl+lPrUMLA65yxi8sF9m5I1rpBlob7/kYKA6V4iv2FtgdmCc1 SCAxwiCC62sDQeVtwxvkjWNgH6gmuToQ3mkG12TzusBq2yZx8IP0wTnYEpS3l0t/JrXBZIIEeeWvz LTM8bVQquVUupAO/yPt1QoPqwpI9KuIkLZQ1QU92BdV821iQwCwpMS9oD+5TrpNCDAIe2cQUfn4hz dT+HhZXd65WSxWOrO4NuFrV4ifBDp71fhBJ8aZBVPaovC3Pdf1Q+I0xaKMfKLjZ+q14FudjLfeCmu pSTYwl+4acQLQnX3J2vJ4PfDGuOADmPYU9Z0ozTjWr6hgdNKfCK6FvA2ZLItlZ3pfmxeQPj9HKb+z F8BvunxVz0QlEnX2mstth3YHVgf77O4rMQm8u0tfRjT6RmM38/4qYHIQHM9jjg+Zfto3LCgD6t6XU ogwq1BXVADLsRbHBu1Zks8edykqF7i+STIG/TvkF/VOpbpe7Wolcp4Fgrutbgfm+/W8/aaw3lVy8C ZVfVbabxep2MkUneIeqefzK4wO3yOnYPed00fJGufK8YVu70/K1j5ZA9C4aiD1Mtcqs3Pgj7Solbx kbLpy+Aaeyw5JNQ82GhzMyt5Uky8etj/ndiGaWqWM=; From: Mark Cave-Ayland To: laurent@vivier.eu, richard.henderson@linaro.org, lucienmp.qemu@gmail.com, qemu-devel@nongnu.org Date: Sun, 25 Sep 2022 14:48:03 +0100 Message-Id: <20220925134804.139706-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220925134804.139706-1-mark.cave-ayland@ilande.co.uk> References: <20220925134804.139706-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8ba7:8700:f0a2:2ba9:489e:6915 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 1/2] target/m68k: increase size of m68k CPU features from uint32_t to uint64_t X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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) X-ZM-MESSAGEID: 1664114115380100001 Content-Type: text/plain; charset="utf-8" There are already 32 feature bits in use, so change the size of the m68k CPU features to uint64_t (along with the associated m68k_feature() functions) to allow up to 64 feature bits to be used. At the same time make use of the BIT_ULL() macro when reading/writing the CPU feature bits to improve readability, and also update m68k_feature() to return a bool rather than an int. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/m68k/cpu.c | 4 ++-- target/m68k/cpu.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index f681be3a2a..8d23c72056 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -38,12 +38,12 @@ static bool m68k_cpu_has_work(CPUState *cs) =20 static void m68k_set_feature(CPUM68KState *env, int feature) { - env->features |=3D (1u << feature); + env->features |=3D BIT_ULL(feature); } =20 static void m68k_unset_feature(CPUM68KState *env, int feature) { - env->features &=3D (-1u - (1u << feature)); + env->features &=3D ~BIT_ULL(feature); } =20 static void m68k_cpu_reset(DeviceState *dev) diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index 67b6c12c28..f5c6e95cb4 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -154,7 +154,7 @@ typedef struct CPUArchState { struct {} end_reset_fields; =20 /* Fields from here on are preserved across CPU reset. */ - uint32_t features; + uint64_t features; } CPUM68KState; =20 /* @@ -539,9 +539,9 @@ enum m68k_features { M68K_FEATURE_TRAPCC, }; =20 -static inline int m68k_feature(CPUM68KState *env, int feature) +static inline bool m68k_feature(CPUM68KState *env, int feature) { - return (env->features & (1u << feature)) !=3D 0; + return (env->features & BIT_ULL(feature)) !=3D 0; } =20 void m68k_cpu_list(void); --=20 2.30.2 From nobody Tue Feb 10 09:27:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664114358698513.1752101771629; Sun, 25 Sep 2022 06:59:18 -0700 (PDT) Received: from localhost ([::1]:34456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocSA9-0006Mv-18 for importer@patchew.org; Sun, 25 Sep 2022 09:59:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocRzf-0002ZK-8D for qemu-devel@nongnu.org; Sun, 25 Sep 2022 09:48:28 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:59900) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocRza-0001Fd-Vi for qemu-devel@nongnu.org; Sun, 25 Sep 2022 09:48:25 -0400 Received: from [2a00:23c4:8ba7:8700:f0a2:2ba9:489e:6915] (helo=kentang.home) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ocRxq-0008Ik-V5; Sun, 25 Sep 2022 14:46:39 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=zztYg6x3Bs72i/QAzx8FyrQ606it2GE2m2edgf/2bUc=; b=kXdwdUSJ3ISMADrqCMgmD4L4ci 7E6U0ancZJ59CZJCiFp0TDagtk9lMp3axu+7vzrYvCNkpdPREcNTdcLuX4IC+5hIPXEM40N9PHJId FVFTFtyXBjRxjHy0EhJi4UfeVO3caMkE3lR6AfTY/j2AlLxKYbb45FqXnYcXoUc6Gs82E0eFEU/kq K5u9Q46ZWhxuTN+LU4SRp7jv/vW2UExNWkazVxQvaEuiCtRRQqFFJRv6e/2u25EofbJyDLA0z0TpM 10fFHGZ+8nQ/ap6WRNFqxvz6gS5e1yGzuZiw8nqaVc4GFqj4d2mI+79YTcN7H9Ic/zRHlVRpHR1YZ RZsCMcQjDxLNFEXGmQePCQyDGqbXcQVU1PnS3uFTUtR6MJCJPpdPP0itL746QyGObxbEd86iAreFv 7Glu9yFBgRKWR8OsnKHaORtgnxPZcLbRJasjAalUmpz6pw+ujnMfCqDREimDxDBRVaFj28q0X3uWE pdNp84VqrQS5TqZlpsYd8wX+vdbCZoI6yC+hJAFyWtbQRbkAzW3qSWvoEFBCFzVXssMTwiXfquIIY XuU4WnF65dAS8oikPMQMN6ZO3WpFJ0y6brbLe4/hl6BbXw0G9KVFSQEFN4X5H5n50wT1ndIAjuHLw Ue+hZ0N8vzlgCye1bIhY4fBbrtVGsqV/Bmp4kpUkw=; From: Mark Cave-Ayland To: laurent@vivier.eu, richard.henderson@linaro.org, lucienmp.qemu@gmail.com, qemu-devel@nongnu.org Date: Sun, 25 Sep 2022 14:48:04 +0100 Message-Id: <20220925134804.139706-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220925134804.139706-1-mark.cave-ayland@ilande.co.uk> References: <20220925134804.139706-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8ba7:8700:f0a2:2ba9:489e:6915 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 2/2] target/m68k: use M68K_FEATURE_MOVEFROMSR_PRIV feature for move_from_sr privilege check X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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) X-ZM-MESSAGEID: 1664114360627100001 Content-Type: text/plain; charset="utf-8" Now that M68K_FEATURE_M68000 has been renamed to M68K_FEATURE_M68K it is ea= sier to see that the privilege exception check is wrong: it is currently only ge= nerated for ColdFire CPUs when in fact it should also be generated for Motorola CPU= s from the 68010 onwards. Introduce a new M68K_FEATURE_MOVEFROMSR_PRIV feature which is set for all n= on- Motorola CPUs, and for all Motorola CPUs from the 68010 onwards and use it = to determine whether a privilege exception should be generated for the MOVE-fr= om-SR instruction. Signed-off-by: Mark Cave-Ayland Reviewed-by: Richard Henderson --- target/m68k/cpu.c | 5 +++++ target/m68k/cpu.h | 2 ++ target/m68k/translate.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 8d23c72056..25d610db21 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -102,6 +102,7 @@ static void m5206_cpu_initfn(Object *obj) CPUM68KState *env =3D &cpu->env; =20 m68k_set_feature(env, M68K_FEATURE_CF_ISA_A); + m68k_set_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV); } =20 /* Base feature set, including isns. for m68k family */ @@ -129,6 +130,7 @@ static void m68010_cpu_initfn(Object *obj) m68k_set_feature(env, M68K_FEATURE_RTD); m68k_set_feature(env, M68K_FEATURE_BKPT); m68k_set_feature(env, M68K_FEATURE_MOVEC); + m68k_set_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV); } =20 /* @@ -241,6 +243,7 @@ static void m5208_cpu_initfn(Object *obj) m68k_set_feature(env, M68K_FEATURE_BRAL); m68k_set_feature(env, M68K_FEATURE_CF_EMAC); m68k_set_feature(env, M68K_FEATURE_USP); + m68k_set_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV); } =20 static void cfv4e_cpu_initfn(Object *obj) @@ -254,6 +257,7 @@ static void cfv4e_cpu_initfn(Object *obj) m68k_set_feature(env, M68K_FEATURE_CF_FPU); m68k_set_feature(env, M68K_FEATURE_CF_EMAC); m68k_set_feature(env, M68K_FEATURE_USP); + m68k_set_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV); } =20 static void any_cpu_initfn(Object *obj) @@ -275,6 +279,7 @@ static void any_cpu_initfn(Object *obj) m68k_set_feature(env, M68K_FEATURE_USP); m68k_set_feature(env, M68K_FEATURE_EXT_FULL); m68k_set_feature(env, M68K_FEATURE_WORD_INDEX); + m68k_set_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV); } =20 static void m68k_cpu_realizefn(DeviceState *dev, Error **errp) diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index f5c6e95cb4..3a9cfe2f33 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -537,6 +537,8 @@ enum m68k_features { M68K_FEATURE_UNALIGNED_DATA, /* TRAPcc insn. (680[2346]0, and CPU32) */ M68K_FEATURE_TRAPCC, + /* MOVE from SR privileged (from 68010) */ + M68K_FEATURE_MOVEFROMSR_PRIV, }; =20 static inline bool m68k_feature(CPUM68KState *env, int feature) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 233b9d8e57..9df17aa4b2 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -4624,7 +4624,7 @@ DISAS_INSN(move_from_sr) { TCGv sr; =20 - if (IS_USER(s) && !m68k_feature(env, M68K_FEATURE_M68K)) { + if (IS_USER(s) && m68k_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV)) { gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE); return; } --=20 2.30.2