[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <167871228994.5837.5974944076233094676.tip-bot2@tip-bot2>
Date: Mon, 13 Mar 2023 12:58:09 -0000
From: "tip-bot2 for Borislav Petkov (AMD)" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: "Borislav Petkov (AMD)" <bp@...en8.de>,
Tom Lendacky <thomas.lendacky@....com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: x86/urgent] virt/coco/sev-guest: Convert the sw_exit_info_2
checking to a switch-case
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: fa4ae42cc60a7dea30e8f2db444b808d80862345
Gitweb: https://git.kernel.org/tip/fa4ae42cc60a7dea30e8f2db444b808d80862345
Author: Borislav Petkov (AMD) <bp@...en8.de>
AuthorDate: Thu, 16 Feb 2023 10:50:11 +01:00
Committer: Borislav Petkov (AMD) <bp@...en8.de>
CommitterDate: Mon, 13 Mar 2023 12:55:34 +01:00
virt/coco/sev-guest: Convert the sw_exit_info_2 checking to a switch-case
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>
Reviewed-by: Tom Lendacky <thomas.lendacky@....com>
Link: https://lore.kernel.org/r/20230307192449.24732-8-bp@alien8.de
---
arch/x86/kernel/sev.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c
index 6a3e142..d67884f 100644
--- a/arch/x86/kernel/sev.c
+++ b/arch/x86/kernel/sev.c
@@ -2210,15 +2210,21 @@ int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned
goto e_put;
*fw_err = ghcb->save.sw_exit_info_2;
- if (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;
+ default:
+ ret = -EIO;
+ break;
}
e_put:
Powered by blists - more mailing lists