Received: by 10.213.65.68 with SMTP id h4csp693362imn; Tue, 27 Mar 2018 07:06:52 -0700 (PDT) X-Google-Smtp-Source: AG47ELt8vPNHrs7RBA0RYQffDyOwYYbdm3I88kEKP6/NKjYBEQZGJUfBDAkXwwKGwGKXMedH1/LS X-Received: by 2002:a17:902:3381:: with SMTP id b1-v6mr27168099plc.214.1522159612846; Tue, 27 Mar 2018 07:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522159612; cv=none; d=google.com; s=arc-20160816; b=cXIGhOvNLnBQ1/qmMNlW14S++8ytyCkXtv4HAet1ZXC9n4Pj8gCNA/B1rjzmQIUo2G sP3GNrdZImXRVp+jVP9mknt5NctdMb7GcKqPNG8+Z8x47TxHJJVDRvMWZ/5cdX1S/n+N IWsUwV3lrGhc469a3OMB6oXWu9xf1+FJHa913uMKfvyWAJmpHD2r1VExBdmpl0BLkNmF np5svkKQHSfNBPmTBJFw7aARgPrpUo+ix1LttMxTMRZZPeT+xki8qCLZU8nVYx9wuOKX cb37ebxC/jXLC/F1ksqJfa83HSG3/wHzjDUMoSC9FpSp4GL31lDLChjA26JEKApWH3d1 5qZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=UpqKEbxDRDffZqJ57KlPuEjqYuzcxzC7QdfcvsYMz7Q=; b=pb7Vl3efA6JSCChn/AB5D4mrqhPaZzhS9IFkuXAplytsAxa8SX5Q3IBHVVtgcrlais VOcSejI6AV5lVGTK2FastfFOesBQ8krcW4LowAV8YVyNo4ZVM+frTA2r3NwhMdgFkwyS U84wBYqS3NraBas1Tuc+e60hFExyBbcoXqoQFFQvHX1ciqJVzJ07f7UXl4qYBbJHR7Ix XG5Oi3RaaIaVHC8JASEW2HdbG9iL//wHYnv/XRxSL+Q2w3deSJzUgaxJ43TRiG50xcMm PGH6j/Z4ULQeKNrlcZYtRjeTEoWSbc6F8bGfZYM1wgfidVncJGFDqaisyXn4MCfw2rUL Kt3Q== 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 h126si894655pgc.817.2018.03.27.07.06.37; Tue, 27 Mar 2018 07:06:52 -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 S1753104AbeC0OEr (ORCPT + 99 others); Tue, 27 Mar 2018 10:04:47 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:52994 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752963AbeC0OEk (ORCPT ); Tue, 27 Mar 2018 10:04:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D91574072CF7; Tue, 27 Mar 2018 14:04:39 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-135.ams2.redhat.com [10.36.116.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4B50215CDB5; Tue, 27 Mar 2018 14:04:37 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.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 Cc: andre.przywara@arm.com, drjones@redhat.com, wei@redhat.com Subject: [RFC v2 07/12] KVM: arm/arm64: Adapt vgic_v3_check_base to multiple rdist regions Date: Tue, 27 Mar 2018 16:04:11 +0200 Message-Id: <1522159456-10419-8-git-send-email-eric.auger@redhat.com> In-Reply-To: <1522159456-10419-1-git-send-email-eric.auger@redhat.com> References: <1522159456-10419-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 27 Mar 2018 14:04:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 27 Mar 2018 14:04:39 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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 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. 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 9a19129..993939d 100644 --- a/virt/kvm/arm/vgic/vgic-v3.c +++ b/virt/kvm/arm/vgic/vgic-v3.c @@ -426,31 +426,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