Received: by 10.192.165.148 with SMTP id m20csp1832052imm; Thu, 26 Apr 2018 02:59:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx49QhgHmDyA3P6IL4xHKWG9GDB86zv1qzRTYZ8gzHlherrVXwqrIxOStZDSrnkDAoyB7tI8z X-Received: by 10.99.127.9 with SMTP id a9mr27375398pgd.347.1524736748418; Thu, 26 Apr 2018 02:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524736748; cv=none; d=google.com; s=arc-20160816; b=A/IT5tRUnUivdsRggawaRTRiEgeHEvPq8hHo9JEOq8gIRD3Ha0Z8FCbIGSfwwWR0Pu SODihl72zcuu9RSpHJehSJBda0wz+klSbvlhdTOGeC4fRznGo2xkwiAiB1VuI2aQInpj ZOcIC/K/ecTJD2awRN8HAXZUW8nvaw92q+MD8GQxQ0LfjjmnXuHybQWmy/sYSv0D6MJy srFF5UgOCSqAJ6+GHNk8gwucm3uZtmodrwW+qD5VKj18jH7tZxSU3aNC+psgQFBHzPhm /9mLIFtLkPCPtYbwlLfukIhUKTH9K9NSgjYUYWrjlsGSfoGwIV19fFoa/L27V/IS2cNG maVA== 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=VnRPnsV6ek2s66QOoewDd3aM0e3FXGwhlNVsvag8vJU=; b=qzF2isO9J5la9uwi1y24s38ilZefWb9BUr/QYrOecTAsi2NS1rmwVopWT+uJ/7x5ln iPLbiYDYolUpxPB6gKK4coXjTz4WJoqstgquzyQraiq7wUkND7Y3e1nwAKRFGEJaKZs9 vME+iJ2zEeJ4FruU+WWsj31w+eJcCNkd0Nz+027RVU25ocw1mSQXzgcKECWmIi7P8V8v iV6oN16kRi4zGa/2XrDP1zl2hqtMlmPN5tiuMEzalCsiUgFJV2i+V5SJMuM1eX0PRRc5 aIza7g2NGR3RozcyTF3552t6ktzFA9jSdvZbc3hWW2OgdOIBmVQhQTuvkemMbXiP1lf7 rBYQ== 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 x22si18122587pfe.318.2018.04.26.02.58.54; Thu, 26 Apr 2018 02:59:08 -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 S1755614AbeDZJ4X (ORCPT + 99 others); Thu, 26 Apr 2018 05:56:23 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60968 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754484AbeDZJ4S (ORCPT ); Thu, 26 Apr 2018 05:56:18 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D1A17CBBA; Thu, 26 Apr 2018 09:56:18 +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 B645684447; Thu, 26 Apr 2018 09:56:11 +0000 (UTC) Subject: Re: [PATCH v3 09/12] KVM: arm/arm64: Check all vcpu redistributors are set on map_resources To: Christoffer Dall References: <1523607658-9166-1-git-send-email-eric.auger@redhat.com> <1523607658-9166-10-git-send-email-eric.auger@redhat.com> <20180424210809.GJ4533@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: Date: Thu, 26 Apr 2018 11:56:10 +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: <20180424210809.GJ4533@C02W217FHV2R.local> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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:56:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 26 Apr 2018 09:56:18 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 On 04/24/2018 11:08 PM, Christoffer Dall wrote: > On Fri, Apr 13, 2018 at 10:20:55AM +0200, Eric Auger wrote: >> On vcpu first run, we eventually know the actual number of vcpus. >> This is a synchronization point to check all redistributors regions >> were assigned. > > Isn't it the other way around? We want to check that all redistributors > (one for every VCPU) has its base address set? (I don't suppose we care > about unused redistributor regions). Yes I meant "to check all redistributors were assigned" > >> On kvm_vgic_map_resources() we check both dist and >> redist were set, eventually check potential base address inconsistencies. > > Do we need to check that again? Didn't we check that at > creation/register time? Yes we need to, to handle the case where the userspace does not provide sufficient rdist region space create 8 vcpus (no iodev registered) define a redist region for 4 (4 iodevs registered) start the vcpus > >> >> Signed-off-by: Eric Auger >> --- >> virt/kvm/arm/vgic/vgic-v3.c | 19 ++++++++++++++----- >> 1 file changed, 14 insertions(+), 5 deletions(-) >> >> diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c >> index b80f650..feabc24 100644 >> --- a/virt/kvm/arm/vgic/vgic-v3.c >> +++ b/virt/kvm/arm/vgic/vgic-v3.c >> @@ -484,16 +484,25 @@ struct vgic_redist_region *vgic_v3_rdist_region_from_index(struct kvm *kvm, >> >> int vgic_v3_map_resources(struct kvm *kvm) >> { >> - int ret = 0; >> struct vgic_dist *dist = &kvm->arch.vgic; >> - struct vgic_redist_region *rdreg = >> - list_first_entry(&dist->rd_regions, >> - struct vgic_redist_region, list); >> + struct kvm_vcpu *vcpu; >> + int ret = 0; >> + int c; >> >> if (vgic_ready(kvm)) >> goto out; >> >> - if (IS_VGIC_ADDR_UNDEF(dist->vgic_dist_base) || !rdreg) { >> + kvm_for_each_vcpu(c, vcpu, kvm) { >> + struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; >> + >> + if (IS_VGIC_ADDR_UNDEF(vgic_cpu->rd_iodev.base_addr)) { >> + kvm_err("vcpu %d redistributor base not set\n", c); > > Shouldn't this be a kvm_debug instead? I think the user can just > provoke this by failing to register enough redistributor regions. yes indeed. > > I'm also wondering if we could check this on vgic_init time for gicv3, > which should have a defined vgic init ordering requirement. That would > make debugging it slightly easier to debug than "my machine isn't > starting, and I get -ENXIO, and it can mean anything". Well at vgic_init time, vcpus are frozen but dist and redist regions are not forced to be set, hence the late check we do in map_resources, on 1st VCPU run. Not sure I get this one? Thanks Eric > >> + ret = -ENXIO; >> + goto out; >> + } >> + } >> + >> + if (IS_VGIC_ADDR_UNDEF(dist->vgic_dist_base)) { >> kvm_err("Need to set vgic distributor addresses first\n"); >> ret = -ENXIO; >> goto out; >> -- >> 2.5.5 >> > > Thanks, > -Christoffer >