From patchwork Fri Jul 1 13:04:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 12903276 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 E4456C43334 for ; Fri, 1 Jul 2022 13:07:37 +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=NfstNyKhelJQ66cugGYDSNoEy5VfFyf8SHHpv4VR61o=; b=Wfhy1ADnsQOjka wNJWmaDFcs4swhToDZaspnKXz8i6HNY37wlpVBGxuPz0ZroFX5C2TSwng5vVypMqIjUdbgk9KPm2G x6wMyPVDm2YhuDaBzCC4c/wu6AL3gy901FVnuB7+tqjOee6GOSRgLdUucAYTowGdsnKPjgVG9GlIh SAWfkrEJdQjNKMlkG4k47b/SWqIzGHEVtBmdq5ntXYpSseTv9XswRGiw1ZRw9ZfzI+pXIT5lYkyNx aieOuuujgh0l+npBVbg53YFn/D4MmbUHKMTsuUOKTyJ9ir9RDbyZ2SzN9QMuCifCX21S3vkbgbaio O028kKu7WLhC5auToDrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7GLs-004wJg-MC; Fri, 01 Jul 2022 13:06:28 +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 1o7GKa-004vj8-9P for linux-arm-kernel@lists.infradead.org; Fri, 01 Jul 2022 13:05:09 +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 F028AB8302D; Fri, 1 Jul 2022 13:05:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2331C341CB; Fri, 1 Jul 2022 13:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656680705; bh=rOuhg1XqOx6dRzKPBvWjKuSlrWKUVCR8XcqOMXrBdIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gjvNApHL0iKo2q1qS/qqIU0LDA8j0bMiMQmF/pw5gbqdaLYD/9blbo2Xq0qTtGzI4 AeI4Zb2JmGh8pbRI/xUNJZtW+QALeoVg7MtdFljy6brjYjCBNT5Q6+mpgJB+0kznm4 sYlh5buBjfC4snlQA2Y24kFPOkofl97pomrsZDEXKANnu3ghScbwRKpZaDT0pxVCon ZSVsav0DvI2tuJ1GAjU6ZxbYA3tipP5bjnIlYCZhMHfPXpxRtv3E8iSToKt8fU3m1y gLkE+7O2VKC0/D5J2s6lLfQCE7DEc0tPwVWkPfelstPSSWhADmFgRBXUC8gyIbVlzH sx2COqulx8lUQ== 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 v6 4/9] arm64: head: allocate more pages for the kernel mapping Date: Fri, 1 Jul 2022 15:04:39 +0200 Message-Id: <20220701130444.2945106-5-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220701130444.2945106-1-ardb@kernel.org> References: <20220701130444.2945106-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1776; h=from:subject; bh=rOuhg1XqOx6dRzKPBvWjKuSlrWKUVCR8XcqOMXrBdIs=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBivvDjKhRarlyHxbNuQ18gZQ+x3Xmq0nAVkpDQH1kN 4ajpC7+JAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYr7w4wAKCRDDTyI5ktmPJCmYDA CECVyeblpJnv7rz1JeHA5S3aq8V/irNQSW3WmjbsSuEilYV+697+lweelW34CZ6LQwmb+HhR9iwOqv 3DaDVPMW2fOXX2cF0l8PviL9QyARbEp58gPjKr1e5NK+1vDU6Pw9V4gDoPvGLhp7PIzJPgRx3qyFOR JbTASHhu3bu2MXuZx/tTwP352GMvZJqvZYFw4UlDAzDhPyLII6slFMvR/PhBp1a6tekGlcqtaphqyW mLLResieD86lsnmIFrjaMLYvP8Ce8ii819PX5R/9odR8lZ21P3VM7uJjfr0QYOXf7zy0Zn7o5o8U8Z VS9dFGxDFS/G216pAydxqnr2cwj25+CqSFlUR82ZmVkY3M0dxxaijAfCXTIGi9HgLMyCLvoUDShL5l W1BGJkrY028pMFWOTkDfabbZt1tkCpaOWRnX9L7VHsmt348Eoz5VicLZZQZm7Jhbq9fJT2idvCI4ZQ FVCLxvKwKU+P841rGvsvPzBKevYYi5eWi4KvBrVwXy9o4= 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-20220701_060508_664867_375EBDF4 X-CRM114-Status: GOOD ( 14.98 ) 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 02e59fa8f293..5b63bdcd0741 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)) /* each PGDIR needs a next level page table */ \ + EARLY_PUDS((vstart), (vend)) /* each PUD needs a next level page table */ \ + EARLY_PMDS((vstart), (vend))) /* each PMD needs a next level page table */ -#define INIT_DIR_SIZE (PAGE_SIZE * EARLY_PAGES(KIMAGE_VADDR, _end)) +#define INIT_DIR_SIZE (PAGE_SIZE * (EARLY_PAGES(KIMAGE_VADDR, _end) + 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. */