The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] riscv: add a warning when physical memory address overflows
@ 2024-08-14  6:26 Yunhui Cui
  2024-08-15 11:01 ` Alexandre Ghiti
  2025-01-30 14:10 ` patchwork-bot+linux-riscv
  0 siblings, 2 replies; 6+ 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


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

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

Thread overview: 6+ 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-15 11:01 ` Alexandre Ghiti
2024-09-18  3:49   ` [External] " yunhui cui
2024-10-23 14:25     ` Punit Agrawal
2025-02-03 15:59       ` Palmer Dabbelt
2025-01-30 14:10 ` patchwork-bot+linux-riscv

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