From: jsg Date: Tue, 4 May 2021 06:32:58 +0000 (+0000) Subject: Check that fdt hart id matches boot hart id before associating an fdt X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=862607c08452591943a6422e312a1baa557180fc;p=openbsd Check that fdt hart id matches boot hart id before associating an fdt node with the primary cpu. Prompted by the polarfire icicle where hart 0 is an mmuless e51 core. ok drahn@ mlarkin@ --- diff --git a/sys/arch/riscv64/dev/mainbus.c b/sys/arch/riscv64/dev/mainbus.c index c94c43f58fb..faa9831427f 100644 --- a/sys/arch/riscv64/dev/mainbus.c +++ b/sys/arch/riscv64/dev/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.2 2021/05/03 21:25:48 kettenis Exp $ */ +/* $OpenBSD: mainbus.c,v 1.3 2021/05/04 06:32:58 jsg Exp $ */ /* * Copyright (c) 2016 Patrick Wildt * Copyright (c) 2017 Mark Kettenis @@ -323,7 +323,7 @@ mainbus_match_primary(struct device *parent, void *match, void *aux) struct fdt_attach_args *fa = aux; struct cfdata *cf = match; - if (fa->fa_nreg < 1) + if (fa->fa_nreg < 1 || fa->fa_reg[0].addr != boot_hart) return 0; return (*cf->cf_attach->ca_match)(parent, match, aux); diff --git a/sys/arch/riscv64/riscv64/machdep.c b/sys/arch/riscv64/riscv64/machdep.c index f33a3526948..7fae71ce895 100644 --- a/sys/arch/riscv64/riscv64/machdep.c +++ b/sys/arch/riscv64/riscv64/machdep.c @@ -567,6 +567,10 @@ initriscv(struct riscv_bootparams *rbp) int len; static uint8_t lladdr[6]; + len = fdt_node_property(node, "boot-hartid", &prop); + if (len == sizeof(boot_hart)) + boot_hart = bemtoh32((uint32_t *)prop); + len = fdt_node_property(node, "bootargs", &prop); if (len > 0) collect_kernel_args(prop);