linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] powerpc: kexec fixes
@ 2024-05-08 13:05 Sourabh Jain
  2024-05-08 13:05 ` [PATCH 1/2] powerpc/kexec_file: fix extra size calculation for kexec FDT Sourabh Jain
  2024-05-08 13:05 ` [PATCH 2/2] powerpc/kexec_file: fix cpus node update to FDT Sourabh Jain
  0 siblings, 2 replies; 5+ messages in thread
From: Sourabh Jain @ 2024-05-08 13:05 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Mahesh Salgaonkar, Sourabh Jain, Naveen N. Rao, Aditya Gupta,
	Hari Bathini

Patch series fixes two kexec issues.

01/02: Update extra size calculation for kexec FDT to avoid kexec load
failure due to FDT_ERR_NOSPACE while including CPU nodes added post
boot and reserved memory ranges.

02/02: Fix update_cpus_node/core_64.c function to include missing device
nodes under /cpus node with device_type != "cpu".

Note: this patch series is rebased on top of the linux-next/master
to avoid the conflict with the below patch series:
https://lore.kernel.org/all/171509287314.62008.11812494124513471250.b4-ty@ellerman.id.au/

Cc: Aditya Gupta <adityag@linux.ibm.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>

Sourabh Jain (2):
  powerpc/kexec_file: fix extra size calculation for kexec FDT
  powerpc/kexec_file: fix cpus node update to FDT

 arch/powerpc/include/asm/kexec.h  |  6 ++--
 arch/powerpc/kexec/core_64.c      | 53 +++++++++++++++++++++----------
 arch/powerpc/kexec/elf_64.c       | 12 +++++--
 arch/powerpc/kexec/file_load_64.c | 53 +++++++++++++------------------
 4 files changed, 70 insertions(+), 54 deletions(-)

-- 
2.44.0


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

* [PATCH 1/2] powerpc/kexec_file: fix extra size calculation for kexec FDT
  2024-05-08 13:05 [PATCH 0/2] powerpc: kexec fixes Sourabh Jain
@ 2024-05-08 13:05 ` Sourabh Jain
  2024-05-09  7:13   ` kernel test robot
  2024-05-09  8:18   ` kernel test robot
  2024-05-08 13:05 ` [PATCH 2/2] powerpc/kexec_file: fix cpus node update to FDT Sourabh Jain
  1 sibling, 2 replies; 5+ messages in thread
From: Sourabh Jain @ 2024-05-08 13:05 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Mahesh Salgaonkar, Sourabh Jain, Naveen N. Rao, Aditya Gupta,
	Hari Bathini

While setting up the FDT for kexec, CPU nodes that are added after the
system boots and reserved memory ranges are incorporated into the
initial_boot_params (base FDT).

However, they are not taken into account when determining the additional
size needed for the kexec FDT. As a result, kexec fails to load,
generating the following error:

[1116.774451] Error updating memory reserve map: FDT_ERR_NOSPACE
kexec_file_load failed: No such process

Therefore, consider the extra size for CPU nodes added post-system boot
and reserved memory ranges while preparing the kexec FDT.

While adding a new parameter to the setup_new_fdt_ppc64 function, it was
noticed that there were a couple of unused parameters, so they were
removed.

Cc: Aditya Gupta <adityag@linux.ibm.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
---
 arch/powerpc/include/asm/kexec.h  |  6 ++--
 arch/powerpc/kexec/elf_64.c       | 12 +++++--
 arch/powerpc/kexec/file_load_64.c | 53 +++++++++++++------------------
 3 files changed, 33 insertions(+), 38 deletions(-)

diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index 95a98b390d62..270ee93a0f7d 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -103,10 +103,8 @@ int load_crashdump_segments_ppc64(struct kimage *image,
 int setup_purgatory_ppc64(struct kimage *image, const void *slave_code,
 			  const void *fdt, unsigned long kernel_load_addr,
 			  unsigned long fdt_load_addr);
-unsigned int kexec_extra_fdt_size_ppc64(struct kimage *image);
-int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
-			unsigned long initrd_load_addr,
-			unsigned long initrd_len, const char *cmdline);
+unsigned int kexec_extra_fdt_size_ppc64(struct kimage *image, struct crash_mem *rmem);
+int setup_new_fdt_ppc64(const struct kimage *image, void *fdt, struct crash_mem *rmem);
 #endif /* CONFIG_PPC64 */
 
 #endif /* CONFIG_KEXEC_FILE */
diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c
index 214c071c58ed..5d6d616404cf 100644
--- a/arch/powerpc/kexec/elf_64.c
+++ b/arch/powerpc/kexec/elf_64.c
@@ -23,6 +23,7 @@
 #include <linux/of_fdt.h>
 #include <linux/slab.h>
 #include <linux/types.h>
+#include <asm/kexec_ranges.h>
 
 static void *elf64_load(struct kimage *image, char *kernel_buf,
 			unsigned long kernel_len, char *initrd,
@@ -36,6 +37,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
 	const void *slave_code;
 	struct elfhdr ehdr;
 	char *modified_cmdline = NULL;
+	struct crash_mem *rmem = NULL;
 	struct kexec_elf_info elf_info;
 	struct kexec_buf kbuf = { .image = image, .buf_min = 0,
 				  .buf_max = ppc64_rma_size };
@@ -102,17 +104,20 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
 		kexec_dprintk("Loaded initrd at 0x%lx\n", initrd_load_addr);
 	}
 
+	ret = get_reserved_memory_ranges(&rmem);
+	if (ret)
+		goto out;
+
 	fdt = of_kexec_alloc_and_setup_fdt(image, initrd_load_addr,
 					   initrd_len, cmdline,
-					   kexec_extra_fdt_size_ppc64(image));
+					   kexec_extra_fdt_size_ppc64(image, rmem));
 	if (!fdt) {
 		pr_err("Error setting up the new device tree.\n");
 		ret = -EINVAL;
 		goto out;
 	}
 
-	ret = setup_new_fdt_ppc64(image, fdt, initrd_load_addr,
-				  initrd_len, cmdline);
+	ret = setup_new_fdt_ppc64(image, fdt, rmem);
 	if (ret)
 		goto out_free_fdt;
 
@@ -146,6 +151,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
 out_free_fdt:
 	kvfree(fdt);
 out:
+	kfree(rmem);
 	kfree(modified_cmdline);
 	kexec_free_elf_info(&elf_info);
 
diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
index 925a69ad2468..41be4546a34e 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -803,10 +803,9 @@ static unsigned int cpu_node_size(void)
 	return size;
 }
 
-static unsigned int kdump_extra_fdt_size_ppc64(struct kimage *image)
+static unsigned int kdump_extra_fdt_size_ppc64(struct kimage *image, unsigned int cpu_nodes)
 {
-	unsigned int cpu_nodes, extra_size = 0;
-	struct device_node *dn;
+	unsigned int extra_size = 0;
 	u64 usm_entries;
 #ifdef CONFIG_CRASH_HOTPLUG
 	unsigned int possible_cpu_nodes;
@@ -826,18 +825,6 @@ static unsigned int kdump_extra_fdt_size_ppc64(struct kimage *image)
 		extra_size += (unsigned int)(usm_entries * sizeof(u64));
 	}
 
-	/*
-	 * Get the number of CPU nodes in the current DT. This allows to
-	 * reserve places for CPU nodes added since the boot time.
-	 */
-	cpu_nodes = 0;
-	for_each_node_by_type(dn, "cpu") {
-		cpu_nodes++;
-	}
-
-	if (cpu_nodes > boot_cpu_node_count)
-		extra_size += (cpu_nodes - boot_cpu_node_count) * cpu_node_size();
-
 #ifdef CONFIG_CRASH_HOTPLUG
 	/*
 	 * Make sure enough space is reserved to accommodate possible CPU nodes
@@ -861,16 +848,30 @@ static unsigned int kdump_extra_fdt_size_ppc64(struct kimage *image)
  *
  * Returns the estimated extra size needed for kexec/kdump kernel FDT.
  */
