summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2025-01-29 11:29:54 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-01-30 13:07:05 +0000
commitafdae789cd0d33c6f7debce2fc41f1af4946d869 (patch)
treed08b7ad217b62c4351e18dcfc26a7d03647502ee
parentb64f735867ead2e1b4cc2df5d1ee8a4273ee7c39 (diff)
downloadedk2-afdae789cd0d33c6f7debce2fc41f1af4946d869.tar.gz
ArmPkg/CpuDxe: Fix error handling in driver initialization
Failure to install the CPU arch protocol is a fatal error, so treat it as such, rather than ignore it, even though we won't get very far if this driver fails to dispatch - at least, we will get an error in a DEBUG build rather than a mysterious failure due to unsatisfied DEPEXes. Failure to install the idle loop event handler is not a fatal error, and it should not cause the driver to exit with an error, as this will unload the driver and keep the installed CPU arch protocol pointer dangling. So keep the ASSERT() on the return value, but return EFI_SUCCESS once we're past the point where the CPU arch protocol has been installed. Since the protocol is never uninstalled, make the CPU handle function local, as there is no point in keeping its value around. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
-rw-r--r--ArmPkg/Drivers/CpuDxe/CpuDxe.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.c b/ArmPkg/Drivers/CpuDxe/CpuDxe.c
index fc63e52784..9bb2b4a600 100644
--- a/ArmPkg/Drivers/CpuDxe/CpuDxe.c
+++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.c
@@ -206,8 +206,7 @@ IdleLoopEventCallback (
//
// Globals used to initialize the protocol
//
-EFI_HANDLE mCpuHandle = NULL;
-EFI_CPU_ARCH_PROTOCOL mCpu = {
+EFI_CPU_ARCH_PROTOCOL mCpu = {
CpuFlushCpuDataCache,
CpuEnableInterrupt,
CpuDisableInterrupt,
@@ -308,6 +307,7 @@ CpuDxeInitialize (
{
EFI_STATUS Status;
EFI_EVENT IdleLoopEvent;
+ EFI_HANDLE CpuHandle;
InitializeExceptions (&mCpu);
@@ -327,14 +327,20 @@ CpuDxeInitialize (
RemapUnusedMemoryNx ();
}
+ CpuHandle = NULL;
+
Status = gBS->InstallMultipleProtocolInterfaces (
- &mCpuHandle,
+ &CpuHandle,
&gEfiCpuArchProtocolGuid,
&mCpu,
&gEfiMemoryAttributeProtocolGuid,
&mMemoryAttribute,
NULL
);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
//
// Make sure GCD and MMU settings match. This API calls gDS->SetMemorySpaceAttributes ()
@@ -358,5 +364,5 @@ CpuDxeInitialize (
);
ASSERT_EFI_ERROR (Status);
- return Status;
+ return EFI_SUCCESS;
}