aboutsummaryrefslogtreecommitdiff
path: root/sys/powerpc/powernv/platform_powernv.c
diff options
context:
space:
mode:
authorLeandro Lupori <luporl@FreeBSD.org>2020-01-29 18:13:44 +0000
committerLeandro Lupori <luporl@FreeBSD.org>2020-01-29 18:13:44 +0000
commita9d8f71f7bc14df7ddcb7080a9fb10fc62beb870 (patch)
treebbf5ade27615187a305f7aca4d4cf44f45a29d84 /sys/powerpc/powernv/platform_powernv.c
parentd8a85b423785c9cae3bf0eb6eef395776f47a73b (diff)
downloadsrc-a9d8f71f7bc14df7ddcb7080a9fb10fc62beb870.tar.gz
src-a9d8f71f7bc14df7ddcb7080a9fb10fc62beb870.zip
[PPC64] Fix NUMA on POWER8
On some POWER8 machines, 'ibm,associativity' property may have 6 cells, which would overflow the 5 cells buffer being used. There was also an issue with the "check if node is root" part, that have been fixed too. Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D23414
Notes
Notes: svn path=/head/; revision=357262
Diffstat (limited to 'sys/powerpc/powernv/platform_powernv.c')
-rw-r--r--sys/powerpc/powernv/platform_powernv.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/sys/powerpc/powernv/platform_powernv.c b/sys/powerpc/powernv/platform_powernv.c
index f6f39da253ec..15e604e52fbb 100644
--- a/sys/powerpc/powernv/platform_powernv.c
+++ b/sys/powerpc/powernv/platform_powernv.c
@@ -517,17 +517,20 @@ powernv_node_numa_domain(platform_t platform, phandle_t node)
cell_t associativity[5];
int i, res;
- res = OF_getproplen(node, "ibm,associativity");
+ res = OF_getencprop(node, "ibm,associativity",
+ associativity, sizeof(associativity));
- /* If already at the root, use default domain. */
- if (res == 0)
- return (0);
- else if (res < 0)
- /* If this node doesn't have associativity, check its parent. */
- return (powernv_node_numa_domain(platform, OF_parent(node)));
-
- OF_getencprop(node, "ibm,associativity",
- associativity, res);
+ /*
+ * If this node doesn't have associativity, or if there are not
+ * enough elements in it, check its parent.
+ */
+ if (res < (int)(sizeof(cell_t) * (platform_associativity + 1))) {
+ node = OF_parent(node);
+ /* If already at the root, use default domain. */
+ if (node == 0)
+ return (0);
+ return (powernv_node_numa_domain(platform, node));
+ }
for (i = 0; i < numa_max_domain; i++) {
if (numa_domains[i] == associativity[platform_associativity])