mbox series

[0/3] arm: Semihosting fixes/improvements for ARMv6 and older

Message ID 20231027204015.1547595-1-sean.anderson@seco.com
Headers show
Series arm: Semihosting fixes/improvements for ARMv6 and older | expand

Message

Sean Anderson Oct. 27, 2023, 8:40 p.m. UTC
This series has a few fixes for semihosting on ARMv6 and older CPUs. The
first two patches address problems regarding the stack pointer and link
register. U-Boot runs in supervisor mode, so taking a software interrupt
will clobber sp/lr. I think we really should run in system mode, since
it has separate sp/lr registers. To quote ARM DDI 0100I:

> The remaining mode is System mode, which is not entered by any
> exception and has exactly the same registers available as User mode.
> However, it is a privileged mode and is therefore not subject to the
> User mode restrictions. It is intended for use by operating system
> tasks that need access to system resources, but wish to avoid using
> the additional registers associated with the exception modes. Avoiding
> such use ensures that the task state is not corrupted by the
> occurrence of any exception.

However, the processor mode has been supervisor for such a long time
(since relocation got introduced) that I would rather not touch it.


Sean Anderson (3):
  arm: Fix software interrupt handler
  arm: semihosting: Fix returning from traps on ARMv6 and lower
  arm: semihosting: Support semihosting fallback on 32-bit ARM

 arch/arm/lib/interrupts.c  | 31 +++++++++++++++++++++++++++++++
 arch/arm/lib/semihosting.S |  6 ++++++
 arch/arm/lib/vectors.S     | 21 ++++++++++++++++++++-
 lib/Kconfig                |  4 ++--
 4 files changed, 59 insertions(+), 3 deletions(-)

Comments

Tom Rini Nov. 10, 2023, 8:17 p.m. UTC | #1
On Fri, 27 Oct 2023 16:40:12 -0400, Sean Anderson wrote:

> This series has a few fixes for semihosting on ARMv6 and older CPUs. The
> first two patches address problems regarding the stack pointer and link
> register. U-Boot runs in supervisor mode, so taking a software interrupt
> will clobber sp/lr. I think we really should run in system mode, since
> it has separate sp/lr registers. To quote ARM DDI 0100I:
> 
> > The remaining mode is System mode, which is not entered by any
> > exception and has exactly the same registers available as User mode.
> > However, it is a privileged mode and is therefore not subject to the
> > User mode restrictions. It is intended for use by operating system
> > tasks that need access to system resources, but wish to avoid using
> > the additional registers associated with the exception modes. Avoiding
> > such use ensures that the task state is not corrupted by the
> > occurrence of any exception.
> 
> [...]

Applied to u-boot/next, thanks!