From patchwork Fri Oct 20 11:49:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10019915 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 8E1A0602CB for ; Fri, 20 Oct 2017 11:49:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74FC32868D for ; Fri, 20 Oct 2017 11:49:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69A2028ED0; Fri, 20 Oct 2017 11:49:53 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AFBE2868D for ; Fri, 20 Oct 2017 11:49:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753155AbdJTLtu (ORCPT ); Fri, 20 Oct 2017 07:49:50 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:56305 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753142AbdJTLts (ORCPT ); Fri, 20 Oct 2017 07:49:48 -0400 Received: by mail-wm0-f66.google.com with SMTP id u138so22162937wmu.4 for ; Fri, 20 Oct 2017 04:49:47 -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=SaWy6dUv7GJhpeuJjnkpkxNGlqSyeOtlpt1hIIP38Jg=; b=hhhuysO9E+Q1WsHN44zZsEycGkC3eoqcrWvYy2urHo7rNeNnU+zsoZ5s1pxBjW5rpb mpZdX5pd/fW6lTBSgpYBYuBTgO4W77Xq1Nd/KE2dNUzpm6wLnhqrJ8U70dQ2s7n72L0o jb2LNbQdGnlAoNGTKRuk67IlJ1xQD9xriA5+M= 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=t0inSNI80lSFoNxQfH7RreOW2Tg7EM3S1UJ4l/NhP2swPZSwrhaRnobzoWmfF40Wsa 2IgAeg44Cj9Wrr108IRv1N34tVfD3qERdhO6mZAagwGtevgpJn8M6pNBiXtlAJnzqKrP dliR3h6TarkKCI5P0+4vu013surlhmur1HsG55+0cwPzJqPJ853vPTWR+ujb3XdWfFMn xxtL6zOigukfl6+Enu0DEbPyob90gwjRgjGra/irHOwWgzXOvdb4sYqb+woZxqW2BjUv 3NM73ajQc1dIAslgWt4YZ8XgvKocgolT9BWbPWPAhH13QnO0U2spqQWkR5nAw1FtjB4E rT3A== X-Gm-Message-State: AMCzsaUhUmSMSolnoILoew8w8nMZf7kxG2/jx3dRVJfFmmVAWWVnWOtf 11yuD6sah7zn2Hl6XatxODoguC81ak4= X-Google-Smtp-Source: ABhQp+QalJsCxNOqcRmnFtbl8Ogd+c3cPEJCt/5wREZn8H2YZ9b4OX84sYPZPUkZFAb60DC9dV3+JA== X-Received: by 10.80.148.98 with SMTP id q31mr5931986eda.29.1508500187134; Fri, 20 Oct 2017 04:49:47 -0700 (PDT) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id f53sm872234ede.63.2017.10.20.04.49.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Oct 2017 04:49:46 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Cc: kvm@vger.kernel.org, Marc Zyngier , Shih-Wei Li , Christoffer Dall Subject: [PATCH v4 04/20] KVM: arm/arm64: Guard kvm_vgic_map_is_active against !vgic_initialized Date: Fri, 20 Oct 2017 13:49:23 +0200 Message-Id: <20171020114939.12554-5-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171020114939.12554-1-christoffer.dall@linaro.org> References: <20171020114939.12554-1-christoffer.dall@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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);