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 D75BAC10F05 for ; Mon, 11 Dec 2023 14:23:09 +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:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ljADk2/VbChBJd08log2/EiTs3x3/GmJavuJXG7bXxU=; b=wFHhAMaI90j0gQ oQ9iniMljKOxgLwAiy8tzuZW1uR7hJ+ZYfq/lY7FfIvNowVSpTU/wPG+qmssEwKmHGPAzE28SO48i ymCPSfyVeWMDNeL1em5P4j7BLoiyFMJQVASe0TrGAebNsF19723MFBYNAK5Vc1IDApcOnkKUVXEvA G9dzLsWZ+4QyJIq9Dr+tzA3G78kyVOzg2lVQwjN+skomAmqkCl2NF6wh+Rs1D7lzEG+3rb012UHnd Q5SwDSbJdXWzrP95WSuKbaM2OaFwhGxUVPIoGSh/ijMpw7hT+Sht6Wph/FFIy2hAayvwkNyxbJVZ+ IrktdYzoNoFugtIu+gMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rChB9-005AEa-33; Mon, 11 Dec 2023 14:22:40 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rChAT-005A5o-0Z for linux-arm-kernel@lists.infradead.org; Mon, 11 Dec 2023 14:22:13 +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 177BD1007; Mon, 11 Dec 2023 06:22:42 -0800 (PST) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.34.127]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 40C153F738; Mon, 11 Dec 2023 06:21:54 -0800 (PST) Date: Mon, 11 Dec 2023 14:21:51 +0000 From: Mark Rutland To: Ard Biesheuvel Cc: Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Marc Zyngier , Ryan Roberts , Anshuman Khandual , Kees Cook Subject: Re: [PATCH v6 04/41] arm64: mm: Move PCI I/O emulation region above the vmemmap region Message-ID: References: <20231129111555.3594833-43-ardb@google.com> <20231129111555.3594833-47-ardb@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231211_062157_680507_91E6DEE9 X-CRM114-Status: GOOD ( 28.42 ) 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 Mon, Dec 11, 2023 at 03:10:00PM +0100, Ard Biesheuvel wrote: > On Mon, 11 Dec 2023 at 14:57, Mark Rutland wrote: > > > > Hi Ard, > > > > On Wed, Nov 29, 2023 at 12:16:00PM +0100, Ard Biesheuvel wrote: > > > From: Ard Biesheuvel > > > > > > Move the PCI I/O region above the vmemmap region in the kernel's VA > > > space. This will permit us to reclaim the lower part of the vmemmap > > > region for vmalloc/vmap allocations when running a 52-bit VA capable > > > build on a 48-bit VA capable system. > > > > > > Signed-off-by: Ard Biesheuvel > > > --- > > > arch/arm64/include/asm/memory.h | 4 ++-- > > > arch/arm64/mm/ptdump.c | 4 ++-- > > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > > > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h > > > index b8d726f951ae..99caeff78e1a 100644 > > > --- a/arch/arm64/include/asm/memory.h > > > +++ b/arch/arm64/include/asm/memory.h > > > @@ -49,8 +49,8 @@ > > > #define MODULES_VSIZE (SZ_2G) > > > #define VMEMMAP_START (-(UL(1) << (VA_BITS - VMEMMAP_SHIFT))) > > > #define VMEMMAP_END (VMEMMAP_START + VMEMMAP_SIZE) > > > -#define PCI_IO_END (VMEMMAP_START - SZ_8M) > > > -#define PCI_IO_START (PCI_IO_END - PCI_IO_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) > > > > This looks simple, but it does have a subtle dependency on VMEMMAP_SIZE being > > sufficiently smaller than the negative offset we choose for VMEMMAP_START, and > > it took mw a while to convince myself that we always ensure that today. I could > > well imagine that we try to reduce that in future (given for most > > configurations we're reserving around double the space we actually need), and > > it would be nice if we could avoid that going wrong. > > > > Yes, we are relying on the fact that the upper region is not covered > by struct pages, so there is guaranteed to be an unused region at the > very top. Yep; exactly. My fear is that in future someone realises that: (-(UL(1) << (VA_BITS - VMEMMAP_SHIFT))) ... is actually reserving ~2x the space it needs for *most* configurations (since for most configurations we only need the VMEMMAP to account for (VA_BITS-1) bits of linear map). If they try to shrink the VMEMMAP region in for those cases, it's liable to overlap subsequent regions and/or to wrap those past the end of the VA space. > One of the constants in the equation that describes the size of this > unused region is the size of a struct page, and so I agree this needs > a couple of static asserts to ensure we don't get inadvertent > overlaps. That'd be great, thanks! Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel