[edk2-devel] [PATCH] ArmPkg/DefaultExceptionHandler: Dump ESR and FAR in RELEASE builds

Ard Biesheuvel posted 1 patch 1 year, 3 months ago
Failed in applying to current master (apply log)
.../AArch64/DefaultExceptionHandler.c                     | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
[edk2-devel] [PATCH] ArmPkg/DefaultExceptionHandler: Dump ESR and FAR in RELEASE builds
Posted by Ard Biesheuvel 1 year, 3 months ago
In RELEASE builds, the AArch64 default exception handler only dumps the
exception type and the ELR, which is the value of the program counter
when the exception was taken. Given that DXE phase drivers are loaded
dynamically at arbitrary addresses, this is probably the least useful
bit of information that can be provided, and knowing the ESR and FAR
would be far more useful, as these describe the nature of the exception,
and that faulting address.

So add those to the console output. Note that these values are also
dumped along with the backtrace, register dump and stack in DEBUG
builds, but not in RELEASE builds.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 .../AArch64/DefaultExceptionHandler.c                     | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
index f2bca5d74005..f557b1e78bde 100644
--- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
+++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
@@ -205,7 +205,13 @@ DefaultExceptionHandler (
 
   mRecursiveException = TRUE;
 
-  CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "\n\n%a Exception at 0x%016lx\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextAArch64->ELR);
+  CharCount = AsciiSPrint (Buffer, sizeof (Buffer),
+                "\n\n%a Exception at 0x%016lx, ESR:0x%016lx FAR:0x%016lx\n",
+                gExceptionTypeString[ExceptionType],
+                SystemContext.SystemContextAArch64->ELR,
+                SystemContext.SystemContextAArch64->ESR,
+                SystemContext.SystemContextAArch64->FAR
+                );
   SerialPortWrite ((UINT8 *)Buffer, CharCount);
   if (gST->ConOut != NULL) {
     AsciiPrint (Buffer);
-- 
2.39.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#99195): https://edk2.groups.io/g/devel/message/99195
Mute This Topic: https://groups.io/mt/96571451/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-