From patchwork Sat Sep 23 00:41:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9967343 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 BADBA600C5 for ; Sat, 23 Sep 2017 00:48:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABBBD28643 for ; Sat, 23 Sep 2017 00:48:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EE66290C8; Sat, 23 Sep 2017 00:48:11 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED 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 3CDB328643 for ; Sat, 23 Sep 2017 00:48:10 +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=mvqAuWoBtulvp27/+UaqU/COMn/3Az0rVVW+w82nP/U=; b=goeW1fXPyec9Fz16w8ZjKl/WjV h7o3Q9wft/OXwH9/0RGbH2l4Qdvy81FVps55XXvjCCcO+8tjs7ElE+/PRtYp4nXrt5GTQbU3cFpNM jAyRALb4P5RdqJvaKLE2f31FIB3/R2BZfdaqT4wa0gZj1oeGQB+6Pjjr/LTDezB+YqR/wRvX2Ui8Z s2+VUr7+AEcAJLAAUqrwDSQ7GmdVJn1gwdpQh1icprv7Nd5jn/PwDma1lK8+WZz3Y3IriyTYpnhR6 d7EovEWDKBtP75iDQjw5P5t/mywsp4lzwAoNoG5gfojZ83a3hfPiF3zwz2IGrGpT4O/Oi72YWzW/b bEbMVMQw==; 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 1dvYbe-0008TJ-09; Sat, 23 Sep 2017 00:47:42 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dvYWk-0003ki-4R for linux-arm-kernel@lists.infradead.org; Sat, 23 Sep 2017 00:42:44 +0000 Received: by mail-wm0-x234.google.com with SMTP id m127so7643766wmm.3 for ; Fri, 22 Sep 2017 17:42:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5qNGftkjXx1lxoy9zQYVzPUA6cx2fHn2jZmgDxhBgEw=; b=PP696rKGdscnYZ4lbdW1tLbjlokFvVLnUQmjqWWY58clo/nFGPNKaQaAqJrfQNSJEN CLkaKDh0TRw3BkMyVPqBtPn/R19nzjh0n/sSwWrjRRtm3VeC/cqOQkVl9pYWJbuqxUk7 qeTgqynFihrUHYdATDsKDFg6GrlEEfHW//G88= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5qNGftkjXx1lxoy9zQYVzPUA6cx2fHn2jZmgDxhBgEw=; b=UFIyty7glNrOS7yUqTmtoCOgDSLRIxeOm5TRwlwdU+AA5pV1BvRTLLiUrLaY65ypDN +g4qFwqB8qqKpZU3Vh4NV3ql5vRf+rVnLihYfZ9WQ0pRmaMbtu6rbg1w/+G+ErJd09sf IX9edc0AmfTbehUZ2rKSoS2D3aaj+v1+rMIZIsdHcJLDcRgNsTNHOCXLmf8quskQBRTV 1IUypUujrUTTkSihTYPOT/+LoQuj3nubOrMhWdgBvPkZdd6Z7seHj7D5tjp+puhKhbaD dL8BiZLiDxgrj/UNYDRia0jWuxL3fzgAcV6+fFCxt7IrClLkOY+DHbc+tXGM+qyvq2JA 0Jag== X-Gm-Message-State: AHPjjUgmov8wkXhbvubtA6BAMmtc4OvQySH3vjdnUfY1yD02X5aGyYpH 9ZY2gtKXwEGrJNQ3he2qtxJ5sA== X-Google-Smtp-Source: AOwi7QBpk6ZdKa1pBd9yf44pZWJKubZl9G7UEt2eJa9O2mTzSff/WyFSXrPM5bCR/B0P/5kB4BqxwA== X-Received: by 10.80.142.17 with SMTP id 17mr6553032edw.115.1506127329420; Fri, 22 Sep 2017 17:42:09 -0700 (PDT) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id c25sm646085edb.57.2017.09.22.17.42.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Sep 2017 17:42:08 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 04/20] KVM: arm/arm64: Guard kvm_vgic_map_is_active against !vgic_initialized Date: Sat, 23 Sep 2017 02:41:51 +0200 Message-Id: <20170923004207.22356-5-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170923004207.22356-1-cdall@linaro.org> References: <20170923004207.22356-1-cdall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170922_174238_832457_9C3AAB8E X-CRM114-Status: GOOD ( 10.76 ) 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 , Catalin Marinas , Will Deacon , kvm@vger.kernel.org, Christoffer Dall 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 If the vgic is not initialized, don't try to grab its spinlocks or traverse its data structures. This is important because we soon have to start considering the active state of a virtual interrupts when doing vcpu_load, which may happen early on before the vgic is initialized. Signed-off-by: Christoffer Dall Acked-by: Marc Zyngier --- virt/kvm/arm/vgic/vgic.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index fed717e..e1f7dbc 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -777,6 +777,9 @@ bool kvm_vgic_map_is_active(struct kvm_vcpu *vcpu, unsigned int virt_irq) struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, virt_irq); bool map_is_active; + if (!vgic_initialized(vcpu->kvm)) + return false; + spin_lock(&irq->irq_lock); map_is_active = irq->hw && irq->active; spin_unlock(&irq->irq_lock);