qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] target/arm: Improve M-profile exception logging
@ 2022-03-15 20:43 Peter Maydell
  2022-03-15 20:43 ` [PATCH 1/2] target/arm: Log M-profile vector table accesses Peter Maydell
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Peter Maydell @ 2022-03-15 20:43 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

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 aborts

This 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

 target/arm/cpu.c      |  5 +++++
 target/arm/m_helper.c | 11 +++++++++++
 2 files changed, 16 insertions(+)

-- 
2.25.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-03-16 13:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-15 20:43 [PATCH 0/2] target/arm: Improve M-profile exception logging Peter Maydell
2022-03-15 20:43 ` [PATCH 1/2] target/arm: Log M-profile vector table accesses Peter Maydell
2022-03-15 21:40   ` Richard Henderson
2022-03-16 11:40   ` Alex Bennée
2022-03-15 20:43 ` [PATCH 2/2] target/arm: Log fault address for M-profile faults Peter Maydell
2022-03-15 21:41   ` Richard Henderson
2022-03-16 12:03   ` Alex Bennée
2022-03-16 13:00 ` [PATCH 0/2] target/arm: Improve M-profile exception logging Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).