All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] riscv: add a warning when physical memory address overflows
@ 2024-08-14  6:26 ` Yunhui Cui
  0 siblings, 0 replies; 12+ messages in thread
From: Yunhui Cui @ 2024-08-14  6:26 UTC (permalink / raw)
  To: punit.agrawal, paul.walmsley, palmer, aou, alexghiti, cuiyunhui,
	chenjiahao16, guoren, vishal.moola, stuart.menefy, linux-riscv,
	linux-kernel

The part of physical memory that exceeds the size of the linear mapping
will be discarded. When the system starts up normally, a warning message
will be printed to prevent confusion caused by the mismatch between the
system memory and the actual physical memory.

Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
 arch/riscv/mm/init.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 52290c9bd04bd..c93164dc51658 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -236,8 +236,12 @@ static void __init setup_bootmem(void)
 	 */
 	if (IS_ENABLED(CONFIG_64BIT)) {
 		max_mapped_addr = __pa(PAGE_OFFSET) + KERN_VIRT_SIZE;
-		memblock_cap_memory_range(phys_ram_base,
-					  max_mapped_addr - phys_ram_base);
+		if (memblock_end_of_DRAM() > max_mapped_addr) {
+			memblock_cap_memory_range(phys_ram_base,
+						  max_mapped_addr - phys_ram_base);
+			pr_warn("Physical memory overflows the linear mapping size: region above 0x%llx removed",
+				max_mapped_addr);
+		}
 	}
 
 
-- 
2.39.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2025-02-03 15:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-14  6:26 [PATCH] riscv: add a warning when physical memory address overflows Yunhui Cui
2024-08-14  6:26 ` Yunhui Cui
2024-08-15 11:01 ` Alexandre Ghiti
2024-08-15 11:01   ` Alexandre Ghiti
2024-09-18  3:49   ` [External] " yunhui cui
2024-09-18  3:49     ` yunhui cui
2024-10-23 14:25     ` Punit Agrawal
2024-10-23 14:25       ` Punit Agrawal
2025-02-03 15:59       ` Palmer Dabbelt
2025-02-03 15:59         ` Palmer Dabbelt
2025-01-30 14:10 ` patchwork-bot+linux-riscv
2025-01-30 14:10   ` patchwork-bot+linux-riscv

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.