From patchwork Mon Dec 4 14:03:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10090411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 17DDE60329 for ; Mon, 4 Dec 2017 14:11:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7F8129284 for ; Mon, 4 Dec 2017 14:11:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D64CA293D5; Mon, 4 Dec 2017 14:11:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, URIBL_DBL_ABUSE_SPAM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 85EC029284 for ; Mon, 4 Dec 2017 14:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=6ZGRr/uL71I+V4645u+SzH96EsRSCGuezEbSD1pm2Bk=; b=hrzUAGQKKaA9oQv7y9mJ5KE+UJ 6qHDh7jeEUDGm4L8yttuOZTJYegf1CktmxjnkGyRveVR1AQyjolOmaOSYK1OFzkcQGRjeXJYAKuA5 MgBbKW9qJ+T8Lzx7vg0raq3sLKdBu5f1H+LOF2/pZT8lWH9VhrMDXkywQLsUnLGnvYSFbSNhMv7Nn QO/LCv5HT9VY3IGvz5c8PXCk0orss83eA3hRSsQBIZNZkNMIPjB31nwCoJ+5mj68fgdorDi30Sxom eVI2oPoxzUcrk2hk5B2H2koAcYFyngb3VvUKP+xsq2zhFEZ/lgkBcS3vF61EZ6U6dRWC9ifJAULH2 /rCxafrA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eLrSG-0001wH-JD; Mon, 04 Dec 2017 14:10:44 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eLrMD-0002Rj-J6 for linux-arm-kernel@lists.infradead.org; Mon, 04 Dec 2017 14:04:44 +0000 Received: by mail-wm0-x244.google.com with SMTP id i11so14463198wmf.4 for ; Mon, 04 Dec 2017 06:04:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=christofferdall-dk.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=26Q+bza+1c3SwfKc8UQVaU0+52zWwjBHo15Kp+xzYjQ=; b=ngj5+LTYFaqniir8Fc7Iw8AwxLYhfB9eYcrQKo3336FZ66hXAPUrY00ZLXRD+xsBHu lIFJHuwUOFb6DIlU6auJZmyzeLD6TH4I3u23NnX8/7/PHfC9m7u9LcYfD7+MmUieyTPz kchgCY642tsjiiqO5jwsM+cM0Qrq8PBrdiNnZjsdcmydDRk3nHyqwisZlVMabpJMQsxE wxayrLTvjC7rAh0SCAOt4/U9copJpC4OB7GbQ+uf9Gsrd0qF2P09H8wIFyw3IXdoOC9c WGD+MB0fcn2CHgo+s0/lwo9zD0zcbcyGSHv+/QaLCnZVsi7pCqhJshCROJs2aBzcFVno 8WGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=26Q+bza+1c3SwfKc8UQVaU0+52zWwjBHo15Kp+xzYjQ=; b=tRYIK86EZZ5viIyYu7FwzjDzXC3Ki6Q99jjcKG1reQklHM4PvkxCQgYgicPLaLjHzc jcQhM96Fim6Uhd4SzWZVwgDoMwouPV4ZgA3wls/SSNA2dk1IqUDlui0kAoWxgZuGaVYp l3uFLRdCJIdj7ZnOxb8g4HlWe5ug8CqRJ6nnXsOnIpwdEg/ppRAoS6MDE8pXUTsxaIpq rQ7iI7yjpP8XKw/BKl15RHwtvK+0509ghEfPYryZxLe9frI3i1d+zi8LiXRelNPpBl76 +3JHXRLHDqCcFYzaA6P9n4ajh+VGMUs4K2SqTDzBsK5CTjv8H4kVPSI3ZGsHQbIclzTK 9n0w== X-Gm-Message-State: AKGB3mJv3ii2SDS/QHJ8TpmoiZIjvbydDbHwpX5gEcZa0tcAjwccxCBb tjsB46HDxPPzEH6yGq/3f5qUWg== X-Google-Smtp-Source: AGs4zMarZxToZmazjtjMDBfUiuu2M1bNkwFQTGFmmpohkOXtt1u/zJsQ5rGy5ALfC8KH9OYcY0HimQ== X-Received: by 10.28.69.136 with SMTP id l8mr6824291wmi.19.1512396250482; Mon, 04 Dec 2017 06:04:10 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id g7sm22794279wra.38.2017.12.04.06.04.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 06:04:09 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 17/19] KVM: arm/arm64: Fix spinlock acquisition in vgic_set_owner Date: Mon, 4 Dec 2017 15:03:46 +0100 Message-Id: <20171204140348.21965-15-cdall@kernel.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171204135637.21620-1-cdall@kernel.org> References: <20171204135637.21620-1-cdall@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171204_060430_577523_2BF18247 X-CRM114-Status: GOOD ( 10.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Christoffer Dall , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier 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 Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- 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 786cce7bd2ec..ecb8e25f5fe5 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; }