Skip to content

Commit f9f67e5

Browse files
Robert Richterrafaeljw
authored andcommitted
x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks()
For configurations that have the kconfig option NUMA_KEEP_MEMINFO disabled, numa_fill_memblks() only returns with NUMA_NO_MEMBLK (-1). SRAT lookup fails then because an existing SRAT memory range cannot be found for a CFMWS address range. This causes the addition of a duplicate numa_memblk with a different node id and a subsequent page fault and kernel crash during boot. Fix this by making numa_fill_memblks() always available regardless of NUMA_KEEP_MEMINFO. As Dan suggested, the fix is implemented to remove numa_fill_memblks() from sparsemem.h and alos using __weak for the function. Note that the issue was initially introduced with [1]. But since phys_to_target_node() was originally used that returned the valid node 0, an additional numa_memblk was not added. Though, the node id was wrong too, a message is seen then in the logs: kernel/numa.c: pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n", [1] commit fd49f99 ("ACPI: NUMA: Add a node and memblk for each CFMWS not in SRAT") Suggested-by: Dan Williams <dan.j.williams@intel.com> Link: https://lore.kernel.org/all/66271b0072317_69102944c@dwillia2-xfh.jf.intel.com.notmuch/ Fixes: 8f10046 ("ACPI/NUMA: Apply SRAT proximity domain to entire CFMWS window") Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Robert Richter <rrichter@amd.com> Acked-by: Borislav Petkov (AMD) <bp@alien8.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent dd5a440 commit f9f67e5

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

arch/x86/include/asm/sparsemem.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ extern int phys_to_target_node(phys_addr_t start);
3737
#define phys_to_target_node phys_to_target_node
3838
extern int memory_add_physaddr_to_nid(u64 start);
3939
#define memory_add_physaddr_to_nid memory_add_physaddr_to_nid
40-
extern int numa_fill_memblks(u64 start, u64 end);
41-
#define numa_fill_memblks numa_fill_memblks
4240
#endif
4341
#endif /* __ASSEMBLY__ */
4442

arch/x86/mm/numa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,8 @@ int memory_add_physaddr_to_nid(u64 start)
929929
}
930930
EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
931931

932+
#endif
933+
932934
static int __init cmp_memblk(const void *a, const void *b)
933935
{
934936
const struct numa_memblk *ma = *(const struct numa_memblk **)a;
@@ -1001,5 +1003,3 @@ int __init numa_fill_memblks(u64 start, u64 end)
10011003
}
10021004
return 0;
10031005
}
1004-
1005-
#endif

drivers/acpi/numa/srat.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ int __init srat_disabled(void)
208208
return acpi_numa < 0;
209209
}
210210

211+
__weak int __init numa_fill_memblks(u64 start, u64 end)
212+
{
213+
return NUMA_NO_MEMBLK;
214+
}
215+
211216
#if defined(CONFIG_X86) || defined(CONFIG_ARM64) || defined(CONFIG_LOONGARCH)
212217
/*
213218
* Callback for SLIT parsing. pxm_to_node() returns NUMA_NO_NODE for

include/linux/numa.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@ int memory_add_physaddr_to_nid(u64 start);
3636
int phys_to_target_node(u64 start);
3737
#endif
3838

39-
#ifndef numa_fill_memblks
40-
static inline int __init numa_fill_memblks(u64 start, u64 end)
41-
{
42-
return NUMA_NO_MEMBLK;
43-
}
44-
#endif
39+
int numa_fill_memblks(u64 start, u64 end);
4540

4641
#else /* !CONFIG_NUMA */
4742
static inline int numa_nearest_node(int node, unsigned int state)

0 commit comments

Comments
 (0)