[armv7] 13.1-BETA2 boots on beaglebone, 14-CURRENT snapshot panics

From: Matteo Riondato <matteo_at_freebsd.org>
Date: Tue, 12 Apr 2022 13:48:14 UTC
Hi All,

While trying to make my beaglebone enhanced boot with the 
am335x-sancloud-bbe.dtb (no success so far), I tried booting it with
the am335x-boneblack.dtb, loaded at the loader prompt.

The publicly available 13.1-BETA2 GENERICSD image boots into multi-user 
(boot -v log available at 
http://rionda.to/files/boot-13.1-BETA2-boneblack.log), while the 
14-CURRENT 20220407 snapshot panics as follows:

ARM Debug Architecture not supported
GDB: debug ports: uart
GDB: current port: uart
KDB: debugger backends: ddb gdb
KDB: current backend: ddb
Copyright (c) 1992-2022 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
	The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 14.0-CURRENT #0 main-n254435-8af24219565: Thu Apr  7 09:31:14 
UTC 2022
root@releng1.nyi.freebsd.org:/usr/obj/usr/src/arm.armv7/sys/GENERIC arm
FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git 
llvmorg-13.0.0-0-gd7b669b3a303)
WARNING: WITNESS option enabled, expect reduced performance.
VT: init without driver.
Preloaded elf kernel "/boot/kernel/kernel" at 0xc0e22000.
Preloaded elf module "/boot/kernel/umodem.ko" at 0xc0e2ae6c.
Preloaded elf module "/boot/kernel/ucom.ko" at 0xc0e2b3d8.
Preloaded dtb "/boot/dtb/am335x-boneblack.dtb" at 0xc0e2b944.
Preloaded TSLOG data "TSLOG" at 0xc0e2b998.
CPU: ARM Cortex-A8 r3p2 (ECO: 0x00000000)
CPU Features: 
   Thumb2, Security, VMSAv7
Optional instructions: 
   UMULL, SMULL, SIMD(ext)
LoUU:2 LoC:3 LoUIS:1 
Cache level 1:
  32KB/64B 4-way data cache WT WB Read-Alloc
  32KB/64B 4-way instruction cache Read-Alloc
Cache level 2:
  256KB/64B 8-way unified cache WT WB Read-Alloc Write-Alloc
real memory  = 1072926720 (1023 MB)
avail memory = 1031000064 (983 MB)
Physical memory chunk(s):
   0x80000000 - 0x87ee8fff,   126 MB (  32489 pages)
   0x87f17000 - 0xbcf26fff,   848 MB ( 217104 pages)
   0xbcf2e000 - 0xbcf2efff,     0 MB (      1 pages)
   0xbcf30000 - 0xbcf31fff,     0 MB (      2 pages)
   0xbcf36000 - 0xbcf36fff,     0 MB (      1 pages)
   0xbcf3c000 - 0xbcf3dfff,     0 MB (      2 pages)
   0xbcf40000 - 0xbcf40fff,     0 MB (      1 pages)
   0xbcf42000 - 0xbcf43fff,     0 MB (      2 pages)
   0xbcf45000 - 0xbff7bfff,    48 MB (  12343 pages)
Excluded memory regions:
   0xb6e00000 - 0xb7d4efff,    15 MB (   3919 pages) NoAlloc 
Static device mappings:
   0x44c00000 - 0x44ffffff mapped at VA 0xffb00000
   0x47400000 - 0x474fffff mapped at VA 0xffa00000
   0x47800000 - 0x478fffff mapped at VA 0xff900000
   0x48000000 - 0x48ffffff mapped at VA 0xfe900000
   0x49000000 - 0x490fffff mapped at VA 0xfe800000
   0x49800000 - 0x49afffff mapped at VA 0xfe500000
   0x4a000000 - 0x4affffff mapped at VA 0xfd500000
