From patchwork Tue Mar 7 14:04:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13163646 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 3D23FC678D4 for ; Tue, 7 Mar 2023 14:17:38 +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=KdenN67r3zE8/ZEEOgQAzD2GUsVI1ERN1nksUmZPXtc=; b=fk9zvFCrPSHtSp fsca7tROA7KR6+VxsCG6ikGPlaJXDTCPPTIaQ/Lu6Ok4I7Mx66cr4WsYlYQe5h/kMALCQBc8CV53o PyuZvmeJWLOU2wWTcZ1k1eWRErYKD7mEKx10yIKOlCfrrY46iQrRSDo2bLt0JBKMqriMnLVumNLSJ ENhfFQVNdyBa6lwJUgl0EXgt2aGP2up5ftrK8nHVobXJDh/lw621ytSGJs77HfdooAWvOq6f7fByZ j4MKZmBXm9hy6W64rEVmkyoKGe0+KBZvyd5slKILSAKMfKD3hQOcVQjKzCuUT+soRYdVn5BUPDDio 2xk+yJy0Zck6w5NQPQkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZY75-000i4k-1x; Tue, 07 Mar 2023 14:16:23 +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 1pZXxt-000dqI-3c for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 14:06:54 +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 7911F6143F; Tue, 7 Mar 2023 14:06:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EAB8C433A0; Tue, 7 Mar 2023 14:06:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678198010; bh=8ouA8Mhr3C7XfVU8ngz8EZDrejuiodn55YE1KadufeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hd9/VBgk9NJvRDq6RUK+jbr33uWwgSWL7Z2sMsvjMCGWKtaEF7wwPVx7AwJx1jPZG +oNKTb3na926drLq1jcY/lSVENGZFGaQGZnZUjbw7VcymUUPEjwv1yRUraOx3LlTUK psYhWxSNZjX84Dj5B+DOLH3m5L8e5paB5Bp9tBo83V2HoaALaxjnYJ9MSv+YW7gw1X ioRTxJ9T6Wo9andEzTsIwvTWuBGgWgKJOvZ0gvxuj3CuNIT8usV4fEAuybERvgGtV+ cOkkuFRb2AeOYmp80YeBbDUiCngbzjQRYJwIeCa6+xFsfXik272RpkAOhh6g0/GF8d 74ms3rGX4bOog== From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook Subject: [PATCH v3 05/60] arm64: mm: Move fixmap region above vmemmap region Date: Tue, 7 Mar 2023 15:04:27 +0100 Message-Id: <20230307140522.2311461-6-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307140522.2311461-1-ardb@kernel.org> References: <20230307140522.2311461-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2530; i=ardb@kernel.org; h=from:subject; bh=8ouA8Mhr3C7XfVU8ngz8EZDrejuiodn55YE1KadufeU=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIYXdhcNR7sNjKYZbhT4M/9T8r06doHveU+vhprsP7h9bf n/+zSe3OkpZGMQ4GGTFFFkEZv99t/P0RKla51myMHNYmUCGMHBxCsBE2tsY/heuu9/7ll/w4fGc fSI/vb5++dTxW/r8Jq0DEdqbDsResJ3DyPBii/aRJQss1urfnvRh+XVF1bU71mnduMutsMrpyLu 95nasAA== 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-20230307_060653_284571_F5E79ACD X-CRM114-Status: GOOD ( 16.59 ) 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 Move the fixmap region above the vmemmap region, so that the start of the vmemmap delineates the end of the region available for vmalloc and vmap allocations and the randomized placement of the kernel and modules. In a subsequent patch, we will take advantage of this to reclaim most of the vmemmap area when running a 52-bit VA capable build with 52-bit virtual addressing disabled at runtime. Note that the existing guard region of 256 MiB covers the fixmap and PCI I/O regions as well, so we can reduce it 8 MiB, which is what we use in other places too. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/memory.h | 2 +- arch/arm64/include/asm/pgtable.h | 2 +- arch/arm64/mm/ptdump.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 6e321cc06a3c30f0..9b9e52d823beccc6 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -51,7 +51,7 @@ #define VMEMMAP_END (VMEMMAP_START + VMEMMAP_SIZE) #define PCI_IO_START (VMEMMAP_END + SZ_8M) #define PCI_IO_END (PCI_IO_START + PCI_IO_SIZE) -#define FIXADDR_TOP (VMEMMAP_START - SZ_32M) +#define FIXADDR_TOP (ULONG_MAX - SZ_8M + 1) #if VA_BITS > 48 #define VA_BITS_MIN (48) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index b6ba466e2e8a3fc7..3eff06c5d0eb73c7 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -22,7 +22,7 @@ * and fixed mappings */ #define VMALLOC_START (MODULES_END) -#define VMALLOC_END (VMEMMAP_START - SZ_256M) +#define VMALLOC_END (VMEMMAP_START - SZ_8M) #define vmemmap ((struct page *)VMEMMAP_START - (memstart_addr >> PAGE_SHIFT)) diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index 9d1f4cdc6672ed5f..76d28056bd14920a 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -45,12 +45,12 @@ static struct addr_marker address_markers[] = { { MODULES_END, "Modules end" }, { VMALLOC_START, "vmalloc() area" }, { VMALLOC_END, "vmalloc() end" }, - { FIXADDR_START, "Fixmap start" }, - { FIXADDR_TOP, "Fixmap end" }, { VMEMMAP_START, "vmemmap start" }, { VMEMMAP_START + VMEMMAP_SIZE, "vmemmap end" }, { PCI_IO_START, "PCI I/O start" }, { PCI_IO_END, "PCI I/O end" }, + { FIXADDR_START, "Fixmap start" }, + { FIXADDR_TOP, "Fixmap end" }, { -1, NULL }, };