[edk2-devel] [PATCH 7/7] [PATCH v2] UefiCpuPkg: BaseRiscV64CpuExceptionHandlerLib: clean up exception handling

Sunil V L sunilvl at ventanamicro.com
Fri Feb 24 10:44:35 UTC 2023


On Thu, Feb 23, 2023 at 05:54:54PM -0600, Andrei Warkentin wrote:
> RegisterCpuInterruptHandler did not allow setting
> exception handlers for anything beyond the timer IRQ.
> Beyond that, it didn't meet the spec around handling
> of inputs.
> 
> RiscVSupervisorModeTrapHandler now will invoke
> set handlers for both exceptions and interrupts.
> Two arrays of handlers are maintained - one for exceptions
> and one for interrupts.
> 
> For unhandled traps, RiscVSupervisorModeTrapHandler dumps
> state using the now implemented DumpCpuContext.
> 
> For EFI_SYSTEM_CONTEXT_RISCV64, extend this with the trapped
> PC address (SEPC), just like on AArch64 (ELR). This is
> necessary for X86EmulatorPkg to work as it allows a trap
> handler to return execution to a different place. Add
> SSTATUS/STVAL as well, at least for debugging purposes. There
> is no value in hiding this.
> 
> Fix nested exception handling. Handler code should not
> be saving SIE (the value is saved in SSTATUS.SPIE) or
> directly restored (that's done by SRET). Save and
> restore the entire SSTATUS and STVAL, too.
> 
> Cc: Sunil V L <sunilvl at ventanamicro.com>
> Cc: Daniel Schaefer <git at danielschaefer.me>
> Signed-off-by: Andrei Warkentin <andrei.warkentin at intel.com>
> ---
>  MdePkg/Include/Protocol/DebugSupport.h        |  32 ++-
>  .../CpuExceptionHandlerLib.h                  |  11 +-
>  UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c         |   6 +-
>  .../CpuExceptionHandlerLib.c                  | 232 ++++++++++++++++--
>  .../SupervisorTrapHandler.S                   |  17 +-
>  5 files changed, 254 insertions(+), 44 deletions(-)
> 
Reviewed-by: Sunil V L <sunilvl at ventanamicro.com>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#100491): https://edk2.groups.io/g/devel/message/100491
Mute This Topic: https://groups.io/mt/97196087/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list