lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5e47b83b-999a-445d-a296-9157ffd3a9ac@amd.com>
Date: Tue, 30 Dec 2025 15:20:28 +0100
From: "Gupta, Pankaj" <pankaj.gupta@....com>
To: Carlos López <clopez@...e.de>, kvm@...r.kernel.org,
 seanjc@...gle.com, pbonzini@...hat.com
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
 dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH 5/6] KVM: SEV: use mutex guard in snp_handle_guest_req()


On 12/19/2025 12:42 PM, Carlos López wrote:
> Simplify the error paths in snp_handle_guest_req() by using a mutex
> guard, allowing early return instead of using gotos.
>
> Signed-off-by: Carlos López <clopez@...e.de>

Reviewed-by: Pankaj Gupta <pankaj.gupta@....com>

> ---
>   arch/x86/kvm/svm/sev.c | 23 ++++++++---------------
>   1 file changed, 8 insertions(+), 15 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 47ff5267ab01..5f46b7f073b0 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -4090,12 +4090,10 @@ static int snp_handle_guest_req(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t resp_
>   	if (!sev_snp_guest(kvm))
>   		return -EINVAL;
>   
> -	mutex_lock(&sev->guest_req_mutex);
> +	guard(mutex)(&sev->guest_req_mutex);
>   
> -	if (kvm_read_guest(kvm, req_gpa, sev->guest_req_buf, PAGE_SIZE)) {
> -		ret = -EIO;
> -		goto out_unlock;
> -	}
> +	if (kvm_read_guest(kvm, req_gpa, sev->guest_req_buf, PAGE_SIZE))
> +		return -EIO;
>   
>   	data.gctx_paddr = __psp_pa(sev->snp_context);
>   	data.req_paddr = __psp_pa(sev->guest_req_buf);
> @@ -4108,21 +4106,16 @@ static int snp_handle_guest_req(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t resp_
>   	 */
>   	ret = sev_issue_cmd(kvm, SEV_CMD_SNP_GUEST_REQUEST, &data, &fw_err);
>   	if (ret && !fw_err)
> -		goto out_unlock;
> +		return ret;
>   
> -	if (kvm_write_guest(kvm, resp_gpa, sev->guest_resp_buf, PAGE_SIZE)) {
> -		ret = -EIO;
> -		goto out_unlock;
> -	}
> +	if (kvm_write_guest(kvm, resp_gpa, sev->guest_resp_buf, PAGE_SIZE))
> +		return -EIO;
>   
>   	/* No action is requested *from KVM* if there was a firmware error. */
>   	svm_vmgexit_no_action(svm, SNP_GUEST_ERR(0, fw_err));
>   
> -	ret = 1; /* resume guest */
> -
> -out_unlock:
> -	mutex_unlock(&sev->guest_req_mutex);
> -	return ret;
> +	/* resume guest */
> +	return 1;
>   }
>   
>   static int snp_handle_ext_guest_req(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t resp_gpa)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