Thread (1 message) flat view 1 message, 1 author, 2025-12-01

Re: [PATCH] arch/x86: memory_hotplug, do not bump up max_pfn for device private pages

From: Gregory Price <gourry@gourry.net>
Date: 2025-12-01 23:01:53
Also in: linux-mm, lkml

On Mon, Dec 01, 2025 at 02:11:35PM -0800, dan.j.williams@intel.com wrote:
[ add Gregory and linux-mm ]

[ full context for new Cc: ]
Balbir Singh wrote:
quoted
Commit 7ffb791423c7 ("x86/kaslr: Reduce KASLR entropy on most x86 systems")
exposed a bug with nokaslr and zone device
interaction, as seen on a system with an AMD iGPU and dGPU (see [1]).
The root cause of the issue is that, the gpu driver registers a zone
                                         ^^^^^^^^^^^^^^ which one, iGPU
					 or dGPU? or they managed by the
					 same driver?

					 (sorry, stickler for vagueness)
quoted
Fix this by not bumping up max_pfn on x86 systems, when pgmap is passed
into add_pages(). The presence of pgmap is used to determine if device
private memory is being added via add_pages().
Concur with Dan's take below here, please check for DEVICE_PRIVATE so as
not to affect DEVICE_COHERENT.  Or if there's a reason to affect
DEVICE_COHERENT, please explain here.
quoted
arch/powerpc is also impacted by this bug, this patch does not fix
the issue for powerpc.

I've left powerpc out of this regression change due to the time required
to setup and test via qemu. I wanted to address the regression quickly
At least +Cc ppc folks to take a look?
+Cc: linux-ppc-dev
quoted hunk
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 0e4270e20fad..4cc8175f9ffd 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -989,7 +989,7 @@ int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
 	 * addressable memory can force device drivers to use bounce buffers
 	 * and impact their performance negatively:
 	 */
-	if (!params->pgmap)
+	if (!params->pgmap || params->pgmap->type != MEMORY_DEVICE_PRIVATE)
 		/* update max_pfn, max_low_pfn and high_memory */
 		update_end_of_memory_vars(start_pfn << PAGE_SHIFT, nr_pages << PAGE_SHIFT);
 
This looks better to me.

~Gregory
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help