From patchwork Tue Sep 12 14:15:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13381761 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 D77C4CA0EEF for ; Tue, 12 Sep 2023 14:17:59 +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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=dVsJOwWx6fgiuj91a/uCO/GrcVvfuVA712nCoBUxd/Y=; b=eJ32Zvq2jLxAJSpOUtWPS/83GX IBmfxSOxNAZV+TpmPe4wTWvR5IMQtMDldTmyAoHMCuvB2h0/MjstUM+0VKX3BTKOdH966Sb3TDjYG KkfsRa6/MBWVr384iGNQFXNJBEqdvfy3O7BQV4bd44WxgnkUPAwRhbZGLzhoEYA/HpjVH2lElPnE1 1BKM2/umq8qGFJbTYQhSIKglTFXCj/RU5qdKtUq/h5+Ts6xW0YFZbNG5BTqdPGSWtVnPLelgRCBO/ i4Cl/YGVn5288flJ9qjpzIQ22RaLCSbBz9SU6bWS0LmvMJTYMLRwpcLWB7JQ9OlC13SfKaSuVFiF2 fCPWlaTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qg4Cr-003VuT-0d; Tue, 12 Sep 2023 14:17:33 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qg4Ck-003Vqi-0V for linux-arm-kernel@lists.infradead.org; Tue, 12 Sep 2023 14:17:27 +0000 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-31c470305cfso3774544f8f.3 for ; Tue, 12 Sep 2023 07:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694528244; x=1695133044; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FGjWmrp/LCWU7fgbtimbKfWIZkwRzJf0Hdf3dUgKZuI=; b=puNgTn/NAbmgBlMMQYr12SDkUFWRSilKCfR3q9I3caekqBN+Oh6x8LCzhapl6QO5PE /mG0zyr9Rrr2Q+GSs7Jr7Dkyk92OmAnv+85E4jFuSdb72R7xLLtpxTnxteQGsxgrJ5yF TD8MX4iVqM10sD/gf4Ovpclrk55eJKNvk5+5HMrqGiZAEFvBNLKx67CB8N++AxYDrGfu 8zpxwXsQUBdm+0ZG9gV4znUS+hPn1oAvH3ss02zgsRJtLYftd4BUQRwqUsC88abeJIqW B9NAE3eyKsSaWU+9+h7f7ULyLnSLpTyJMr+2rIBJ39YbPWQfJQMFjFrqTLrEkJGkWtPT DwAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694528244; x=1695133044; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FGjWmrp/LCWU7fgbtimbKfWIZkwRzJf0Hdf3dUgKZuI=; b=ZHDuj6Hg4Li8Ky4tp5NYb6IyhY7PvvVEDgi5uDRmH41QVg0onP3D4DczHf97BVWqZJ /rR1R8ja8VJo15sBM6mA1WgloumLUrR6ArIIiHCitORBWxL78NSrkIk+5aGovnGuBbNi yoXmgHQxN9lmCmHSzoqCg1jU9us39adHM/9zkerQiOM3uGN2CKy8Yk9lq9F9tIJmN85E 1Dr6WfyvlxS9iZuzeWJk+pIabQVUqNCHFzhRzb793YXAhTPhKTeMMg4OayuKB4RiY4cS tix0I8NXNFpkcyFetN9ZOv+xdD4dD8suspPdxkRgUHYZplzu/sXgJ9JVNRd9FWJR0gYU +UBQ== X-Gm-Message-State: AOJu0YxEk439lBYUIyRdDCdlbKxDQ5309E6r6u5zQ8xTOVptYx0WbCZE kMI4fqGW7vJmVcsSTDlVbFXGD/mKdj6xZx1pdYwBs3GJCfcPwmM+CSeAoAz0kVGG02lqOMAcSC8 aqXXiFacVnD+W3slEyiWmHRD59VQNzonzxMSN/0mmGi4GWKb60j+dAAlIggI41pqHvOucEiUuIO s= X-Google-Smtp-Source: AGHT+IGFFC5O8+gMrQywD0Q5wAh+VnPsRyGgbLbWJ+mj8xp1nxE3EuVVUMf3XsWK9ESTMZprPMSAENTF X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:6000:362:b0:31f:3049:5759 with SMTP id f2-20020a056000036200b0031f30495759mr154885wrf.1.1694528244400; Tue, 12 Sep 2023 07:17:24 -0700 (PDT) Date: Tue, 12 Sep 2023 14:15:55 +0000 In-Reply-To: <20230912141549.278777-63-ardb@google.com> Mime-Version: 1.0 References: <20230912141549.278777-63-ardb@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=2524; i=ardb@kernel.org; h=from:subject; bh=TcKfFJ74di7EwtwuCY+EKlB4E2qjOZmy9HG1PFKjSg8=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIZWhaPbFA1tXqbRE7n6Z03UgeYPBqqp3c94cCFw268vJN 1VbXR7e7yhlYRDjYJAVU2QRmP333c7TE6VqnWfJwsxhZQIZwsDFKQATqd/L8IdX2LF8UZZov0XM yqucu4+s/ST8me/okyfLlXdfSStnsuhlZLihWyXqdGTpAwV7v1fBqfpC0yOd2vsvux660OGpPoW TgRUA X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog Message-ID: <20230912141549.278777-68-ardb@google.com> Subject: [PATCH v4 05/61] arm64: mm: Move fixmap region above vmemmap region From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook , Joey Gouly X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230912_071726_196887_6597339B X-CRM114-Status: GOOD ( 16.14 ) 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 From: Ard Biesheuvel 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 99caeff78e1a..2745bed8ae5b 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 (-UL(SZ_8M)) #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 7f7d9b1df4e5..01fddcc2ae4d 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 d1df56d44f8a..3958b008f908 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_TOT_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_TOT_START, "Fixmap start" }, + { FIXADDR_TOP, "Fixmap end" }, { -1, NULL }, };