From patchwork Mon Nov 18 18:16:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 13878941 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 30DB2D591AD for ; Mon, 18 Nov 2024 18:18:55 +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=TnSYudl8LgJnfeoPjXZCrrq6bAGwcihoW/+IO3jYjJw=; b=lN/u0UuE9hZlHtjXQXHNgZ1IDU NW2T7fcvrYZceW1Nm07LoEKG70BYAG4G2ZdM7ghyNRKkjRpM18VvHB9YnlKfNEvkLjfnplRm2m/9Y +NI8IpWJLVlWc848eLxEJ3PAoFvFsGlQFeka5RiHte/j1IcYXuh4rCbMc/caOILlD9LZ2Ru9X+t8d MfHM2DV7rXo8OA38lVn9e/AGOmQBHfKET2j7PdH3sIbcxE2QrY82aQ6PhpVrP/olRvhWhYvUjS7Fg Bu4hVYQaiOA0Me7YiBSiBtmSjpwhJrkAJ8Sf8MO9dYlLgET+rWI2Q7aCVih6PR1UwmUXiZNlAkVjN rYIdbxYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tD6Ki-0000000AJom-0Qz7; Mon, 18 Nov 2024 18:18:44 +0000 Received: from mail-northcentralusazlp170120005.outbound.protection.outlook.com ([2a01:111:f403:c105::5] helo=CH5PR02CU005.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tD6Jl-0000000AJco-1gd9 for linux-arm-kernel@lists.infradead.org; Mon, 18 Nov 2024 18:17:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ejEGfq2MewT4jq3JNJiBitwAzxwHyqQHlBgse3723dx5Nu94JH3KDZk1YVUMq8zvCn8RvygTY/1VxVUnWeERLH4DjnU9pbKPdNKF0JUzKBDAwDHO4KU6RWbEhZZ5be0fPAMQEFzo22s/FnJngh33p1Njke/ALLYEC1M0MEuEjnWpCjKbouzKi/GGDOv57v0nj1xLek5LeSglKsUbzK/q9ujWmGC/lcziLRhofzk5ewgbDpc4OkKeEZVea5ObkrJ8rP9uAFxpBrGx6JPKJ4QXsNeTVpr7eukwWpIDo8ar6c5coaOwDl4qKYPko3TOPO0Re+7+1WQFSz3uOSHqjsBgig== 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=TnSYudl8LgJnfeoPjXZCrrq6bAGwcihoW/+IO3jYjJw=; b=JP//7XOWhnqHzND2FTt2Cg7gjt7UMpKj8aCndkcLDcW3IXQgxekmAYnmec52wlHnWTBN5W8E/JWpwOTABf3Hd2Bq9XFqynTvRHCQxdCvHRLX3nWISGwS/JHHrblFnRMroMuP+ylq3DPgT5z7rbEfJZdVsaxNw2/n99cz0kpu9erJAoK7gl+V8LqgdkQKImHW6iCu7guzobyetbmKoROeetRKAxVaZvl28hsR2IEnoVVCTbLb+9BAvLmyqU6MfmDfvDOKHqLw7FBv9VqxfA6XSRg24OC5U4+6VYYbaCtAHJE/OM6w+idnsgYkfpl+XoWAb6fCy6olhgyHYR8bp57tiQ== 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=TnSYudl8LgJnfeoPjXZCrrq6bAGwcihoW/+IO3jYjJw=; b=XIVlTWxdRQux3DoGWx5wQWTLBvkZaCHPN6l8+1w9Oioz8ZWVfA4c7i0Vw98AVU1vv97sH/CTXzdGHKeZiYdsaKAc3NcUx63xi6ypr03GNXz/Hv618lx3yawAGsQnqihT5ArToTWGBx9HHxyctGEJYHx4kZUXo0J9PhTzVYY+7pc= 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 CYYPR01MB8601.prod.exchangelabs.com (2603:10b6:930:c5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Mon, 18 Nov 2024 18:17:40 +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:40 +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 1/3] arm64: cpufeature: detect FEAT_BBM level 2 Date: Mon, 18 Nov 2024 10:16:08 -0800 Message-ID: <20241118181711.962576-2-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_|CYYPR01MB8601:EE_ X-MS-Office365-Filtering-Correlation-Id: 25208b6d-855a-4742-c88a-08dd07fd49b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: x0MJm+zd3HCcLtuEQ8BCjbULl1BCHKhNYIYgoDvCy08jP7vx90YBrVZlfIlBw9+a0fD7bpYnC7oC+lRDvUs0khRgowyNT0WcgGY5x02mnrta+ia/rEY4InpFXyaiaSIHVt4hLsLiPQtSMQNMyGgynLIrbJzzyjqni2TmTEv/90yfELvkVIr/rfBcxLnmcW/Kkx7cR7xnsS/BxRKZoQ699xigoM0x4H/kPYXv67EXQWAF3NgzsxanJVJhhXwvKpteG7AEnkmeqZo7TCg4AvsVBH9/m73v2rZmjVOCkKHkpC7aEgh7r5DrsfGZtOJdETIZH9zkBpn+huXVKOD5EH2pEnOOVFGBcsZgxIeDhVISvyBcnEo95g8ZKN4vrEG8+L8cKDeYhM5KRMOWz81WOUVH6ko+uo2AonfCq7ySP+bGtf1y50sRYBuREghr5w4ra2zHafQbaXPeU34B7ioNV++AoIK3/pRSXII9M640FJpoM/ndBV8SZE1uERWVlS4S2DDTUrewcqqRea9F/NLdrOzqXWx9JZl2TYbqTTNIn2ZkUxSRAEVxOAjyUSE+TRZAN/RJ+hlEhCvoPnwvs0jMT+nvJTi1xuBV2e6KGzTimxj8/sjdzRmO+EmJUk0ZqfG+bdC/GN1a1tuka+v11kCQ2MADe7w2mKZXqB9EittyCa8j6dg0+cmUXshPPaDCXssUPUZe1HA1iwkRUUyaVj8H0VrQOeralj4RWU4GYIUETHOd6n1GLfF4DvDaftL4T1ABG2mz6AnhyGV20EGuWZLvMdyMIDO70WO0GPfiYS7Lg0WtYrDTVGI6BlNnTh45LpotwGLSIq/BLNnBszygsYJOa7qzieDt/Ivuzh6CcmIsxHi1mLc2zb7mO4HSTEWv6pzSXkKgLv/ddNLNvPoHi3x2Vrox8M3ulDgIgdzGyi9DGJXkfK066Sn2JFE7cgTox8r9yZQld27hxNuatKqmE8BJgzJKO84ZyZ8rn5x+3vCjM5SeFqfNSm/n+y0wnMnEvh/DHJnsNG3LEri/uSERBJhbnYS4hZ9w80Go8+vQTjoYNbfQCNJMyLUGPQFMayT+W7pqvY/P5NYb75MTKho3qbjEym3bN7kTV1OgVg2UflJhdqqA5I3YQt2cqyISEuYaUyLVNIGjaweXEC0NjSzX9FMBtPt2xwyqJHGyGRioBUA18hW5OjG5OlqNmp8WtFSW3WM+x990fUJ6hGZNcg5KrHq/z0vKcZ/qc2bQIf97pLPsz+JLyQE8/AGnF5ejieYPcR9lR0er7MieIJFfB4HzOcuOoAKhWFe01EJCbXoPBqbwKGUgOJOUjQg54BaHB/MuyFtmmtkHtnfJYpl2RGB43ON1U15NUcauo74L/8uQdmV6MBb19jo= 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)(1800799024)(52116014)(376014)(366016)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HA+NuMCEDTERAKgZcZ0rsi33zbb1DxY6NU4bqPRQST4rksJ9PeEGGBVHk4+1TC8J22+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g+iE7FfC5jKIrOmX46jY29jQCUTWjpfJFbZVuq2f1qa9Q5crHCCFMo85flCznUoc53eLswb4mSIe6CSPbpojNlLeR8Q8aeiPOrzzD4DI9yF11juc2+3ws0HZHR8Vy/EqhstSyajYG9yoFaWecoXX+f/mrrfJD2WPIRNz/Vn24jPjCywGNguTQH3UFv6XzB+UyWO6BgGmKVLq0kzpvGNqrcPXZzaGoKo4QKiRFnpW5ct1UjxPkr2zP3DKKWP7V2N+OSUY59WjqjHZofJ0O9kG3YufAdRb7jV2Z9J5pgsKqrziTAJd1bgrpVmIWPDAvS/U7AA3+mlUnXW3cnkkMgX21pD9JNfC+RgxezP8Lq8MW/WKdxysIJb2xY10OyXLJ1ogNJHkjzO7ZuuxrjqQ9ro1BU3kb9QFezcgkVy40cvmLQCauuMzQcYmHTla+WNQaRryJA+lXdIKTuyjjbnjmUZQKGizsM9rEPyOHaGd9X1eD4WYqVs8spqhJg= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25208b6d-855a-4742-c88a-08dd07fd49b2 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:40.2416 (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: +zQL03NfoA4XCaxHG5FB8ePWSM/2nH1dPxIGm3onmF+CncmVYeK57TFOdmLfHhiGUPvzc4KJKNCUxDlAuUbLu791WhWVmGTugkT5EpU3V+k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR01MB8601 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241118_101745_456212_4ABA386A X-CRM114-Status: GOOD ( 11.42 ) 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 useful to split large page table without breaking the page table entry. The following patch will use to improve performance. Detect it in cpufeature and use BOOT_CPU feature for now, if the late CPU cores have conflict, kernel will not bring them up. Signed-off-by: Yang Shi --- arch/arm64/include/asm/cpufeature.h | 15 +++++++++++++++ arch/arm64/kernel/cpufeature.c | 11 +++++++++++ arch/arm64/tools/cpucaps | 1 + 3 files changed, 27 insertions(+) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 3d261cc123c1..c7ca5f9f88bb 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -838,6 +838,21 @@ static inline bool system_supports_poe(void) alternative_has_cap_unlikely(ARM64_HAS_S1POE); } +static inline bool system_supports_bbmlv2(void) +{ + return cpus_have_final_boot_cap(ARM64_HAS_BBMLV2); +} + +static inline bool bbmlv2_available(void) +{ + u64 mmfr2; + u32 bbm; + + 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; +} + int do_emulate_mrs(struct pt_regs *regs, u32 sys_reg, u32 rt); bool try_emulate_mrs(struct pt_regs *regs, u32 isn); diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 718728a85430..cb916747cd31 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1866,6 +1866,11 @@ static bool has_lpa2(const struct arm64_cpu_capabilities *entry, int scope) } #endif +static bool has_bbmlv2(const struct arm64_cpu_capabilities *entry, int scope) +{ + return bbmlv2_available(); +} + #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 #define KPTI_NG_TEMP_VA (-(1UL << PMD_SHIFT)) @@ -2890,6 +2895,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = { ARM64_CPUID_FIELDS(ID_AA64MMFR3_EL1, S1POE, IMP) }, #endif + { + .desc = "BBM Level 2", + .capability = ARM64_HAS_BBMLV2, + .type = ARM64_CPUCAP_BOOT_CPU_FEATURE, + .matches = has_bbmlv2, + }, {}, }; diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps index eedb5acc21ed..175b7eb42b0b 100644 --- a/arch/arm64/tools/cpucaps +++ b/arch/arm64/tools/cpucaps @@ -14,6 +14,7 @@ HAS_ADDRESS_AUTH_ARCH_QARMA5 HAS_ADDRESS_AUTH_IMP_DEF HAS_AMU_EXTN HAS_ARMv8_4_TTL +HAS_BBMLV2 HAS_CACHE_DIC HAS_CACHE_IDC HAS_CNP