From patchwork Tue Jan 23 14:53:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13527530 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 C2B00C47258 for ; Tue, 23 Jan 2024 14:54: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=+YsccQ1/z2uDca++Ruf30o0mLgZpkDBQfuu2ceSEJYA=; b=arH3KoxjQAaAC4dYk1Fgvsw/Ga PyGbJy6SDeInark0+8HB8i4S4H0rhXwLTgMIL40Gq84c1Wr+u6JXFGcj4IxtsFYypGf0wXOzynZyC 68TdAp8/EkrarrQfukDzex0j173JIan4O86OrgCy2Y/7f0Y7wdlIXfqOrGQpNt8TeC5JjYZ8qtBAe pE5gAKBLxpv03n5DPm6p50xXaOiHBDCaGIfhRS4pXjbalVKIrhNB9Vjtf291//SxMDhLluxymWTm/ lfT0lK1OO7thC7Ge3LPyDSDkR7P1j3jSvX/O6OwuQqFxBM3ZyX/DLGrS+SPX6kybLWtxfFt3giDYT JIle+4Lw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rSIAc-00GtdF-1H; Tue, 23 Jan 2024 14:54:34 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rSIAV-00Gtb0-2S for linux-arm-kernel@lists.infradead.org; Tue, 23 Jan 2024 14:54:29 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5e73bd9079eso72048237b3.2 for ; Tue, 23 Jan 2024 06:54:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706021665; x=1706626465; 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=NPxGZ40dkByGWudN3BtDjpXgJcnI+pEUOr8DDOXiZlc=; b=PUOaQ6P/x0zArKZGOPoapWbTy2wjygNnRLOWpqqbH30u+b5ZzKeljRwuLgdD0jwbf+ vTOCAcM2CDYj8PnS2lEp9H/d5ShJRBfXxxlfD3Wc2VwgJA1+Hoo9SAtHSihv7U7LPeym TFGJdG3JQR53sz7jUsCJtyoq1n9CAL6Cc/kDduZnKfMzgrNMYD/Am0RZ8BOBgouXuecN L0Kr/D14BcKfaP0+6f8QgBouVmX4f6bBrDOT4Jgwwtu+Y+H0Z5wmogaYVbtfYDg3+28S Axzb1VqQNy7K8tOQQEPCS5g1LMxi04G1sWpIVR4qSXl3WuAbmzC5S8EDhCG6GZsu06q6 N9rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706021665; x=1706626465; 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=NPxGZ40dkByGWudN3BtDjpXgJcnI+pEUOr8DDOXiZlc=; b=kVyfAklJkwk2/5kBmhlGoAQUkaz6etfCCNvgKA3RggjmGTZdCk2WnLyqI4dEoUKYwy tJHn+XpZYYIQDJtWr4cyDmAADX/isdXTbwfqXhA6Szwwp/jO04DwmEubvGIBwh6+leCU BLQrKGfDHmGytRYafCpR9g31iRaHaov6c7jAbd4ABX2/9AB2eEWzFyxO5maQaaz9bSt5 y/vR5H4ItRWnfoomtVQFgHxGDh/F6Y+fJUaNdiR/KHx5Xe/AQniUb0AQ//fafsrBM4BG zeqZOlIjV8bPzr2QJcIvddbsPUdPATgjdHBjcUmlNrUQRYjI5XYucjHAOV5NNkOcMNcp E8yQ== X-Gm-Message-State: AOJu0Yzy5kdICDxhW0pCglJve/QbUnvjhsyVM6WWQROj/vcjqIO2fqdy PxyN7Fq/g8kzYubRa+SjNw3NNqBXc31HB48ngVHuRPBQ0700PsVhqJNXj+YrbwrpS758inH1e+O e8r4xg6AlMAki7Qk2qfJfdjj6jw9Y4OTqtsVRoeBz6BrZjCX2gBRzHUPLtpDsX6H1EqblLDzGl4 VmQXhSRYf/E59kt8zhFBVK/fXZchQLGhkhfO0aYZwQ X-Google-Smtp-Source: AGHT+IGpHWru25yldacDYV6MVHekADw1NaRTtTKSQXcptCgpKuNXEt4vYPiia3cA+AYeV2PMvFOcfhrI X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:6902:2412:b0:dc2:4cf5:9ed0 with SMTP id dr18-20020a056902241200b00dc24cf59ed0mr2737746ybb.5.1706021665497; Tue, 23 Jan 2024 06:54:25 -0800 (PST) Date: Tue, 23 Jan 2024 15:53:01 +0100 In-Reply-To: <20240123145258.1462979-52-ardb+git@google.com> Mime-Version: 1.0 References: <20240123145258.1462979-52-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=3092; i=ardb@kernel.org; h=from:subject; bh=gYLVr8321g17hWMeRcnC+K3579d3jinccJ0uP287Skg=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIXX9pbP6PR/37FEXPH3sos/eRQtyGzZlRV69v3HjlTYDz 5n5KudqO0pZGMQ4GGTFFFkEZv99t/P0RKla51myMHNYmUCGMHBxCsBEhL8y/E/4K7PyRXekzLXp 9XO4yidE/2xVZMxufugcZtS89HhpejXDP91chU0cTkWt03Z+cQ/m3SiSUaowI///RfE67t6CDZn PGQE= X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240123145258.1462979-54-ardb+git@google.com> Subject: [PATCH v7 02/50] 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240123_065427_796354_A5B6532D X-CRM114-Status: GOOD ( 17.34 ) 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. Acked-by: Mark Rutland Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/memory.h | 2 +- arch/arm64/include/asm/pgtable.h | 2 +- arch/arm64/mm/fixmap.c | 3 +++ arch/arm64/mm/ptdump.c | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index b04fa8a8a262..f3be3ea74138 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 79ce70fbb751..2aa2e3c961d7 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/fixmap.c b/arch/arm64/mm/fixmap.c index c0a3301203bd..6fc17b2e1714 100644 --- a/arch/arm64/mm/fixmap.c +++ b/arch/arm64/mm/fixmap.c @@ -16,6 +16,9 @@ #include #include +/* ensure that the fixmap region does not grow down into the PCI I/O region */ +static_assert(FIXADDR_TOT_START > PCI_IO_END); + #define NR_BM_PTE_TABLES \ SPAN_NR_ENTRIES(FIXADDR_TOT_START, FIXADDR_TOP, PMD_SHIFT) #define NR_BM_PMD_TABLES \ diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index 46acb2a24da0..a929b5a321db 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_END, "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 }, };