All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: cgel.zte@gmail.com
Cc: pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
	hpa@zytor.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	ye xingchen <ye.xingchen@zte.com.cn>
Subject: Re: [PATCH linux-next v2] KVM: SVM: Remove the unneeded result variable
Date: Mon, 22 Aug 2022 16:00:42 +0000	[thread overview]
Message-ID: <YwOoKk5PLnEDGI2A@google.com> (raw)
In-Reply-To: <20220822013720.199757-1-ye.xingchen@zte.com.cn>

On Mon, Aug 22, 2022, cgel.zte@gmail.com wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Return the value from sev_guest_activate(&activate, error) and
> sev_issue_cmd_external_user(f.file, id, data, error) directly
> instead of storing it in another redundant variable.And also change
> the position of handle and asid to simplify the code.
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---
> v1 -> v2
> Suggested-by: SeanChristopherson <seanjc@google.com>
> 
> Change the position of handle and asid.
> Change the explain about this patch.
> Dropping the comment about asid + handle.
>  arch/x86/kvm/svm/sev.c | 19 ++++++-------------
>  1 file changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 28064060413a..4448f2e512b9 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -276,31 +276,24 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
>  
>  static int sev_bind_asid(struct kvm *kvm, unsigned int handle, int *error)
>  {
> -	struct sev_data_activate activate;
> -	int asid = sev_get_asid(kvm);
> -	int ret;
> -
> -	/* activate ASID on the given handle */
> -	activate.handle = handle;
> -	activate.asid   = asid;
> -	ret = sev_guest_activate(&activate, error);
> +	struct sev_data_activate activate = {
> +		.handle = handle,
> +		.asid = sev_get_asid(kvm),
> +	};
>  
> -	return ret;
> +	return sev_guest_activate(&activate, error);
>  }
>  
>  static int __sev_issue_cmd(int fd, int id, void *data, int *error)
>  {
>  	struct fd f;
> -	int ret;
>  
>  	f = fdget(fd);
>  	if (!f.file)
>  		return -EBADF;
>  
> -	ret = sev_issue_cmd_external_user(f.file, id, data, error);
> -
>  	fdput(f);
> -	return ret;
> +	return sev_issue_cmd_external_user(f.file, id, data, error);

Again, this is broken, the fdput() needs to stay after f.file is consumed, i.e.
eliminating "ret" is wrong.

>  }
>  
>  static int sev_issue_cmd(struct kvm *kvm, int id, void *data, int *error)
> -- 
> 2.25.1

      reply	other threads:[~2022-08-22 16:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-22  1:37 [PATCH linux-next v2] KVM: SVM: Remove the unneeded result variable cgel.zte
2022-08-22 16:00 ` Sean Christopherson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YwOoKk5PLnEDGI2A@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=cgel.zte@gmail.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=ye.xingchen@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.