qemu arm: increasing log-level causes exception

Zack Marvel zpmarvel at gmail.com
Sun Feb 14 02:38:48 CET 2021


Hello,

I wanted to observe some debug messages, so I increased the log level 
from 6 to 7. Otherwise, my configuration matches 'qemu_arm_defconfig'. 
This resulted in a PREFETCH fault. The backtrace is included below.

My u-boot version is v2021.01. My compiler is arm-none-eabi-gcc 7.3.1 
from Debian. I tested qemu 3.1.0 (from Debian) and 5.1.0 (which I 
built), invoked like this:

	qemu-system-arm -machine virt -cpu cortex-a15 -m 2G -bios 
u-boot/build.qemu_arm/u-boot.bin

I think this is happening because the code has been relocated and the 
MMU enabled, but the functions pointed to by 
gd->cur_serial_dev->driver->ops still point to the code in flash:


(gdb) p *((struct dm_serial_ops*)(gd->cur_serial_dev->driver->ops))
$3 = {setbrg = 0x4296c <pl01x_serial_setbrg>, getc = 0x42af0 
<pl01x_serial_getc>, putc = 0x42b34 <pl01x_serial_putc>, pending = 
0x42b68 <pl01x_serial_pending>, clear = 0x0 <v7_arch_cp15_set_l2aux_ctrl>,
   getconfig = 0x0 <v7_arch_cp15_set_l2aux_ctrl>, setconfig = 0x0 
<v7_arch_cp15_set_l2aux_ctrl>, getinfo = 0x0 <v7_arch_cp15_set_l2aux_ctrl>}


I was able to workaround this behavior by adding

	gd->cur_serial_dev = NULL;

in board_init_r before the post-relocation initialization sequence is 
executed. Rearranging init_sequence_r so that log_init runs after 
serial_initialize works too.

I would like to contribute a patch, but I require some guidance. Is 
there a better way to indicate that log messages should not be output 
until the driver has been reinitialized by board_init_r? Or is there a 
better initialization order?


Thanks and best regards,
Zack Marvel


Backtrace:

#0  pl01x_serial_putc (dev=0x401fe180, ch=105 'i') at 
../drivers/serial/serial_pl01x.c:316
#1  0xbff73504 in _serial_putc (dev=dev at entry=0x401fe180, ch=<optimized 
out>) at ../drivers/serial/serial-uclass.c:187
#2  0xbff736a8 in _serial_puts (str=0xbedf0a05 "nitcall: 00017180 
(relocated to bff48180)\n", dev=0x401fe180) at 
../drivers/serial/serial-uclass.c:194
#3  serial_puts (str=<optimized out>) at 
../drivers/serial/serial-uclass.c:271
#4  0xbffb0e30 in printf (fmt=0xbffd0c6a "%s%s") at ../lib/vsprintf.c:805
#5  0xbff58f24 in log_console_emit (ldev=<optimized out>, 
rec=0xbedf0c44) at ../common/log_console.c:39
#6  0xbff58cc4 in log_dispatch (rec=0xbedf0c3c) at ../common/log.c:218
#7  _log (cat=LOGC_NONE, level=LOGL_DEBUG, file=<optimized out>, 
line=<optimized out>, func=0xbffbcdb1 "initcall_run_list", 
fmt=0xbffc0ef3 "initcall: %p (relocated to %p)\n") at ../common/log.c:252
#8  0xbff48388 in initcall_run_list (init_sequence=0xbffe03a0) at 
../include/initcall.h:39
#9  board_init_r (new_gd=<optimized out>, dest_addr=<optimized out>) at 
../common/board_r.c:928
#10 0xbff327cc in ?? () at ../arch/arm/lib/crt0.S:167


More information about the U-Boot mailing list