summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorBorislav Petkov (AMD) <bp@alien8.de>2023-02-15 13:39:41 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-22 15:34:05 +0300
commit9579ca57104b055e248d0a00180a0d0889213b71 (patch)
tree73d15fc59bc7ac8a6a5988e2a800a2c6c0d25218 /arch
parent12319ef1cfc7786864107f09f899c0daaac054e3 (diff)
downloadlinux-9579ca57104b055e248d0a00180a0d0889213b71.tar.xz
virt/coco/sev-guest: Simplify extended guest request handling
commit 970ab823743fb54b42002ec76c51481f67436444 upstream. Return a specific error code - -ENOSPC - to signal the too small cert data buffer instead of checking exit code and exitinfo2. While at it, hoist the *fw_err assignment in snp_issue_guest_request() so that a proper error value is returned to the callers. [ Tom: check override_err instead of err. ] Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20230307192449.24732-4-bp@alien8.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/sev.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c
index 2e739b0b7533..5dc9c53a5d6f 100644
--- a/arch/x86/kernel/sev.c
+++ b/arch/x86/kernel/sev.c
@@ -2209,15 +2209,16 @@ int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned
if (ret)
goto e_put;
+ *fw_err = ghcb->save.sw_exit_info_2;
if (ghcb->save.sw_exit_info_2) {
/* 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)
+ ghcb->save.sw_exit_info_2 == SNP_GUEST_REQ_INVALID_LEN) {
input->data_npages = ghcb_get_rbx(ghcb);
-
- *fw_err = ghcb->save.sw_exit_info_2;
-
- ret = -EIO;
+ ret = -ENOSPC;
+ } else {
+ ret = -EIO;
+ }
}
e_put: