mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] remove the initrd resource in /proc/iomem  as the initrd has freed the reserved memblock.
@ 2019-07-02 10:34 Yi Wang
  2019-07-02 15:18 ` James Morse
  0 siblings, 1 reply; 2+ messages in thread
From: Yi Wang @ 2019-07-02 10:34 UTC (permalink / raw)
  To: catalin.marinas
  Cc: will.deacon, akpm, rppt, f.fainelli, logang, robin.murphy,
	ghackmann, hannes, david, linux-arm-kernel, linux-kernel,
	xue.zhihong, wang.yi59, jiang.xuexin, Junhua Huang

From: Junhua Huang <huang.junhua@zte.com.cn>

The 'commit 50d7ba36b916 ("arm64: export memblock_reserve()d regions via /proc/iomem")'
show the reserved memblock in /proc/iomem. But the initrd's reserved memblock
will be freed in free_initrd_mem(), which executes after the reserve_memblock_reserved_regions().
So there are some incorrect information shown in /proc/iomem. e.g.:
80000000-bbdfffff : System RAM
  80080000-813effff : Kernel code
  813f0000-8156ffff : reserved
  81570000-817fcfff : Kernel data
  83400000-83ffffff : reserved
  90000000-90004fff : reserved
  b0000000-b2618fff : reserved
  b8c00000-bbbfffff : reserved
In this case, the range from b0000000 to b2618fff is reserved for initrd, which should be
clean from the resource tree after it was freed. As kexec-tool will collect the iomem reserved info 
and use it in second kernel, which causes error message generated a second time.

At the same time, we should free the reserved memblock in an aligned manner because 
the initrd reserves the memblock in an aligned manner in arm64_memblock_init(). 
Otherwise there are some fragments in memblock_reserved regions. e.g.:
/sys/kernel/debug/memblock # cat reserved 
   0: 0x0000000080080000..0x00000000817fafff
   1: 0x0000000083400000..0x0000000083ffffff
   2: 0x0000000090000000..0x000000009000407f
   3: 0x00000000b0000000..0x00000000b000003f
   4: 0x00000000b26184ea..0x00000000b2618fff
The fragments like the ranges from b0000000 to b000003f and from b26184ea to b2618fff 
should be freed.

Signed-off-by: Junhua Huang <huang.junhua@zte.com.cn>
---
 arch/arm64/mm/init.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index d2adffb81b5d..14ba8113eab5 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -580,8 +580,16 @@ void free_initmem(void)
 #ifdef CONFIG_BLK_DEV_INITRD
 void __init free_initrd_mem(unsigned long start, unsigned long end)
 {
+	struct resource *res = NULL;
+
 	free_reserved_area((void *)start, (void *)end, 0, "initrd");
-	memblock_free(__virt_to_phys(start), end - start);
+	start = __virt_to_phys(start) & PAGE_MASK;
+	end = PAGE_ALIGN(__virt_to_phys(end));
+	memblock_free(start, end - start);
+	res = lookup_resource(&iomem_resource, memblock_start_of_DRAM());
+	if (res != NULL)
+		__release_region(res, start, end - start);
+
 }
 #endif
 
-- 
2.15.2


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

end of thread, other threads:[~2019-07-02 15:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-02 10:34 [PATCH] remove the initrd resource in /proc/iomem as the initrd has freed the reserved memblock Yi Wang
2019-07-02 15:18 ` James Morse

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

all inboxes | Powered by JetHome®