From patchwork Fri Nov 11 17:11:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13040645 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 E975FC4332F for ; Fri, 11 Nov 2022 17:31:23 +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=sSojMrNuHCqA9vo3elYfcq7VtgN55VlMF7S4IR4u0n4=; b=G7l2jlErNRenZJ sd8mQvPTt5VBgTKM0Iaq/R0bovygIEWKz8wD4uqLbZ28EZv6qhbe+fnnJY57ojOvRm4w3nNo/V8ca 4WKlh+wU+neFfSK9bSFW15mDGF8OTwW81ybg0HylQkazulCKjYtXFHdezHJ750vv9/3H+tV6hiXLZ HbE+78XmbhmXBM5gvqhougz6iKDvpuDBtwT1D11cf6sPOUkrwLDD/ldQ7FdwMJUdOaJjsv7TOy4xU AFfKiP4kQHCr1AAnBbODZiOumOoVQTmfSw1NuPuTAB34QOHOJSk4j18/KhXZLGufycsA1PjtFkyb9 Dx5aGWWCuIVm4xc0CPaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1otXqy-00HGu4-HH; Fri, 11 Nov 2022 17:30:09 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1otXaf-00H7zp-7R for linux-arm-kernel@lists.infradead.org; Fri, 11 Nov 2022 17:13:18 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 753AC6206D; Fri, 11 Nov 2022 17:13:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05B70C43143; Fri, 11 Nov 2022 17:13:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668186795; bh=1v3DWjp9u6JUJ8R6/MzaiaJY023C2XcQtQfQsZ68rbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z5mCV13tJis9u4QL4RE2BbQ7E2n1RRnyb6VcjXkkxhN5eCU01H1xoVUBXDiuGyG95 2b/PnyKFaoX6OUecLHr+FCrqn6v1/VM/VMsVk2yEK9W3SYxToNlCx7w0fN8FoCtIIK /tJ55fPUv+pNnE3uFA+Bmu8PmLdT5447AbThLLCFEFFJhvBltflyNzZzJtCzkC5RKf xmHRmg0Q831NMeQ5ClDOk0A0tyiDkHppCjdaW4QgSM6F8NYKSC+2IBJ6YdBFK7wSo/ boxzvDUI6HIyuVcfcrmZaTck1ygp6uaYhXcuUQ+OjUKiNVfc+Do10ndHOrl+uh+HZc ihNUQOk434iiQ== 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 25/33] arm64: head: allocate more pages for the kernel mapping Date: Fri, 11 Nov 2022 18:11:53 +0100 Message-Id: <20221111171201.2088501-26-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=1825; i=ardb@kernel.org; h=from:subject; bh=1v3DWjp9u6JUJ8R6/MzaiaJY023C2XcQtQfQsZ68rbk=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjboJStHfyR8xmljYehRL4CmLUPlwJlw2nbF4jbjQb etKOSiiJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY26CUgAKCRDDTyI5ktmPJA2mC/ 45YmtZgKZUJNsPg9NVRBRFfqA0EOSPz63gKxA2sBny8GoH87eQTamUdke9S4uLpXG1GXQsOkapNa1H rAbJty072ti3NmKY1uiLY949EO29XxraS5LQddquu2nMxTxRdFub9/EgEN+1ebhFPW48HxSBlavVpE Hz1RsemrZkJ1Lq9BdJXtiDQbntJPYndDiqRi6ANQ1dFCOROOwnjbDb/lshrXBV45/JBZbRET2ghKxk ziY9uTb+JSM2Gp/wObvUZCiJ60gZmQmZNB3mlBTlLIbOz1mp2fn+tIvjtmj/X6QAJ2AFqjtxOVZw90 QZ1KRaTrdWljgiaJ5dSGgk2f2DvjGQa4iO+pi1trrdZe9RuBKa0Sta1SvV4s1mPDxlUKwe2Ivwaavx la+uxzQSZm+YiTuclB53CLxEu+FmCfOWnL1w5/yF7FwgWb1TfjD9wYsdMzEQfTJBpAI0u4jW7Ulr4C XbV1Y7dW9pF8441pOMlOhDwaArT0Rhf8XJ9NmSGDysups= 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_091317_408213_73D1B991 X-CRM114-Status: GOOD ( 14.57 ) 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 preparation for switching to an early kernel mapping routine that maps each segment according to its precise boundaries, and with the correct attributes, let's allocate some extra pages for page tables for the 4k page size configuration. This is necessary because the start and end of each segment may not be aligned to the block size, and so we'll need an extra page table at each segment boundary. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/kernel-pgtable.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kernel-pgtable.h b/arch/arm64/include/asm/kernel-pgtable.h index 32d14f481f0c3f37..ed0db7fc0022d34e 100644 --- a/arch/arm64/include/asm/kernel-pgtable.h +++ b/arch/arm64/include/asm/kernel-pgtable.h @@ -85,7 +85,7 @@ + EARLY_PGDS((vstart), (vend), add) /* each PGDIR needs a next level page table */ \ + EARLY_PUDS((vstart), (vend), add) /* each PUD needs a next level page table */ \ + EARLY_PMDS((vstart), (vend), add)) /* each PMD needs a next level page table */ -#define INIT_DIR_SIZE (PAGE_SIZE * EARLY_PAGES(KIMAGE_VADDR, _end, EARLY_KASLR)) +#define INIT_DIR_SIZE (PAGE_SIZE * (EARLY_PAGES(KIMAGE_VADDR, _end, EARLY_KASLR) + EARLY_SEGMENT_EXTRA_PAGES)) /* the initial ID map may need two extra pages if it needs to be extended */ #if VA_BITS < 48 @@ -106,6 +106,15 @@ #define SWAPPER_TABLE_SHIFT PMD_SHIFT #endif +/* The number of segments in the kernel image (text, rodata, inittext, initdata, data+bss) */ +#define KERNEL_SEGMENT_COUNT 5 + +#if SWAPPER_BLOCK_SIZE > SEGMENT_ALIGN +#define EARLY_SEGMENT_EXTRA_PAGES (KERNEL_SEGMENT_COUNT + 1) +#else +#define EARLY_SEGMENT_EXTRA_PAGES 0 +#endif + /* * Initial memory map attributes. */