linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: kdump: Skip kmemleak scan reserved memory for kdump
@ 2021-08-27  9:22 Chen Wandun
  2021-08-30  4:05 ` Kefeng Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chen Wandun @ 2021-08-27  9:22 UTC (permalink / raw)
  To: catalin.marinas, will, ardb, rppt, akpm, nsaenz,
	anshuman.khandual, geert+renesas, rafael.j.wysocki, robh,
	kirill.shtuemov, sfr, linux-arm-kernel, linux-kernel,
	wangkefeng.wang
  Cc: weiyongjun1, guohanjun, Chen Wandun

Trying to boot with kdump + kmemleak, command will result in a crash:
"echo scan > /sys/kernel/debug/kmemleak"

crashkernel reserved: 0x0000000007c00000 - 0x0000000027c00000 (512 MB)
Kernel command line: BOOT_IMAGE=(hd1,gpt2)/vmlinuz-5.14.0-rc5-next-20210809+ root=/dev/mapper/ao-root ro rd.lvm.lv=ao/root rd.lvm.lv=ao/swap crashkernel=512M
Unable to handle kernel paging request at virtual address ffff000007c00000
Mem abort info:
  ESR = 0x96000007
  EC = 0x25: DABT (current EL), IL = 32 bits
  SET = 0, FnV = 0
  EA = 0, S1PTW = 0
  FSC = 0x07: level 3 translation fault
Data abort info:
  ISV = 0, ISS = 0x00000007
  CM = 0, WnR = 0
swapper pgtable: 64k pages, 48-bit VAs, pgdp=00002024f0d80000
[ffff000007c00000] pgd=1800205ffffd0003, p4d=1800205ffffd0003, pud=1800205ffffd0003, pmd=1800205ffffc0003, pte=0068000007c00f06
Internal error: Oops: 96000007 [#1] SMP
pstate: 804000c9 (Nzcv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : scan_block+0x98/0x230
lr : scan_block+0x94/0x230
sp : ffff80008d6cfb70
x29: ffff80008d6cfb70 x28: 0000000000000000 x27: 0000000000000000
x26: 00000000000000c0 x25: 0000000000000001 x24: 0000000000000000
x23: ffffa88a6b18b398 x22: ffff000007c00ff9 x21: ffffa88a6ac7fc40
x20: ffffa88a6af6a830 x19: ffff000007c00000 x18: 0000000000000000
x17: 0000000000000000 x16: 0000000000000000 x15: ffffffffffffffff
x14: ffffffff00000000 x13: ffffffffffffffff x12: 0000000000000020
x11: 0000000000000000 x10: 0000000001080000 x9 : ffffa88a6951c77c
x8 : ffffa88a6a893988 x7 : ffff203ff6cfb3c0 x6 : ffffa88a6a52b3c0
x5 : ffff203ff6cfb3c0 x4 : 0000000000000000 x3 : 0000000000000000
x2 : 0000000000000001 x1 : ffff20226cb56a40 x0 : 0000000000000000
Call trace:
 scan_block+0x98/0x230
 scan_gray_list+0x120/0x270
 kmemleak_scan+0x3a0/0x648
 kmemleak_write+0x3ac/0x4c8
 full_proxy_write+0x6c/0xa0
 vfs_write+0xc8/0x2b8
 ksys_write+0x70/0xf8
 __arm64_sys_write+0x24/0x30
 invoke_syscall+0x4c/0x110
 el0_svc_common+0x9c/0x190
 do_el0_svc+0x30/0x98
 el0_svc+0x28/0xd8
 el0t_64_sync_handler+0x90/0xb8
 el0t_64_sync+0x180/0x184

The reserved memory for kdump will be looked up by kmemleak, this area
will be set invalid when kdump service is bring up. That will result in
crash when kmemleak scan this area.

Fixes: 461ef12c4375 ("memblock: make memblock_find_in_range method private")
Signed-off-by: Chen Wandun <chenwandun@huawei.com>
---
 arch/arm64/mm/init.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index b16be52233c6..dc0c44622bfd 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -30,6 +30,7 @@
 #include <linux/crash_dump.h>
 #include <linux/hugetlb.h>
 #include <linux/acpi_iort.h>
+#include <linux/kmemleak.h>
 
 #include <asm/boot.h>
 #include <asm/fixmap.h>
@@ -101,6 +102,7 @@ static void __init reserve_crashkernel(void)
 	pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n",
 		crash_base, crash_base + crash_size, crash_size >> 20);
 
+	kmemleak_ignore_phys(crash_base);
 	crashk_res.start = crash_base;
 	crashk_res.end = crash_base + crash_size - 1;
 }
-- 
2.18.0.huawei.25


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

* Re: [PATCH] arm64: kdump: Skip kmemleak scan reserved memory for kdump
  2021-08-27  9:22 [PATCH] arm64: kdump: Skip kmemleak scan reserved memory for kdump Chen Wandun
@ 2021-08-30  4:05 ` Kefeng Wang
  2021-08-30 10:40 ` Mike Rapoport
  2021-08-31 17:40 ` Catalin Marinas
  2 siblings, 0 replies; 4+ messages in thread
From: Kefeng Wang @ 2021-08-30  4:05 UTC (permalink / raw)
  To: Chen Wandun, catalin.marinas, will, ardb, rppt, akpm, nsaenz,
	anshuman.khandual, geert+renesas, rafael.j.wysocki, robh,
	kirill.shtuemov, sfr, linux-arm-kernel, linux-kernel
  Cc: weiyongjun1, guohanjun, Linux Memory Management List


On 2021/8/27 17:22, Chen Wandun wrote:
> Trying to boot with kdump + kmemleak, command will result in a crash:
> "echo scan > /sys/kernel/debug/kmemleak"
>
> crashkernel reserved: 0x0000000007c00000 - 0x0000000027c00000 (512 MB)
> Kernel command line: BOOT_IMAGE=(hd1,gpt2)/vmlinuz-5.14.0-rc5-next-20210809+ root=/dev/mapper/ao-root ro rd.lvm.lv=ao/root rd.lvm.lv=ao/swap crashkernel=512M
> Unable to handle kernel paging request at virtual address ffff000007c00000
> Mem abort info:
>    ESR = 0x96000007
>    EC = 0x25: DABT (current EL), IL = 32 bits
>    SET = 0, FnV = 0
>    EA = 0, S1PTW = 0
>    FSC = 0x07: level 3 translation fault
> Data abort info:
>    ISV = 0, ISS = 0x00000007
>    CM = 0, WnR = 0
> swapper pgtable: 64k pages, 48-bit VAs, pgdp=00002024f0d80000
> [ffff000007c00000] pgd=1800205ffffd0003, p4d=1800205ffffd0003, pud=1800205ffffd0003, pmd=1800205ffffc0003, pte=0068000007c00f06
> Internal error: Oops: 96000007 [#1] SMP
> pstate: 804000c9 (Nzcv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> pc : scan_block+0x98/0x230
> lr : scan_block+0x94/0x230
> sp : ffff80008d6cfb70
> x29: ffff80008d6cfb70 x28: 0000000000000000 x27: 0000000000000000
> x26: 00000000000000c0 x25: 0000000000000001 x24: 0000000000000000
> x23: ffffa88a6b18b398 x22: ffff000007c00ff9 x21: ffffa88a6ac7fc40
> x20: ffffa88a6af6a830 x19: ffff000007c00000 x18: 0000000000000000
> x17: 0000000000000000 x16: 0000000000000000 x15: ffffffffffffffff
> x14: ffffffff00000000 x13: ffffffffffffffff x12: 0000000000000020
> x11: 0000000000000000 x10: 0000000001080000 x9 : ffffa88a6951c77c
> x8 : ffffa88a6a893988 x7 : ffff203ff6cfb3c0 x6 : ffffa88a6a52b3c0
> x5 : ffff203ff6cfb3c0 x4 : 0000000000000000 x3 : 0000000000000000
> x2 : 0000000000000001 x1 : ffff20226cb56a40 x0 : 0000000000000000
> Call trace:
>   scan_block+0x98/0x230
>   scan_gray_list+0x120/0x270
>   kmemleak_scan+0x3a0/0x648
>   kmemleak_write+0x3ac/0x4c8
>   full_proxy_write+0x6c/0xa0
>   vfs_write+0xc8/0x2b8
>   ksys_write+0x70/0xf8
>   __arm64_sys_write+0x24/0x30
>   invoke_syscall+0x4c/0x110
>   el0_svc_common+0x9c/0x190
>   do_el0_svc+0x30/0x98
>   el0_svc+0x28/0xd8
>   el0t_64_sync_handler+0x90/0xb8
>   el0t_64_sync+0x180/0x184
>
> The reserved memory for kdump will be looked up by kmemleak, this area
> will be set invalid when kdump service is bring up. That will result in
> crash when kmemleak scan this area.
>
> Fixes: 461ef12c4375 ("memblock: make memblock_find_in_range method private")
> Signed-off-by: Chen Wandun <chenwandun@huawei.com>
Reviewed-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>   arch/arm64/mm/init.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index b16be52233c6..dc0c44622bfd 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -30,6 +30,7 @@
>   #include <linux/crash_dump.h>
>   #include <linux/hugetlb.h>
>   #include <linux/acpi_iort.h>
> +#include <linux/kmemleak.h>
>   
>   #include <asm/boot.h>
>   #include <asm/fixmap.h>
> @@ -101,6 +102,7 @@ static void __init reserve_crashkernel(void)
>   	pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n",
>   		crash_base, crash_base + crash_size, crash_size >> 20);
>   
> +	kmemleak_ignore_phys(crash_base);
>   	crashk_res.start = crash_base;
>   	crashk_res.end = crash_base + crash_size - 1;
>   }

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

* Re: [PATCH] arm64: kdump: Skip kmemleak scan reserved memory for kdump
  2021-08-27  9:22 [PATCH] arm64: kdump: Skip kmemleak scan reserved memory for kdump Chen Wandun
  2021-08-30  4:05 ` Kefeng Wang
@ 2021-08-30 10:40 ` Mike Rapoport
  2021-08-31 17:40 ` Catalin Marinas
  2 siblings, 0 replies; 4+ messages in thread
From: Mike Rapoport @ 2021-08-30 10:40 UTC (permalink / raw)
  To: Chen Wandun, Andrew Morton
  Cc: catalin.marinas, will, ardb, nsaenz, anshuman.khandual,
	geert+renesas, rafael.j.wysocki, robh, kirill.shtuemov, sfr,
	linux-arm-kernel, linux-kernel, wangkefeng.wang, weiyongjun1,
	guohanjun

On Fri, Aug 27, 2021 at 05:22:46PM +0800, Chen Wandun wrote:
> Trying to boot with kdump + kmemleak, command will result in a crash:
> "echo scan > /sys/kernel/debug/kmemleak"
> 
> crashkernel reserved: 0x0000000007c00000 - 0x0000000027c00000 (512 MB)
> Kernel command line: BOOT_IMAGE=(hd1,gpt2)/vmlinuz-5.14.0-rc5-next-20210809+ root=/dev/mapper/ao-root ro rd.lvm.lv=ao/root rd.lvm.lv=ao/swap crashkernel=512M
> Unable to handle kernel paging request at virtual address ffff000007c00000
> Mem abort info:
>   ESR = 0x96000007
>   EC = 0x25: DABT (current EL), IL = 32 bits
>   SET = 0, FnV = 0
>   EA = 0, S1PTW = 0
>   FSC = 0x07: level 3 translation fault
> Data abort info:
>   ISV = 0, ISS = 0x00000007
>   CM = 0, WnR = 0
> swapper pgtable: 64k pages, 48-bit VAs, pgdp=00002024f0d80000
> [ffff000007c00000] pgd=1800205ffffd0003, p4d=1800205ffffd0003, pud=1800205ffffd0003, pmd=1800205ffffc0003, pte=0068000007c00f06
> Internal error: Oops: 96000007 [#1] SMP
> pstate: 804000c9 (Nzcv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> pc : scan_block+0x98/0x230
> lr : scan_block+0x94/0x230
> sp : ffff80008d6cfb70
> x29: ffff80008d6cfb70 x28: 0000000000000000 x27: 0000000000000000
> x26: 00000000000000c0 x25: 0000000000000001 x24: 0000000000000000
> x23: ffffa88a6b18b398 x22: ffff000007c00ff9 x21: ffffa88a6ac7fc40
> x20: ffffa88a6af6a830 x19: ffff000007c00000 x18: 0000000000000000
> x17: 0000000000000000 x16: 0000000000000000 x15: ffffffffffffffff
> x14: ffffffff00000000 x13: ffffffffffffffff x12: 0000000000000020
> x11: 0000000000000000 x10: 0000000001080000 x9 : ffffa88a6951c77c
> x8 : ffffa88a6a893988 x7 : ffff203ff6cfb3c0 x6 : ffffa88a6a52b3c0
> x5 : ffff203ff6cfb3c0 x4 : 0000000000000000 x3 : 0000000000000000
> x2 : 0000000000000001 x1 : ffff20226cb56a40 x0 : 0000000000000000
> Call trace:
>  scan_block+0x98/0x230
>  scan_gray_list+0x120/0x270
>  kmemleak_scan+0x3a0/0x648
>  kmemleak_write+0x3ac/0x4c8
>  full_proxy_write+0x6c/0xa0
>  vfs_write+0xc8/0x2b8
>  ksys_write+0x70/0xf8
>  __arm64_sys_write+0x24/0x30
>  invoke_syscall+0x4c/0x110
>  el0_svc_common+0x9c/0x190
>  do_el0_svc+0x30/0x98
>  el0_svc+0x28/0xd8
>  el0t_64_sync_handler+0x90/0xb8
>  el0t_64_sync+0x180/0x184
> 
> The reserved memory for kdump will be looked up by kmemleak, this area
> will be set invalid when kdump service is bring up. That will result in
> crash when kmemleak scan this area.
> 
> Fixes: 461ef12c4375 ("memblock: make memblock_find_in_range method private")

The commit id will change because patches in mmotm tree do not have stable
commit ids...

> Signed-off-by: Chen Wandun <chenwandun@huawei.com>

Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>

Andrew, can you please pick it up?

> ---
>  arch/arm64/mm/init.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index b16be52233c6..dc0c44622bfd 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -30,6 +30,7 @@
>  #include <linux/crash_dump.h>
>  #include <linux/hugetlb.h>
>  #include <linux/acpi_iort.h>
> +#include <linux/kmemleak.h>
>  
>  #include <asm/boot.h>
>  #include <asm/fixmap.h>
> @@ -101,6 +102,7 @@ static void __init reserve_crashkernel(void)
>  	pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n",
>  		crash_base, crash_base + crash_size, crash_size >> 20);
>  
> +	kmemleak_ignore_phys(crash_base);
>  	crashk_res.start = crash_base;
>  	crashk_res.end = crash_base + crash_size - 1;
>  }
> -- 
> 2.18.0.huawei.25
> 

-- 
Sincerely yours,
Mike.

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

* Re: [PATCH] arm64: kdump: Skip kmemleak scan reserved memory for kdump
  2021-08-27  9:22 [PATCH] arm64: kdump: Skip kmemleak scan reserved memory for kdump Chen Wandun
  2021-08-30  4:05 ` Kefeng Wang
  2021-08-30 10:40 ` Mike Rapoport
@ 2021-08-31 17:40 ` Catalin Marinas
  2 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2021-08-31 17:40 UTC (permalink / raw)
  To: Chen Wandun
  Cc: will, ardb, rppt, akpm, nsaenz, anshuman.khandual, geert+renesas,
	rafael.j.wysocki, robh, kirill.shtuemov, sfr, linux-arm-kernel,
	linux-kernel, wangkefeng.wang, weiyongjun1, guohanjun

On Fri, Aug 27, 2021 at 05:22:46PM +0800, Chen Wandun wrote:
> Trying to boot with kdump + kmemleak, command will result in a crash:
> "echo scan > /sys/kernel/debug/kmemleak"
> 
> crashkernel reserved: 0x0000000007c00000 - 0x0000000027c00000 (512 MB)
> Kernel command line: BOOT_IMAGE=(hd1,gpt2)/vmlinuz-5.14.0-rc5-next-20210809+ root=/dev/mapper/ao-root ro rd.lvm.lv=ao/root rd.lvm.lv=ao/swap crashkernel=512M
> Unable to handle kernel paging request at virtual address ffff000007c00000
> Mem abort info:
>   ESR = 0x96000007
>   EC = 0x25: DABT (current EL), IL = 32 bits
>   SET = 0, FnV = 0
>   EA = 0, S1PTW = 0
>   FSC = 0x07: level 3 translation fault
> Data abort info:
>   ISV = 0, ISS = 0x00000007
>   CM = 0, WnR = 0
> swapper pgtable: 64k pages, 48-bit VAs, pgdp=00002024f0d80000
> [ffff000007c00000] pgd=1800205ffffd0003, p4d=1800205ffffd0003, pud=1800205ffffd0003, pmd=1800205ffffc0003, pte=0068000007c00f06
> Internal error: Oops: 96000007 [#1] SMP
> pstate: 804000c9 (Nzcv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> pc : scan_block+0x98/0x230
> lr : scan_block+0x94/0x230
> sp : ffff80008d6cfb70
> x29: ffff80008d6cfb70 x28: 0000000000000000 x27: 0000000000000000
> x26: 00000000000000c0 x25: 0000000000000001 x24: 0000000000000000
> x23: ffffa88a6b18b398 x22: ffff000007c00ff9 x21: ffffa88a6ac7fc40
> x20: ffffa88a6af6a830 x19: ffff000007c00000 x18: 0000000000000000
> x17: 0000000000000000 x16: 0000000000000000 x15: ffffffffffffffff
> x14: ffffffff00000000 x13: ffffffffffffffff x12: 0000000000000020
> x11: 0000000000000000 x10: 0000000001080000 x9 : ffffa88a6951c77c
> x8 : ffffa88a6a893988 x7 : ffff203ff6cfb3c0 x6 : ffffa88a6a52b3c0
> x5 : ffff203ff6cfb3c0 x4 : 0000000000000000 x3 : 0000000000000000
> x2 : 0000000000000001 x1 : ffff20226cb56a40 x0 : 0000000000000000
> Call trace:
>  scan_block+0x98/0x230
>  scan_gray_list+0x120/0x270
>  kmemleak_scan+0x3a0/0x648
>  kmemleak_write+0x3ac/0x4c8
>  full_proxy_write+0x6c/0xa0
>  vfs_write+0xc8/0x2b8
>  ksys_write+0x70/0xf8
>  __arm64_sys_write+0x24/0x30
>  invoke_syscall+0x4c/0x110
>  el0_svc_common+0x9c/0x190
>  do_el0_svc+0x30/0x98
>  el0_svc+0x28/0xd8
>  el0t_64_sync_handler+0x90/0xb8
>  el0t_64_sync+0x180/0x184
> 
> The reserved memory for kdump will be looked up by kmemleak, this area
> will be set invalid when kdump service is bring up. That will result in
> crash when kmemleak scan this area.
> 
> Fixes: 461ef12c4375 ("memblock: make memblock_find_in_range method private")
> Signed-off-by: Chen Wandun <chenwandun@huawei.com>
> ---
>  arch/arm64/mm/init.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index b16be52233c6..dc0c44622bfd 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -30,6 +30,7 @@
>  #include <linux/crash_dump.h>
>  #include <linux/hugetlb.h>
>  #include <linux/acpi_iort.h>
> +#include <linux/kmemleak.h>
>  
>  #include <asm/boot.h>
>  #include <asm/fixmap.h>
> @@ -101,6 +102,7 @@ static void __init reserve_crashkernel(void)
>  	pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n",
>  		crash_base, crash_base + crash_size, crash_size >> 20);
>  
> +	kmemleak_ignore_phys(crash_base);
>  	crashk_res.start = crash_base;
>  	crashk_res.end = crash_base + crash_size - 1;
>  }

I'd add a comment here along the lines of (feel free to change it):

	/*
	 * The crashkernel memory will be removed from the kernel linear
	 * map. Inform kmemleak so that it won't try to access it.
	 */

With that:

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

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

end of thread, other threads:[~2021-08-31 17:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27  9:22 [PATCH] arm64: kdump: Skip kmemleak scan reserved memory for kdump Chen Wandun
2021-08-30  4:05 ` Kefeng Wang
2021-08-30 10:40 ` Mike Rapoport
2021-08-31 17:40 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).