From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zack Marvel Date: Sat, 13 Feb 2021 18:38:48 -0700 Subject: qemu arm: increasing log-level causes exception Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 , getc = 0x42af0 , putc = 0x42b34 , pending = 0x42b68 , clear = 0x0 , getconfig = 0x0 , setconfig = 0x0 , getinfo = 0x0 } 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=) 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=) 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=, 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=, line=, 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=, dest_addr=) at ../common/board_r.c:928 #10 0xbff327cc in ?? () at ../arch/arm/lib/crt0.S:167