From mboxrd@z Thu Jan 1 00:00:00 1970 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 0CD1FC77B7A for ; Mon, 17 Apr 2023 16:19:04 +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:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tuyxD4uVwsqFK4T4KyzbfyuCWKrldskTPkkOiBK1nDU=; b=GhVDgFiC/N67eL bUI58y5aAPbsN5rderPgs5AKmjK7kg2QBk3gzOgRCfZVO3TB+lCJxPsjrgH5aL8NmNw36oH67VD+Z Kl0ByyG2qTfUpzdYt72jheUAxmhIBFTKbfwE0TMb23jEZXia5Mo9WeKIjzFDcW2ETXKhgUMUAvBK4 QAVTf+Zidlf1CSJg9pqJAnA6GPFoQZkheTNvtMVuSOqby1VI1cFrO9UjPSCWX01Hq9+IIL1rb9kdX HlfpmY/t+2UtYVVSjj6OfLcRgFBRo9cb7309MkrpJJDeeUwRo+MOnsg12Kfx7QGm3qK2a5MCdsjSL c/dgE5E1FrVFJfCS8r6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poRYZ-00H1qU-1P; Mon, 17 Apr 2023 16:18:19 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poRYW-00H1pk-1L for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 16:18:17 +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 25A331691; Mon, 17 Apr 2023 09:18:56 -0700 (PDT) Received: from [10.57.68.227] (unknown [10.57.68.227]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 380B03F5A1; Mon, 17 Apr 2023 09:18:11 -0700 (PDT) Message-ID: <5219d157-27b1-c721-cb88-ce4f8f4f9807@arm.com> Date: Mon, 17 Apr 2023 17:18:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH v3 32/60] arm64: head: allocate more pages for the kernel mapping Content-Language: en-US To: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Anshuman Khandual , Kees Cook References: <20230307140522.2311461-1-ardb@kernel.org> <20230307140522.2311461-33-ardb@kernel.org> From: Ryan Roberts In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_091816_500053_E5CC08B9 X-CRM114-Status: GOOD ( 17.54 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 17/04/2023 17:11, Ard Biesheuvel wrote: > On Mon, 17 Apr 2023 at 17:48, Ryan Roberts wrote: >> >> On 07/03/2023 14:04, Ard Biesheuvel wrote: >>> 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 4d13c73171e1e360..50b5c145358a5d8e 100644 >>> --- a/arch/arm64/include/asm/kernel-pgtable.h >>> +++ b/arch/arm64/include/asm/kernel-pgtable.h >>> @@ -80,7 +80,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 >>> @@ -101,6 +101,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) >> >> I'm guessing the block size for 4K pages is PMD, so you need these extra pages >> to define PTEs for the case where the section start/end addresses are not on >> exact 2MB boundaries? But in that case, isn't it possible that you would need 2 >> extra PTE tables per segment - one for the start and one for the end? >> > > The end of one segment is the start of another, so we need one at the > start, plus one each for each segment end. Ahh, of course. Thanks. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel