From patchwork Sat Sep 23 00:41:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9967295 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 7905B602CB for ; Sat, 23 Sep 2017 00:42:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C05929590 for ; Sat, 23 Sep 2017 00:42:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60E9A299C6; Sat, 23 Sep 2017 00:42:16 +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 1F81B29590 for ; Sat, 23 Sep 2017 00:42:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752519AbdIWAmO (ORCPT ); Fri, 22 Sep 2017 20:42:14 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:49155 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752413AbdIWAmK (ORCPT ); Fri, 22 Sep 2017 20:42:10 -0400 Received: by mail-wm0-f50.google.com with SMTP id r74so7645649wme.4 for ; Fri, 22 Sep 2017 17:42:10 -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=PP696rKGdscnYZ4lbdW1tLbjlokFvVLnUQmjqWWY58clo/nFGPNKaQaAqJrfQNSJEN CLkaKDh0TRw3BkMyVPqBtPn/R19nzjh0n/sSwWrjRRtm3VeC/cqOQkVl9pYWJbuqxUk7 qeTgqynFihrUHYdATDsKDFg6GrlEEfHW//G88= 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=PzJYj5Bg2TBYrbFdoJB/R6MgS8L6j6f7u5lL4rlIFdvcR6pD7z+w+g3xSsEyN+omgv DCDvJR9+d8CRZzHSbTFJ++VUNVK0d2gYAu+P+Hw56DNU7iqqJgBLG0hYwQqgI5TXCGN9 O0tXEKClBVV8EXJF1OLHn/eSdySG3wwgmtE2vudxrDFZstxM4ekR+oj9apWjaoYiBoJs ND2si22S5LAkmS73XF0gSFS+cj0VU8mc9W13fTN8yi8sKmKZbwF1z1+QfiEI7NiRfOdj YxqH5L8KrZ4hESt5Wl3e080OUYCq7i5tWILrvwS6AmzHrp8p6lxUmrErvK9SzAcsudsS iQKQ== X-Gm-Message-State: AHPjjUgehc/eBe6hdHy/Gtod6nmaNytgvPer68jpQKu5dMQ3TmwCIcZg xtA5uXe+aEyRRTBiLYmd3UbN8g== X-Google-Smtp-Source: AOwi7QBpk6ZdKa1pBd9yf44pZWJKubZl9G7UEt2eJa9O2mTzSff/WyFSXrPM5bCR/B0P/5kB4BqxwA== X-Received: by 10.80.142.17 with SMTP id 17mr6553032edw.115.1506127329420; Fri, 22 Sep 2017 17:42:09 -0700 (PDT) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id c25sm646085edb.57.2017.09.22.17.42.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Sep 2017 17:42:08 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Cc: kvm@vger.kernel.org, Marc Zyngier , Will Deacon , Catalin Marinas , Christoffer Dall Subject: [PATCH v3 04/20] KVM: arm/arm64: Guard kvm_vgic_map_is_active against !vgic_initialized Date: Sat, 23 Sep 2017 02:41:51 +0200 Message-Id: <20170923004207.22356-5-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170923004207.22356-1-cdall@linaro.org> References: <20170923004207.22356-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 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);