-unsigned int kexec_extra_fdt_size_ppc64(struct kimage *image)
+unsigned int kexec_extra_fdt_size_ppc64(struct kimage *image, struct crash_mem *rmem)
 {
-	unsigned int extra_size = 0;
+	struct device_node *dn;
+	unsigned int cpu_nodes, extra_size = 0;
 
 	// Budget some space for the password blob. There's already extra space
 	// for the key name
 	if (plpks_is_available())
 		extra_size += (unsigned int)plpks_get_passwordlen();
 
-	return extra_size + kdump_extra_fdt_size_ppc64(image);
+	/* Get the number of CPU nodes in the current device tree */
+	for_each_node_by_type(dn, "cpu") {
+		cpu_nodes++;
+	}
+
+	/* Consider extra space for CPU nodes added since the boot time */
+	if (cpu_nodes > boot_cpu_node_count)
+		extra_size += (cpu_nodes - boot_cpu_node_count) * cpu_node_size();
+
+	/* Consider extra space for reserved memory ranges if any */
+	if (rmem->nr_ranges > 0)
+		extra_size += sizeof(struct fdt_reserve_entry) * rmem->nr_ranges;
+
+	return extra_size + kdump_extra_fdt_size_ppc64(image, cpu_nodes);
 }
 
 static int copy_property(void *fdt, int node_offset, const struct device_node *dn,
@@ -924,18 +925,13 @@ static int update_pci_dma_nodes(void *fdt, const char *dmapropname)
  *                       being loaded.
  * @image:               kexec image being loaded.
  * @fdt:                 Flattened device tree for the next kernel.
- * @initrd_load_addr:    Address where the next initrd will be loaded.
- * @initrd_len:          Size of the next initrd, or 0 if there will be none.
- * @cmdline:             Command line for the next kernel, or NULL if there will
- *                       be none.
+ * @rmem:                Reserved memory ranges.
  *
  * Returns 0 on success, negative errno on error.
  */
-int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
-			unsigned long initrd_load_addr,
-			unsigned long initrd_len, const char *cmdline)
+int setup_new_fdt_ppc64(const struct kimage *image, void *fdt, struct crash_mem *rmem)
 {
-	struct crash_mem *umem = NULL, *rmem = NULL;
+	struct crash_mem *umem = NULL;
 	int i, nr_ranges, ret;
 
 #ifdef CONFIG_CRASH_DUMP
@@ -991,10 +987,6 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
 		goto out;
 
 	/* Update memory reserve map */
-	ret = get_reserved_memory_ranges(&rmem);
-	if (ret)
-		goto out;
-
 	nr_ranges = rmem ? rmem->nr_ranges : 0;
 	for (i = 0; i < nr_ranges; i++) {
 		u64 base, size;
@@ -1014,7 +1006,6 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
 		ret = plpks_populate_fdt(fdt);
 
 out:
-	kfree(rmem);
 	kfree(umem);
 	return ret;
 }
-- 
2.44.0


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

* [PATCH 2/2] powerpc/kexec_file: fix cpus node update to FDT
  2024-05-08 13:05 [PATCH 0/2] powerpc: kexec fixes Sourabh Jain
  2024-05-08 13:05 ` [PATCH 1/2] powerpc/kexec_file: fix extra size calculation for kexec FDT Sourabh Jain
@ 2024-05-08 13:05 ` Sourabh Jain
  1 sibling, 0 replies; 5+ messages in thread
From: Sourabh Jain @ 2024-05-08 13:05 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Mahesh Salgaonkar, Sourabh Jain, Naveen N. Rao, Aditya Gupta,
	Hari Bathini

While updating the cpus node, commit 40c753993e3a ("powerpc/kexec_file:
 Use current CPU info while setting up FDT") first deletes all subnodes
under the /cpus node. However, while adding sub-nodes back, it missed
adding cpus subnodes whose device_type != "cpu", such as l2-cache*,
l3-cache*, ibm,powerpc-cpu-features.

Fix this by only deleting cpus sub-nodes of device_type == "cpus" and
then adding all available nodes with device_type == "cpu".

Fixes: 40c753993e3a ("powerpc/kexec_file: Use current CPU info while setting up FDT")
Cc: Aditya Gupta <adityag@linux.ibm.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
---
 arch/powerpc/kexec/core_64.c | 53 +++++++++++++++++++++++++-----------
 1 file changed, 37 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c
index 85050be08a23..2e625c2cb6b9 100644
--- a/arch/powerpc/kexec/core_64.c
+++ b/arch/powerpc/kexec/core_64.c
@@ -456,9 +456,15 @@ static int add_node_props(void *fdt, int node_offset, const struct device_node *
  * @fdt:              Flattened device tree of the kernel.
  *
  * Returns 0 on success, negative errno on error.
+ *
+ * Note: expecting no subnodes under /cpus/<node> with device_type == "cpu".
+ * If this changes, update this function to include them.
  */
 int update_cpus_node(void *fdt)
 {
+	int prev_node_offset;
+	const char *device_type;
+	const struct fdt_property *prop;
 	struct device_node *cpus_node, *dn;
 	int cpus_offset, cpus_subnode_offset, ret = 0;
 
@@ -469,30 +475,44 @@ int update_cpus_node(void *fdt)
 		return cpus_offset;
 	}
 
-	if (cpus_offset > 0) {
-		ret = fdt_del_node(fdt, cpus_offset);
+	prev_node_offset = cpus_offset;
+	/* Delete sub-nodes of /cpus node with device_type == "cpu" */
+	for (cpus_subnode_offset = fdt_first_subnode(fdt, cpus_offset); cpus_subnode_offset >= 0;) {
+		/* Ignore nodes that do not have a device_type property or device_type != "cpu" */
+		prop = fdt_get_property(fdt, cpus_subnode_offset, "device_type", NULL);
+		if (!prop || strcmp(prop->data, "cpu")) {
+			prev_node_offset = cpus_subnode_offset;
+			goto next_node;
+		}
+
+		ret = fdt_del_node(fdt, cpus_subnode_offset);
 		if (ret < 0) {
-			pr_err("Error deleting /cpus node: %s\n", fdt_strerror(ret));
-			return -EINVAL;
+			pr_err("Failed to delete a cpus sub-node: %s\n", fdt_strerror(ret));
+			return ret;
 		}
+next_node:
+		if (prev_node_offset == cpus_offset)
+			cpus_subnode_offset = fdt_first_subnode(fdt, cpus_offset);
+		else
+			cpus_subnode_offset = fdt_next_subnode(fdt, prev_node_offset);
 	}
 
-	/* Add cpus node to fdt */
-	cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"), "cpus");
-	if (cpus_offset < 0) {
-		pr_err("Error creating /cpus node: %s\n", fdt_strerror(cpus_offset));
+	cpus_node = of_find_node_by_path("/cpus");
+	/* Fail here to avoid kexec/kdump kernel boot hung */
+	if (!cpus_node) {
+		pr_err("No /cpus node found\n");
 		return -EINVAL;
 	}
 
-	/* Add cpus node properties */
-	cpus_node = of_find_node_by_path("/cpus");
-	ret = add_node_props(fdt, cpus_offset, cpus_node);
-	of_node_put(cpus_node);
-	if (ret < 0)
-		return ret;
+	/* Add all /cpus sub-nodes of device_type == "cpu" to FDT */
+	for_each_child_of_node(cpus_node, dn) {
+		/* Ignore device nodes that do not have a device_type property
+		 * or device_type != "cpu".
+		 */
+		device_type = of_get_property(dn, "device_type", NULL);
+		if (!device_type || strcmp(device_type, "cpu"))
+			continue;
 
-	/* Loop through all subnodes of cpus and add them to fdt */
-	for_each_node_by_type(dn, "cpu") {
 		cpus_subnode_offset = fdt_add_subnode(fdt, cpus_offset, dn->full_name);
 		if (cpus_subnode_offset < 0) {
 			pr_err("Unable to add %s subnode: %s\n", dn->full_name,
@@ -506,6 +526,7 @@ int update_cpus_node(void *fdt)
 			goto out;
 	}
 out:
+	of_node_put(cpus_node);
 	of_node_put(dn);
 	return ret;
 }
-- 
2.44.0


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

* Re: [PATCH 1/2] powerpc/kexec_file: fix extra size calculation for kexec FDT
  2024-05-08 13:05 ` [PATCH 1/2] powerpc/kexec_file: fix extra size calculation for kexec FDT Sourabh Jain
@ 2024-05-09  7:13   ` kernel test robot
  2024-05-09  8:18   ` kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2024-05-09  7:13 UTC (permalink / raw)
  To: Sourabh Jain, linuxppc-dev
  Cc: llvm, Mahesh Salgaonkar, Sourabh Jain, oe-kbuild-all,
	Naveen N. Rao, Aditya Gupta, Hari Bathini

Hi Sourabh,

kernel test robot noticed the following build warnings:

[auto build test WARNING on next-20240508]
[cannot apply to powerpc/next powerpc/fixes linus/master v6.9-rc7 v6.9-rc6 v6.9-rc5 v6.9-rc7]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Sourabh-Jain/powerpc-kexec_file-fix-extra-size-calculation-for-kexec-FDT/20240508-211003
base:   next-20240508
patch link:    https://lore.kernel.org/r/20240508130558.1939304-2-sourabhjain%40linux.ibm.com
patch subject: [PATCH 1/2] powerpc/kexec_file: fix extra size calculation for kexec FDT
config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20240509/202405091511.8Sd2zYrn-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 0ab4458df0688955620b72cc2c72a32dffad3615)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240509/202405091511.8Sd2zYrn-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405091511.8Sd2zYrn-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from arch/powerpc/kexec/file_load_64.c:17:
   In file included from include/linux/kexec.h:18:
   In file included from include/linux/vmcore_info.h:6:
   In file included from include/linux/elfcore.h:11:
   In file included from include/linux/ptrace.h:10:
   In file included from include/linux/pid_namespace.h:7:
   In file included from include/linux/mm.h:2253:
   include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     500 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     501 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     507 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     508 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     514 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     519 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     520 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:528:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     528 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     529 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
>> arch/powerpc/kexec/file_load_64.c:863:3: warning: variable 'cpu_nodes' is uninitialized when used here [-Wuninitialized]
     863 |                 cpu_nodes++;
         |                 ^~~~~~~~~
   arch/powerpc/kexec/file_load_64.c:854:24: note: initialize the variable 'cpu_nodes' to silence this warning
     854 |         unsigned int cpu_nodes, extra_size = 0;
         |                               ^
         |                                = 0
   6 warnings generated.


vim +/cpu_nodes +863 arch/powerpc/kexec/file_load_64.c

   843	
   844	/**
   845	 * kexec_extra_fdt_size_ppc64 - Return the estimated additional size needed to
   846	 *                              setup FDT for kexec/kdump kernel.
   847	 * @image:                      kexec image being loaded.
   848	 *
   849	 * Returns the estimated extra size needed for kexec/kdump kernel FDT.
   850	 */
   851	unsigned int kexec_extra_fdt_size_ppc64(struct kimage *image, struct crash_mem *rmem)
   852	{
   853		struct device_node *dn;
   854		unsigned int cpu_nodes, extra_size = 0;
   855	
   856		// Budget some space for the password blob. There's already extra space
   857		// for the key name
   858		if (plpks_is_available())
   859			extra_size += (unsigned int)plpks_get_passwordlen();
   860	
   861		/* Get the number of CPU nodes in the current device tree */
   862		for_each_node_by_type(dn, "cpu") {
 > 863			cpu_nodes++;
   864		}
   865	
   866		/* Consider extra space for CPU nodes added since the boot time */
   867		if (cpu_nodes > boot_cpu_node_count)
   868			extra_size += (cpu_nodes - boot_cpu_node_count) * cpu_node_size();
   869	
   870		/* Consider extra space for reserved memory ranges if any */
   871		if (rmem->nr_ranges > 0)
   872			extra_size += sizeof(struct fdt_reserve_entry) * rmem->nr_ranges;
   873	
   874		return extra_size + kdump_extra_fdt_size_ppc64(image, cpu_nodes);
   875	}
   876	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH 1/2] powerpc/kexec_file: fix extra size calculation for kexec FDT
  2024-05-08 13:05 ` [PATCH 1/2] powerpc/kexec_file: fix extra size calculation for kexec FDT Sourabh Jain
  2024-05-09  7:13   ` kernel test robot
@ 2024-05-09  8:18   ` kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2024-05-09  8:18 UTC (permalink / raw)
  To: Sourabh Jain, linuxppc-dev
  Cc: Mahesh Salgaonkar, Sourabh Jain, oe-kbuild-all, Naveen N. Rao,
	Aditya Gupta, Hari Bathini

Hi Sourabh,

kernel test robot noticed the following build warnings:

[auto build test WARNING on next-20240508]
[cannot apply to powerpc/next powerpc/fixes linus/master v6.9-rc7 v6.9-rc6 v6.9-rc5 v6.9-rc7]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Sourabh-Jain/powerpc-kexec_file-fix-extra-size-calculation-for-kexec-FDT/20240508-211003
base:   next-20240508
patch link:    https://lore.kernel.org/r/20240508130558.1939304-2-sourabhjain%40linux.ibm.com
patch subject: [PATCH 1/2] powerpc/kexec_file: fix extra size calculation for kexec FDT
config: powerpc64-randconfig-002-20240509 (https://download.01.org/0day-ci/archive/20240509/202405091617.IRRnTyRE-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240509/202405091617.IRRnTyRE-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405091617.IRRnTyRE-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> arch/powerpc/kexec/file_load_64.c:852: warning: Function parameter or struct member 'rmem' not described in 'kexec_extra_fdt_size_ppc64'


vim +852 arch/powerpc/kexec/file_load_64.c

2377c92e37fe97 Hari Bathini 2021-02-04  843  
33f2cc0a2e90f7 Hari Bathini 2024-02-26  844  /**
33f2cc0a2e90f7 Hari Bathini 2024-02-26  845   * kexec_extra_fdt_size_ppc64 - Return the estimated additional size needed to
33f2cc0a2e90f7 Hari Bathini 2024-02-26  846   *                              setup FDT for kexec/kdump kernel.
33f2cc0a2e90f7 Hari Bathini 2024-02-26  847   * @image:                      kexec image being loaded.
33f2cc0a2e90f7 Hari Bathini 2024-02-26  848   *
33f2cc0a2e90f7 Hari Bathini 2024-02-26  849   * Returns the estimated extra size needed for kexec/kdump kernel FDT.
33f2cc0a2e90f7 Hari Bathini 2024-02-26  850   */
f2c160891d3206 Sourabh Jain 2024-05-08  851  unsigned int kexec_extra_fdt_size_ppc64(struct kimage *image, struct crash_mem *rmem)
33f2cc0a2e90f7 Hari Bathini 2024-02-26 @852  {
f2c160891d3206 Sourabh Jain 2024-05-08  853  	struct device_node *dn;
f2c160891d3206 Sourabh Jain 2024-05-08  854  	unsigned int cpu_nodes, extra_size = 0;
33f2cc0a2e90f7 Hari Bathini 2024-02-26  855  
33f2cc0a2e90f7 Hari Bathini 2024-02-26  856  	// Budget some space for the password blob. There's already extra space
33f2cc0a2e90f7 Hari Bathini 2024-02-26  857  	// for the key name
33f2cc0a2e90f7 Hari Bathini 2024-02-26  858  	if (plpks_is_available())
33f2cc0a2e90f7 Hari Bathini 2024-02-26  859  		extra_size += (unsigned int)plpks_get_passwordlen();
33f2cc0a2e90f7 Hari Bathini 2024-02-26  860  
f2c160891d3206 Sourabh Jain 2024-05-08  861  	/* Get the number of CPU nodes in the current device tree */
f2c160891d3206 Sourabh Jain 2024-05-08  862  	for_each_node_by_type(dn, "cpu") {
f2c160891d3206 Sourabh Jain 2024-05-08  863  		cpu_nodes++;
f2c160891d3206 Sourabh Jain 2024-05-08  864  	}
f2c160891d3206 Sourabh Jain 2024-05-08  865  
f2c160891d3206 Sourabh Jain 2024-05-08  866  	/* Consider extra space for CPU nodes added since the boot time */
f2c160891d3206 Sourabh Jain 2024-05-08  867  	if (cpu_nodes > boot_cpu_node_count)
f2c160891d3206 Sourabh Jain 2024-05-08  868  		extra_size += (cpu_nodes - boot_cpu_node_count) * cpu_node_size();
f2c160891d3206 Sourabh Jain 2024-05-08  869  
f2c160891d3206 Sourabh Jain 2024-05-08  870  	/* Consider extra space for reserved memory ranges if any */
f2c160891d3206 Sourabh Jain 2024-05-08  871  	if (rmem->nr_ranges > 0)
f2c160891d3206 Sourabh Jain 2024-05-08  872  		extra_size += sizeof(struct fdt_reserve_entry) * rmem->nr_ranges;
f2c160891d3206 Sourabh Jain 2024-05-08  873  
f2c160891d3206 Sourabh Jain 2024-05-08  874  	return extra_size + kdump_extra_fdt_size_ppc64(image, cpu_nodes);
33f2cc0a2e90f7 Hari Bathini 2024-02-26  875  }
33f2cc0a2e90f7 Hari Bathini 2024-02-26  876  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2024-05-09  8:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-08 13:05 [PATCH 0/2] powerpc: kexec fixes Sourabh Jain
2024-05-08 13:05 ` [PATCH 1/2] powerpc/kexec_file: fix extra size calculation for kexec FDT Sourabh Jain
2024-05-09  7:13   ` kernel test robot
2024-05-09  8:18   ` kernel test robot
2024-05-08 13:05 ` [PATCH 2/2] powerpc/kexec_file: fix cpus node update to FDT Sourabh Jain

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).