Linux s390 Architecture development
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Christoffer Dall <christoffer.dall@linaro.org>, kvm@vger.kernel.org
Cc: "Andrew Jones" <drjones@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"Marc Zyngier" <marc.zyngier@arm.com>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org,
	"James Hogan" <jhogan@kernel.org>,
	linux-mips@linux-mips.org, "Alexander Graf" <agraf@suse.com>,
	kvm-ppc@vger.kernel.org,
	"Christian Borntraeger" <borntraeger@de.ibm.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	linux-s390@vger.kernel.org
Subject: Re: [PATCH v2 13/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_fpu
Date: Wed, 29 Nov 2017 18:37:40 +0100	[thread overview]
Message-ID: <f3e93346-7d6c-1f3f-1ec7-0823d46a83b7@redhat.com> (raw)
In-Reply-To: <20171129164116.16167-14-christoffer.dall@linaro.org>

On 29.11.2017 17:41, Christoffer Dall wrote:
> Move vcpu_load() and vcpu_put() into the architecture specific
> implementations of kvm_arch_vcpu_ioctl_set_fpu().
> 
> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> ---
>  arch/s390/kvm/kvm-s390.c | 15 ++++++++++++---
>  arch/x86/kvm/x86.c       |  8 ++++++--
>  virt/kvm/kvm_main.c      |  2 --
>  3 files changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 88dcb89..43278f3 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -2752,15 +2752,24 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
>  
>  int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
>  {
> -	if (test_fp_ctl(fpu->fpc))
> -		return -EINVAL;
> +	int ret = 0;
> +
> +	vcpu_load(vcpu);
> +
> +	if (test_fp_ctl(fpu->fpc)) {
> +		ret = -EINVAL;
> +		goto out;
> +	}
>  	vcpu->run->s.regs.fpc = fpu->fpc;
>  	if (MACHINE_HAS_VX)
>  		convert_fp_to_vx((__vector128 *) vcpu->run->s.regs.vrs,
>  				 (freg_t *) fpu->fprs);
>  	else
>  		memcpy(vcpu->run->s.regs.fprs, &fpu->fprs, sizeof(fpu->fprs));
> -	return 0;
> +
> +out:
> +	vcpu_put(vcpu);
> +	return ret;
>  }
>  
>  int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 8b54567..fd8b92f 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -7699,8 +7699,11 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
>  
>  int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
>  {
> -	struct fxregs_state *fxsave =
> -			&vcpu->arch.guest_fpu.state.fxsave;
> +	struct fxregs_state *fxsave;
> +
> +	vcpu_load(vcpu);
> +
> +	fxsave = &vcpu->arch.guest_fpu.state.fxsave;
>  
>  	memcpy(fxsave->st_space, fpu->fpr, 128);
>  	fxsave->cwd = fpu->fcw;
> @@ -7711,6 +7714,7 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
>  	fxsave->rdp = fpu->last_dp;
>  	memcpy(fxsave->xmm_space, fpu->xmm, sizeof fxsave->xmm_space);
>  
> +	vcpu_put(vcpu);
>  	return 0;
>  }
>  
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 73ad70a..06751bb 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2689,9 +2689,7 @@ static long kvm_vcpu_ioctl(struct file *filp,
>  			fpu = NULL;
>  			goto out;
>  		}
> -		vcpu_load(vcpu);
>  		r = kvm_arch_vcpu_ioctl_set_fpu(vcpu, fpu);
> -		vcpu_put(vcpu);
>  		break;
>  	}
>  	default:
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 

Thanks,

David / dhildenb

  reply	other threads:[~2017-11-29 17:37 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-29 16:41 [PATCH v2 00/16] Move vcpu_load and vcpu_put calls to arch code Christoffer Dall
2017-11-29 16:41 ` [PATCH v2 01/16] KVM: Take vcpu->mutex outside vcpu_load Christoffer Dall
2017-11-29 17:17   ` David Hildenbrand
2017-11-29 17:20     ` Paolo Bonzini
2017-11-29 17:22       ` David Hildenbrand
2017-11-29 17:35         ` Christoffer Dall
2017-11-29 16:41 ` [PATCH v2 02/16] KVM: Prepare for moving vcpu_load/vcpu_put into arch specific code Christoffer Dall
2017-11-29 17:25   ` David Hildenbrand
2017-11-29 16:41 ` [PATCH v2 03/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_run Christoffer Dall
2017-11-29 16:41 ` [PATCH v2 04/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_regs Christoffer Dall
2017-11-29 16:41 ` [PATCH v2 05/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_regs Christoffer Dall
2017-11-29 16:41 ` [PATCH v2 06/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_sregs Christoffer Dall
2017-11-29 16:41 ` [PATCH v2 07/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_sregs Christoffer Dall
2017-11-29 16:41 ` [PATCH v2 08/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_mpstate Christoffer Dall
2017-11-29 17:47   ` David Hildenbrand
2017-11-29 16:41 ` [PATCH v2 09/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_mpstate Christoffer Dall
2017-11-29 17:46   ` David Hildenbrand
2017-11-29 16:41 ` [PATCH v2 10/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_translate Christoffer Dall
2017-11-29 17:44   ` David Hildenbrand
2017-11-29 16:41 ` [PATCH v2 11/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_guest_debug Christoffer Dall
2017-11-29 17:43   ` David Hildenbrand
2017-11-29 16:41 ` [PATCH v2 12/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_fpu Christoffer Dall
2017-11-29 17:40   ` David Hildenbrand
2017-11-29 16:41 ` [PATCH v2 13/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_fpu Christoffer Dall
2017-11-29 17:37   ` David Hildenbrand [this message]
2017-11-29 16:41 ` [PATCH v2 14/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl Christoffer Dall
2017-11-29 16:41 ` [PATCH v2 15/16] KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN Christoffer Dall
2017-11-29 17:30   ` David Hildenbrand
2017-11-29 17:34     ` Christoffer Dall
2017-11-29 16:41 ` [PATCH v2 16/16] KVM: arm/arm64: Move vcpu_load call after kvm_vcpu_first_run_init Christoffer Dall

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=f3e93346-7d6c-1f3f-1ec7-0823d46a83b7@redhat.com \
    --to=david@redhat.com \
    --cc=agraf@suse.com \
    --cc=borntraeger@de.ibm.com \
    --cc=christoffer.dall@linaro.org \
    --cc=cohuck@redhat.com \
    --cc=drjones@redhat.com \
    --cc=jhogan@kernel.org \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox