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 71C52C46CA3 for ; Wed, 29 Nov 2023 12:31:35 +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=redvmOFStJpH8SJ+XRx+tMhtWl1PvUCUhqfgquxxEJA=; b=wZQTSZjlhZsYhqvaZU3jAFU4Li /B18RpvXoWJU7BZxPb376gKoI93KO6TmqFEd4pe4gRR4mDllAEXm2S4A8s8AqVgSLpy+IbLmom1x7 que8Qn9RkT2x0OViCYVJsE1oOCC6dJ+gs2RTgusbD30fU+VPo4ect4RL3VLM+LNjNHM4XNM5aNSeC xgGAI2DJE24VgK41ch+9Xf3uioLoQu3ZXhmxXv1VkwEQWTGTkOJbrsjRL56xJA9gZO/ab34cOC8+/ djLK/UMQj7fNrdlYFvhsq5fOlfJAnDs/Fvf3Sj4ihftZJGB2rcDoR1MDU91dM9Z7dXVE+S8aOR5lL n+WTNhAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8Jie-008KC2-1B; Wed, 29 Nov 2023 12:31:08 +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 1r8IZT-007z5n-0V for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2023 11:17:36 +0000 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-332ee6c2a1aso3571799f8f.1 for ; Wed, 29 Nov 2023 03:17:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701256653; x=1701861453; 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=V86olf1EKJaGQIDLZDyTyPOGst5YdmjimBytLucyYgQ=; b=X1yIMLfo4gTET+6O5flWJcMzga9gRz3QiJg0c82y+peSOZqMs1F8SKttLRJzLn74ug +8Etq5oZ92+FfwzWAexKpOknRq+Mc67jHzV4LUjXsWXIkM853oweb4SK+1MKfacjL/pr Ksr3z+YwHwsi7MlrdJrmfv/0rLe0p2kdzDTCnUeYsFsMEZVSLVLQlvFXO+D7P3fPTN+G 3Ny6VAePvJ90Z41JVeBjTZcplSWt3+3YDJ9uC10re4TOG6g59zRmcdJeueKYOSdOLqGJ 5JzPEyP9Sh20XtDvEvgHcnRHJj9tS01sd04Z+ucpge0YyJtKRy5cRgXMEYlrICyiVW2K 0l1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701256653; x=1701861453; 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=V86olf1EKJaGQIDLZDyTyPOGst5YdmjimBytLucyYgQ=; b=gfAS36x5iFeGDwjriuoXjiNTkh4hEq1n3XiIYjd//8imUpFYL5UC++SHv3W9CUrSLJ YL9sgEK8POEWJjmvLyNdSy+u8sB4EIQZX+CYiL+b4/GUnReitBJpj1zUerX/DowqajFQ +Vt66ZoR7AKzJehD4Xv5JxoeNAnijrBL6jTXjiCVZ9C4o0wA91Q86GQo2RjFiNjdG77A v7MzzikzQdOuN/WomOZlbNNYEJS+9XsXo7s3wLEaoR8Nco70nxy5bDdm9Y0YOnTsDTCA SNsbjQuwu2hjGlogjW4/Wl6yE1qG8qZJCILwE5Cacrs4jS8qYTulH6gWMNIAxTVC9pNW Zvxg== X-Gm-Message-State: AOJu0YysBBBdyBdboqhsbdpUDqtM+ExhJ9jtjmjM8kuqRvstJ4oKubKW RumtnS9XcsIpV3Byw6pYpx0xinaZqzF92IrPiS1kU7k3loF7axv5fG6hH9e9XIH6Fc5Q29gjS/U +ZJ1FdMzOQzk7eZh6ahJYq06H64QtSrnXv5HpwW+LGGcyL0RnqADZiMRnTNjw4iSKNvzbCvVECp A= X-Google-Smtp-Source: AGHT+IGATGiRTEK8I1KK/PRRAcWGLUKmWTikb9MbBlyG3mAkI0XAegCIbF0l7s5YO4iHIqe/J/NVE43g X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a5d:688e:0:b0:332:c0aa:ce15 with SMTP id h14-20020a5d688e000000b00332c0aace15mr276791wru.10.1701256653195; Wed, 29 Nov 2023 03:17:33 -0800 (PST) Date: Wed, 29 Nov 2023 12:16:04 +0100 In-Reply-To: <20231129111555.3594833-43-ardb@google.com> Mime-Version: 1.0 References: <20231129111555.3594833-43-ardb@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=2460; i=ardb@kernel.org; h=from:subject; bh=wwOsRm3FZFgGJ9li8cLLVrn99cMWNOQlYRvDxthbRTc=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JITVdtnSRgn5Unf+zP/m2Qsd0H3BM7HP/sTJOMUZ2ke/hy v8FNXEdpSwMYhwMsmKKLAKz/77beXqiVK3zLFmYOaxMIEMYuDgFYCJKvIwM37YacImJv81cK8qx Ivvh09AdKXs+9MX7v3htXzHh399V3xn+V2gtEv5xpcU70uGAS9NvieXqTit/z7tzOfsY3y3ZmF+ KrAA= X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Message-ID: <20231129111555.3594833-51-ardb@google.com> Subject: [PATCH v6 08/41] arm64: vmemmap: Avoid base2 order of struct page size to dimension 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-20231129_031735_205784_7268B9E0 X-CRM114-Status: GOOD ( 17.32 ) 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 From: Ard Biesheuvel The placement and size of the vmemmap region in the kernel virtual address space is currently derived from the base2 order of the size of a struct page. This makes for nicely aligned constants with lots of leading 0xf and trailing 0x0 digits, but given that the actual struct pages are indexed as an ordinary array, this resulting region is severely overdimensioned when the size of a struct page is just over a power of 2. This doesn't matter today, but once we enable 52-bit virtual addressing for 4k pages configurations, the vmemmap region may take up almost half of the upper VA region with the current struct page upper bound at 64 bytes. And once we enable KMSAN or other features that push the size of a struct page over 64 bytes, we will run out of VMALLOC space entirely. So instead, let's derive the region size from the actual size of a struct page, and place the entire region 1 GB from the top of the VA space, where it still doesn't share any lower level translation table entries with the fixmap. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/memory.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 2745bed8ae5b..b49575a92afc 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -30,8 +30,8 @@ * keep a constant PAGE_OFFSET and "fallback" to using the higher end * of the VMEMMAP where 52-bit support is not available in hardware. */ -#define VMEMMAP_SHIFT (PAGE_SHIFT - STRUCT_PAGE_MAX_SHIFT) -#define VMEMMAP_SIZE ((_PAGE_END(VA_BITS_MIN) - PAGE_OFFSET) >> VMEMMAP_SHIFT) +#define VMEMMAP_RANGE (_PAGE_END(VA_BITS_MIN) - PAGE_OFFSET) +#define VMEMMAP_SIZE ((VMEMMAP_RANGE >> PAGE_SHIFT) * sizeof(struct page)) /* * PAGE_OFFSET - the virtual address of the start of the linear map, at the @@ -47,8 +47,8 @@ #define MODULES_END (MODULES_VADDR + MODULES_VSIZE) #define MODULES_VADDR (_PAGE_END(VA_BITS_MIN)) #define MODULES_VSIZE (SZ_2G) -#define VMEMMAP_START (-(UL(1) << (VA_BITS - VMEMMAP_SHIFT))) -#define VMEMMAP_END (VMEMMAP_START + VMEMMAP_SIZE) +#define VMEMMAP_START (VMEMMAP_END - VMEMMAP_SIZE) +#define VMEMMAP_END (-UL(SZ_1G)) #define PCI_IO_START (VMEMMAP_END + SZ_8M) #define PCI_IO_END (PCI_IO_START + PCI_IO_SIZE) #define FIXADDR_TOP (-UL(SZ_8M)) -- 2.43.0.rc1.413.gea7ed67945-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel