From patchwork Mon Jul 17 14:27:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9845251 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 F159D60386 for ; Mon, 17 Jul 2017 14:27:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4E4728509 for ; Mon, 17 Jul 2017 14:27:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9F5D2851E; Mon, 17 Jul 2017 14:27: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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 8B21A2851D for ; Mon, 17 Jul 2017 14:27:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751481AbdGQO1e (ORCPT ); Mon, 17 Jul 2017 10:27:34 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:36088 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751300AbdGQO12 (ORCPT ); Mon, 17 Jul 2017 10:27:28 -0400 Received: by mail-wm0-f41.google.com with SMTP id t70so17256298wmt.1 for ; Mon, 17 Jul 2017 07:27:28 -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=EAkutlriR4Qt7sOT2yHs4D368UTdvhoZrmx2WXdYnhrOVNhdx+gtngXZaTLIzMApG+ BrphMwT/uRS2rnp64uVVLTHkyB85V982AUsKTY9YNGnsNZyRYVeQZJwkmb6thIDx2bdL CHj73qDqQ1wUVW01GF673IcQcDfsBMmujOn3s= 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=G67Gl5N2004OBErnAfoVp6VOZ+PljmYfo+A+VP9gTVGyiaTw7Zd5C4ZjHNa65sz7pv 6nlP4Czpn7AiiKVnTEODYMv37ggzzvSuOhoEwjMyiINWrh3d/vQNxLUiDedYdKWCzwon QB9p7W7uVcFDyPSAQn/n5jvDm2SJyGLuun0pWCpz0GUyx4ChtVTcip7Mk1dukePCqQOn IWffAbdsbhyNGo8S/achTBPQarMMPj+1XCHyf+YuMSE9JKiA89IMep5c4Z3KLVf/E+SX WIv6YbbaK5+yrLmlW+SumqEImve+/gofFy9l3Fw8vXeQchFgiq4qynnPYtwKb0rXGTpR Xv7A== X-Gm-Message-State: AIVw112JxXmeefk6BF12YOftiTYHUgiwUjep3rWQRTsgqQhuRxHd9KAQ LK4ZBUoOyVyrm6FV X-Received: by 10.80.138.34 with SMTP id i31mr17587640edi.119.1500301647572; Mon, 17 Jul 2017 07:27:27 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id b30sm9428952edd.6.2017.07.17.07.27.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 07:27:26 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Cc: kvm@vger.kernel.org, Marc Zyngier , Christoffer Dall Subject: [RFC PATCH v2 03/19] KVM: arm/arm64: Guard kvm_vgic_map_is_active against !vgic_initialized Date: Mon, 17 Jul 2017 16:27:02 +0200 Message-Id: <20170717142718.13853-4-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170717142718.13853-1-cdall@linaro.org> References: <20170717142718.13853-1-cdall@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 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 --- 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);