From patchwork Tue Sep 4 19:21:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 145951 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4051976ljw; Tue, 4 Sep 2018 12:24:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZmJkL52nRTIbI1i5Iwaf/I8m0PuemVCK36Fib2+ln+z5chIoDbtAlHqwMZnbI1f75laDX5 X-Received: by 2002:ab0:60ae:: with SMTP id f14-v6mr18461434uam.153.1536089080624; Tue, 04 Sep 2018 12:24:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536089080; cv=none; d=google.com; s=arc-20160816; b=Dx4TP5T7kctv5uzy3Yk3PSYUbmC8GzqSm1Q1M4HhR8GgRoTym4CloPSwEF9rrYzxCC RYn/sWs3w15wBktUZiVLbtOSjUhCG+5llSeiiDfh5fuXccdGx1NJsBtlZunTCqlAU22Q K9JUlOBtvfvG0hLl0t3MDEYr8S3ImkQKtmYnamm3wrWZA05i7wrti3tD/ghSifwA7ULK 6N2tDIXvjMXQOu0E/CHel+aMayzElKB465UiIcc3Y84CQiR3Zf6vS0xhgN/3LuEvInoO lIVtH4CRyYOCsRCJFXY3hMTg3Po3I3AvTQUDiUJBIDNLeU9Pto8OBFBSPZmMjchpp38s I7og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :arc-authentication-results; bh=X3nev+kZEwz/YlV+F/miqOHY7iNLKGJ/Xe94JIVJIBk=; b=LvWZzggY8zeHC2W9fvdTHx8qC9zizvPAzNHOAzduhyDre6CInu7ADXWrpSe2tzTqPw pZPtgVP9nItsjS6f4VK/qbs3tmcoicG5LR9+ivW+5VwhVOpxJDwIxw2M8StYrTAMa4vA VhJ1mptcJbXS6gT8dfblOVZ/CWgZgvtuqyaHr1v7bSfo80CJzZHE1VS4cak8EjmxHoQr wCbovhZOalonIJytglv9rwhJPfHw7vJthpu7PhxWxyzNQGe3A/lA8Jxy+38ENuxu8iDj Nc7GZ6YBUZiXU9RG6UmF2TA0Mcq+yEJVgkVTW59TnnP3KxiEALNL8KYP7KEYxLuYA8qh PEsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id i189-v6si7073688vkc.178.2018.09.04.12.24.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Sep 2018 12:24:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1fxGtp-0005Qs-LS; Tue, 04 Sep 2018 19:22:05 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1fxGto-0005QW-2O for xen-devel@lists.xenproject.org; Tue, 04 Sep 2018 19:22:04 +0000 X-Inumbo-ID: 931407a2-b077-11e8-a8a5-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 931407a2-b077-11e8-a8a5-bc764e045a96; Tue, 04 Sep 2018 21:20:25 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0CE3B15AD; Tue, 4 Sep 2018 12:22:03 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.emea.arm.com [10.4.12.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F24263F575; Tue, 4 Sep 2018 12:22:01 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 4 Sep 2018 20:21:52 +0100 Message-Id: <20180904192153.17210-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180904192153.17210-1-julien.grall@arm.com> References: <20180904192153.17210-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 2/3] xen/arm: vgic-v3: Don't create empty re-distributor regions X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org, shameerali.kolothum.thodi@huawei.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the moment, Xen is assuming the hardware domain will have the same number of re-distributor regions as the host. However, as the number of CPUs or the stride (e.g on GICv4) may be different we end up exposing regions which does not contain any re-distributors. When booting, Linux will go through all the re-distributor region to check whether a property (e.g vPLIs) is available accross all the re-distributors. This will result to a data abort on empty regions because there are no underlying re-distributor. So we need to limit the number of regions exposed to the hardware domain. The code reworked to only expose the minimun number of regions required by the hardware domain. It is assumed the regions will be populated starting from the first one. Reported-by: Shameerali Kolothum Thodi Signed-off-by: Julien Grall --- xen/arch/arm/gic-v3.c | 10 ++++++++-- xen/arch/arm/vgic-v3.c | 11 +++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index b2ed0f8b55..4a984cfb12 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1274,8 +1274,10 @@ static int gicv3_make_hwdom_dt_node(const struct domain *d, * GIC has two memory regions: Distributor + rdist regions * CPU interface and virtual cpu interfaces accessesed as System registers * So cells are created only for Distributor and rdist regions + * The hardware domain may not used all the regions. So only copy + * what is necessary. */ - new_len = new_len * (gicv3.rdist_count + 1); + new_len = new_len * (d->arch.vgic.nr_regions + 1); hw_reg = dt_get_property(gic, "reg", &len); if ( !hw_reg ) @@ -1503,7 +1505,11 @@ static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset) /* Add Generic Redistributor */ size = sizeof(struct acpi_madt_generic_redistributor); - for ( i = 0; i < gicv3.rdist_count; i++ ) + /* + * The hardware domain may not used all the regions. So only copy + * what is necessary. + */ + for ( i = 0; i < d->arch.vgic.nr_regions; i++ ) { gicr = (struct acpi_madt_generic_redistributor *)(base_ptr + table_len); gicr->header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR; diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index df1bab3a35..9f729862da 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -1695,8 +1695,19 @@ static int vgic_v3_real_domain_init(struct domain *d) d->arch.vgic.rdist_regions[i].first_cpu = first_cpu; first_cpu += size / GICV3_GICR_SIZE; + + if ( first_cpu >= d->max_vcpus ) + break; } + /* + * The hardware domain may not used all the re-distributors + * regions (e.g when the number of vCPUs does not match the + * number of pCPUs). Update the number of regions to avoid + * exposing unused region as they will not get emulated. + */ + d->arch.vgic.nr_regions = i + 1; + d->arch.vgic.intid_bits = vgic_v3_hw.intid_bits; } else