Commit fa4ae42c authored by Borislav Petkov (AMD)'s avatar Borislav Petkov (AMD)

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: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20230307192449.24732-8-bp@alien8.de
parent d25bae7d
...@@ -2210,15 +2210,21 @@ int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned ...@@ -2210,15 +2210,21 @@ int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned
goto e_put; goto e_put;
*fw_err = ghcb->save.sw_exit_info_2; *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 */ /* Number of expected pages are returned in RBX */
if (exit_code == SVM_VMGEXIT_EXT_GUEST_REQUEST && if (exit_code == SVM_VMGEXIT_EXT_GUEST_REQUEST) {
ghcb->save.sw_exit_info_2 == SNP_GUEST_REQ_INVALID_LEN) {
input->data_npages = ghcb_get_rbx(ghcb); input->data_npages = ghcb_get_rbx(ghcb);
ret = -ENOSPC; ret = -ENOSPC;
} else { break;
ret = -EIO;
} }
fallthrough;
default:
ret = -EIO;
break;
} }
e_put: e_put:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment