From patchwork Fri Oct 27 08:34:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10029387 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 4D08D602D6 for ; Fri, 27 Oct 2017 08:36:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39A4928F5C for ; Fri, 27 Oct 2017 08:36:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E89B28F5D; Fri, 27 Oct 2017 08:36:56 +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 B267B28F55 for ; Fri, 27 Oct 2017 08:36:55 +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=KGwdM8rD7LLd6jv3O2AVCb8iZacX96rb9St11zqPKmo=; b=fXNcWpLcoVgvVOWx0hIT0AVK38 CCU4J38zdngQY/vgJbjd1qzagPS1il8f1g4Pz4ofBl5WIFf+pUTg1J02hPQZvJPA/Q5OQ9WNkUX6U lh0RZiq8SX4CbaH0bsImIi94aQPjqhWkwvuYDRkH6nrGdBP6AQO/6GV6mX6AvBIfhbadJDjKWrFps S25yv243ynaV+LNxM4E0/cPZ4OU8n3/jVG18CbJPo+BjnU3acyXLN4F3kmQzUP8weHEz62lqA8jld sg0L0hn0TbJ3/W0ANqWOJirTfc6tteK5G49aWTPc2kNmx3uG8OnWLmUxXV0vMN8FULlAHXnp17IEK QP93FOFw==; 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 1e808M-0001CC-Kz; Fri, 27 Oct 2017 08:36:54 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e807E-0008Pl-Ax for linux-arm-kernel@lists.infradead.org; Fri, 27 Oct 2017 08:35:47 +0000 Received: by mail-lf0-x243.google.com with SMTP id p184so6508550lfe.12 for ; Fri, 27 Oct 2017 01:35:23 -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=UJFcB2iVEz6Q8DZqUKMJ+SazexqfUfWhNObCxcWBu6c=; b=IXcB+OtXUibWlxrTabtbewc34cqkUb0/+oiWUP1IgbvAhgvmK6iEgSA7ZjKOtApElI v26Bbqsot4zSkYG1C15/YIsXEqDkYHQ2C3Aykt8i8gTZ75fOEb5QoCrDvljm1TV97z5i ihyBlkeZfPKVOSLdqYnBVIYDM/4amuT20b68w= 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=UJFcB2iVEz6Q8DZqUKMJ+SazexqfUfWhNObCxcWBu6c=; b=uRw0DYTrSMA25nQHM+ifm2or0vtwqWBUbLWnsAGOPrUa5e9pcbsfwSch1Ug39WyZ5p 6G1Fr9JK/QY2Ko9bBXacsHm78aP3xNjV8PFAmpi3i5eLlr71AY5dChchyPgMc+rFQ0Ai LZlbVVFbtTr0mTZDQ5ZUbk+icb5t7fbWeINqULbc8hJARDIez6NKec/2+g97ag2GZXO1 OIZn8I0VpNz+HMmWkBTJJHVJSGiuf9FF6bSknIlUai5XJfJ0Tq6j9VgR30uOdYY0C4yw wyUmJK5nzGjLoNVyu1ukn1HZQJkXHbuUoI8fKtaqCGpJVtK8w2x+o2Sg/TrKgxfu9FHy EcRw== X-Gm-Message-State: AMCzsaVAaZ+xKnnmHg7cJqT7iilrcqpzc7GOtEtfGzH0WX/YN+yr8TDF zmk3LtMCySl2fZ0v3dvqwARJZNvR1dQ= X-Google-Smtp-Source: ABhQp+SSk3CF3+i2E/bK3ZkaVVvvFBNzJ6uK75RQ3qS8L+fIzUypYCqmv5U/pqgvMNBlmsPLRApKnA== X-Received: by 10.25.92.21 with SMTP id q21mr8674483lfb.141.1509093322241; Fri, 27 Oct 2017 01:35:22 -0700 (PDT) Received: from localhost.localdomain (212.27.17.163.bredband.3.dk. [212.27.17.163]) by smtp.gmail.com with ESMTPSA id d204sm1471957lfe.73.2017.10.27.01.35.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Oct 2017 01:35:21 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 04/20] KVM: arm/arm64: Guard kvm_vgic_map_is_active against !vgic_initialized Date: Fri, 27 Oct 2017 10:34:25 +0200 Message-Id: <1509093281-15225-5-git-send-email-cdall@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509093281-15225-1-git-send-email-cdall@linaro.org> References: <1509093281-15225-1-git-send-email-cdall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171027_013544_790857_32453BCA X-CRM114-Status: GOOD ( 10.91 ) 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: Christoffer Dall , kvm@vger.kernel.org, Marc Zyngier , Catalin Marinas , Will Deacon , Eric Auger 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);