Skip to contentSkip to conversation

KVM: SEV: Fix uninitialized firmware error code

PATCH In review Michael Roth 2 participants 2 messages May 13, 2024 – May 15, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: SEV: Fix uninitialized firmware error code

The current code triggers a clang warning due to passing back an uninitialized firmware return code in cases where an attestation request is aborted before getting sent to userspace. Since firmware has not been involved at this point the appropriate value is 0.

Fixes 32fde9e18b3f ("KVM: SEV: Provide support for SNP_EXTENDED_GUEST_REQUEST NAE event")
---
 arch/x86/kvm/svm/sev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/svm/sev.c +1 -2
index 57c2c8025547..59c0d89a4d52 100644
@@ -4048,7 +4048,6 @@ static int snp_begin_ext_guest_req(struct kvm_vcpu *vcpu)
 	int vmm_ret = SNP_GUEST_VMM_ERR_GENERIC;
 	struct vcpu_svm *svm = to_svm(vcpu);
 	unsigned long data_npages;
-	sev_ret_code fw_err;
 	gpa_t data_gpa;
 
 	if (!sev_snp_guest(vcpu->kvm))
@@ -4075,7 +4074,7 @@ static int snp_begin_ext_guest_req(struct kvm_vcpu *vcpu)
 	return 0; /* forward request to userspace */
 
 abort_request:
-	ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, SNP_GUEST_ERR(vmm_ret, fw_err));
+	ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, SNP_GUEST_ERR(vmm_ret, 0));
 	return 1; /* resume guest */
 }
 
Signature · 1 line
2.25.1
Tested-by on v1 1/1
#1 lore raw
Quoted 9 lines · Michael Roth

The current code triggers a clang warning due to passing back an uninitialized firmware return code in cases where an attestation request is aborted before getting sent to userspace. Since firmware has not been involved at this point the appropriate value is 0.

Fixes 32fde9e18b3f ("KVM: SEV: Provide support for SNP_EXTENDED_GUEST_REQUEST NAE event")

This obviously resolves the warning:

Quoted 28 lines
---
 arch/x86/kvm/svm/sev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/svm/sev.c +1 -2
index 57c2c8025547..59c0d89a4d52 100644
@@ -4048,7 +4048,6 @@ static int snp_begin_ext_guest_req(struct kvm_vcpu *vcpu)
 	int vmm_ret = SNP_GUEST_VMM_ERR_GENERIC;
 	struct vcpu_svm *svm = to_svm(vcpu);
 	unsigned long data_npages;
-	sev_ret_code fw_err;
 	gpa_t data_gpa;
 
 	if (!sev_snp_guest(vcpu->kvm))
@@ -4075,7 +4074,7 @@ static int snp_begin_ext_guest_req(struct kvm_vcpu *vcpu)
 	return 0; /* forward request to userspace */
 
 abort_request:
-	ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, SNP_GUEST_ERR(vmm_ret, fw_err));
+	ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, SNP_GUEST_ERR(vmm_ret, 0));
 	return 1; /* resume guest */
 }
 
Signature · 1 line
2.25.1