diff mbox series

[v2,29/30] KVM: PPC: add KVM_SET_ONE_REG/KVM_GET_ONE_REG to async ioctl

Message ID 1519753958-11756-19-git-send-email-wei.guo.simon@gmail.com
State Changes Requested
Headers show
Series None | expand

Commit Message

Simon Guo Feb. 27, 2018, 5:52 p.m. UTC
From: Simon Guo <wei.guo.simon@gmail.com>

In both HV/PR KVM, the KVM_SET_ONE_REG/KVM_GET_ONE_REG ioctl should
be able to perform without load vcpu. This patch adds
KVM_SET_ONE_REG/KVM_GET_ONE_REG implementation to async ioctl
function.

Signed-off-by: Simon Guo <wei.guo.simon@gmail.com>
---
 arch/powerpc/kvm/powerpc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Paul Mackerras May 15, 2018, 6:15 a.m. UTC | #1
On Wed, Feb 28, 2018 at 01:52:37AM +0800, wei.guo.simon@gmail.com wrote:
> From: Simon Guo <wei.guo.simon@gmail.com>
> 
> In both HV/PR KVM, the KVM_SET_ONE_REG/KVM_GET_ONE_REG ioctl should
> be able to perform without load vcpu. This patch adds
> KVM_SET_ONE_REG/KVM_GET_ONE_REG implementation to async ioctl
> function.
> 
> Signed-off-by: Simon Guo <wei.guo.simon@gmail.com>
> ---
>  arch/powerpc/kvm/powerpc.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 7987fa3..6afd004 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -1619,6 +1619,19 @@ long kvm_arch_vcpu_async_ioctl(struct file *filp,
>  			return -EFAULT;
>  		return kvm_vcpu_ioctl_interrupt(vcpu, &irq);
>  	}
> +
> +	if ((ioctl == KVM_SET_ONE_REG) || (ioctl == KVM_GET_ONE_REG)) {
> +		struct kvm_one_reg reg;
> +
> +		if (copy_from_user(&reg, argp, sizeof(reg)))
> +			return -EFAULT;
> +
> +		if (ioctl == KVM_SET_ONE_REG)
> +			return kvm_vcpu_ioctl_set_one_reg(vcpu, &reg);
> +		else
> +			return kvm_vcpu_ioctl_get_one_reg(vcpu, &reg);
> +	}
> +
>  	return -ENOIOCTLCMD;
>  }

This seems dangerous to me, since now we can have set/get one_reg
running in parallel with vcpu execution.  Is there a really compelling
reason to do this?  If not I'd rather not make this change.

Paul.
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Simon Guo May 16, 2018, 2:13 a.m. UTC | #2
Hi Paul,
On Tue, May 15, 2018 at 04:15:26PM +1000, Paul Mackerras wrote:
> On Wed, Feb 28, 2018 at 01:52:37AM +0800, wei.guo.simon@gmail.com wrote:
> > From: Simon Guo <wei.guo.simon@gmail.com>
> > 
> > In both HV/PR KVM, the KVM_SET_ONE_REG/KVM_GET_ONE_REG ioctl should
> > be able to perform without load vcpu. This patch adds
> > KVM_SET_ONE_REG/KVM_GET_ONE_REG implementation to async ioctl
> > function.
> > 
> > Signed-off-by: Simon Guo <wei.guo.simon@gmail.com>
> > ---
> >  arch/powerpc/kvm/powerpc.c | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> > 
> > diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> > index 7987fa3..6afd004 100644
> > --- a/arch/powerpc/kvm/powerpc.c
> > +++ b/arch/powerpc/kvm/powerpc.c
> > @@ -1619,6 +1619,19 @@ long kvm_arch_vcpu_async_ioctl(struct file *filp,
> >  			return -EFAULT;
> >  		return kvm_vcpu_ioctl_interrupt(vcpu, &irq);
> >  	}
> > +
> > +	if ((ioctl == KVM_SET_ONE_REG) || (ioctl == KVM_GET_ONE_REG)) {
> > +		struct kvm_one_reg reg;
> > +
> > +		if (copy_from_user(&reg, argp, sizeof(reg)))
> > +			return -EFAULT;
> > +
> > +		if (ioctl == KVM_SET_ONE_REG)
> > +			return kvm_vcpu_ioctl_set_one_reg(vcpu, &reg);
> > +		else
> > +			return kvm_vcpu_ioctl_get_one_reg(vcpu, &reg);
> > +	}
> > +
> >  	return -ENOIOCTLCMD;
> >  }
> 
> This seems dangerous to me, since now we can have set/get one_reg
> running in parallel with vcpu execution.  Is there a really compelling
> reason to do this?  If not I'd rather not make this change.

I will remove this patch.
Thanks,
- Simon
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 7987fa3..6afd004 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -1619,6 +1619,19 @@  long kvm_arch_vcpu_async_ioctl(struct file *filp,
 			return -EFAULT;
 		return kvm_vcpu_ioctl_interrupt(vcpu, &irq);
 	}
+
+	if ((ioctl == KVM_SET_ONE_REG) || (ioctl == KVM_GET_ONE_REG)) {
+		struct kvm_one_reg reg;
+
+		if (copy_from_user(&reg, argp, sizeof(reg)))
+			return -EFAULT;
+
+		if (ioctl == KVM_SET_ONE_REG)
+			return kvm_vcpu_ioctl_set_one_reg(vcpu, &reg);
+		else
+			return kvm_vcpu_ioctl_get_one_reg(vcpu, &reg);
+	}
+
 	return -ENOIOCTLCMD;
 }