From patchwork Mon Dec 4 13:56:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10090307 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 979E56056E for ; Mon, 4 Dec 2017 13:56:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DD9F29035 for ; Mon, 4 Dec 2017 13:56:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72AFD2912D; Mon, 4 Dec 2017 13:56:48 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_DBL_ABUSE_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 EA4DA290BC for ; Mon, 4 Dec 2017 13:56:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754168AbdLDN4p (ORCPT ); Mon, 4 Dec 2017 08:56:45 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:38760 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752920AbdLDN4l (ORCPT ); Mon, 4 Dec 2017 08:56:41 -0500 Received: by mail-wr0-f195.google.com with SMTP id o2so17384978wro.5 for ; Mon, 04 Dec 2017 05:56:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=christofferdall-dk.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZT5oglIYnM/6cguB+N6ZgO9xTgV+yE8P1fliJQG4/90=; b=aTE/+SkE0AmuEMSRgKXwN3sg7KM8uz5B04eC3CiXQgLODa4IR+/p1fso+jVRrP3V+9 1XfZUuK1BPNlVmANFc4JWihbnQWL2GkV1U6q6cWP5u1cf9ZI5fowwLpZBl67w7e3S1AX X059nzIUA7mrUzNFWKLLfzUbDB0F7Ss4f5SI/dLbBLZez87637+2mD8vhl/IiN4/+pRR kiQV1LN+QHFGx1pTXcSuycoinQWrVFZ/Jq3X0KFjSuHTTc8ydOShqeS9auNhWZxYCBdE Oc8F3QRDnTtLbhekQN/VuXHfoiTV2dKX0MI4I4N5YI7gH41OD32ItBRaYW1yccZ+D3ET HFag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ZT5oglIYnM/6cguB+N6ZgO9xTgV+yE8P1fliJQG4/90=; b=Jyd2bqTclCZtaphGveuV2YGUi8v2r8jpvO8KGpb7WKT6mZq+VWJ7U/0F35kfWo1Knx 4P0gxb2b1B1mvZ8nBWZ7i/8yCudRdhdLC94p42LSAuxb0YHEY7KdN92IyPK6tU3UtrEG cgUGQkfXa8vbRcTWBt3AcNcjxZiWo1Uo6hCRFlyZoLVRZ5yFF/KT2F5HcC8AV4xvdRwj wfQLPd2yarMcmr3ytRnPtqfL4rAl2F8LHDubnIt+5xzCvRcezW+qUDuzWB9vk7CZbOQ8 3gAttKFkdKz5J+2yKxQfsXSW/aE4VGpEtTxM9a1AC5fB5USAF3YEa4z2fVWN9XOcguW2 lipA== X-Gm-Message-State: AKGB3mJXqae3zVWx4gBQ5urERySf2busYnXe/R/7tR2+4UTXifjv6xAB voctiuWTZ5/iLwaTpuC+0kZQFw== X-Google-Smtp-Source: AGs4zMb17cVEQstGrX5jvy05djVL2wE5/JSqU3HF7CF3V3RsAX0n/OSKfjGSiifMW9VwF0sGwP4ufQ== X-Received: by 10.223.187.3 with SMTP id r3mr6279465wrg.34.1512395800562; Mon, 04 Dec 2017 05:56:40 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id o27sm12056103wro.9.2017.12.04.05.56.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 05:56:39 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Marc Zyngier , Andre Przywara , Christoffer Dall Subject: [PULL 02/19] KVM: arm/arm64: VGIC: extend !vgic_is_initialized guard Date: Mon, 4 Dec 2017 14:56:20 +0100 Message-Id: <20171204135637.21620-3-cdall@kernel.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171204135637.21620-1-cdall@kernel.org> References: <20171204135637.21620-1-cdall@kernel.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andre Przywara Commit f39d16cbabf9 ("KVM: arm/arm64: Guard kvm_vgic_map_is_active against !vgic_initialized") introduced a check whether the VGIC has been initialized before accessing the spinlock and the VGIC data structure. However the vgic_get_irq() call in the variable declaration sneaked through the net, so lets make sure that this also gets called only after we actually allocated the arrays this function accesses. Reviewed-by: Eric Auger Signed-off-by: Andre Przywara Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index b168a328a9e0..786cce7bd2ec 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -823,13 +823,14 @@ void vgic_kick_vcpus(struct kvm *kvm) bool kvm_vgic_map_is_active(struct kvm_vcpu *vcpu, unsigned int vintid) { - struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, vintid); + struct vgic_irq *irq; bool map_is_active; unsigned long flags; if (!vgic_initialized(vcpu->kvm)) return false; + irq = vgic_get_irq(vcpu->kvm, vcpu, vintid); spin_lock_irqsave(&irq->irq_lock, flags); map_is_active = irq->hw && irq->active; spin_unlock_irqrestore(&irq->irq_lock, flags);