Received: by 10.192.165.156 with SMTP id m28csp427123imm; Fri, 13 Apr 2018 01:26:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+vxmouL3Ne0W8c6R+fL8F6Nk1AMRUD56aFKegJfRMCbYTP7t7xP1apaCKHM+Q1mYpR5UtW X-Received: by 2002:a17:902:830b:: with SMTP id bd11-v6mr4314816plb.13.1523608009511; Fri, 13 Apr 2018 01:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523608009; cv=none; d=google.com; s=arc-20160816; b=Vj+merbINfV2+TK36/Kht/sXj2fWmnkIWUTzOZXAQpe7c34VCvopf797X+y4XmUdsw 8vcalD5zaa3Wt0tiwNhTUDKl5/YDqVveQ0Tj/fiYtZX7JgLkk2fsAOD4hnsPy6FO4jSf 7YEArD2/GmD4Q2I20egQT5zm9PtVNShmUj3B2Q2Wi91hlgCUgdDQxoDKRmtWlVH6J4vb xv+MKvfVskvSB/AiQzmS5Lbx6YHDLqEwUMsIim5Gp7j25P6xT3nC49fnjy5EcpQBuX1t FSy+6p0mmoshQm30kHbRTmVNEDhydBICK1fqRwbQ78ojRo1qlyFoUUCw86EfQaYDuszE EDKA== 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=ve1HaXtZfHuLtdSIyAIz5E4LtDrhbzuTOj3ZCVG14gI=; b=NqU7Sx4SMOkSJqINpyHpoWPB9ur29rgkmGi1NgOYaUZL6ZtGJhqWHRwD0mFkzrbJ8j 1MFSXZZSP6PcdpyXr1Ir0DbxFOBTFEMsCfIjiSk1b5suIfHahUd8GwFzrcEskIiSjJY0 CY9F5pj+DdJf3btzxdTiJW1gWkWHYedJ+BEc/wCdDTrsjgnFaFnONGi72BJvcBpq7Bol X+tYHGmxGnOUDHrYKCS84w1KQO44n4iHbx0zueClb4gsOQngQFCqFRFBXMx7kmsuAmyZ 0C8wx3LouOpMvpd0Tg8Dy7WBLELLY6DnU/OOgPvbS4pl1s/HJu+WGI6R5b78d/uuEqlO YZ6g== 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 v9-v6si4986570plp.614.2018.04.13.01.26.35; Fri, 13 Apr 2018 01:26:49 -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 S1754040AbeDMIYA (ORCPT + 99 others); Fri, 13 Apr 2018 04:24:00 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46942 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753459AbeDMIVU (ORCPT ); Fri, 13 Apr 2018 04:21:20 -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 D35BB8DC32; Fri, 13 Apr 2018 08:21:19 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-192.ams2.redhat.com [10.36.116.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFDBA215CDC8; Fri, 13 Apr 2018 08:21:17 +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: [PATCH v3 07/12] KVM: arm/arm64: Adapt vgic_v3_check_base to multiple rdist regions Date: Fri, 13 Apr 2018 10:20:53 +0200 Message-Id: <1523607658-9166-8-git-send-email-eric.auger@redhat.com> In-Reply-To: <1523607658-9166-1-git-send-email-eric.auger@redhat.com> References: <1523607658-9166-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.2]); Fri, 13 Apr 2018 08:21:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 13 Apr 2018 08:21:19 +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 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