summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2025-01-30 13:51:30 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-01-30 16:01:56 +0000
commitef80dd8fad8c177609a5719c4ec0a6d5b90fbfb7 (patch)
tree4eb62df73ddd7c83578489a2fb17749b3e3d1b68
parent74376f0b72b9e7ca24d3892df0fb7b07aa7af6fb (diff)
downloadedk2-ef80dd8fad8c177609a5719c4ec0a6d5b90fbfb7.tar.gz
ArmPkg: Stop using ArmDisassemblerLib
ArmDisassemblerLib is used to pretty print the instruction that triggered an unhandled exception, but it was never implemented for AARCH64, and according to the existing file comment, Thumb2 support (which is used predominantly when building EDK2 for 32-bit ARM due to its smaller size) is incomplete. The DEBUG diagnostics that are produced on an unhandled exception are generally sufficient to dump the entire executable that triggered it, and so this disassembly is of limited value, especially because it doesn't work on AARCH64. So let's start getting rid of it, by dropping references to it in code and in the various .INF and .DSC files. Once out-of-tree platforms have been allowed to catch up, we can remove the library implementation and its class definition entirely. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
-rw-r--r--ArmPkg/ArmPkg.dsc1
-rw-r--r--ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.dsc1
-rw-r--r--ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c1
-rw-r--r--ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c32
-rw-r--r--ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf1
5 files changed, 1 insertions, 35 deletions
diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
index 061d9d60dc..7e8def29ca 100644
--- a/ArmPkg/ArmPkg.dsc
+++ b/ArmPkg/ArmPkg.dsc
@@ -70,7 +70,6 @@
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
ArmSvcLib|ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
- ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
OpteeLib|ArmPkg/Library/OpteeLib/OpteeLib.inf
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
diff --git a/ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.dsc b/ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.dsc
index 28ebe68b41..f93d31776f 100644
--- a/ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.dsc
+++ b/ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.dsc
@@ -26,7 +26,6 @@
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x27
[LibraryClasses]
- ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf
diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
index 9b5adeaf89..5f9bcf7966 100644
--- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
+++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
@@ -14,7 +14,6 @@
#include <Library/DebugLib.h>
#include <Library/PeCoffGetEntryPointLib.h>
#include <Library/PrintLib.h>
-#include <Library/ArmDisassemblerLib.h>
#include <Library/SerialPortLib.h>
#include <Library/UefiBootServicesTableLib.h>
diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
index accad647d6..50e4205c23 100644
--- a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
+++ b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
@@ -13,7 +13,6 @@
#include <Library/DebugLib.h>
#include <Library/PeCoffGetEntryPointLib.h>
#include <Library/PrintLib.h>
-#include <Library/ArmDisassemblerLib.h>
#include <Library/SerialPortLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
@@ -210,9 +209,6 @@ DefaultExceptionHandler (
UINT32 DfsrStatus;
UINT32 IfsrStatus;
BOOLEAN DfsrWrite;
- UINT32 PcAdjust;
-
- PcAdjust = 0;
CharCount = AsciiSPrint (
Buffer,
@@ -233,11 +229,7 @@ DefaultExceptionHandler (
UINT32 ImageBase;
UINT32 PeCoffSizeOfHeader;
UINT32 Offset;
- CHAR8 CpsrStr[CPSR_STRING_SIZE]; // char per bit. Lower 5-bits are mode
- // that is a 3 char string
- CHAR8 Buffer[80];
- UINT8 *DisAsm;
- UINT32 ItBlock;
+ CHAR8 CpsrStr[CPSR_STRING_SIZE];
CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr);
DEBUG ((DEBUG_ERROR, "%a\n", CpsrStr));
@@ -256,25 +248,6 @@ DefaultExceptionHandler (
// get the offset that matches the link map.
//
DEBUG ((DEBUG_ERROR, "loaded at 0x%08x (PE/COFF offset) 0x%x (ELF or Mach-O offset) 0x%x", ImageBase, Offset, Offset - PeCoffSizeOfHeader));
-
- // If we come from an image it is safe to show the instruction. We know it should not fault
- DisAsm = (UINT8 *)(UINTN)SystemContext.SystemContextArm->PC;
- ItBlock = 0;
- DisassembleInstruction (&DisAsm, (SystemContext.SystemContextArm->CPSR & BIT5) == BIT5, TRUE, &ItBlock, Buffer, sizeof (Buffer));
- DEBUG ((DEBUG_ERROR, "\n%a", Buffer));
-
- switch (ExceptionType) {
- case EXCEPT_ARM_UNDEFINED_INSTRUCTION:
- case EXCEPT_ARM_SOFTWARE_INTERRUPT:
- case EXCEPT_ARM_PREFETCH_ABORT:
- case EXCEPT_ARM_DATA_ABORT:
- // advance PC past the faulting instruction
- PcAdjust = (UINTN)DisAsm - SystemContext.SystemContextArm->PC;
- break;
-
- default:
- break;
- }
}
DEBUG_CODE_END ();
@@ -312,7 +285,4 @@ DefaultExceptionHandler (
// Clear the error registers that we have already displayed incase some one wants to keep going
SystemContext.SystemContextArm->DFSR = 0;
SystemContext.SystemContextArm->IFSR = 0;
-
- // If some one is stepping past the exception handler adjust the PC to point to the next instruction
- SystemContext.SystemContextArm->PC += PcAdjust;
}
diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
index c7d31f6408..30291a4663 100644
--- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
+++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
@@ -35,7 +35,6 @@
PrintLib
DebugLib
PeCoffGetEntryPointLib
- ArmDisassemblerLib
SerialPortLib
UefiBootServicesTableLib