Re: [14-CURRENT]BBB can't boot 14-CURRENT GENERICSD-20210805

From: Mark Johnston <markj_at_freebsd.org>
Date: Sat, 14 Aug 2021 15:12:03 UTC
On Sat, Aug 14, 2021 at 06:15:37PM +0900, Yoshiro MIHIRA wrote:
> I can use 13.0-STABLE-arm-armv7-GENERICSD-20210812 on Beaglebone Black[OK].
> 
> However, I tested 14-CURRENT GENERICSD-20210805 on Beaglebone Black.
> It can't boot with the below message[NG].
> 
> Please let me know to solve this issue.
> 
> If I use the same microSD on Raspberry PI2, it can boot without issue.
> I put all boot console messages.
> https://people.freebsd.org/~sanpei/20210814-boot-NG-14-GENERICSD-20210805
> 
> <<BOOT message>
> mem: <memory>
> ofwbus0: <Open Firmware Device Tree>
> ti_sysc0: <TI SYSC Interconnect> on ofwbus0
> panic: Assertion size > 0 failed at /usr/src/sys/kern/subr_vmem.c:1332

I guess that the DTB has changed somehow such that this error path
is getting exercised.  This patch should allow you to boot without
panicking, at least.

diff --git a/sys/arm/ti/ti_sysc.c b/sys/arm/ti/ti_sysc.c
index b16158aa5d83..4fda12f05725 100644
--- a/sys/arm/ti/ti_sysc.c
+++ b/sys/arm/ti/ti_sysc.c
@@ -306,6 +306,8 @@ parse_regfields(struct ti_sysc_softc *sc) {
 
 	/* Grab the content of reg properties */
 	nreg = OF_getproplen(node, "reg");
+	if (nreg == -1)
+		return (ENXIO);
 	reg = malloc(nreg, M_DEVBUF, M_WAITOK);
 	OF_getencprop(node, "reg", reg, nreg);