All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoffer Dall <cdall@linaro.org>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: 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, "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 14/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl
Date: Sun, 26 Nov 2017 09:09:43 +0000	[thread overview]
Message-ID: <20171126090943.GH28855@cbox> (raw)
In-Reply-To: <20171125205718.7731-15-christoffer.dall@linaro.org>

Hi,

[replying to myself]

On Sat, Nov 25, 2017 at 09:57:17PM +0100, Christoffer Dall wrote:
> Move the calls to vcpu_load() and vcpu_put() in to the architecture
> specific implementations of kvm_arch_vcpu_ioctl() which dispatches
> further architecture-specific ioctls on to other functions.
> 
> Some architectures support asynchronous vcpu ioctls which cannot call
> vcpu_load() or take the vcpu->mutex, because that would prevent
> concurrent execution with a running VCPU, which is the intended purpose
> of these ioctls, for example because they inject interrupts.
> 
> We move the checks for these specifics into the architecture code for
> MIPS, S390 and PPC, and it has the added benefit of getting rid of the
> ifdef in the generic dispatcher.
> 
> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> ---
>  arch/mips/kvm/mips.c       | 51 +++++++++++++++++++++++----------------
>  arch/powerpc/kvm/powerpc.c | 15 +++++++-----
>  arch/s390/kvm/kvm-s390.c   | 21 +++++++++-------
>  arch/x86/kvm/x86.c         | 24 ++++++++++++++-----
>  virt/kvm/arm/arm.c         | 60 ++++++++++++++++++++++++++++++++--------------
>  virt/kvm/kvm_main.c        | 15 +-----------
>  6 files changed, 114 insertions(+), 72 deletions(-)
> 

[...]

> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 66e5c2445a87..027a6259c3c4 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -1621,16 +1621,18 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
>  	void __user *argp = (void __user *)arg;
>  	long r;
>  
> -	switch (ioctl) {
> -	case KVM_INTERRUPT: {
> +	if (ioctl = KVM_INTERRUPT) {
>  		struct kvm_interrupt irq;
> -		r = -EFAULT;
>  		if (copy_from_user(&irq, argp, sizeof(irq)))
> -			goto out;
> -		r = kvm_vcpu_ioctl_interrupt(vcpu, &irq);
> -		goto out;
> +			return -EFAULT;
> +		return kvm_vcpu_ioctl_interrupt(vcpu, &irq);
>  	}
>  
> +	r = vcpu_load(vcpu);
> +	if (r)
> +		return r;
> +
> +	switch (ioctl) {
>  	case KVM_ENABLE_CAP:
>  	{
>  		struct kvm_enable_cap cap;
> @@ -1670,6 +1672,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
>  	}
>  
>  out:
> +	vcpu_put(r);
>  	return r;

This should obviously be
	vcpu_put(vcpu);

Fixed for v2.

Thanks,
-Christoffer

WARNING: multiple messages have this Message-ID (diff)
From: Christoffer Dall <cdall@linaro.org>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: 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, "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 14/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl
Date: Sun, 26 Nov 2017 10:09:43 +0100	[thread overview]
Message-ID: <20171126090943.GH28855@cbox> (raw)
In-Reply-To: <20171125205718.7731-15-christoffer.dall@linaro.org>

Hi,

[replying to myself]

On Sat, Nov 25, 2017 at 09:57:17PM +0100, Christoffer Dall wrote:
> Move the calls to vcpu_load() and vcpu_put() in to the architecture
> specific implementations of kvm_arch_vcpu_ioctl() which dispatches
> further architecture-specific ioctls on to other functions.
> 
> Some architectures support asynchronous vcpu ioctls which cannot call
> vcpu_load() or take the vcpu->mutex, because that would prevent
> concurrent execution with a running VCPU, which is the intended purpose
> of these ioctls, for example because they inject interrupts.
> 
> We move the checks for these specifics into the architecture code for
> MIPS, S390 and PPC, and it has the added benefit of getting rid of the
> ifdef in the generic dispatcher.
> 
> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> ---
>  arch/mips/kvm/mips.c       | 51 +++++++++++++++++++++++----------------
>  arch/powerpc/kvm/powerpc.c | 15 +++++++-----
>  arch/s390/kvm/kvm-s390.c   | 21 +++++++++-------
>  arch/x86/kvm/x86.c         | 24 ++++++++++++++-----
>  virt/kvm/arm/arm.c         | 60 ++++++++++++++++++++++++++++++++--------------
>  virt/kvm/kvm_main.c        | 15 +-----------
>  6 files changed, 114 insertions(+), 72 deletions(-)
> 

[...]

> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 66e5c2445a87..027a6259c3c4 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -1621,16 +1621,18 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
>  	void __user *argp = (void __user *)arg;
>  	long r;
>  
> -	switch (ioctl) {
> -	case KVM_INTERRUPT: {
> +	if (ioctl == KVM_INTERRUPT) {
>  		struct kvm_interrupt irq;
> -		r = -EFAULT;
>  		if (copy_from_user(&irq, argp, sizeof(irq)))
> -			goto out;
> -		r = kvm_vcpu_ioctl_interrupt(vcpu, &irq);
> -		goto out;
> +			return -EFAULT;
> +		return kvm_vcpu_ioctl_interrupt(vcpu, &irq);
>  	}
>  
> +	r = vcpu_load(vcpu);
> +	if (r)
> +		return r;
> +
> +	switch (ioctl) {
>  	case KVM_ENABLE_CAP:
>  	{
>  		struct kvm_enable_cap cap;
> @@ -1670,6 +1672,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
>  	}
>  
>  out:
> +	vcpu_put(r);
>  	return r;

This should obviously be
	vcpu_put(vcpu);

Fixed for v2.

Thanks,
-Christoffer

WARNING: multiple messages have this Message-ID (diff)
From: cdall@linaro.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 14/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl
Date: Sun, 26 Nov 2017 10:09:43 +0100	[thread overview]
Message-ID: <20171126090943.GH28855@cbox> (raw)
In-Reply-To: <20171125205718.7731-15-christoffer.dall@linaro.org>

Hi,

[replying to myself]

On Sat, Nov 25, 2017 at 09:57:17PM +0100, Christoffer Dall wrote:
> Move the calls to vcpu_load() and vcpu_put() in to the architecture
> specific implementations of kvm_arch_vcpu_ioctl() which dispatches
> further architecture-specific ioctls on to other functions.
> 
> Some architectures support asynchronous vcpu ioctls which cannot call
> vcpu_load() or take the vcpu->mutex, because that would prevent
> concurrent execution with a running VCPU, which is the intended purpose
> of these ioctls, for example because they inject interrupts.
> 
> We move the checks for these specifics into the architecture code for
> MIPS, S390 and PPC, and it has the added benefit of getting rid of the
> ifdef in the generic dispatcher.
> 
> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> ---
>  arch/mips/kvm/mips.c       | 51 +++++++++++++++++++++++----------------
>  arch/powerpc/kvm/powerpc.c | 15 +++++++-----
>  arch/s390/kvm/kvm-s390.c   | 21 +++++++++-------
>  arch/x86/kvm/x86.c         | 24 ++++++++++++++-----
>  virt/kvm/arm/arm.c         | 60 ++++++++++++++++++++++++++++++++--------------
>  virt/kvm/kvm_main.c        | 15 +-----------
>  6 files changed, 114 insertions(+), 72 deletions(-)
> 

[...]

> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 66e5c2445a87..027a6259c3c4 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -1621,16 +1621,18 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
>  	void __user *argp = (void __user *)arg;
>  	long r;
>  
> -	switch (ioctl) {
> -	case KVM_INTERRUPT: {
> +	if (ioctl == KVM_INTERRUPT) {
>  		struct kvm_interrupt irq;
> -		r = -EFAULT;
>  		if (copy_from_user(&irq, argp, sizeof(irq)))
> -			goto out;
> -		r = kvm_vcpu_ioctl_interrupt(vcpu, &irq);
> -		goto out;
> +			return -EFAULT;
> +		return kvm_vcpu_ioctl_interrupt(vcpu, &irq);
>  	}
>  
> +	r = vcpu_load(vcpu);
> +	if (r)
> +		return r;
> +
> +	switch (ioctl) {
>  	case KVM_ENABLE_CAP:
>  	{
>  		struct kvm_enable_cap cap;
> @@ -1670,6 +1672,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
>  	}
>  
>  out:
> +	vcpu_put(r);
>  	return r;

This should obviously be
	vcpu_put(vcpu);

Fixed for v2.

Thanks,
-Christoffer

  reply	other threads:[~2017-11-26  9:09 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-25 20:57 [PATCH 00/15] Move vcpu_load and vcpu_put calls to arch code Christoffer Dall
2017-11-25 20:57 ` Christoffer Dall
2017-11-25 20:57 ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 01/15] KVM: Prepare for moving vcpu_load/vcpu_put into arch specific code Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-27 16:53   ` Paolo Bonzini
2017-11-27 16:53     ` Paolo Bonzini
2017-11-27 16:53     ` Paolo Bonzini
2017-11-27 19:58     ` Christoffer Dall
2017-11-27 19:58       ` Christoffer Dall
2017-11-27 19:58       ` Christoffer Dall
2017-11-27 20:55       ` Paolo Bonzini
2017-11-27 20:55         ` Paolo Bonzini
2017-11-27 20:55         ` Paolo Bonzini
2017-11-25 20:57 ` [PATCH 02/15] KVM: Factor out vcpu->pid adjustment for KVM_RUN Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 03/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_run Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 04/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_regs Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 05/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_regs Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 06/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_sregs Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 07/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_sregs Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 08/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_mpstate Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 09/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_mpstate Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 10/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_translate Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 11/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_guest_debug Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-27 19:28   ` Christoffer Dall
2017-11-27 19:28     ` Christoffer Dall
2017-11-27 19:28     ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 12/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_fpu Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 13/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_fpu Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 14/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-26  9:09   ` Christoffer Dall [this message]
2017-11-26  9:09     ` Christoffer Dall
2017-11-26  9:09     ` Christoffer Dall
2017-11-25 20:57 ` [PATCH 15/15] KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-25 20:57   ` Christoffer Dall
2017-11-26  9:11 ` [PATCH 00/15] Move vcpu_load and vcpu_put calls to arch code Christoffer Dall
2017-11-26  9:11   ` Christoffer Dall
2017-11-26  9:11   ` Christoffer Dall
2017-11-26  9:11   ` Christoffer Dall
2017-11-28 20:55 ` David Hildenbrand
2017-11-28 20:55   ` David Hildenbrand
2017-11-28 20:55   ` David Hildenbrand
2017-11-28 21:29   ` Paolo Bonzini
2017-11-28 21:29     ` Paolo Bonzini
2017-11-28 21:29     ` Paolo Bonzini

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=20171126090943.GH28855@cbox \
    --to=cdall@linaro.org \
    --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 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.