lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250601102924.2417248-1-wheatfox17@icloud.com>
Date: Sun,  1 Jun 2025 18:29:24 +0800
From: Yulong Han <wheatfox17@...oud.com>
To: chenhuacai@...nel.org
Cc: kernel@...0n.name,
	broonie@...nel.org,
	loongarch@...ts.linux.dev,
	linux-kernel@...r.kernel.org,
	Yulong Han <wheatfox17@...oud.com>
Subject: [PATCH] LoongArch: Add numa_add_reserved_memblk() support in numa

This patch fixes the error below when compiling kernel with
loongarch's loongson3_defconfig:

drivers/acpi/numa/srat.c: In function ‘acpi_parse_cfmws’:
drivers/acpi/numa/srat.c:467:13: error: implicit declaration of function
‘numa_add_reserved_memblk’ [-Werror=implicit-function-declaration]
  467 |         if (numa_add_reserved_memblk(node, start, end) < 0) {

The error is caused by the missing the newly added 
numa_add_reserved_memblk (under include/linux/numa_memblks.h) definition
inside loongarch's numa related code.

The commit's code(style) was formatted by ./scripts/checkpatch.pl

Signed-off-by: Yulong Han <wheatfox17@...oud.com>
---
 arch/loongarch/include/asm/numa.h | 13 +++++++------
 arch/loongarch/kernel/numa.c      | 31 ++++++++++++++++++++++++++++---
 2 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/arch/loongarch/include/asm/numa.h b/arch/loongarch/include/asm/numa.h
index b5f9de9f102e4..dc35d20914c82 100644
--- a/arch/loongarch/include/asm/numa.h
+++ b/arch/loongarch/include/asm/numa.h
@@ -28,17 +28,18 @@ struct numa_memblk {
 	int			nid;
 };
 
-#define NR_NODE_MEMBLKS		(MAX_NUMNODES*2)
+#define NR_NODE_MEMBLKS		(MAX_NUMNODES * 2)
 struct numa_meminfo {
 	int			nr_blks;
 	struct numa_memblk	blk[NR_NODE_MEMBLKS];
 };
 
-extern int __init numa_add_memblk(int nodeid, u64 start, u64 end);
+int __init numa_add_memblk(int nodeid, u64 start, u64 end);
+int __init numa_add_reserved_memblk(int nid, u64 start, u64 end);
 
-extern void __init early_numa_add_cpu(int cpuid, s16 node);
-extern void numa_add_cpu(unsigned int cpu);
-extern void numa_remove_cpu(unsigned int cpu);
+void __init early_numa_add_cpu(int cpuid, s16 node);
+void numa_add_cpu(unsigned int cpu);
+void numa_remove_cpu(unsigned int cpu);
 
 static inline void numa_clear_node(int cpu)
 {
@@ -49,7 +50,7 @@ static inline void set_cpuid_to_node(int cpuid, s16 node)
 	__cpuid_to_node[cpuid] = node;
 }
 
-extern int early_cpu_to_node(int cpu);
+int early_cpu_to_node(int cpu);
 
 #else
 
diff --git a/arch/loongarch/kernel/numa.c b/arch/loongarch/kernel/numa.c
index 30a72fd528c0e..0185a9a609897 100644
--- a/arch/loongarch/kernel/numa.c
+++ b/arch/loongarch/kernel/numa.c
@@ -31,6 +31,7 @@ unsigned char node_distances[MAX_NUMNODES][MAX_NUMNODES];
 EXPORT_SYMBOL(node_distances);
 
 static struct numa_meminfo numa_meminfo;
+static struct numa_meminfo numa_reserved_meminfo;
 cpumask_t cpus_on_node[MAX_NUMNODES];
 cpumask_t phys_cpus_on_node[MAX_NUMNODES];
 EXPORT_SYMBOL(cpus_on_node);
@@ -136,12 +137,14 @@ void __init early_numa_add_cpu(int cpuid, s16 node)
 void numa_add_cpu(unsigned int cpu)
 {
 	int nid = cpu_to_node(cpu);
+
 	cpumask_set_cpu(cpu, &cpus_on_node[nid]);
 }
 
 void numa_remove_cpu(unsigned int cpu)
 {
 	int nid = cpu_to_node(cpu);
+
 	cpumask_clear_cpu(cpu, &cpus_on_node[nid]);
 }
 
@@ -155,7 +158,7 @@ static int __init numa_add_memblk_to(int nid, u64 start, u64 end,
 	/* whine about and ignore invalid blks */
 	if (start > end || nid < 0 || nid >= MAX_NUMNODES) {
 		pr_warn("NUMA: Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n",
-			   nid, start, end - 1);
+			nid, start, end - 1);
 		return 0;
 	}
 
@@ -187,6 +190,28 @@ int __init numa_add_memblk(int nid, u64 start, u64 end)
 	return numa_add_memblk_to(nid, start, end, &numa_meminfo);
 }
 
+/**
+ * numa_add_reserved_memblk - Add one numa_memblk to numa_reserved_meminfo
+ * @nid: NUMA node ID of the new memblk
+ * @start: Start address of the new memblk
+ * @end: End address of the new memblk
+ *
+ * Add a new memblk to the numa_reserved_meminfo.
+ *
+ * Usage Case: numa_cleanup_meminfo() reconciles all numa_memblk instances
+ * against memblock_type information and moves any that intersect reserved
+ * ranges to numa_reserved_meminfo. However, when that information is known
+ * ahead of time, we use numa_add_reserved_memblk() to add the numa_memblk
+ * to numa_reserved_meminfo directly.
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
+ */
+int __init numa_add_reserved_memblk(int nid, u64 start, u64 end)
+{
+	return numa_add_memblk_to(nid, start, end, &numa_reserved_meminfo);
+}
+
 static void __init node_mem_init(unsigned int node)
 {
 	unsigned long start_pfn, end_pfn;
@@ -194,7 +219,7 @@ static void __init node_mem_init(unsigned int node)
 
 	node_addrspace_offset = nid_to_addrbase(node);
 	pr_info("Node%d's addrspace_offset is 0x%lx\n",
-			node, node_addrspace_offset);
+		node, node_addrspace_offset);
 
 	get_pfn_range_for_nid(node, &start_pfn, &end_pfn);
 	pr_info("Node%d: start_pfn=0x%lx, end_pfn=0x%lx\n",
@@ -285,7 +310,7 @@ static void __init init_node_memblock(void)
 		case EFI_MEMORY_MAPPED_IO:
 		case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
 			pr_info("Resvd: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx Bytes\n",
-					mem_type, mem_start, mem_size);
+				mem_type, mem_start, mem_size);
 			break;
 		}
 	}
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