[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230216124602.26849-2-bp@alien8.de>
Date: Thu, 16 Feb 2023 13:45:58 +0100
From: Borislav Petkov <bp@...en8.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Dionna Glaze <dionnaglaze@...gle.com>,
Joerg Roedel <jroedel@...e.de>,
Michael Roth <michael.roth@....com>,
Nikunj A Dadhania <nikunj@....com>,
Peter Gonda <pgonda@...gle.com>,
Tom Lendacky <Thomas.Lendacky@....com>,
linux-coco@...ts.linux.dev, x86@...nel.org
Subject: [PATCH 07/11] virt/coco/sev-guest: Convert the sw_exit_info_2 checking to a switch-case
From: "Borislav Petkov (AMD)" <bp@...en8.de>
snp_issue_guest_request() checks the value returned by the hypervisor in
sw_exit_info_2 and returns a different error depending on it.
Convert those checks into a switch-case to make it more readable when
more error values are going to be checked in the future.
No functional changes.
Signed-off-by: Borislav Petkov (AMD) <bp@...en8.de>
---
arch/x86/kernel/sev.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c
index ee53cab887fa..d6655fccefc8 100644
--- a/arch/x86/kernel/sev.c
+++ b/arch/x86/kernel/sev.c
@@ -2209,17 +2209,23 @@ int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned
if (ret)
goto e_put;
- if (ghcb->save.sw_exit_info_2) {
+ *fw_err = ghcb->save.sw_exit_info_2;
+ switch (*fw_err) {
+ case 0:
+ break;
+
+ case SNP_GUEST_REQ_INVALID_LEN:
/* Number of expected pages are returned in RBX */
- if (exit_code == SVM_VMGEXIT_EXT_GUEST_REQUEST &&
- ghcb->save.sw_exit_info_2 == SNP_GUEST_REQ_INVALID_LEN) {
+ if (exit_code == SVM_VMGEXIT_EXT_GUEST_REQUEST) {
input->data_npages = ghcb_get_rbx(ghcb);
ret = -ENOSPC;
- } else {
- ret = -EIO;
+ break;
}
+ fallthrough;
- *fw_err = ghcb->save.sw_exit_info_2;
+ default:
+ ret = -EIO;
+ break;
}
e_put:
--
2.35.1
Powered by blists - more mailing lists