From patchwork Fri Nov 11 17:11:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13040622 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 0E42FC4332F for ; Fri, 11 Nov 2022 17:14:13 +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=gZiZxkq3MB4SN3Kpyw74+Lad9LGVRvYX+/dBoV6zNik=; b=iqqPybsptlHZZO SU37YKAhfr7iv6KSNNfcyVR1t6dutkzufMzrczfpQ12517Yg/QI00xWXmaRKEBtVdTyh1h/nF3VFP UfXfbth1DyCH/KOSY+MgNXgYCuVieRv8YGZG3glr5xjlnl5m5foEShzQo8DL05C9PL7WkeUBrDXnR MxpLXADpRx0v7XQFNggOjU16UVqeeSV4QopCjJayUDp4PjpKZtsl+tgvjyZr7umgJSe8pAARpfWy+ HLIaa9Lq9TORqRxhD9KnZ3VimevNi9qh8OpoCEp/211G0S50S+KbIQgvRlDDRtKGczpoCEwWJO4Fs 9iEUUaLFfj8yF1sphlKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1otXaN-00H7of-Cr; Fri, 11 Nov 2022 17:13:00 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1otXZp-00H7Um-QC for linux-arm-kernel@lists.infradead.org; Fri, 11 Nov 2022 17:12:27 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6B64FB8266E; Fri, 11 Nov 2022 17:12:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C09CC43143; Fri, 11 Nov 2022 17:12:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668186743; bh=gtt5pGHgRthVGPZRRIcJQzKvp+dB6EGtAB54jUbejCw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OwabbIkfduAipKggnrpEJZjr8C+HwjoThN9rumzg2HfMUz0ByZAKeqN9u7d2nhA4N zbEww8cm3f0FRIgiIqNSQHYcAGQckGOjUFbMkttyLNLrZb/4+MkDEa/Utlxe9Lu0zu 2uoTkU8uHGi6qu4yLmN9ldHQQikwZx2eAAwKgOaQ42DuOq+A3nsCmOXpyZyB6mXFHk IzctRzyfak9PrAzv5Q/JJRE8CRTPfCGlLwTOSf8Ph+PQq6yieGT7rKqQ9bYodXGP/c zUmNc1B2vD6MBG3rJ1ebrfrZ6X09OE5/51MYRT0ozLoQ4VQcT7zpGQPrqsct8bztf3 sxmHwlL2HdBSg== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Marc Zyngier , Will Deacon , Mark Rutland , Kees Cook , Catalin Marinas , Mark Brown , Anshuman Khandual Subject: [PATCH v7 02/33] arm64: mm: Avoid swapper block size when choosing vmemmap granularity Date: Fri, 11 Nov 2022 18:11:30 +0100 Message-Id: <20221111171201.2088501-3-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221111171201.2088501-1-ardb@kernel.org> References: <20221111171201.2088501-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1399; i=ardb@kernel.org; h=from:subject; bh=gtt5pGHgRthVGPZRRIcJQzKvp+dB6EGtAB54jUbejCw=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjboIrLR09qep9dTEu83lqqtQkTD3Slfq7j5BFz470 FqKNis2JAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY26CKwAKCRDDTyI5ktmPJOSWC/ 9YeLc2A4jH1IuBRg1oMSimuElHyiTkJYH/JKPbI7MS/3A2TNzsyyIi2wjpETPxl3irEbvKY26ppQRG 0yBZL4daM+IyRpKhSp3Et13pTfHT+Ji68Qv7VtkrGZjT4I/VZ5lBpPXbqC/Pv18w/bChaE0EExmocO 4oHyfT6Ed4Vlrbp+0tadbIbeWJccYmPD9GVzXSypVsZhrGHL3vopjCJaBzYCieAkc0P1wyEjvIAZbY OPNhXS/9ciG+Wa4ZZTxr1xSVViGCKP3IDd9DBG1WqiB5xn7dvnM2aQk+Y/vQmI6qUov3ar/cHGuqDF naXOyRep/9fFrvINKPQxm3FPbyK4MALTO5bBS2WbEj5AI+Vs2+M5f42UhlGC5G0/9FxmfjfnztLOoJ 1J+6e9KRasMcGKI16lbhJTJVkEH0jKCAfkkcvholZKiGH+L9AsftS63btyxX/IZ4VIg2LGZjes7Kd/ krLIOxzzFbJ5TVG7Ek6oexRo8CzhHYgLFMTEuRQ1/lSqo= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221111_091226_048661_9C0D7097 X-CRM114-Status: GOOD ( 16.93 ) 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 The logic to decide between PTE and PMD mappings in the vmemmap region is currently based on the granularity of the initial ID map but those things have little to do with each other. The reason we use PMDs here on 4k pagesize kernels is because a struct page array describing a single section of memory takes up at least the size described by a PMD, and so mapping down to pages is pointless. So use the correct conditional, and add a comment to clarify it. This allows us to remove or rename the swapper block size related constants in the future. Signed-off-by: Ard Biesheuvel Reviewed-by: Anshuman Khandual --- arch/arm64/mm/mmu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 757c2fe54d2e99f0..0c35e1f195678695 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1196,7 +1196,12 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, WARN_ON((start < VMEMMAP_START) || (end > VMEMMAP_END)); - if (!ARM64_KERNEL_USES_PMD_MAPS) + /* + * Use page mappings for the vmemmap region if the area taken up by a + * struct page array covering a single section is smaller than the area + * covered by a PMD. + */ + if (SECTION_SIZE_BITS - VMEMMAP_SHIFT < PMD_SHIFT) return vmemmap_populate_basepages(start, end, node, altmap); do {