All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoffer Dall <cdall@linaro.org>
To: Marc Zyngier <marc.zyngier@arm.com>
Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH] KVM: arm/arm64: Fix spinlock acquisition in vgic_set_owner
Date: Fri, 1 Dec 2017 08:55:07 +0100	[thread overview]
Message-ID: <20171201075507.GA4218@cbox> (raw)
In-Reply-To: <20171130170030.29827-1-marc.zyngier@arm.com>

On Thu, Nov 30, 2017 at 05:00:30PM +0000, Marc Zyngier wrote:
> vgic_set_owner acquires the irq lock without disabling interrupts,
> resulting in a lockdep splat (an interrupt could fire and result
> in the same lock being taken if the same virtual irq is to be
> injected).
> 
> In practice, it is almost impossible to trigger this bug, but
> better safe than sorry. Convert the lock acquisition to a
> spin_lock_irqsave() and keep lockdep happy.
> 
> Reported-by: James Morse <james.morse@arm.com>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>

Applied, thanks.
-Christoffer

> ---
>  virt/kvm/arm/vgic/vgic.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c
> index b168a328a9e0..8d863e6405a5 100644
> --- a/virt/kvm/arm/vgic/vgic.c
> +++ b/virt/kvm/arm/vgic/vgic.c
> @@ -492,6 +492,7 @@ int kvm_vgic_unmap_phys_irq(struct kvm_vcpu *vcpu, unsigned int vintid)
>  int kvm_vgic_set_owner(struct kvm_vcpu *vcpu, unsigned int intid, void *owner)
>  {
>  	struct vgic_irq *irq;
> +	unsigned long flags;
>  	int ret = 0;
>  
>  	if (!vgic_initialized(vcpu->kvm))
> @@ -502,12 +503,12 @@ int kvm_vgic_set_owner(struct kvm_vcpu *vcpu, unsigned int intid, void *owner)
>  		return -EINVAL;
>  
>  	irq = vgic_get_irq(vcpu->kvm, vcpu, intid);
> -	spin_lock(&irq->irq_lock);
> +	spin_lock_irqsave(&irq->irq_lock, flags);
>  	if (irq->owner && irq->owner != owner)
>  		ret = -EEXIST;
>  	else
>  		irq->owner = owner;
> -	spin_unlock(&irq->irq_lock);
> +	spin_unlock_irqrestore(&irq->irq_lock, flags);
>  
>  	return ret;
>  }
> -- 
> 2.11.0
> 

      reply	other threads:[~2017-12-01  7:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30 17:00 [PATCH] KVM: arm/arm64: Fix spinlock acquisition in vgic_set_owner Marc Zyngier
2017-12-01  7:55 ` Christoffer Dall [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=20171201075507.GA4218@cbox \
    --to=cdall@linaro.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=marc.zyngier@arm.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.