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: 10019987 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 F1C0E602CB for ; Fri, 20 Oct 2017 11:58:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D995028EC0 for ; Fri, 20 Oct 2017 11:58:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE7EF28ED0; Fri, 20 Oct 2017 11:58:12 +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=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_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 7733728EC0 for ; Fri, 20 Oct 2017 11:58:12 +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=usr698+/UsvKt66Pc7HFL4XNsO 8UHzcDmyJP02KK3Yw+eY04bKGwZH2ZnErSYL+ZruTKxwr8K4nKVnBzZkCDh4zdTkuPfaEzX/x77C6 nLDGlMovYM3dCwxCB/S3OpcC7gomwVMWwt69SNTRRwyPMDsQKK6kSJYn91gPozYe9oePVEhAbkqK1 SV7RrirAHheQQ5V73ZSPXlm3bZa/J/6WXon1lUn5swXrfa0ctptwe8BgIwUDDBALRY04MQ2vhvmdZ mOlSn8epY+p3oZtk6R5fE388lMKchkHSn4A1KhFdrY2V77A1PzxjNxMUJqn5RJyJEWgicJYl24i6v WG/MBDZQ==; 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 1e5VwG-0008JC-36; Fri, 20 Oct 2017 11:58:08 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e5VoW-000839-QT for linux-arm-kernel@lists.infradead.org; Fri, 20 Oct 2017 11:50:12 +0000 Received: by mail-wm0-x242.google.com with SMTP id l68so21954635wmd.5 for ; Fri, 20 Oct 2017 04:49:48 -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=nwA1T/SqOCQtLnoNWrPlAcemhoifqUbZmW7BcxryIo4DNp672LL04TH73sS2iTpGgN lUVdm/PK5qWMOMVqy4PwJtFoEm5xvtjeUeGZ4TWnZaS4w6wvGndc6PMrCxE3D7RmSUti 6DyixoTiYSvtbraCrk7oqe1ALY63PfZ8eg+yNmOaz5nVyGOOU2BrwTEaBFeCwBvHsLnE yQO4KLsF9YtTfgzQ/fKoV5bZWyWTeakIZ1xOlD/N2gsolC9YrL6QAoscZD/7iKqxrL4A WnQFYe83aSNGt+uekod8/ybcZuj/JrpDXweMEOKkJ3K3LgBhcCniUi3+WhZjGqEmFfI6 +4UA== X-Gm-Message-State: AMCzsaVBBDqXwnDPENV298Qu6kdAb5vxbCLwJvG9MAkwy71dZOWh9Hcc ++wsWs4SRR6zyNXhvD3MqHV8Yg== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171020_045009_270836_9128BE0C 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 , Shih-Wei Li , kvm@vger.kernel.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);