On 15/3/22 21:43, Peter Maydell wrote:
Our current logging for M-profile exceptions has a couple of holes which are particularly confusing for the case of an exception taken immediately out of reset: * we don't log the initial PC/SP loaded from the vector table * we don't log the PC we load from the vector table when we take an exception * we don't log the address for i-side abortsThis case is quite common where the user has failed to provide a vector table in their ELF file and QEMU thus loads garbage for the initial PC. At the moment the logging looks like: $ qemu-system-arm [...] -d in_asm,cpu,exec,int Taking exception 3 [Prefetch Abort] on CPU 0 ...with CFSR.IACCVIOL ...BusFault with BFSR.STKERR ...taking pending nonsecure exception 3 ---------------- IN: 0x20000558: 08000079 stmdaeq r0, {r0, r3, r4, r5, r6} After this patchset it looks like: $ qemu-system-arm [...] -d in_asm,cpu,exec,int Loaded reset SP 0x0 PC 0x0 from vector table Loaded reset SP 0xd008f8df PC 0xf000bf00 from vector table Taking exception 3 [Prefetch Abort] on CPU 0 ...at fault address 0xf000bf00 ...with CFSR.IACCVIOL ...BusFault with BFSR.STKERR ...taking pending nonsecure exception 3 ...loading from element 3 of non-secure vector table at 0xc ...loaded new PC 0x20000558 ---------------- IN: 0x20000558: 08000079 stmdaeq r0, {r0, r3, r4, r5, r6} and I think it is somewhat clearer that we loaded a bogus PC from the vector table at reset, faulted at that address, loaded the HardFault entry point which was bogus but at least readable, and started executing code from there. The double-logging of the reset loads is the result of the way we currently reset the CPU twice on QEMU startup. If we ever manage to fix that silliness it'll go away. (Patchset inspired by a stackexchange question: https://stackoverflow.com/questions/71486314/loading-an-elf-file-into-qemu ) thanks -- PMM Peter Maydell (2): target/arm: Log M-profile vector table accesses target/arm: Log fault address for M-profile faults
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
