Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ARM: 8616/1: dt: Respect property size when parsing CPUs

Whilst MPIDR values themselves are less than 32 bits, it is still
perfectly valid for a DT to have #address-cells > 1 in the CPUs node,
resulting in the "reg" property having leading zero cell(s). In that
situation, the big-endian nature of the data conspires with the current
behaviour of only reading the first cell to cause the kernel to think
all CPUs have ID 0, and become resoundingly unhappy as a consequence.

Take the full property length into account when parsing CPUs so as to
be correct under any circumstances.

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Robin Murphy and committed by
Russell King
ba6dea4f 1a57c286

+11 -3
+11 -3
arch/arm/kernel/devtree.c
··· 88 return; 89 90 for_each_child_of_node(cpus, cpu) { 91 u32 hwid; 92 93 if (of_node_cmp(cpu->type, "cpu")) ··· 101 * properties is considered invalid to build the 102 * cpu_logical_map. 103 */ 104 - if (of_property_read_u32(cpu, "reg", &hwid)) { 105 pr_debug(" * %s missing reg property\n", 106 cpu->full_name); 107 of_node_put(cpu); ··· 110 } 111 112 /* 113 - * 8 MSBs must be set to 0 in the DT since the reg property 114 * defines the MPIDR[23:0]. 115 */ 116 - if (hwid & ~MPIDR_HWID_BITMASK) { 117 of_node_put(cpu); 118 return; 119 }
··· 88 return; 89 90 for_each_child_of_node(cpus, cpu) { 91 + const __be32 *cell; 92 + int prop_bytes; 93 u32 hwid; 94 95 if (of_node_cmp(cpu->type, "cpu")) ··· 99 * properties is considered invalid to build the 100 * cpu_logical_map. 101 */ 102 + cell = of_get_property(cpu, "reg", &prop_bytes); 103 + if (!cell || prop_bytes < sizeof(*cell)) { 104 pr_debug(" * %s missing reg property\n", 105 cpu->full_name); 106 of_node_put(cpu); ··· 107 } 108 109 /* 110 + * Bits n:24 must be set to 0 in the DT since the reg property 111 * defines the MPIDR[23:0]. 112 */ 113 + do { 114 + hwid = be32_to_cpu(*cell++); 115 + prop_bytes -= sizeof(*cell); 116 + } while (!hwid && prop_bytes > 0); 117 + 118 + if (prop_bytes || (hwid & ~MPIDR_HWID_BITMASK)) { 119 of_node_put(cpu); 120 return; 121 }