Received: by 10.192.165.148 with SMTP id m20csp1750079imm; Thu, 26 Apr 2018 01:31:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpo8ixUUsJf3ofXKkY+zraED7Pp4/TWUqwRBbekqq6GOn129fQing0cXNdRDRHi7naUbFZj X-Received: by 2002:a17:902:bd0a:: with SMTP id p10-v6mr4119212pls.69.1524731472732; Thu, 26 Apr 2018 01:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524731472; cv=none; d=google.com; s=arc-20160816; b=GKILAlrRRswFZ1IJ81EC8KC/nB/K84SzHhVAv6p/wxe+AA2Actko+5gvm4SRc5wsDy +KIDLek1nnL5LSUhZimJUvGxQnT40CUK7N8v8gv3OBm7F1wI6Xz8F0itbkSIPlGAsqHD XpiruZYat7nCy60DiPJinZVC9+jP1evjOO5Cut6AW3CXlljyJFKz1UIHzyYkOpX1F9PI Ur9LAcZpIpPVRnFFZyapVG5L6h48lwiMK2DgL3WNqzLVqd6ot+l+ZYWKKtosjPOmHoPr KyelkD9PxNQKBTuOtECNfwlqJWGkHo2sEyls2r5nJOkKR9YSmLUhRyA2nBU2I2F3PYC2 SEjg== 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=SEs16ZyiDm7Ogqj5/NwlVK0PVbn8OGjt8mJQTyT0YMA=; b=FkJmoIx+9ORQFqOVnkEp+/euFoP+xx5/QwtobMFXkh4pxqh5VTBUHLkcez4XA3jRNk tOyPBsn8mGKHbMS/FNetI5kSVnSVuJZY8h/tJXOM3lB24ay8qjafWwTuh+px3UAdCbYa 0r7bNsyb4GfDYdhbzoSZ8oBmx8AmF5b1R30y4vDaB/MrQ7xI7OVlcBQZTVhftZIPlhTn qJotQcM9FpnfilRpzyxSuYOsZKPpUUj48OQb3kzKbBPiGWWUgOWPhOZsq/fbbzErfxI5 w/+16zimY1tiFnV5gJFf7VZD8g+Q//gMf9F2q8SEOUlPIKFCg0M2nUDkl5i2FNeZaI1h Ye2g== 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 h12si17128698pfn.300.2018.04.26.01.30.58; Thu, 26 Apr 2018 01:31:12 -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 S1754116AbeDZI3r (ORCPT + 99 others); Thu, 26 Apr 2018 04:29:47 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55836 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753655AbeDZI3o (ORCPT ); Thu, 26 Apr 2018 04:29:44 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A00C781A88C4; Thu, 26 Apr 2018 08:29:43 +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 DC47E10EE6C1; Thu, 26 Apr 2018 08:29:36 +0000 (UTC) Subject: Re: [PATCH v3 07/12] KVM: arm/arm64: Adapt vgic_v3_check_base to multiple rdist regions To: Christoffer Dall References: <1523607658-9166-1-git-send-email-eric.auger@redhat.com> <1523607658-9166-8-git-send-email-eric.auger@redhat.com> <20180424210748.GH4533@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: <557b2aaf-3f6f-ea11-55e2-5667b651922b@redhat.com> Date: Thu, 26 Apr 2018 10:29:35 +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: <20180424210748.GH4533@C02W217FHV2R.local> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 26 Apr 2018 08:29:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 26 Apr 2018 08:29:43 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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:53AM +0200, Eric Auger wrote: >> We introduce a new helper to check there is no overlap between >> dist region (if set) and registered rdist regions. This both >> handles the case of legacy single rdist region (implicitly sized >> with the number of online vcpus) and the new case of multiple >> explicitly sized rdist regions. > > I don't understand this change, really. Is this just a cleanup, or > changing some functionality (why?). > > I think this could have come with the introduction of > vgic_v3_rdist_overlap() before patch 6, and then patch 6 could have been > simplified (hopefully) to just call this "check that nothing in the > world ever collides withi itself" function. I have merged this patch and vgic_v3_rd_region_size + vgic_v3_rdist_overlap and put it before this patch. Also I reworked the commit message which was unclear I acknowledge. With respect to using the adapted vgic_v3_check_base() in vgic_v3_insert_redist_region(), it is less obvious to me. In vgic_v3_insert_redist_region we do the checks *before* inserting the new rdist region in the list of redist regions. While vgic_v3_check_base() does the checks on already registered rdist and dist regions. So I would be tempted to leave vgic_v3_insert_redist_region() implementation as it is. Thanks Eric > >> >> Signed-off-by: Eric Auger >> --- >> virt/kvm/arm/vgic/vgic-v3.c | 26 +++++++++----------------- >> 1 file changed, 9 insertions(+), 17 deletions(-) >> >> diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c >> index dbcba5f..b80f650 100644 >> --- a/virt/kvm/arm/vgic/vgic-v3.c >> +++ b/virt/kvm/arm/vgic/vgic-v3.c >> @@ -432,31 +432,23 @@ bool vgic_v3_rdist_overlap(struct kvm *kvm, gpa_t base, size_t size) >> bool vgic_v3_check_base(struct kvm *kvm) >> { >> struct vgic_dist *d = &kvm->arch.vgic; >> - gpa_t redist_size = KVM_VGIC_V3_REDIST_SIZE; >> - struct vgic_redist_region *rdreg = >> - list_first_entry(&d->rd_regions, >> - struct vgic_redist_region, list); >> - >> - redist_size *= atomic_read(&kvm->online_vcpus); >> + struct vgic_redist_region *rdreg; >> >> if (!IS_VGIC_ADDR_UNDEF(d->vgic_dist_base) && >> d->vgic_dist_base + KVM_VGIC_V3_DIST_SIZE < d->vgic_dist_base) >> return false; >> >> - if (rdreg && (rdreg->base + redist_size < rdreg->base)) >> - return false; >> + list_for_each_entry(rdreg, &d->rd_regions, list) { >> + if (rdreg->base + vgic_v3_rd_region_size(kvm, rdreg) < >> + rdreg->base) >> + return false; >> + } >> >> - /* Both base addresses must be set to check if they overlap */ >> - if (IS_VGIC_ADDR_UNDEF(d->vgic_dist_base) || !rdreg) >> + if (IS_VGIC_ADDR_UNDEF(d->vgic_dist_base)) >> return true; >> >> - if (d->vgic_dist_base + KVM_VGIC_V3_DIST_SIZE <= rdreg->base) >> - return true; >> - >> - if (rdreg->base + redist_size <= d->vgic_dist_base) >> - return true; >> - >> - return false; >> + return !vgic_v3_rdist_overlap(kvm, d->vgic_dist_base, >> + KVM_VGIC_V3_DIST_SIZE); >> } >> >> /** >> -- >> 2.5.5 >> > Otherwise this patch looks correct to me. > > Thanks, > -Christoffer >