RISC-V: skip cpu-map when parsing elf_hwcap

The fill_elf_hwcap() function expects to find only cpu nodes under the
/cpus entry of the device tree. Newer versions of QEMU insert a cpu-map
node which describes the CPU topology, breaking this function. To fix
this, simply skip any non-cpu entries.

Reviewed by:	markj, kp, jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D22151
This commit is contained in:
Mitchell Horne 2019-10-25 21:39:29 +00:00
parent aea1c841f4
commit 29c8b9137b

View File

@ -142,11 +142,9 @@ fill_elf_hwcap(void *dummy __unused)
* ISAs, keep only the extension bits that are common to all harts.
*/
for (node = OF_child(node); node > 0; node = OF_peer(node)) {
if (!ofw_bus_node_is_compatible(node, "riscv")) {
if (bootverbose)
printf("fill_elf_hwcap: Can't find cpu\n");
return;
}
/* Skip any non-CPU nodes, such as cpu-map. */
if (!ofw_bus_node_is_compatible(node, "riscv"))
continue;
len = OF_getprop(node, "riscv,isa", isa, sizeof(isa));
KASSERT(len <= ISA_NAME_MAXLEN, ("ISA string truncated"));