From patchwork Wed Oct 9 02:50:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 13827463 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 6A083CF0433 for ; Wed, 9 Oct 2024 02:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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:In-Reply-To:References:List-Owner; bh=o9MCI123r/ELpJADf3nyJWnD0jeMU/uGAQJxG9X3K90=; b=bY7tW296xPSUECwmKdBFycmN/3 6S2TDZQa/eJMUt846MSMOYKtvZqbS5bVeORHNbhxUV+u3Sga/791AfIk/vbJ5tLjsdnOcU8xOtSbM RvzAkhB83v1fVzNgmtuZOjdbKE+/glVjWHHeRb9qtmkCniRAmM6yieejNxiM2vmCErGU4XW/GqVRH 0oBdGulS/f7k5+8eGRsc0j03rQUijx1g3YdOEZw32qGhZDuzfx0s2xUl+lLIITYwNrvw3nZeV2koc jnl1vNmjeSx/Fp/ZOmYWQ9g7JWDdwhKb74jdyz8anso/fff3wKSUj+Pgrfk/2hxL87gmju+P/edhi 7RBLXeqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syMnv-00000007kOC-003o; Wed, 09 Oct 2024 02:51:59 +0000 Received: from mail-co1nam11on20627.outbound.protection.outlook.com ([2a01:111:f403:2416::627] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syMmb-00000007kI3-0kYd for linux-arm-kernel@lists.infradead.org; Wed, 09 Oct 2024 02:50:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=klY0Tqkh/QofPeWfGGLl9Hhe1CW68C2cXeSzhK0KZ7RcWrkodIXchIUqp+XQoHrZUvu36Fsigj74T5T9g+DlV9ap2ngtCcAncxC4YOMUKQc7qTk75WKPZW7WrwSX3kIwg1BNY/fK10DKbLW0hm8STu0jDAg2I58V0TcIIOBavDD45T2VlXwuMQeR8mue1uw3/fcHBXim1ngsyLZ2R+yWRZ0rprfqO75yGFpyQQsikzrzJomJW2qMf3LYq5m+3DFkyTSzGcf5mgh8aiTlqUrknqQymtwoH5Ot1Oet/mA90PalC+isOgLmT0Ya7eHtyQqeR4iKqaGI8LWlXZG2YegcLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o9MCI123r/ELpJADf3nyJWnD0jeMU/uGAQJxG9X3K90=; b=RzCR4Fgn62NnPO9OApIqtjFFr2W8/s/h38yZyZ/EB6s6UgDjZT/YvUwv6YFLhwcLZTicdzF3tJeXf1usz4UMv8o52egA+aBCfbxGrdvG/EnTu0QDTojv0NHJkMRlwgfoxm9VjPUOZ/u4H/8HqS5dtY4KJxRQLmqxg/Xe638WlOeA/jzG+zWuqQpazqRWn0FMh2qGDOUTbhAtjwWCUMuJzOsf744nfYYYMuhsjH62BPCd3NP360lOzZIPLCif6KTPTGjNRiGR6aPW+8ev9gg/XzW+TppBwkJvSlKzGZBycn3DfIZvdUDjybiAgJW41COMGB2HGP0BornuOcLLHxb0Lg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o9MCI123r/ELpJADf3nyJWnD0jeMU/uGAQJxG9X3K90=; b=qdMdsxeDR8RECilYXmqZlBGt2UmwLwYJ0WFLX9wkL1WEKlvI+NGy0WSb8SySA+YCSlFDgx7ExLjiPJC0xp+fnnrXlxLXYI5kYbBH85nqcOkDGXu4FGm3wBLNocuEEcAaPv/OJD9Q2J9iiGjAs17hTQfMKKXk3RGXWbE1Zo1WfAWYzfqBmOM/W38LzpcfTlwn4MN5ouDVFMCvDSPfGl/FKO4XuTFPg4VwbPX+2a8xKAHFB0f0BnHcA/Zn/7zvKJ+MNDzfU4C8IvP8A2Hm6NtSBa/D5XS0SAs/Q4UkL2X/T3p8Hbg+x/zAJoGQW1KJHy86GNq157S//EsPCgtJZ6znsw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SJ0PR12MB5469.namprd12.prod.outlook.com (2603:10b6:a03:37f::16) by CY8PR12MB7121.namprd12.prod.outlook.com (2603:10b6:930:62::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Wed, 9 Oct 2024 02:50:28 +0000 Received: from SJ0PR12MB5469.namprd12.prod.outlook.com ([fe80::ff21:d180:55f2:d0c0]) by SJ0PR12MB5469.namprd12.prod.outlook.com ([fe80::ff21:d180:55f2:d0c0%6]) with mapi id 15.20.8026.020; Wed, 9 Oct 2024 02:50:28 +0000 From: John Hubbard To: Andrew Morton Cc: Thomas Gleixner , David Hildenbrand , Will Deacon , Alistair Popple , Jordan Niethe , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-mm@kvack.org, LKML , John Hubbard Subject: [PATCH] kaslr: rename physmem_end and PHYSMEM_END to direct_map_physmem_end Date: Tue, 8 Oct 2024 19:50:24 -0700 Message-ID: <20241009025024.89813-1-jhubbard@nvidia.com> X-Mailer: git-send-email 2.47.0 X-NVConfidentiality: public X-ClientProxiedBy: SJ0PR03CA0371.namprd03.prod.outlook.com (2603:10b6:a03:3a1::16) To SJ0PR12MB5469.namprd12.prod.outlook.com (2603:10b6:a03:37f::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR12MB5469:EE_|CY8PR12MB7121:EE_ X-MS-Office365-Filtering-Correlation-Id: 97d53673-ecc7-4bf6-99e3-08dce80d222f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: Z81KeJV4uzocaARxve1qvMp8i0Yfj8Zx6B0E5k/tFWlFpU/GGD6Lnvu/EgeLwuqfaXqM2xOjbOKvHxxlHPuHqmFdQlpK2GH7mqVVUSARXqIo5XxndINYr9q5xfmJbtutNCdE/uyEvl/SB0zCsEwvPX1CAiZegZtZETk4h4Oems9GoJ5aPJhLG0blKwVzkqcYSzSqMXLfZpfZEIS772y4Y9KwppLTYU5W/c3uAAPwMqL3bHxoMwS77Pk2H/rZSGYiIddUtyS3kyMskzFLy2MHOnvTWQIce+aGx/6qm3kmDp0P+Pbkc4yMEO9t7bJLSfU5/+lOpxIncq0AZm7S31+ooY3exNhoh7JqmJyE0mQ7ngfGUVBWyfGbRNFOOdJieBGGfHigaXhAWpyq0nqEMpSfoBKvbFKUmT7eRDrPGuMoCP4XxlSkWEGXfPFqSLGjEx0rpdtbKnho2gBmpFoit283LlcW3alIPtZ83TUQC5gBvhgS7dAY76OL9+DzJopSv2E/sHYB4Wjvr/T3t7xxOJVD98Dtx53GsofXzT+yCVomnWubg9FtxEJkYWRRO1ubgRCt0FXbEG+s/drKvCaNGHTY7d+BmnQl74MxUFeNHpIYdsNigWHjQmLwpdoMkXNCXpWSFu3RXxrD9V+5mbCI5uASLMgNFjeFF6AMeDY0mjs1ZgOnyS1zTRZv8hBO+pEqrmd2GJHMkrmp+kjhXmjtnIHPsGr9kqs9pOJu9z/ZRpy5aGWIP5erYqcl4cDXVmfgN6Zu7pvdrT6HIvsGNjUDrb7S/3hyHe+7xj5ADvkJd2xoyD+jqn77bkjqzwUR6RYjzTjCP/2EU9AUHP+aOnWA2RCkiui7suoz8//IK54AnZAAwLTVrHy0qtDHJL/qewD1mvpf1hpNC/4jPmBiOj5x5uwWNc3LVEb/OtDy99W7z5WmqUGJU2ZMNrxUYDrFDKKvEJixOYzbora5rmEfN2w7ae7fi4QP8j3+rbfvqSw7IqA4FwNA2N1PSfoZoxahYS4u7Q2eSMh7QRsPvRvU3va+6oAzsPdEfCg5hCJSFdNLfEgwLa7+A97mkwqsQgpLZOhlGiFG2KsqWBzX9WRLqObm6+l3uvNz1uFqTmiyEOxXDKzD+/NfWrSLVSTKT/iFPFgxMiHJFWM09XnNVho8DmT5f9NDNY8bY4KMm3khRYh5R9zmnBT7TQv18LpW1JGWbHom7daJYsfeaFNSNXdz5+cehak0VaROOFdNJYGARHuO5m2JoEGT/lQ/PN/EDYJWYEgitGG1B+2rmmpF/7gCR/NB5lGg8g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR12MB5469.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Jh5LVzpuPDM/7lLtpqfJxneAJ0uKhktlVX7NliLb+AmIn5cu4VIs6yntks5wz/rpxwj0FeoxfZjb75lwiZ3OVtIzV0m7aqDzVBdMP8TGoni9n03htGMmdUAKWfLQtl43RtR/BfTmoySRjuybW8PHRY2miJo3isa3EM4kapp4ch6v0Jps7pSmSmeQWmZD4wIgl85gYzYAT/c6Xdl/jyxBYMz6ywcijcX7V4WddcGwk6m3JDG5GIuH2oHmmR9tbSVLKvU1rn323DpmDD/sZtOUHYOVA6jecpMVrgImNB0JY6yEXk8jxoP/X0NYB7ytC3qIBaIyiEip8CnHiRNrq/uP4SPmQqpEwQGsxE/beoBsBSA8w+p9wWplB0R41XkeUmyfo0hqxMDWQpUBl6QDBmcFz5GPzNVzq/06ekpYhTu/v9ON8H1bjpoQf9+6LNxXJWHJT1ZE2sYY2i5vd/8nKOtOXevU4pCt6ubYUXePn8YCfAvkeEa6kr7V5VEh9NQbHeLp1EHNbr9PZ18CJMlCeEyB3q2TQfah/KewKrRSgPPq5NHetLNS/NCECiLO5nifx0EbIWtbTaGtpcEYwDXuHMlQvjw+qND8jULFfLRaWb2W6q/ZmqjE3zVP5JIFe2E9WVVgqRVQaeIo/AimpgEGuT84UD2WrlzYqqrBpuOD0KnStvVSzBLr3Gpn3Ee+N4jqG9HzRIwHtBaiF8d8mIvfLWPBdrWDR9QDXSHJMEqAXg9dofdko3K3xte8FxKm9UL7t/u19eE1Edee6jedfcpZYzklS5ZxeZhO6E+lUUgY3XP2HvWMJMy2+zK0iiA1ennWvzy5T62uQVhwcr0xI6UmkWcZs0uc0ibSY797FxDiNbQPuDzUIx8YwBu0ykCfHGeutELUSwWwuRxwN2p4qbgBGbhZfkPlrtpgKjoJ4hxmdfgSekufa+3VRU6e7rb0CLPB2VZWHSG8a3AcxYlpWy8GXhg7ru+Kv/H+PmOnwWrP058Utv/W5eF68qZa0OOl4HUXaBsZvVuCWXpom2zN+NUTXGBtSXSfG0DPv+JI2sos8x5DDXVlTG/OyD7fK77AoGVtgXpbz99kgNLbHd/AFN/fAwvilhmkTahnV09AlMYUVGUq1FSgXaRkypdNH8wfVbkzmi5236lAqJjU6bPdnKJzan1Bo2eY3QINXcYFGEJQNotNvz01G8jOA4MRdrg7gITfzrxv2dCqiNc4nPgMJ4FojSZC1RBVHajWMy7yXllMogjzl+3Tdkf/yUWJnY3AlbNNxTxDPcBgv3AuNBWp8iryR9X78p2PEkPj43Uu6OVqgjxLpbvM1Sj5vq2UTlgFmqGiOTtP60ABco2urWjlKKzpPckkOZajynps/5XNwmyiCT8b8+PRx7a2fMmLeoS6FLuNc9a6PsKwJeNSc3PcBmo3/GXDGkBIL15tLtNqTqAYaK6fPg/Wi+Wmntwfc1fydqIi/CGJ4iifVfXmf4z7vGQhkKy3buyZJrXaOoNf0/nkfRsdaeVxySTxFsyouFk8Bd8r17t4M4040xv/QMZtWV8GjWqxNdptS5ec/reNvom06Y+2aUtxYGjiYtuy2dcNZArkyeuo X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97d53673-ecc7-4bf6-99e3-08dce80d222f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR12MB5469.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 02:50:28.6449 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VXKEyM0G/VHjKpI9AmmXQJ1k5qrvLMMVr25jPlfKWlmJXJHWEFzp5sVwW4dlznuvaJUpUlnfg3zFXo43BaqThg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7121 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241008_195037_439665_F9C1944D X-CRM114-Status: GOOD ( 21.83 ) 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 For clarity. It's increasingly hard to reason about the code, when KASLR is moving around the boundaries. In this case where KASLR is randomizing the location of the kernel image within physical memory, the maximum number of address bits for physical memory has not changed. What has changed is the ending address of memory that is allowed to be directly mapped by the kernel. Let's name the variable, and the associated macro accordingly. Also, enhance the comment above the direct_map_physmem_end definition, to further clarify how this all works. Cc: Thomas Gleixner Cc: Alistair Popple Cc: Jordan Niethe Cc: David Hildenbrand Signed-off-by: John Hubbard Reviewed-by: Pankaj Gupta Acked-by: David Hildenbrand Acked-by: Will Deacon Reviewed-by: Mike Rapoport (Microsoft) --- David Hildenbrand, I recall you had an unanswered question in this vicinity [1] when tglx's recent kaslr fix was being reviewed. Maybe this will help with that. [1] https://lore.kernel.org/linux-mm/ee205448-5fdd-495e-9d7c-c8a2b59f9c9e@roeck-us.net/T/#mdf442f077c9023590e144dbed2b04a109793484d thanks, John Hubbard arch/arm64/include/asm/memory.h | 2 +- arch/x86/include/asm/page_64.h | 2 +- arch/x86/include/asm/pgtable_64_types.h | 2 +- arch/x86/mm/init_64.c | 2 +- arch/x86/mm/kaslr.c | 14 +++++++++----- include/linux/mm.h | 6 +++--- kernel/resource.c | 4 ++-- mm/memory_hotplug.c | 2 +- mm/sparse.c | 2 +- 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 0480c61dbb4f..73eaa8c2536a 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -110,7 +110,7 @@ #define PAGE_END (_PAGE_END(VA_BITS_MIN)) #endif /* CONFIG_KASAN */ -#define PHYSMEM_END __pa(PAGE_END - 1) +#define DIRECT_MAP_PHYSMEM_END __pa(PAGE_END - 1) #define MIN_THREAD_SHIFT (14 + KASAN_THREAD_SHIFT) diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h index f3d257c45225..d63576608ce7 100644 --- a/arch/x86/include/asm/page_64.h +++ b/arch/x86/include/asm/page_64.h @@ -17,7 +17,7 @@ extern unsigned long phys_base; extern unsigned long page_offset_base; extern unsigned long vmalloc_base; extern unsigned long vmemmap_base; -extern unsigned long physmem_end; +extern unsigned long direct_map_physmem_end; static __always_inline unsigned long __phys_addr_nodebug(unsigned long x) { diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h index a98e53491a4e..ec68f8369bdc 100644 --- a/arch/x86/include/asm/pgtable_64_types.h +++ b/arch/x86/include/asm/pgtable_64_types.h @@ -141,7 +141,7 @@ extern unsigned int ptrs_per_p4d; #endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */ #ifdef CONFIG_RANDOMIZE_MEMORY -# define PHYSMEM_END physmem_end +# define DIRECT_MAP_PHYSMEM_END direct_map_physmem_end #endif /* diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index ff253648706f..5a564130b9d0 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -961,7 +961,7 @@ int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages, unsigned long end = ((start_pfn + nr_pages) << PAGE_SHIFT) - 1; int ret; - if (WARN_ON_ONCE(end > PHYSMEM_END)) + if (WARN_ON_ONCE(end > DIRECT_MAP_PHYSMEM_END)) return -ERANGE; ret = __add_pages(nid, start_pfn, nr_pages, params); diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c index 230f1dee4f09..70d3353c92fa 100644 --- a/arch/x86/mm/kaslr.c +++ b/arch/x86/mm/kaslr.c @@ -52,7 +52,7 @@ static __initdata struct kaslr_memory_region { } kaslr_regions[] = { { .base = &page_offset_base, - .end = &physmem_end, + .end = &direct_map_physmem_end, }, { .base = &vmalloc_base, @@ -62,8 +62,12 @@ static __initdata struct kaslr_memory_region { }, }; -/* The end of the possible address space for physical memory */ -unsigned long physmem_end __ro_after_init; +/* + * The end of the physical address space that can be mapped directly by the + * kernel. This starts out at (1< __START_KERNEL_map); /* Preset the end of the possible address space for physical memory */ - physmem_end = ((1ULL << MAX_PHYSMEM_BITS) - 1); + direct_map_physmem_end = ((1ULL << MAX_PHYSMEM_BITS) - 1); if (!kaslr_memory_enabled()) return; @@ -145,7 +149,7 @@ void __init kernel_randomize_memory(void) vaddr += get_padding(&kaslr_regions[i]); /* * KASLR trims the maximum possible size of the - * direct-map. Update the physmem_end boundary. + * direct-map. Update the direct_map_physmem_end boundary. * No rounding required as the region starts * PUD aligned and size is in units of TB. */ diff --git a/include/linux/mm.h b/include/linux/mm.h index ecf63d2b0582..92c35fb60d18 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -97,11 +97,11 @@ extern const int mmap_rnd_compat_bits_max; extern int mmap_rnd_compat_bits __read_mostly; #endif -#ifndef PHYSMEM_END +#ifndef DIRECT_MAP_PHYSMEM_END # ifdef MAX_PHYSMEM_BITS -# define PHYSMEM_END ((1ULL << MAX_PHYSMEM_BITS) - 1) +# define DIRECT_MAP_PHYSMEM_END ((1ULL << MAX_PHYSMEM_BITS) - 1) # else -# define PHYSMEM_END (((phys_addr_t)-1)&~(1ULL<<63)) +# define DIRECT_MAP_PHYSMEM_END (((phys_addr_t)-1)&~(1ULL<<63)) # endif #endif diff --git a/kernel/resource.c b/kernel/resource.c index b730bd28b422..afa3ad09b834 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -1871,7 +1871,7 @@ static resource_size_t gfr_start(struct resource *base, resource_size_t size, if (flags & GFR_DESCENDING) { resource_size_t end; - end = min_t(resource_size_t, base->end, PHYSMEM_END); + end = min_t(resource_size_t, base->end, DIRECT_MAP_PHYSMEM_END); return end - size + 1; } @@ -1888,7 +1888,7 @@ static bool gfr_continue(struct resource *base, resource_size_t addr, * @size did not wrap 0. */ return addr > addr - size && - addr <= min_t(resource_size_t, base->end, PHYSMEM_END); + addr <= min_t(resource_size_t, base->end, DIRECT_MAP_PHYSMEM_END); } static resource_size_t gfr_next(resource_size_t addr, resource_size_t size, diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 621ae1015106..c43b4e7fb298 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1681,7 +1681,7 @@ struct range __weak arch_get_mappable_range(void) struct range mhp_get_pluggable_range(bool need_mapping) { - const u64 max_phys = PHYSMEM_END; + const u64 max_phys = DIRECT_MAP_PHYSMEM_END; struct range mhp_range; if (need_mapping) { diff --git a/mm/sparse.c b/mm/sparse.c index dc38539f8560..4cb9793f0b52 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -129,7 +129,7 @@ static inline int sparse_early_nid(struct mem_section *section) static void __meminit mminit_validate_memmodel_limits(unsigned long *start_pfn, unsigned long *end_pfn) { - unsigned long max_sparsemem_pfn = (PHYSMEM_END + 1) >> PAGE_SHIFT; + unsigned long max_sparsemem_pfn = (DIRECT_MAP_PHYSMEM_END + 1) >> PAGE_SHIFT; /* * Sanity checks - do not allow an architecture to pass