diff mbox series

[kvm-unit-tests,v2,03/10] x86 AMD SEV: Skip SEV-ES if SEV is unsupported

Message ID 20211116204053.220523-4-zxwang42@gmail.com (mailing list archive)
State New, archived
Headers show
Series x86_64 UEFI set up process refactor and scripts fixes | expand

Commit Message

Zixuan Wang Nov. 16, 2021, 8:40 p.m. UTC
From: Sean Christopherson <seanjc@google.com>

Skip the SEV-ES setup if SEV is unsupported. Also update the printf to
include error codes.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 lib/x86/setup.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/lib/x86/setup.c b/lib/x86/setup.c
index 86ff400..68ee74c 100644
--- a/lib/x86/setup.c
+++ b/lib/x86/setup.c
@@ -300,29 +300,24 @@  efi_status_t setup_efi(efi_bootinfo_t *efi_bootinfo)
 	}
 
 	status = setup_amd_sev();
+	/* Continue if AMD SEV is not supported, but skip SEV-ES setup */
+	if (status == EFI_UNSUPPORTED) {
+		goto continue_setup_after_sev;
+	}
+
 	if (status != EFI_SUCCESS) {
-		switch (status) {
-		case EFI_UNSUPPORTED:
-			/* Continue if AMD SEV is not supported */
-			break;
-		default:
-			printf("Set up AMD SEV failed\n");
-			return status;
-		}
+		printf("AMD SEV setup failed, error = 0x%lx\n", status);
+		return status;
 	}
 
 	status = setup_amd_sev_es();
-	if (status != EFI_SUCCESS) {
-		switch (status) {
-		case EFI_UNSUPPORTED:
-			/* Continue if AMD SEV-ES is not supported */
-			break;
-		default:
-			printf("Set up AMD SEV-ES failed\n");
-			return status;
-		}
+	if (status != EFI_SUCCESS && status != EFI_UNSUPPORTED) {
+		printf("AMD SEV-ES setup failed, error = 0x%lx\n", status);
+		return status;
 	}
 
+continue_setup_after_sev:
+
 	reset_apic();
 	setup_gdt_tss();
 	setup_idt();