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

Ard Biesheuvel

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@...>
.../AArch64/DefaultExceptionHandler.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

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