linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mips: fix HIGHMEM initialization
@ 2025-12-31 10:57 Mike Rapoport
  2025-12-31 12:43 ` AW: " markus.stockhausen
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Rapoport @ 2025-12-31 10:57 UTC (permalink / raw)
  To: Thomas Bogendoerfer
  Cc: Andrew Morton, Chris Packham, Mike Rapoport, Thomas Gleixner,
	hauke, jelonek.jonas, markus.stockhausen, linux-mips,
	linux-kernel, linux-mm

From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>

Commit 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing") overzealously
removed mem_init_free_highmem() function that beside freeing high memory
pages checked for CPU support for high memory as a prerequisite.

Partially restore mem_init_free_highmem() with a new highmem_init() name
and make it discard high memory in case there is no CPU support for it.

Reported-by: markus.stockhausen@gmx.de
Fixes: 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing")
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
 arch/mips/mm/init.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index a673d3d68254..8986048f9b11 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -425,6 +425,28 @@ void __init paging_init(void)
 static struct kcore_list kcore_kseg0;
 #endif
 
+static inline void __init highmem_init(void)
+{
+#ifdef CONFIG_HIGHMEM
+	unsigned long tmp;
+
+	/*
+	 * If CPU cannot support HIGHMEM discard the memory above highstart_pfn
+	 */
+	if (cpu_has_dc_aliases) {
+		memblock_remove(PFN_PHYS(highstart_pfn), -1);
+		return;
+	}
+
+	for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
+		struct page *page = pfn_to_page(tmp);
+
+		if (!memblock_is_memory(PFN_PHYS(tmp)))
+			SetPageReserved(page);
+	}
+#endif
+}
+
 void __init arch_mm_preinit(void)
 {
 	/*
@@ -435,6 +457,7 @@ void __init arch_mm_preinit(void)
 
 	maar_init();
 	setup_zero_pages();	/* Setup zeroed pages.  */
+	highmem_init();
 
 #ifdef CONFIG_64BIT
 	if ((unsigned long) &_text > (unsigned long) CKSEG0)
-- 
2.51.0



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-31 12:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-31 10:57 [PATCH] mips: fix HIGHMEM initialization Mike Rapoport
2025-12-31 12:43 ` AW: " markus.stockhausen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox