* Re: [PATCH v4 03/10] of: fdt: Add generic support for parsing elf core headers property
@ 2021-07-15 1:08 kernel test robot
0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-07-15 1:08 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 5508 bytes --]
CC: kbuild-all(a)lists.01.org
In-Reply-To: <24d93c713f6faeaee6105f57c3d94ac17f12405f.1626266516.git.geert+renesas@glider.be>
References: <24d93c713f6faeaee6105f57c3d94ac17f12405f.1626266516.git.geert+renesas@glider.be>
TO: Geert Uytterhoeven <geert+renesas@glider.be>
TO: Rob Herring <robh+dt@kernel.org>
TO: Russell King <linux@armlinux.org.uk>
TO: Nicolas Pitre <nico@fluxnic.net>
TO: Ard Biesheuvel <ardb@kernel.org>
TO: Linus Walleij <linus.walleij@linaro.org>
TO: Catalin Marinas <catalin.marinas@arm.com>
TO: Will Deacon <will@kernel.org>
TO: Nick Kossifidis <mick@ics.forth.gr>
TO: Paul Walmsley <paul.walmsley@sifive.com>
TO: Palmer Dabbelt <palmer@dabbelt.com>
Hi Geert,
I love your patch! Perhaps something to improve:
[auto build test WARNING on robh/for-next]
[also build test WARNING on arm64/for-next/core arm/for-next linus/master v5.14-rc1 next-20210714]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Geert-Uytterhoeven/Add-generic-support-for-kdump-DT-properties/20210714-205223
base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
:::::: branch date: 12 hours ago
:::::: commit date: 12 hours ago
config: x86_64-randconfig-b001-20210714 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 8d69635ed9ecf36fd0ca85906bfde17949671cbe)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# apt-get install iwyu # include-what-you-use
# https://github.com/0day-ci/linux/commit/3b97a030801ac122756ae95f428bf673ed5b3857
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Geert-Uytterhoeven/Add-generic-support-for-kdump-DT-properties/20210714-205223
git checkout 3b97a030801ac122756ae95f428bf673ed5b3857
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross C=1 CHECK=iwyu O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/of/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
iwyu warnings: (new ones prefixed by >>)
drivers/of/fdt.c:31:1: iwyu: warning: superfluous #include <asm/page.h>
drivers/of/fdt.c:30:1: iwyu: warning: superfluous #include <asm/setup.h>
>> drivers/of/fdt.c:11:1: iwyu: warning: superfluous #include <linux/crash_dump.h>
drivers/of/fdt.c:12:1: iwyu: warning: superfluous #include <linux/crc32.h>
drivers/of/fdt.c:25:1: iwyu: warning: superfluous #include <linux/debugfs.h>
drivers/of/fdt.c:22:1: iwyu: warning: superfluous #include <linux/errno.h>
drivers/of/fdt.c:14:1: iwyu: warning: superfluous #include <linux/initrd.h>
drivers/of/fdt.c:13:1: iwyu: warning: superfluous #include <linux/kernel.h>
drivers/of/fdt.c:24:1: iwyu: warning: superfluous #include <linux/libfdt.h>
drivers/of/fdt.c:15:1: iwyu: warning: superfluous #include <linux/memblock.h>
drivers/of/fdt.c:19:1: iwyu: warning: superfluous #include <linux/of_reserved_mem.h>
drivers/of/fdt.c:28:1: iwyu: warning: superfluous #include <linux/random.h>
drivers/of/fdt.c:26:1: iwyu: warning: superfluous #include <linux/serial_core.h>
drivers/of/fdt.c:20:1: iwyu: warning: superfluous #include <linux/sizes.h>
drivers/of/fdt.c:27:1: iwyu: warning: superfluous #include <linux/sysfs.h>
vim +11 drivers/of/fdt.c
606ad42aa3b1fe Rob Herring 2016-06-15 10
3b97a030801ac1 Geert Uytterhoeven 2021-07-14 @11 #include <linux/crash_dump.h>
08d53aa58cb162 Ard Biesheuvel 2014-11-14 12 #include <linux/crc32.h>
41f880091c15b0 Grant Likely 2009-11-23 13 #include <linux/kernel.h>
f7b3a8355ba6ca Grant Likely 2009-11-24 14 #include <linux/initrd.h>
a1727da599ad03 Grant Likely 2013-08-28 15 #include <linux/memblock.h>
f8062386671a59 Guenter Roeck 2015-12-05 16 #include <linux/mutex.h>
e169cfbef46d62 Grant Likely 2009-11-23 17 #include <linux/of.h>
e169cfbef46d62 Grant Likely 2009-11-23 18 #include <linux/of_fdt.h>
3f0c8206644836 Marek Szyprowski 2014-02-28 19 #include <linux/of_reserved_mem.h>
e8d9d1f5485b52 Marek Szyprowski 2014-02-28 20 #include <linux/sizes.h>
4ef7b373df330b Jeremy Kerr 2010-02-14 21 #include <linux/string.h>
4ef7b373df330b Jeremy Kerr 2010-02-14 22 #include <linux/errno.h>
fe14042358fac0 Stephen Neuendorffer 2010-11-18 23 #include <linux/slab.h>
e6a6928c3ea1d0 Rob Herring 2014-04-02 24 #include <linux/libfdt.h>
b0a6fb36a49f72 Rob Herring 2014-04-02 25 #include <linux/debugfs.h>
fb11ffe74c794a Rob Herring 2014-03-27 26 #include <linux/serial_core.h>
08d53aa58cb162 Ard Biesheuvel 2014-11-14 27 #include <linux/sysfs.h>
428826f5358c92 Hsin-Yi Wang 2019-08-23 28 #include <linux/random.h>
51975db0b7333c Grant Likely 2010-02-01 29
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 48852 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 00/10] Add generic support for kdump DT properties @ 2021-07-14 12:50 Geert Uytterhoeven 2021-07-14 12:50 ` Geert Uytterhoeven 0 siblings, 1 reply; 5+ messages in thread From: Geert Uytterhoeven @ 2021-07-14 12:50 UTC (permalink / raw) To: Rob Herring, Russell King, Nicolas Pitre, Ard Biesheuvel, Linus Walleij, Catalin Marinas, Will Deacon, Nick Kossifidis, Paul Walmsley, Palmer Dabbelt, Albert Ou, Frank Rowand, Dave Young, Mike Rapoport Cc: Baoquan He, Vivek Goyal, Andrew Morton, devicetree, linux-arm-kernel, linux-riscv, kexec, linux-mm, linux-renesas-soc, linux-kernel, Geert Uytterhoeven Hi all, This patch series adds generic support for parsing DT properties related to crash dump kernels ("linux,elfcorehdr" and "linux,elfcorehdr" under the "/chosen" node), makes use of it on arm64, arm32, and (partially) riscv, and performs a few cleanups. It is an evolution of the combination of [1] and [2]. The series consists of 5 parts: 1. Patches 1-2 prepare (the visibility of) variables used to hold information retrieved from the DT properties. 2. Patches 3-5 add support to the FDT core for parsing the properties. This can co-exist safely with architecture-specific parsing, until the latter has been removed. 3. Patch 6 removes the non-standard handling of "linux,elfcorehdr" on riscv. I think this can be applied independently, as the non-standard handling is in v5.13, but upstream riscv kdump support is still incomplete. 4. Patches 7-9 convert arm64 to use the generic handling instead of its own implementation. 5. Patch 10 adds support for kdump properties to arm32. The corresponding patch for kexec-tools is "[PATCH] arm: kdump: Add DT properties to crash dump kernel's DTB"[3], which is still valid. Changes compared to the previous versions: - Make elfcorehdr_{addr,size} always visible, - Add variables for usable memory limitation, - Use IS_ENABLED() instead of #ifdef (incl. initrd and arm64), - Clarify what architecture-specific code is still responsible for, - Add generic support for parsing linux,usable-memory-range, - Remove custom linux,usable-memory-range parsing on arm64, - Use generic handling on ARM. This has been tested on arm32 and arm64, and compile-tested on riscv64. Thanks for your comments! [1] "[PATCH v3] ARM: Parse kdump DT properties" https://lore.kernel.org/r/20210317113130.2554368-1-geert+renesas@glider.be/ [2] "[PATCH 0/3] Add generic-support for linux,elfcorehdr and fix riscv" https://lore.kernel.org/r/cover.1623780059.git.geert+renesas@glider.be/ [3] "[PATCH] arm: kdump: Add DT properties to crash dump kernel's DTB" https://lore.kernel.org/linux-arm-kernel/20200902154129.6358-1-geert+renesas@glider.be/ Geert Uytterhoeven (10): crash_dump: Make elfcorehdr_{addr,size} always visible memblock: Add variables for usable memory limitation of: fdt: Add generic support for parsing elf core headers property of: fdt: Add generic support for parsing usable memory range property of: fdt: Use IS_ENABLED(CONFIG_BLK_DEV_INITRD) instead of #ifdef riscv: Remove non-standard linux,elfcorehdr handling arm64: kdump: Remove custom linux,elfcorehdr parsing arm64: kdump: Remove custom linux,usable-memory-range parsing arm64: kdump: Use IS_ENABLED(CONFIG_CRASH_DUMP) instead of #ifdef ARM: Parse kdump DT properties Documentation/devicetree/bindings/chosen.txt | 12 ++-- .../arm/boot/compressed/fdt_check_mem_start.c | 48 ++++++++++++-- arch/arm/mm/init.c | 30 +++++++++ arch/arm64/mm/init.c | 63 +------------------ arch/riscv/mm/init.c | 20 ------ drivers/of/fdt.c | 63 ++++++++++++++++--- include/linux/crash_dump.h | 7 ++- include/linux/memblock.h | 6 ++ mm/memblock.c | 2 + 9 files changed, 148 insertions(+), 103 deletions(-) -- 2.25.1 Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 03/10] of: fdt: Add generic support for parsing elf core headers property 2021-07-14 12:50 [PATCH v4 00/10] Add generic support for kdump DT properties Geert Uytterhoeven 2021-07-14 12:50 ` Geert Uytterhoeven (?) @ 2021-07-14 12:50 ` Geert Uytterhoeven 0 siblings, 0 replies; 5+ messages in thread From: Geert Uytterhoeven @ 2021-07-14 12:50 UTC (permalink / raw) To: Rob Herring, Russell King, Nicolas Pitre, Ard Biesheuvel, Linus Walleij, Catalin Marinas, Will Deacon, Nick Kossifidis, Paul Walmsley, Palmer Dabbelt, Albert Ou, Frank Rowand, Dave Young, Mike Rapoport Cc: Baoquan He, Vivek Goyal, Andrew Morton, devicetree, linux-arm-kernel, linux-riscv, kexec, linux-mm, linux-renesas-soc, linux-kernel, Geert Uytterhoeven There are two methods to specify the location of the elf core headers: using the "elfcorehdr=" kernel parameter, as handled by generic code in kernel/crash_dump.c, or using the "linux,elfcorehdr" property under the "/chosen" node in the Device Tree, as handled by architecture-specific code in arch/arm64/mm/init.c. Extend support for "linux,elfcorehdr" to all platforms supporting DT by adding platform-agnostic handling for parsing this property to the FDT core code. This can co-exist safely with the architecture-specific parsing, until the latter has been removed. This requires moving the call to of_scan_flat_dt() up, as the code scanning the "/chosen" node now needs to be aware of the values of "#address-cells" and "#size-cells". Architecture-specific code still has to reserve the memory used by the elf core headers, if present. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- About the change to chosen.txt: I have a similar change for schemas/chosen.yaml in dt-schema. v4: - Use IS_ENABLED() instead of #ifdef, - Clarify what architecture-specific code is still responsible for. --- Documentation/devicetree/bindings/chosen.txt | 6 ++-- drivers/of/fdt.c | 34 ++++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/chosen.txt b/Documentation/devicetree/bindings/chosen.txt index 45e79172a646c537..5b0b94eb2d04e79d 100644 --- a/Documentation/devicetree/bindings/chosen.txt +++ b/Documentation/devicetree/bindings/chosen.txt @@ -106,9 +106,9 @@ respectively, of the root node. linux,elfcorehdr ---------------- -This property (currently used only on arm64) holds the memory range, -the address and the size, of the elf core header which mainly describes -the panicked kernel's memory layout as PT_LOAD segments of elf format. +This property holds the memory range, the address and the size, of the elf +core header which mainly describes the panicked kernel's memory layout as +PT_LOAD segments of elf format. e.g. / { diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 344f16bb04ccf081..f797d52c5b492cb7 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) "OF: fdt: " fmt +#include <linux/crash_dump.h> #include <linux/crc32.h> #include <linux/kernel.h> #include <linux/initrd.h> @@ -908,6 +909,32 @@ static inline void early_init_dt_check_for_initrd(unsigned long node) } #endif /* CONFIG_BLK_DEV_INITRD */ +/** + * early_init_dt_check_for_elfcorehdr - Decode elfcorehdr location from flat + * tree + * @node: reference to node containing elfcorehdr location ('chosen') + */ +static void __init early_init_dt_check_for_elfcorehdr(unsigned long node) +{ + const __be32 *prop; + int len; + + if (!IS_ENABLED(CONFIG_CRASH_DUMP)) + return; + + pr_debug("Looking for elfcorehdr property... "); + + prop = of_get_flat_dt_prop(node, "linux,elfcorehdr", &len); + if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells))) + return; + + elfcorehdr_addr = dt_mem_next_cell(dt_root_addr_cells, &prop); + elfcorehdr_size = dt_mem_next_cell(dt_root_size_cells, &prop); + + pr_debug("elfcorehdr_start=0x%llx elfcorehdr_size=0x%llx\n", + elfcorehdr_addr, elfcorehdr_size); +} + #ifdef CONFIG_SERIAL_EARLYCON int __init early_init_dt_scan_chosen_stdout(void) @@ -1055,6 +1082,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, return 0; early_init_dt_check_for_initrd(node); + early_init_dt_check_for_elfcorehdr(node); /* Retrieve command line */ p = of_get_flat_dt_prop(node, "bootargs", &l); @@ -1199,14 +1227,14 @@ void __init early_init_dt_scan_nodes(void) { int rc = 0; + /* Initialize {size,address}-cells info */ + of_scan_flat_dt(early_init_dt_scan_root, NULL); + /* Retrieve various information from the /chosen node */ rc = of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); if (!rc) pr_warn("No chosen node found, continuing without\n"); - /* Initialize {size,address}-cells info */ - of_scan_flat_dt(early_init_dt_scan_root, NULL); - /* Setup memory, calling early_init_dt_add_memory_arch */ of_scan_flat_dt(early_init_dt_scan_memory, NULL); } -- 2.25.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 03/10] of: fdt: Add generic support for parsing elf core headers property @ 2021-07-14 12:50 ` Geert Uytterhoeven 0 siblings, 0 replies; 5+ messages in thread From: Geert Uytterhoeven @ 2021-07-14 12:50 UTC (permalink / raw) To: Rob Herring, Russell King, Nicolas Pitre, Ard Biesheuvel, Linus Walleij, Catalin Marinas, Will Deacon, Nick Kossifidis, Paul Walmsley, Palmer Dabbelt, Albert Ou, Frank Rowand, Dave Young, Mike Rapoport Cc: Baoquan He, Vivek Goyal, Andrew Morton, devicetree, linux-arm-kernel, linux-riscv, kexec, linux-mm, linux-renesas-soc, linux-kernel, Geert Uytterhoeven There are two methods to specify the location of the elf core headers: using the "elfcorehdr=" kernel parameter, as handled by generic code in kernel/crash_dump.c, or using the "linux,elfcorehdr" property under the "/chosen" node in the Device Tree, as handled by architecture-specific code in arch/arm64/mm/init.c. Extend support for "linux,elfcorehdr" to all platforms supporting DT by adding platform-agnostic handling for parsing this property to the FDT core code. This can co-exist safely with the architecture-specific parsing, until the latter has been removed. This requires moving the call to of_scan_flat_dt() up, as the code scanning the "/chosen" node now needs to be aware of the values of "#address-cells" and "#size-cells". Architecture-specific code still has to reserve the memory used by the elf core headers, if present. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- About the change to chosen.txt: I have a similar change for schemas/chosen.yaml in dt-schema. v4: - Use IS_ENABLED() instead of #ifdef, - Clarify what architecture-specific code is still responsible for. --- Documentation/devicetree/bindings/chosen.txt | 6 ++-- drivers/of/fdt.c | 34 ++++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/chosen.txt b/Documentation/devicetree/bindings/chosen.txt index 45e79172a646c537..5b0b94eb2d04e79d 100644 --- a/Documentation/devicetree/bindings/chosen.txt +++ b/Documentation/devicetree/bindings/chosen.txt @@ -106,9 +106,9 @@ respectively, of the root node. linux,elfcorehdr ---------------- -This property (currently used only on arm64) holds the memory range, -the address and the size, of the elf core header which mainly describes -the panicked kernel's memory layout as PT_LOAD segments of elf format. +This property holds the memory range, the address and the size, of the elf +core header which mainly describes the panicked kernel's memory layout as +PT_LOAD segments of elf format. e.g. / { diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 344f16bb04ccf081..f797d52c5b492cb7 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) "OF: fdt: " fmt +#include <linux/crash_dump.h> #include <linux/crc32.h> #include <linux/kernel.h> #include <linux/initrd.h> @@ -908,6 +909,32 @@ static inline void early_init_dt_check_for_initrd(unsigned long node) } #endif /* CONFIG_BLK_DEV_INITRD */ +/** + * early_init_dt_check_for_elfcorehdr - Decode elfcorehdr location from flat + * tree + * @node: reference to node containing elfcorehdr location ('chosen') + */ +static void __init early_init_dt_check_for_elfcorehdr(unsigned long node) +{ + const __be32 *prop; + int len; + + if (!IS_ENABLED(CONFIG_CRASH_DUMP)) + return; + + pr_debug("Looking for elfcorehdr property... "); + + prop = of_get_flat_dt_prop(node, "linux,elfcorehdr", &len); + if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells))) + return; + + elfcorehdr_addr = dt_mem_next_cell(dt_root_addr_cells, &prop); + elfcorehdr_size = dt_mem_next_cell(dt_root_size_cells, &prop); + + pr_debug("elfcorehdr_start=0x%llx elfcorehdr_size=0x%llx\n", + elfcorehdr_addr, elfcorehdr_size); +} + #ifdef CONFIG_SERIAL_EARLYCON int __init early_init_dt_scan_chosen_stdout(void) @@ -1055,6 +1082,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, return 0; early_init_dt_check_for_initrd(node); + early_init_dt_check_for_elfcorehdr(node); /* Retrieve command line */ p = of_get_flat_dt_prop(node, "bootargs", &l); @@ -1199,14 +1227,14 @@ void __init early_init_dt_scan_nodes(void) { int rc = 0; + /* Initialize {size,address}-cells info */ + of_scan_flat_dt(early_init_dt_scan_root, NULL); + /* Retrieve various information from the /chosen node */ rc = of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); if (!rc) pr_warn("No chosen node found, continuing without\n"); - /* Initialize {size,address}-cells info */ - of_scan_flat_dt(early_init_dt_scan_root, NULL); - /* Setup memory, calling early_init_dt_add_memory_arch */ of_scan_flat_dt(early_init_dt_scan_memory, NULL); } -- 2.25.1 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 03/10] of: fdt: Add generic support for parsing elf core headers property @ 2021-07-14 12:50 ` Geert Uytterhoeven 0 siblings, 0 replies; 5+ messages in thread From: Geert Uytterhoeven @ 2021-07-14 12:50 UTC (permalink / raw) To: Rob Herring, Russell King, Nicolas Pitre, Ard Biesheuvel, Linus Walleij, Catalin Marinas, Will Deacon, Nick Kossifidis, Paul Walmsley, Palmer Dabbelt, Albert Ou, Frank Rowand, Dave Young, Mike Rapoport Cc: Baoquan He, Vivek Goyal, Andrew Morton, devicetree, linux-arm-kernel, linux-riscv, kexec, linux-mm, linux-renesas-soc, linux-kernel, Geert Uytterhoeven There are two methods to specify the location of the elf core headers: using the "elfcorehdr=" kernel parameter, as handled by generic code in kernel/crash_dump.c, or using the "linux,elfcorehdr" property under the "/chosen" node in the Device Tree, as handled by architecture-specific code in arch/arm64/mm/init.c. Extend support for "linux,elfcorehdr" to all platforms supporting DT by adding platform-agnostic handling for parsing this property to the FDT core code. This can co-exist safely with the architecture-specific parsing, until the latter has been removed. This requires moving the call to of_scan_flat_dt() up, as the code scanning the "/chosen" node now needs to be aware of the values of "#address-cells" and "#size-cells". Architecture-specific code still has to reserve the memory used by the elf core headers, if present. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- About the change to chosen.txt: I have a similar change for schemas/chosen.yaml in dt-schema. v4: - Use IS_ENABLED() instead of #ifdef, - Clarify what architecture-specific code is still responsible for. --- Documentation/devicetree/bindings/chosen.txt | 6 ++-- drivers/of/fdt.c | 34 ++++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/chosen.txt b/Documentation/devicetree/bindings/chosen.txt index 45e79172a646c537..5b0b94eb2d04e79d 100644 --- a/Documentation/devicetree/bindings/chosen.txt +++ b/Documentation/devicetree/bindings/chosen.txt @@ -106,9 +106,9 @@ respectively, of the root node. linux,elfcorehdr ---------------- -This property (currently used only on arm64) holds the memory range, -the address and the size, of the elf core header which mainly describes -the panicked kernel's memory layout as PT_LOAD segments of elf format. +This property holds the memory range, the address and the size, of the elf +core header which mainly describes the panicked kernel's memory layout as +PT_LOAD segments of elf format. e.g. / { diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 344f16bb04ccf081..f797d52c5b492cb7 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) "OF: fdt: " fmt +#include <linux/crash_dump.h> #include <linux/crc32.h> #include <linux/kernel.h> #include <linux/initrd.h> @@ -908,6 +909,32 @@ static inline void early_init_dt_check_for_initrd(unsigned long node) } #endif /* CONFIG_BLK_DEV_INITRD */ +/** + * early_init_dt_check_for_elfcorehdr - Decode elfcorehdr location from flat + * tree + * @node: reference to node containing elfcorehdr location ('chosen') + */ +static void __init early_init_dt_check_for_elfcorehdr(unsigned long node) +{ + const __be32 *prop; + int len; + + if (!IS_ENABLED(CONFIG_CRASH_DUMP)) + return; + + pr_debug("Looking for elfcorehdr property... "); + + prop = of_get_flat_dt_prop(node, "linux,elfcorehdr", &len); + if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells))) + return; + + elfcorehdr_addr = dt_mem_next_cell(dt_root_addr_cells, &prop); + elfcorehdr_size = dt_mem_next_cell(dt_root_size_cells, &prop); + + pr_debug("elfcorehdr_start=0x%llx elfcorehdr_size=0x%llx\n", + elfcorehdr_addr, elfcorehdr_size); +} + #ifdef CONFIG_SERIAL_EARLYCON int __init early_init_dt_scan_chosen_stdout(void) @@ -1055,6 +1082,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, return 0; early_init_dt_check_for_initrd(node); + early_init_dt_check_for_elfcorehdr(node); /* Retrieve command line */ p = of_get_flat_dt_prop(node, "bootargs", &l); @@ -1199,14 +1227,14 @@ void __init early_init_dt_scan_nodes(void) { int rc = 0; + /* Initialize {size,address}-cells info */ + of_scan_flat_dt(early_init_dt_scan_root, NULL); + /* Retrieve various information from the /chosen node */ rc = of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); if (!rc) pr_warn("No chosen node found, continuing without\n"); - /* Initialize {size,address}-cells info */ - of_scan_flat_dt(early_init_dt_scan_root, NULL); - /* Setup memory, calling early_init_dt_add_memory_arch */ of_scan_flat_dt(early_init_dt_scan_memory, NULL); } -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 03/10] of: fdt: Add generic support for parsing elf core headers property @ 2021-07-14 12:50 ` Geert Uytterhoeven 0 siblings, 0 replies; 5+ messages in thread From: Geert Uytterhoeven @ 2021-07-14 12:50 UTC (permalink / raw) To: Rob Herring, Russell King, Nicolas Pitre, Ard Biesheuvel, Linus Walleij, Catalin Marinas, Will Deacon, Nick Kossifidis, Paul Walmsley, Palmer Dabbelt, Albert Ou, Frank Rowand, Dave Young, Mike Rapoport Cc: Baoquan He, Vivek Goyal, Andrew Morton, devicetree, linux-arm-kernel, linux-riscv, kexec, linux-mm, linux-renesas-soc, linux-kernel, Geert Uytterhoeven There are two methods to specify the location of the elf core headers: using the "elfcorehdr=" kernel parameter, as handled by generic code in kernel/crash_dump.c, or using the "linux,elfcorehdr" property under the "/chosen" node in the Device Tree, as handled by architecture-specific code in arch/arm64/mm/init.c. Extend support for "linux,elfcorehdr" to all platforms supporting DT by adding platform-agnostic handling for parsing this property to the FDT core code. This can co-exist safely with the architecture-specific parsing, until the latter has been removed. This requires moving the call to of_scan_flat_dt() up, as the code scanning the "/chosen" node now needs to be aware of the values of "#address-cells" and "#size-cells". Architecture-specific code still has to reserve the memory used by the elf core headers, if present. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- About the change to chosen.txt: I have a similar change for schemas/chosen.yaml in dt-schema. v4: - Use IS_ENABLED() instead of #ifdef, - Clarify what architecture-specific code is still responsible for. --- Documentation/devicetree/bindings/chosen.txt | 6 ++-- drivers/of/fdt.c | 34 ++++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/chosen.txt b/Documentation/devicetree/bindings/chosen.txt index 45e79172a646c537..5b0b94eb2d04e79d 100644 --- a/Documentation/devicetree/bindings/chosen.txt +++ b/Documentation/devicetree/bindings/chosen.txt @@ -106,9 +106,9 @@ respectively, of the root node. linux,elfcorehdr ---------------- -This property (currently used only on arm64) holds the memory range, -the address and the size, of the elf core header which mainly describes -the panicked kernel's memory layout as PT_LOAD segments of elf format. +This property holds the memory range, the address and the size, of the elf +core header which mainly describes the panicked kernel's memory layout as +PT_LOAD segments of elf format. e.g. / { diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 344f16bb04ccf081..f797d52c5b492cb7 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) "OF: fdt: " fmt +#include <linux/crash_dump.h> #include <linux/crc32.h> #include <linux/kernel.h> #include <linux/initrd.h> @@ -908,6 +909,32 @@ static inline void early_init_dt_check_for_initrd(unsigned long node) } #endif /* CONFIG_BLK_DEV_INITRD */ +/** + * early_init_dt_check_for_elfcorehdr - Decode elfcorehdr location from flat + * tree + * @node: reference to node containing elfcorehdr location ('chosen') + */ +static void __init early_init_dt_check_for_elfcorehdr(unsigned long node) +{ + const __be32 *prop; + int len; + + if (!IS_ENABLED(CONFIG_CRASH_DUMP)) + return; + + pr_debug("Looking for elfcorehdr property... "); + + prop = of_get_flat_dt_prop(node, "linux,elfcorehdr", &len); + if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells))) + return; + + elfcorehdr_addr = dt_mem_next_cell(dt_root_addr_cells, &prop); + elfcorehdr_size = dt_mem_next_cell(dt_root_size_cells, &prop); + + pr_debug("elfcorehdr_start=0x%llx elfcorehdr_size=0x%llx\n", + elfcorehdr_addr, elfcorehdr_size); +} + #ifdef CONFIG_SERIAL_EARLYCON int __init early_init_dt_scan_chosen_stdout(void) @@ -1055,6 +1082,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, return 0; early_init_dt_check_for_initrd(node); + early_init_dt_check_for_elfcorehdr(node); /* Retrieve command line */ p = of_get_flat_dt_prop(node, "bootargs", &l); @@ -1199,14 +1227,14 @@ void __init early_init_dt_scan_nodes(void) { int rc = 0; + /* Initialize {size,address}-cells info */ + of_scan_flat_dt(early_init_dt_scan_root, NULL); + /* Retrieve various information from the /chosen node */ rc = of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); if (!rc) pr_warn("No chosen node found, continuing without\n"); - /* Initialize {size,address}-cells info */ - of_scan_flat_dt(early_init_dt_scan_root, NULL); - /* Setup memory, calling early_init_dt_add_memory_arch */ of_scan_flat_dt(early_init_dt_scan_memory, NULL); } -- 2.25.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-07-15 1:08 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-07-15 1:08 [PATCH v4 03/10] of: fdt: Add generic support for parsing elf core headers property kernel test robot -- strict thread matches above, loose matches on Subject: below -- 2021-07-14 12:50 [PATCH v4 00/10] Add generic support for kdump DT properties Geert Uytterhoeven 2021-07-14 12:50 ` [PATCH v4 03/10] of: fdt: Add generic support for parsing elf core headers property Geert Uytterhoeven 2021-07-14 12:50 ` Geert Uytterhoeven 2021-07-14 12:50 ` Geert Uytterhoeven 2021-07-14 12:50 ` Geert Uytterhoeven
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.