Received: by 10.192.165.148 with SMTP id m20csp1801923imm; Thu, 26 Apr 2018 02:26:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Ej9eoYp2VJteIJupXElDS/qURluuvCp0ng1eEVIrIZsqae9HzH4U+CV0rN8mDaSsenz9x X-Received: by 10.99.116.67 with SMTP id e3mr26330574pgn.369.1524734799532; Thu, 26 Apr 2018 02:26:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524734799; cv=none; d=google.com; s=arc-20160816; b=MFODr2H/KDF2EvwdVKP8DDi3kpcDc19Q6ebUOcOKL8mgn5MxgN1y2GOIE036dSMygQ ck1433+91UVF9GSIDmQ2yDePmuHLgztdDeji8IIO3awggYO+C/dM2gCiLQGfJzeg6rEV OoVGPFalID6zSUBUYXwc+FY3g/wGZfilkaLk/Zpjk3SLOxyqynMrBUo50XaCrcyI7DsQ BP75D8fKWt8aRzF5RJp9IueGKVWqoFjs86+IjwNZUymOp9MmXZNVADW5IJowkVhLOpi2 yiW7rOhaLPVZhiQ/h49E0A5PochKSEKRjBN0mhikMI2tumJl7lAar35adrSdOJOOPUzZ Fm1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=I5YKue0UXp5DdAxmArTzyXqEjzLMNr34Cx/78yxhc+0=; b=gVYioy9fTk40Uqnl7dIHOND9ACZ+IHIKxbzcnePpYNJYV/U4JMk+Gj0ATIDMpSl99p ACZrvjqP2z6drpEI9pUQnzA+qyHxDcgbboDxpEBEYfD308Z8yLhybmkQJeWilhwQxyc6 98ZTNwsOb1jQgTXoudN5Ft48juftnQuuoDPHdpR03mY3gXRsltnB7nV6uQPXqVEM0+J6 yYQ0VaPB2Zw48ZfGhpiF1P/+VCA6tTHzZb8OjIuKodsSoVsIakpBVSvOC5D4hKXIKIWt IibfeZ1MQADRIdiy6ASFo7l2RwwSRdhTudPMWpfYQc/aJklup4bouXfBhHtwav5mcz50 TeZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1-v6si18000864plo.128.2018.04.26.02.26.25; Thu, 26 Apr 2018 02:26:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754734AbeDZJZO (ORCPT + 99 others); Thu, 26 Apr 2018 05:25:14 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59566 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754116AbeDZJZL (ORCPT ); Thu, 26 Apr 2018 05:25:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6AD6D8D682; Thu, 26 Apr 2018 09:25:10 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-141.ams2.redhat.com [10.36.116.141]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C0BF2026E03; Thu, 26 Apr 2018 09:25:08 +0000 (UTC) Subject: Re: [PATCH v3 08/12] KVM: arm/arm64: Check vcpu redist base before registering an iodev To: Christoffer Dall References: <1523607658-9166-1-git-send-email-eric.auger@redhat.com> <1523607658-9166-9-git-send-email-eric.auger@redhat.com> <20180424210759.GI4533@C02W217FHV2R.local> 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@kernel.org, peter.maydell@linaro.org, andre.przywara@arm.com, drjones@redhat.com, wei@redhat.com From: Auger Eric Message-ID: <73b8e64b-3c14-b937-487a-78f3cc73fde5@redhat.com> Date: Thu, 26 Apr 2018 11:25:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20180424210759.GI4533@C02W217FHV2R.local> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 26 Apr 2018 09:25:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 26 Apr 2018 09:25:10 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christoffer, On 04/24/2018 11:07 PM, Christoffer Dall wrote: > On Fri, Apr 13, 2018 at 10:20:54AM +0200, Eric Auger wrote: >> As we are going to register several redist regions, >> vgic_register_all_redist_iodevs() may be called several times. We need >> to register a redist_iodev for a given vcpu only once. > > Wouldn't it be more natural to change that caller to only register the > iodevs for that region? vgic_register_redist_iodev() is the place where we decide where we map a given vcpu redist into a given redist region. Calling vgic_register_redist_iodev for only the vcpus mapping to the redist region would force to inverse the logic. I think it would bring more upheavals in the code than bringing benefit? This new check somehow corresponds to what we had before: " if (IS_VGIC_ADDR_UNDEF(vgic->vgic_redist_base)) return 0; " Thanks Eric > > Thanks, > -Christoffer > >> So let's >> check if the base address has already been set. Initialize this latter >> in kvm_vgic_vcpu_early_init(). >> >> Signed-off-by: Eric Auger >> --- >> virt/kvm/arm/vgic/vgic-init.c | 3 +++ >> virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 +++ >> 2 files changed, 6 insertions(+) >> >> diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c >> index 6456371..7e040e7 100644 >> --- a/virt/kvm/arm/vgic/vgic-init.c >> +++ b/virt/kvm/arm/vgic/vgic-init.c >> @@ -82,6 +82,9 @@ void kvm_vgic_vcpu_early_init(struct kvm_vcpu *vcpu) >> INIT_LIST_HEAD(&vgic_cpu->ap_list_head); >> spin_lock_init(&vgic_cpu->ap_list_lock); >> >> + vgic_cpu->rd_iodev.base_addr = VGIC_ADDR_UNDEF; >> + vgic_cpu->sgi_iodev.base_addr = VGIC_ADDR_UNDEF; >> + >> /* >> * Enable and configure all SGIs to be edge-triggered and >> * configure all PPIs as level-triggered. >> diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c >> index 5273fb8..df23e66 100644 >> --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c >> +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c >> @@ -592,6 +592,9 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu) >> gpa_t rd_base, sgi_base; >> int ret; >> >> + if (!IS_VGIC_ADDR_UNDEF(vgic_cpu->rd_iodev.base_addr)) >> + return 0; >> + >> /* >> * We may be creating VCPUs before having set the base address for the >> * redistributor region, in which case we will come back to this >> -- >> 2.5.5 >> >