From patchwork Tue Nov 7 10:47:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10046373 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 6AE6F60360 for ; Tue, 7 Nov 2017 10:49:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 464AA287C3 for ; Tue, 7 Nov 2017 10:49:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AFF229DB3; Tue, 7 Nov 2017 10:49:35 +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 E317C287C3 for ; Tue, 7 Nov 2017 10:49:34 +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=La/8M04fz4BlSzwqIlgvmQU/ORMgfeUt+r3qiPe2EdE=; b=ZyMwLcGpzSJaCCORkJ05eTVacZ Aq7l+RLfRJzz78ZuzE+vU4QC237tKQQp9jiDr0ivSyBNuT0267rpedVJ3NGQwzBTz6XZ6+iqaJzuq cgq+cXD+HE0N0alSFaRJyUPFUiRBL67MtMkWiu2hKV3J03jQhl8vaX42WuptZ5DZdG3wmIZJvl0P4 CH2JGahWJuYs3KsNXSeIBVHtDLlEAjf9JH9VLB6N6KmA5u1oLDoBZSL3BEiQ0JS7ZBqiMWa03F4dT Ko/SDCQBIZRUUg9sanBSWJfqo5UWuqf55gPIvImt+aipwMRgrpg/K37l+ePpwecPubfdOfIO/E15C AJ5mZlBA==; 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 1eC1RV-0001cD-Fl; Tue, 07 Nov 2017 10:49:17 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eC1Qr-0000xZ-Fa for linux-arm-kernel@lists.infradead.org; Tue, 07 Nov 2017 10:48:44 +0000 Received: by mail-wm0-x241.google.com with SMTP id t139so2848508wmt.1 for ; Tue, 07 Nov 2017 02:48:16 -0800 (PST) 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=SaWy6dUv7GJhpeuJjnkpkxNGlqSyeOtlpt1hIIP38Jg=; b=T04rs6iJ1N2rTYkDubM59oe3WQvWtGHwAshMzRcXoxcObe7pj8XLGS9NOFyPTIpUvy 9DNA+PDW1s6i3ZOs63hi8tKDUT/W0c7IFXe8S4bAWGzrIj/68HUJGKcJ/GLlenYfs8eT 6rnlFD8Sv/IqFoTbrH3uWCVqgGXRWy1TU8yd0= 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=SaWy6dUv7GJhpeuJjnkpkxNGlqSyeOtlpt1hIIP38Jg=; b=RGJyvD4W5+rIC2e70ZUiDts6XN4rpe0TkFls2L0F7TRpB5jE1Fa24nNh6RBWV4fZZu 2bMjZ2BbYXZSup4l34rJQgB7dmbqvFvIl8kZxgPDMScqiRMglbh2MwqKwZfnDlTbN/Mi IJJmTcWJHpqtZaTwnv1Hs0pieGZM46V2V+KqC6uD5EMINkQVrHiTVI+5N3rQ9NsdtkR8 auvVtC/Eycitfp6WOyZAYVjZ3SuXdYzuljb8g3M6Vr1wJgc3ppQ8z8wIjf/H8KHqEz5B tuNg0JKMOKB4KrLkWsA2ofd1khlyT7C/gNKYrSVxfmFZGQoqRPepP0d+xWP8ArSrW2si rJ5w== X-Gm-Message-State: AMCzsaXBMN09w/aMNxeBGaEsOL8Zbjy4n+BDh7VXBobf0O5xuMPPExHs BEily23oDr2Zr6ev3N7TuAM8lA== X-Google-Smtp-Source: ABhQp+Rna7RBlp3W16r97mQBCPVwdGq9kAwN2He15tL5a2q0mh1lWikw7J5Yggd2XRRO/J3epSil8Q== X-Received: by 10.80.185.68 with SMTP id m62mr24464429ede.239.1510051693864; Tue, 07 Nov 2017 02:48:13 -0800 (PST) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id q12sm1044958edj.29.2017.11.07.02.48.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Nov 2017 02:48:13 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 03/26] KVM: arm/arm64: Guard kvm_vgic_map_is_active against !vgic_initialized Date: Tue, 7 Nov 2017 11:47:36 +0100 Message-Id: <20171107104800.30021-4-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171107104800.30021-1-christoffer.dall@linaro.org> References: <20171107104800.30021-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171107_024837_985426_9E6F0BF2 X-CRM114-Status: GOOD ( 10.82 ) 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 , kvmarm@lists.cs.columbia.edu, 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: Christoffer Dall 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 fed717e07938..e1f7dbcfece0 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);