From patchwork Thu Jan 11 18:55:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10158345 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 ABFA9601A1 for ; Thu, 11 Jan 2018 18:55:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C5261FF22 for ; Thu, 11 Jan 2018 18:55:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EBF922B1F; Thu, 11 Jan 2018 18:55:57 +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=unavailable 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 146061FF22 for ; Thu, 11 Jan 2018 18:55:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965408AbeAKSzn (ORCPT ); Thu, 11 Jan 2018 13:55:43 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:44280 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965209AbeAKSzm (ORCPT ); Thu, 11 Jan 2018 13:55:42 -0500 Received: by mail-wm0-f66.google.com with SMTP id t8so7481428wmc.3 for ; Thu, 11 Jan 2018 10:55:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=cCAQeKHlmoj02bCFCrsl7zMjn9v9KRx/9s58HbE949w=; b=MkczDAE31zdH6+DCGU92y4CJCxW6UVOwpV2mF+FzK7mjVRswu/BMZnJac1UfmtB877 fxJ4rWT1qUV1ubwRe3RceXHmWGsyTN3pzFQEls/5Lzj4xwhTAtJ0+WtsPcuva4qraVpd dhg4uC6QRyCuj5Qu2ipMSGHl4ZRdJro1VUtXc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=cCAQeKHlmoj02bCFCrsl7zMjn9v9KRx/9s58HbE949w=; b=bHIPRS6rLrC7ZI2dy58UVyo1cN+AhX9s8L7Gy+wOxJRguv2N797oxnxQemwgaY/24G HSTWIqQqTaY/nvM0lSP2owzdngjv9l+ogsF6XG0t9m0FgipBmqgBqXO4sZuW1kIp/Odl ZQy3U812r4mtoWK1RGU+bd9nabIOYxvF6zWU/7P48/39hJZzvDe/l2bsBm8Ic3lpu9MF zzZWuwt46ZJHl3TUZJrNmdfdusHVucpHjJqQY9q1koLgY2+eALkWBUlj3Iwgd+gZ4uvY NLuSz+LcJaOmRmzc/jzttRhNS/C+UsNHICymzZSPieZirpVKiFAXmtYrn9nFckVVv9UC rvxg== X-Gm-Message-State: AKGB3mKmO//aOAoGTOjj059iJokjqCKQzHEHyTuaE35vdanMD/MDXAsG hqct/EzfhJpL7lWhUbEjTQ2wytE3ie4= X-Google-Smtp-Source: ACJfBov+oGBivElRE420zJOqXIqBUXZpEmiTrKtLlJApGtRDORYiMNBBtYmnqhekmnfZB4+ilrn0Cg== X-Received: by 10.80.205.73 with SMTP id d9mr31816763edj.107.1515696940568; Thu, 11 Jan 2018 10:55:40 -0800 (PST) Received: from localhost (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id k90sm2258706edc.20.2018.01.11.10.55.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jan 2018 10:55:39 -0800 (PST) Date: Thu, 11 Jan 2018 19:55:38 +0100 From: Christoffer Dall To: Eric Auger Cc: eric.auger.pro@gmail.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com, cdall@linaro.org Subject: Re: [PATCH v2] KVM: arm/arm64: vgic-its: Fix vgicv4 init Message-ID: <20180111185538.GI15307@cbox> References: <1515405174-21066-1-git-send-email-eric.auger@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1515405174-21066-1-git-send-email-eric.auger@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Jan 08, 2018 at 10:52:54AM +0100, Eric Auger wrote: > Commit 3d1ad640f8c94 ("KVM: arm/arm64: Fix GICv4 ITS initialization > issues") moved the vgic_supports_direct_msis() check in vgic_v4_init(). > However when vgic_v4_init is called from vgic_its_create(), the has_its > field is not yet set. Hence vgic_supports_direct_msis returns false and > vgic_v4_init does nothing. > > Let's move the check back to vgic_v4_init caller. > > Fixes: 3d1ad640f8c94 ("KVM: arm/arm64: Fix GICv4 ITS initialization issues") > Signed-off-by: Eric Auger > > --- > > v1 -> v2: > - move the check to the caller Why this change, I slightly preferred the first version of this patch, but I will admit that the "has_its = true; no_wait(); has_its = false;" things is pretty ugly... > - identify the right commit this patch fixes > --- > virt/kvm/arm/vgic/vgic-init.c | 8 +++++--- > virt/kvm/arm/vgic/vgic-its.c | 2 +- > virt/kvm/arm/vgic/vgic-v4.c | 3 --- > 3 files changed, 6 insertions(+), 7 deletions(-) > > diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c > index 6231012..40be908 100644 > --- a/virt/kvm/arm/vgic/vgic-init.c > +++ b/virt/kvm/arm/vgic/vgic-init.c > @@ -285,9 +285,11 @@ int vgic_init(struct kvm *kvm) > if (ret) > goto out; > > - ret = vgic_v4_init(kvm); > - if (ret) > - goto out; > + if (vgic_supports_direct_msis(kvm)) { > + ret = vgic_v4_init(kvm); > + if (ret) > + goto out; > + } > > kvm_for_each_vcpu(i, vcpu, kvm) > kvm_vgic_vcpu_enable(vcpu); > diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c > index 8e633bd..aebc88d 100644 > --- a/virt/kvm/arm/vgic/vgic-its.c > +++ b/virt/kvm/arm/vgic/vgic-its.c > @@ -1687,7 +1687,7 @@ static int vgic_its_create(struct kvm_device *dev, u32 type) > if (!its) > return -ENOMEM; > > - if (vgic_initialized(dev->kvm)) { > + if (kvm_vgic_global_state.has_gicv4 && vgic_initialized(dev->kvm)) { ... but now we're using vgic_supports_direct_msis() in one part of the init path and a half-open coded version of that in another path, which is not very pretty. So I actually would suggest doing the init stuff more open-coded, because init of the gic/its/gicv4 is a mess anyway. Something like this: Does that work? Thanks, -Christoffer diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c index 62310122ee78..743ca5cb05ef 100644 --- a/virt/kvm/arm/vgic/vgic-init.c +++ b/virt/kvm/arm/vgic/vgic-init.c @@ -285,9 +285,11 @@ int vgic_init(struct kvm *kvm) if (ret) goto out; - ret = vgic_v4_init(kvm); - if (ret) - goto out; + if (vgic_has_its(kvm)) { + ret = vgic_v4_init(kvm); + if (ret) + goto out; + } kvm_for_each_vcpu(i, vcpu, kvm) kvm_vgic_vcpu_enable(vcpu); diff --git a/virt/kvm/arm/vgic/vgic-v4.c b/virt/kvm/arm/vgic/vgic-v4.c index 4a37292855bc..bc4265154bac 100644 --- a/virt/kvm/arm/vgic/vgic-v4.c +++ b/virt/kvm/arm/vgic/vgic-v4.c @@ -118,7 +118,7 @@ int vgic_v4_init(struct kvm *kvm) struct kvm_vcpu *vcpu; int i, nr_vcpus, ret; - if (!vgic_supports_direct_msis(kvm)) + if (!kvm_vgic_global_state.has_gicv4) return 0; /* Nothing to see here... move along. */ if (dist->its_vm.vpes)