From patchwork Mon Nov 18 18:16:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 13878944 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 CBCC6D591AC for ; Mon, 18 Nov 2024 18:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=CMy6CyGxIl2yyFuR4S4pWWa5p+rMXlhUtz651DwcqwQ=; b=zwyf0RhnDCVVhD05Dm5HtfGtf2 7McAtYeBZEPWsKsg/jNJGTv9kjJfU2zODvb101gJGAazkqjzG6YtJp+k6Ki+MRfsqZlgFGspD2hFo zy+zCN9La9scVaLDfsFvTUKtAmpv6EWjOQ/eu8JOt2zjsu6wM73hKi1isS9DfmHmX8jF/5M5TNxVS EA4S9Z7CAwDaHonfmgllYRc4lm9Ew7Wq1TJjbJbjbXpB8759piJyMEGMxrUouZxZ4mr8MQHw+mfD/ BrOCcRfUx2xRpjJS7Ll7/EpFUV6oB8zZFDcuusCbTUqswtmHfxu7CEdUsS/vLFJkag/D/JpR9NnK0 UVWZTuuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tD6NP-0000000AKFl-07FQ; Mon, 18 Nov 2024 18:21:31 +0000 Received: from mail-mw2nam10on20715.outbound.protection.outlook.com ([2a01:111:f403:2412::715] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tD6K0-0000000AJeq-00F4 for linux-arm-kernel@lists.infradead.org; Mon, 18 Nov 2024 18:18:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Hi7zeUyZqqupLF2Eo13vUeAYErRz/DDn8XpdwzPIKT//WjNAsXsL4qFo+x/xSZVY7cQuMENtOpwWQ1nOdSEYniAkox7NP+yKyW0SB+AFfH3BAZ4gQZ713nBNVg9Oq/kLfny6+rPj+a9ctCFBSC64AQckZH0V/9Wu0hnxchYHdu7lhGJWg0uJ+oCao3bO0x7blK9TNwAbEMhx4fElTaFR6zNCtqYywDsc9kG3lMfraZY5eb1CezmhfS/2V+k4LDTD6bBdrB9/35YvuaJUWmLZIzowHVpHZE+jxkKYd15nLjj7yuciyCSD1Anqb7bgvJkwFyCr97Lbpk8AlmRBfQ6m5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CMy6CyGxIl2yyFuR4S4pWWa5p+rMXlhUtz651DwcqwQ=; b=U9TDf9H+JuKlyCMcCGFkitK8uqFAkNnqHQ+LC+8aD/PjfmjYXfMyfg/DIAv2TrTOaRUgYj2BwzJ9WoWVFGA0i68q0+RpaOFq+3umbTMkUETGj8jMIopN96FCGRrMshNBnbj8cOBqIlUBKX8ARZlNNb1OT3pUAOeycxYpC594aa3//paUCUd1cnNoFBBkx2SkUel20LMAIqGhsfW2cGqxUCLS86T0NDIbrKEzBvDKwujhavhbIi5U7VAcRQou14XU6PBuSHb00euNfOfy8gJNznd8eTRZ9Ohkz0v/WkF0uoD1WpCJe5zOmPBxGt8FyRNixZdiB5OQx1cT3Rs9+/hBJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CMy6CyGxIl2yyFuR4S4pWWa5p+rMXlhUtz651DwcqwQ=; b=JYLYKSNz6fD0PyStP2uk0RcgebJJRAacERu9FX7RtjCpccxSgRDJSe3WFVGDaw9fRD/P14nMTu+2D/8I1Kl3CNbux4ckzLugJr8onIa1bTr8I5DqiSHf9hlE5oTDEargi9uEgM2cuHfSdqLl+JPydBK5X5AS9blXTNFX20i33tU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB6873.prod.exchangelabs.com (2603:10b6:610:112::22) by CO1PR01MB6694.prod.exchangelabs.com (2603:10b6:303:f5::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.13; Mon, 18 Nov 2024 18:17:41 +0000 Received: from CH0PR01MB6873.prod.exchangelabs.com ([fe80::3850:9112:f3bf:6460]) by CH0PR01MB6873.prod.exchangelabs.com ([fe80::3850:9112:f3bf:6460%4]) with mapi id 15.20.8182.013; Mon, 18 Nov 2024 18:17:41 +0000 From: Yang Shi To: catalin.marinas@arm.com, will@kernel.org Cc: cl@gentwo.org, scott@os.amperecomputing.com, yang@os.amperecomputing.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] arm64: cpufeature: workaround AmpereOne FEAT_BBM level 2 Date: Mon, 18 Nov 2024 10:16:10 -0800 Message-ID: <20241118181711.962576-4-yang@os.amperecomputing.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20241118181711.962576-1-yang@os.amperecomputing.com> References: <20241118181711.962576-1-yang@os.amperecomputing.com> X-ClientProxiedBy: CH0PR13CA0038.namprd13.prod.outlook.com (2603:10b6:610:b2::13) To CH0PR01MB6873.prod.exchangelabs.com (2603:10b6:610:112::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB6873:EE_|CO1PR01MB6694:EE_ X-MS-Office365-Filtering-Correlation-Id: e78287f5-fcf0-4a65-e06a-08dd07fd4a99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: P1gMl1sy1BiyWADik0Ii2kIoNw3t4O8mH8WT49zKqcICZVBIEwH0cwFHAJQP2h3vU0lK4qQsplUdpyhuivL7MEWYOllIhG+6fI3ln97CFzi+b9S43EUEDQ+sluhk07xTExiNhif3Y/T65zYTGbHIlM1cKjcwBOSPgiBr+1gEirn2LTVqj57+Zc62TFGw0+2kMEfe1zb2LRDF8xCtnbhMlmDfv8m7Tm+OkHK3tlAL4Zzf4PalYxIjGDysqNWNhyJJV+K1GmaFshhWt9X4mvhVX1kVsqPlOaAd+bhAtqoPWWV7HfA7r8Qoqgovzj0tc1PBEEejBVnRzg4j4ZSVS3YmZZI7fe21DJfeO5+tllydJ/runcbBJN+svuGcZeaLkMpVrGHSPv7IAWUJ5pWjsfpoJLfOl3dpvB7LAHt+A2NLVA7XE5i0eTBxzmKKSal+pbwOVee3cueKrsRYBggDpLeW4o7I9XY/TaMsB/tzIsVpOwfMmr0fXThsx4NYXD1+117hJLixZ7J2nowGtyHZZS71O9C7CbkQw+fz0PgcbHQHmqrrY924PwVGZvxCBl+yO/4wLdJ7BbBiU8RUPbT+6v0jjDGLUWyOcMAGkxE2KsQnnm/DgiyNrb/nq1QOiu6oeyouRCjUzQZ7Qd+xR9DrNh0FpI1uDk3V/uR4Eisn1irAmR17MnFqk8mBwnAyEcoqZyMbPVkWaWYT6OgN6xoStLfFpQV8k0aagBQxn6wiC7bRJvW0uqx28daowZqMLtZqd3zVFRwWnu2hNYohK0HazgOMl5qKFYePznPGRppkq2K2Aq8SDxISsxlcBGkaA9wB4UH/Q5V4nrLBqcxsw31524O0kzrgaalLKxEKcG5CBhn1dRSJN5GBJIxFYf5Ftlrrrdmp0uv6qMlnDfCuRqMnJGW6jAEuuhCNq3lYjiF+lbnuTIFL58rMjaR1IKumC6OvE7HKQUyQME2iPFlgvr4Be+5vlBTXvki1dPIMV9g3iO6Yod4ZkRezh5ikVm2aRaCtlPAInTm9OmWvqAaCs8r+GVC/OU9Pz0i2DhE1g8t3iiqE2BjEZgn0GMFzI24dBOTEjx2GR6DOmxPb0gLexH5X3JtXaubkj1XpN1OdeLY0eS9yQLuNGMZC5F7yA07/A1iRTavugnK+3j5QEmHxZM8ZEoT3phzSFQVucGf5vYSRCG1pcKepzOJZfJ126ipKD7eOiUgLLv4h6gRE2befFCrgQN/dv7MHz0MWAiZtruK2TmykHfqm1oxnE5FvVYuqX0veygaDOX1rBxzkwAGLVUlMh2CvmxGgQvw2d/h8/cqV+YLDsTkL8a8lQup/5iUwh3h4/QVn/VPUoonNIwJIqRN5nxVAsYjXktVsuilSunPs2FgmxjQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR01MB6873.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9X/xPXVQ9qv6qgJ2Vp/i1qBP3x9nIfwPp+GeKpsyxHe8+/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+Ppj8NtG12b8ecczagGwfqSx5H7e/fUH7oGo6iduz0B7wPgfXOUaZV5mxenNgltqCfiI8bUvNojIyTFfhsCpkQg4B+PqLTUNEAeMfpUKWStBKgKH1NYvd9RF2K6vngaQaPSS5XkZ5lbXGOFboiHSZ5EnNFbPPyfrQC1nmZ9aNj2hOpiMhFOeu52NZjyO+VIZULwWFYle5u5KSqc60OvDXBgJHQnG5T309UVnz+aOdoKarxziMzU7mIUMytetmpH6MaOFNx9g/y7MNlVoHUx/IzN1UhBZC7evlSz59qUKYJ46znExdE+WmpH8QOiTCQzMxDEP5SOfLTA9SzQnDsDbg0lkFmZq5624bDnnDv7VGcKVU132uZFIwWPptC7vv222kNb0V37VBBv3FJj/tdAWXfUKiWMWVVVnr/YRlw71dtWyyWCJ7nat4sZ4hrJgCuyJ6SRTGo9p6wy0Z8iKuyeV3Bcn0IHzkdJZnMCSgSTCviB+VnTp85lfpY5tnXhCYqEdMHE= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: e78287f5-fcf0-4a65-e06a-08dd07fd4a99 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB6873.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 18:17:41.7273 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7hQsEjbUiLQHeNv3BEQsI7d+IbcUReWIfRKKcg4RKdI4P36VUchiI/6dUAiCSWixfE8rKzo/TKdeuHU81wVIXcSuP8aFRqezXzFTiB8bT04= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR01MB6694 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241118_101800_036015_5D09970F X-CRM114-Status: GOOD ( 10.20 ) 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 FEAT_BBM level 2 is not advertised on AmpereOne because of a bug when collapsing stage 2 mappings from smaller to larger translations. That doesn't impact splitting stage 1 mappings (whether stage 2 is enabled or not), so workaround it by detecting CPUID. Signed-off-by: Yang Shi Reviewed-by: Christoph Lameter --- arch/arm64/include/asm/cpufeature.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index c7ca5f9f88bb..d9b20eb43d31 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -847,10 +847,19 @@ static inline bool bbmlv2_available(void) { u64 mmfr2; u32 bbm; + static const struct midr_range ampereone[] = { + MIDR_ALL_VERSIONS(MIDR_AMPERE1), + MIDR_ALL_VERSIONS(MIDR_AMPERE1A), + {} + }; mmfr2 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR2_EL1); bbm = cpuid_feature_extract_unsigned_field(mmfr2, ID_AA64MMFR2_EL1_BBM_SHIFT); - return bbm == ID_AA64MMFR2_EL1_BBM_2; + if ((bbm == ID_AA64MMFR2_EL1_BBM_2) || + is_midr_in_range_list(read_cpuid_id(), ampereone)) + return true; + + return false; } int do_emulate_mrs(struct pt_regs *regs, u32 sys_reg, u32 rt);