From patchwork Mon Nov 20 12:37:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13461193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8099C54FB9 for ; Mon, 20 Nov 2023 12:40:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=erdP9KX4lImTvLUKRiwiyfwoU3Crj94xUB4O+oKX45o=; b=xKyW2QMah6Wdsw 0Kzu5c7o0H2pSDCofmwqqoQURZcSBOxA74Pl77xwE+1+xDK1ccfRX53JU3pGczWjeXV4VFbrY+vL1 /wA7qnQbb/R43/z73YFhYTNQZs6iB/d2p81JzNO+xThatL32DnWQ3sCDjQjmsCMZTU9+lcAzPnDKI samPLHVeA9aAWRMQVdtKVRU29J1++rKYZHSdOpl3FmV7Rdso0OFQUPK/4ZJwKbja4jIRkFlIw++Hz BA02PASo7F2QSVn8C3DL14D3PHg709omB27eH6M4ONY4JdyIegGgY7arvGM+lKwj6rrKbiWVcdpem Po7gZfsWIZExiL0FeIaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r53Z0-00C1OQ-2d; Mon, 20 Nov 2023 12:39:42 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r53XC-00C0yJ-01 for linux-arm-kernel@lists.infradead.org; Mon, 20 Nov 2023 12:37:56 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1129A6123E; Mon, 20 Nov 2023 12:37:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B982CC433CC; Mon, 20 Nov 2023 12:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700483867; bh=J11CtFVHtqBhTKJa3YGjPeX49bSAPr/MKFFq1o+SJc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KdkvXORB6GX0oMhAbwziRyLprTu3HSP5BlVEy+t4jcBGouRRAjGYWvWdPPKGj1XcT TZfRI6KWQDZEbETCGu3EdJ2W80ejyHCFetWhV/P9fAI4+3Btob5aeL7qX/vzksZr8J AHFtEvMqAUHmtQxTqh054dZO+QBjAEDI/wR+lY9uJmZJ9i5E1Ab2EqYvirTtEwyO31 mS2yzwL/jJeX/3quTKXkY404juCUULmCue2w1NmQgDO/wYribUiymx5rRS6jbdSNQ8 j2GrZejq2oZZTqgkKqsjCnvwsimha+pjsB/4mebGVdwZNpaxaP78Qr1b8EAxL2Zs1Z DcBKkua4rAGdg== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1r53X7-00EjJv-QZ; Mon, 20 Nov 2023 12:37:45 +0000 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu Subject: [PATCH v2 10/13] arm64: Add MIDR-based override infrastructure Date: Mon, 20 Nov 2023 12:37:18 +0000 Message-Id: <20231120123721.851738-11-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231120123721.851738-1-maz@kernel.org> References: <20231120123721.851738-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, ardb@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231120_043750_170671_A029A5E6 X-CRM114-Status: GOOD ( 12.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In order to be able to use the override infrastructure to "fix" CPUs that have deviated from teh architecture spec, add a new pile of hacks on top of the existing one, allowing a feature to be overriden based on matching a MIDR list. Signed-off-by: Marc Zyngier Reviewed-by: Suzuki K Poulose --- arch/arm64/kernel/idreg-override.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c index 7b5b9dc20e6b..57c145bf50b7 100644 --- a/arch/arm64/kernel/idreg-override.c +++ b/arch/arm64/kernel/idreg-override.c @@ -321,6 +321,23 @@ static __init void parse_cmdline(void) __parse_cmdline(prop, true); } +struct midr_override_data { + const char feature[FTR_ALIAS_OPTION_LEN]; + const struct midr_range ranges[]; +}; + +static const struct midr_override_data * const midr_ovr_data[] __initconst = { +}; + +static void __init apply_midr_overrides(void) +{ + const u64 midr = read_cpuid_id(); + + for (int i = 0; i < ARRAY_SIZE(midr_ovr_data); i++) + if (is_midr_in_range_list(midr, midr_ovr_data[i]->ranges)) + __parse_cmdline(midr_ovr_data[i]->feature, false); +} + /* Keep checkers quiet */ void init_feature_override(u64 boot_status); @@ -337,6 +354,8 @@ asmlinkage void __init init_feature_override(u64 boot_status) __boot_status = boot_status; + apply_midr_overrides(); + parse_cmdline(); for (i = 0; i < ARRAY_SIZE(regs); i++) {