[edk2] [PATCH 06/12] OvmfPkg/IoMmuDxe: propagate errors from AmdSevInstallIoMmuProtocol()

Laszlo Ersek posted 12 patches 7 years, 4 months ago
[edk2] [PATCH 06/12] OvmfPkg/IoMmuDxe: propagate errors from AmdSevInstallIoMmuProtocol()
Posted by Laszlo Ersek 7 years, 4 months ago
If we cannot install the IOMMU protocol for whatever reason, exit the
driver with an error. The same is already done for the IOMMU Absent
protocol.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/IoMmuDxe/AmdSevIoMmu.h | 2 +-
 OvmfPkg/IoMmuDxe/AmdSevIoMmu.c | 4 ++--
 OvmfPkg/IoMmuDxe/IoMmuDxe.c    | 4 +---
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/OvmfPkg/IoMmuDxe/AmdSevIoMmu.h b/OvmfPkg/IoMmuDxe/AmdSevIoMmu.h
index 88dabfc2c435..0f2155350817 100644
--- a/OvmfPkg/IoMmuDxe/AmdSevIoMmu.h
+++ b/OvmfPkg/IoMmuDxe/AmdSevIoMmu.h
@@ -34,7 +34,7 @@
   MemEncryptSevLib.
 
 **/
-VOID
+EFI_STATUS
 EFIAPI
 AmdSevInstallIoMmuProtocol (
   VOID
diff --git a/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c b/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c
index 954062442782..8c2c23356a40 100644
--- a/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c
+++ b/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c
@@ -499,20 +499,20 @@ EDKII_IOMMU_PROTOCOL  mAmdSev = {
   Initialize Iommu Protocol.
 
 **/
-VOID
+EFI_STATUS
 EFIAPI
 AmdSevInstallIoMmuProtocol (
   VOID
   )
 {
   EFI_STATUS  Status;
   EFI_HANDLE  Handle;
 
   Handle = NULL;
   Status = gBS->InstallMultipleProtocolInterfaces (
                   &Handle,
                   &gEdkiiIoMmuProtocolGuid, &mAmdSev,
                   NULL
                   );
-  ASSERT_EFI_ERROR (Status);
+  return Status;
 }
diff --git a/OvmfPkg/IoMmuDxe/IoMmuDxe.c b/OvmfPkg/IoMmuDxe/IoMmuDxe.c
index 27b1856e0a17..0ea42cbc13ce 100644
--- a/OvmfPkg/IoMmuDxe/IoMmuDxe.c
+++ b/OvmfPkg/IoMmuDxe/IoMmuDxe.c
@@ -31,27 +31,25 @@ EFIAPI
 IoMmuDxeEntryPoint (
   IN EFI_HANDLE         ImageHandle,
   IN EFI_SYSTEM_TABLE   *SystemTable
   )
 {
   EFI_STATUS    Status;
   EFI_HANDLE    Handle;
 
-  Status = EFI_SUCCESS;
-
   //
   // When SEV is enabled, install IoMmu protocol otherwise install the
   // placeholder protocol so that other dependent module can run.
   //
   if (MemEncryptSevIsEnabled ()) {
-    AmdSevInstallIoMmuProtocol ();
+    Status = AmdSevInstallIoMmuProtocol ();
   } else {
     Handle = NULL;
 
     Status = gBS->InstallMultipleProtocolInterfaces (
                   &Handle,
                   &gIoMmuAbsentProtocolGuid,
                   NULL, NULL);
   }
 
   return Status;
 }
-- 
2.13.1.3.g8be5a757fa67


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel