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: 10029353 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 402D7602D6 for ; Fri, 27 Oct 2017 08:35:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EB4528F55 for ; Fri, 27 Oct 2017 08:35:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2369B28F5C; Fri, 27 Oct 2017 08:35:34 +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 B6D5E28F55 for ; Fri, 27 Oct 2017 08:35:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752346AbdJ0Ifb (ORCPT ); Fri, 27 Oct 2017 04:35:31 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:45568 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752269AbdJ0IfX (ORCPT ); Fri, 27 Oct 2017 04:35:23 -0400 Received: by mail-lf0-f67.google.com with SMTP id n69so6542834lfn.2 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=cpU6qQGT32F7tAQShh5EzdSkpvPeEildctHKNt27nngas4mzptgX+5GSvmW9Ul8wJz Y0ys/cFdBM9cciQEIW1r/mfryz4DyZKGPk4VLEtVbONfPCRAUIs2L4QO1aWYUa2i9v8T EY4pXCJHicPKLWO4Hic7TrKBVOPgRT3/w8Eu64BuKSitWkaVdVA0dban3Gwx53/PVbkg tm1oKkflxY/RfE1gFph5sZMt6VmDxTJBPMV/dw3Ys9x84nJ6P3ODA1dKdtcE7Iet89hi VEYxaHYKIoreLulgTHUwWynTMxUOEdqueDOjw6oV/8p+6ohzoYAZRn7Zo2Qkg9dLVzsk VfTg== X-Gm-Message-State: AMCzsaV1cMGnE0siz48GuRM8JzIaj/1UQZOJOU9ws1o/o6ZCOtjDce/y UfauHdak0kSHwS45c6hIiKLleA== 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 Cc: Marc Zyngier , Eric Auger , kvm@vger.kernel.org, Catalin Marinas , Will Deacon , Christoffer Dall 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> 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);