From patchwork Mon Oct 14 10:58:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13834933 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 C5515D16258 for ; Mon, 14 Oct 2024 12:35:58 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VfAcTUi91ptQaK/CGe1CeXA9aaPE8rozFIbYUTlYxXU=; b=hi/zZWyBJSfhstyKYdMyZTwlsL 5bLX8suflNTvmnYAhu0di2Gbs+P149bAusbBWCueKpGQwLBa5EVZeamMzTJOw4gZz3JRh3aYHRtJJ BCYnrk5FaFDeZvIrIs3YPvDplxTbkzdmAg90IbpopDzmf1EarTF7IfG9jdAyEJabGHN6EwCjEy1Zh P849ETInyJSEwcabNXobyPyMqd8GDhqEA2NO2LjEpl6JeD3sLNvI95URPtl8rMfoIYj8T8pKu8OuM dZiHxTUiuiOdch2LT7/Q2hvkGmZ7HZfKR4nF9ectZXYzvduVw9rqbPGWp7sWU4ST8IAWi2En9j9xY AZHeCaow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0KIe-000000056H5-3Kl4; Mon, 14 Oct 2024 12:35:48 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0Ipu-00000004ogb-2JYN for linux-arm-kernel@lists.infradead.org; Mon, 14 Oct 2024 11:02:04 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A49A51A25; Mon, 14 Oct 2024 04:02:31 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A5B033F51B; Mon, 14 Oct 2024 04:01:59 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , David Hildenbrand , Greg Marsden , Ivan Ivanov , Kalesh Singh , Marc Zyngier , Mark Rutland , Matthias Brugger , Miroslav Benes , Will Deacon Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v1 51/57] arm64: Introduce cpu features for page sizes Date: Mon, 14 Oct 2024 11:58:58 +0100 Message-ID: <20241014105912.3207374-51-ryan.roberts@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014105912.3207374-1-ryan.roberts@arm.com> References: <20241014105514.3206191-1-ryan.roberts@arm.com> <20241014105912.3207374-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_040202_656580_2AAC26DC X-CRM114-Status: GOOD ( 13.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 Introduce one boot cpu feature per page size, ARM64_USE_PAGE_SIZE_*K. These will enable use of the alternatives framework to patch code based on the page size selected at boot. Additionally, this provides a neat way to figure out what page size is in use during boot from the kernel log. Signed-off-by: Ryan Roberts --- ***NOTE*** Any confused maintainers may want to read the cover note here for context: https://lore.kernel.org/all/20241014105514.3206191-1-ryan.roberts@arm.com/ arch/arm64/kernel/cpufeature.c | 25 +++++++++++++++++++++++++ arch/arm64/tools/cpucaps | 3 +++ 2 files changed, 28 insertions(+) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 7705c9c0e7142..e5618423bb99d 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1831,6 +1831,13 @@ static bool has_nv1(const struct arm64_cpu_capabilities *entry, int scope) is_midr_in_range_list(read_cpuid_id(), nv1_ni_list))); } +static bool use_page_size(const struct arm64_cpu_capabilities *entry, int scope) +{ + return (entry->capability == ARM64_USE_PAGE_SIZE_4K && PAGE_SIZE == SZ_4K) || + (entry->capability == ARM64_USE_PAGE_SIZE_16K && PAGE_SIZE == SZ_16K) || + (entry->capability == ARM64_USE_PAGE_SIZE_64K && PAGE_SIZE == SZ_64K); +} + static bool has_lpa2_at_stage1(u64 mmfr0) { unsigned int tgran; @@ -2881,6 +2888,24 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .matches = has_nv1, ARM64_CPUID_FIELDS_NEG(ID_AA64MMFR4_EL1, E2H0, NI_NV1) }, + { + .desc = "4K page size", + .capability = ARM64_USE_PAGE_SIZE_4K, + .type = ARM64_CPUCAP_BOOT_CPU_FEATURE, + .matches = use_page_size, + }, + { + .desc = "16K page size", + .capability = ARM64_USE_PAGE_SIZE_16K, + .type = ARM64_CPUCAP_BOOT_CPU_FEATURE, + .matches = use_page_size, + }, + { + .desc = "64K page size", + .capability = ARM64_USE_PAGE_SIZE_64K, + .type = ARM64_CPUCAP_BOOT_CPU_FEATURE, + .matches = use_page_size, + }, {}, }; diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps index ac3429d892b9a..5cb75675303c6 100644 --- a/arch/arm64/tools/cpucaps +++ b/arch/arm64/tools/cpucaps @@ -71,6 +71,9 @@ SPECTRE_BHB SSBS SVE UNMAP_KERNEL_AT_EL0 +USE_PAGE_SIZE_4K +USE_PAGE_SIZE_16K +USE_PAGE_SIZE_64K WORKAROUND_834220 WORKAROUND_843419 WORKAROUND_845719