linux-mips
[Top] [All Lists]

Re: [PATCH v3 07/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_

To: David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH v3 07/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_sregs
From: Christoffer Dall <christoffer.dall@linaro.org>
Date: Mon, 11 Dec 2017 10:19:21 +0100
Cc: Christoffer Dall <cdall@kernel.org>, kvm@vger.kernel.org, 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, Paul Mackerras <paulus@ozlabs.org>, kvm-ppc@vger.kernel.org, Christian Borntraeger <borntraeger@de.ibm.com>, Cornelia Huck <cohuck@redhat.com>, linux-s390@vger.kernel.org
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xG75J/MCYrAAx2rG6EGc/KJJFMK36f+JruBbyYOYwBQ=; b=LWou24NiMgcviOV+gj1ajhFZsVzdd2q1MDO1FPb4MFGBNn7Vl8X3dEuDUSxgwIVN9y 0Zi/yLcOcTfTrdju0D+xIUgrIjPlU1qnKlubIbHBc5gSK2FtWu4tMru4xn4/Ye9HSss/ fh4771DcYF6XfDcW+Vr2Gn3Q5BtzEjmcDGREs=
In-reply-to: <0faf23f5-3540-47ac-19a9-0f44b2c782a0@redhat.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20171204203538.8370-1-cdall@kernel.org> <20171204203538.8370-8-cdall@kernel.org> <0faf23f5-3540-47ac-19a9-0f44b2c782a0@redhat.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.5.21 (2010-09-15)
On Fri, Dec 08, 2017 at 05:26:02PM +0100, David Hildenbrand wrote:
> 
> >  
> >  int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs 
> > *regs)
> > diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> > index f647e121070e..cdf0be02c95a 100644
> > --- a/arch/powerpc/kvm/booke.c
> > +++ b/arch/powerpc/kvm/booke.c
> > @@ -1632,18 +1632,25 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu 
> > *vcpu,
> >  {
> >     int ret;
> >  
> > +   vcpu_load(vcpu);
> > +
> > +   ret = -EINVAL;
> 
> you can initialize this directly.
> 
> >     if (vcpu->arch.pvr != sregs->pvr)
> > -           return -EINVAL;
> > +           goto out;
> >  
> >     ret = set_sregs_base(vcpu, sregs);
> >     if (ret < 0)
> > -           return ret;
> > +           goto out;
> >  
> >     ret = set_sregs_arch206(vcpu, sregs);
> >     if (ret < 0)
> > -           return ret;
> > +           goto out;
> > +
> > +   ret = vcpu->kvm->arch.kvm_ops->set_sregs(vcpu, sregs);
> >  
> > -   return vcpu->kvm->arch.kvm_ops->set_sregs(vcpu, sregs);
> > +out:
> > +   vcpu_put(vcpu);
> > +   return ret;
> >  }
> >  
> >  int kvmppc_get_one_reg(struct kvm_vcpu *vcpu, u64 id,
> > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> > index 18011fc4ac49..d95b4f15e52b 100644
> > --- a/arch/s390/kvm/kvm-s390.c
> > +++ b/arch/s390/kvm/kvm-s390.c
> > @@ -2729,8 +2729,12 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu 
> > *vcpu, struct kvm_regs *regs)
> >  int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
> >                               struct kvm_sregs *sregs)
> >  {
> > +   vcpu_load(vcpu);
> > +
> >     memcpy(&vcpu->run->s.regs.acrs, &sregs->acrs, sizeof(sregs->acrs));
> >     memcpy(&vcpu->arch.sie_block->gcr, &sregs->crs, sizeof(sregs->crs));
> > +
> > +   vcpu_put(vcpu);
> >     return 0;
> >  }
> >  
> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> > index 20a5f6776eea..a31a80aee0b9 100644
> > --- a/arch/x86/kvm/x86.c
> > +++ b/arch/x86/kvm/x86.c
> > @@ -7500,15 +7500,19 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu 
> > *vcpu,
> >     int mmu_reset_needed = 0;
> >     int pending_vec, max_bits, idx;
> >     struct desc_ptr dt;
> > +   int ret;
> > +
> > +   vcpu_load(vcpu);
> >  
> > +   ret = -EINVAL;
> 
> dito

Sure.

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

Thanks for the review!
-Christoffer

<Prev in Thread] Current Thread [Next in Thread>