No PSCI/SMCCC call function found
Texas Instruments AM335x Processor, Revision ES2.1
random: no preloaded entropy cache
random: no platform bootloader entropy
arc4random: WARNING: initial seeding bypassed the cryptographic random 
device because it was not yet seeded and the knob 
'bypass_before_seeding' was enabled.
VIMAGE (virtualized network stack) enabled
hostuuid: using 00000000-0000-0000-0000-000000000000
ULE: setup cpu 0
snd_unit_init() u=0x00ff8000 [512] d=0x00007c00 [32] c=0x000003ff [1024]
feeder_register: snd_unit=-1 snd_maxautovchans=16 latency=2 
feeder_rate_min=1 feeder_rate_max=2016000 feeder_rate_round=25
random: entropy device external interface
firmware: 'sdma-imx6q' version 0: 2196 bytes loaded at 0xc092a318
crypto: <crypto core>
null: <full device, null device, zero device>
openfirm: <Open Firmware control device>
kbd0 at kbdmux0
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
cpuid = 0
time = 1
KDB: stack backtrace:
db_trace_self() at db_trace_self
	 pc = 0xc05cdb84  lr = 0xc007ac8c (db_trace_self_wrapper+0x30)
	 sp = 0xc0f14a98  fp = 0xc0f14bb0
db_trace_self_wrapper() at db_trace_self_wrapper+0x30
	 pc = 0xc007ac8c  lr = 0xc02e5c48 (vpanic+0x170)
	 sp = 0xc0f14bb8  fp = 0xc0f14bd8
	 r4 = 0x00000100  r5 = 0x00000000
	 r6 = 0xc07314a8  r7 = 0xc0916f10
vpanic() at vpanic+0x170
	 pc = 0xc02e5c48  lr = 0xc02e59f8 (dump_savectx)
	 sp = 0xc0f14be0  fp = 0xc0f14be4
	 r4 = 0x00000000  r5 = 0xc2b24000
	 r6 = 0x00000000  r7 = 0xc0f14c50
	 r8 = 0xc0b65ec0  r9 = 0x00000002
	r10 = 0xc0f14c2c
dump_savectx() at dump_savectx
	 pc = 0xc02e59f8  lr = 0xc0354fe4 (vmem_xalloc)
	 sp = 0xc0f14bec  fp = 0xc0f14c20
vmem_xalloc() at vmem_xalloc
	 pc = 0xc0354fe4  lr = 0xc0593f18 (kmem_malloc_domainset+0x9c)
	 sp = 0xc0f14c28  fp = 0xc0f14c70
	 r4 = 0xc0048f30  r5 = 0xc0e0b0ec
	 r6 = 0xc0f14c1c  r7 = 0x00000000
	 r8 = 0xc2b24000  r9 = 0x00000000
	r10 = 0xc0f14c50
kmem_malloc_domainset() at kmem_malloc_domainset+0x9c
	 pc = 0xc0593f18  lr = 0xc02bf748 (malloc_large+0x2c)
	 sp = 0xc0f14c78  fp = 0xc0f14c88
	 r4 = 0xc08e7714  r5 = 0xd53dca80
	 r6 = 0x00000000  r7 = 0x00000002
	 r8 = 0x00000d74  r9 = 0xc079ae29
	r10 = 0x00000d74
malloc_large() at malloc_large+0x2c
	 pc = 0xc02bf748  lr = 0xc06a3940 (ti_sysc_attach+0x19c)
	 sp = 0xc0f14c90  fp = 0xc0f14cd0
	 r4 = 0xc387b400  r5 = 0xd53dca80
	 r6 = 0xffffffff  r7 = 0xc387b428
ti_sysc_attach() at ti_sysc_attach+0x19c
	 pc = 0xc06a3940  lr = 0xc032439c (device_attach+0x4f0)
	 sp = 0xc0f14cd8  fp = 0xc0f14d20
	 r4 = 0xd53dc800  r5 = 0xd53dca80
	 r6 = 0x3a780a0c  r7 = 0x00000000
	 r8 = 0xc0b6a924  r9 = 0xc077cf27
	r10 = 0xd6f1a500
device_attach() at device_attach+0x4f0
	 pc = 0xc032439c  lr = 0xc0323e10 (device_probe_and_attach+0x8c)
	 sp = 0xc0f14d28  fp = 0xc0f14d40
	 r4 = 0xd53dc800  r5 = 0xc3868f40
	 r6 = 0x5e4a6f28  r7 = 0xffffffff
	 r8 = 0x00000000  r9 = 0x00000000
	r10 = 0xd6f1a6e0
device_probe_and_attach() at device_probe_and_attach+0x8c
	 pc = 0xc0323e10  lr = 0xc0325804 (bus_generic_attach+0x1c)
	 sp = 0xc0f14d48  fp = 0xc0f14d50
	 r4 = 0xd53dc800  r5 = 0x00000000
	 r6 = 0xc0f14d60 r10 = 0xd6f1a6e0
bus_generic_attach() at bus_generic_attach+0x1c
	 pc = 0xc0325804  lr = 0xc00e4248 (ofwbus_attach+0x138)
	 sp = 0xc0f14d58  fp = 0xc0f14d90
	 r4 = 0xd53dca80 r10 = 0xd6f1a6e0
ofwbus_attach() at ofwbus_attach+0x138
	 pc = 0xc00e4248  lr = 0xc032439c (device_attach+0x4f0)
	 sp = 0xc0f14d98  fp = 0xc0f14de0
	 r4 = 0xd53dca80  r5 = 0xd53dcb00
	 r6 = 0x39cf0259  r7 = 0x00000000
	 r8 = 0xc0b6a924  r9 = 0xc077cf27
device_attach() at device_attach+0x4f0
	 pc = 0xc032439c  lr = 0xc0323e10 (device_probe_and_attach+0x8c)
	 sp = 0xc0f14de8  fp = 0xc0f14e00
	 r4 = 0xd53dca80  r5 = 0xc3868f40
	 r6 = 0x5e4a6f28  r7 = 0x00000000
	 r8 = 0xc0b01654  r9 = 0xc0b01658
	r10 = 0x03800000
device_probe_and_attach() at device_probe_and_attach+0x8c
	 pc = 0xc0323e10  lr = 0xc0326278 (bus_generic_new_pass+0xb4)
	 sp = 0xc0f14e08  fp = 0xc0f14e20
	 r4 = 0xd53dca80  r5 = 0xc08dde38
	 r6 = 0xc08b986c r10 = 0x03800000
bus_generic_new_pass() at bus_generic_new_pass+0xb4
	 pc = 0xc0326278  lr = 0xc03262c4 (bus_generic_new_pass+0x100)
	 sp = 0xc0f14e28  fp = 0xc0f14e40
	 r4 = 0xd53dcb00  r5 = 0xc08dde38
	 r6 = 0xd53dd700  r7 = 0x00000000
	 r8 = 0xc0b01654 r10 = 0x03800000
bus_generic_new_pass() at bus_generic_new_pass+0x100
	 pc = 0xc03262c4  lr = 0xc03213cc (bus_set_pass+0x54)
	 sp = 0xc0f14e48  fp = 0xc0f14e60
	 r4 = 0xc389d4a0  r5 = 0xc08dde38
	 r6 = 0xd53dd700  r7 = 0xc0b01654
	 r8 = 0x7fffffff r10 = 0x03800000
bus_set_pass() at bus_set_pass+0x54
	 pc = 0xc03213cc  lr = 0xc02708c0 (mi_startup+0x2cc)
	 sp = 0xc0f14e68  fp = 0xc0f14e90
	 r4 = 0x0fffffff  r5 = 0xc08b3764
	 r6 = 0xc0ae31b8  r7 = 0x00000000
	 r8 = 0xc0ae31b4  r9 = 0xc38a3324
mi_startup() at mi_startup+0x2cc
	 pc = 0xc02708c0  lr = 0xc0000344 (btext+0x144)
	 sp = 0xc0f14e98  fp = 0x00000000
	 r4 = 0xc0000478  r5 = 0xc0ba0000
	 r6 = 0xbb102340  r7 = 0x00c52078
	 r8 = 0xc0e22000  r9 = 0xbcf085d8
	r10 = 0x00000000
btext() at btext+0x144
	 pc = 0xc0000344  lr = 0xc0000344 (btext+0x144)
	 sp = 0xc0f14e98  fp = 0x00000000
KDB: enter: panic
[ thread pid 0 tid 100000 ]
Stopped at      kdb_enter+0x58: ldrb    r15, [r15, r15, ror r15]!
  db>

I'm not a kernel hacker, but I'll be happy to give more information as 
needed, when told what to type at the db> prompt =)

I can also build my own image trying to bisect the problem, but wonder 
if anyone has any hint of what commit(s) could be causing this issue.

(I also wonder whether I should be posting on freebsd-current@, rather 
than freebsd-arm@ . Suggestions accepted)

Thanks,
Matteo