From patchwork Fri Mar 9 15:11:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 131148 Delivered-To: patch@linaro.org Received: by 10.80.194.209 with SMTP id u17csp1135544edf; Fri, 9 Mar 2018 07:14:07 -0800 (PST) X-Google-Smtp-Source: AG47ELtXjZqUED0wGs26D5ScYoOZEhQIrP8ffm1g0jR9uFRazsazTqHRNILIoolabdpYhwjZ+mt2 X-Received: by 2002:a24:378f:: with SMTP id r137-v6mr3805135itr.151.1520608447754; Fri, 09 Mar 2018 07:14:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520608447; cv=none; d=google.com; s=arc-20160816; b=wGIRDzJO8HY0KNKfjHjfFtROQxY0GRFn41yuNtjyFDNAASOGOUbGFz0zCZPhcKNz/R N1/8t64iqd7HuNPFuAsXen0YEcN7kXmRvVDAJay/juA3VArriY8PRGPS0rGWs3X+EWvS PzGjS5JxN3i1CFfcc82v5gevANHjy07DgVyGioSBWJZZJ2CvBDdClrr/UcXXO7FFmDxE 6Wj2mi4DRH3HLlhe4rqnBIxRPHCReI/Nk/nE2YCVJF/DMK3psyyryqQQfqUGYhATm6SS Ba21sTI2S+fFwstbTBP7E74t2illzf2xWUV2i6pVKenLvC+F0d9BHoAqD3poroNDtIsj PUrg== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=B7i6iLooQeaufqgJZHEy8g+JUU06k7eIpOr2HN0lIbU=; b=erYcbE87H52hpOxzw4scZRnkqAHnUye36nbJK6fTDOFuDf78wZqq44NvDtRkfw0zUC ZIn4afIr7lW6YRK32tZ6eEyyoPn1bCX49d238gDD0z27N/nIkXpTTFex+vIahnCjhcjk LPjLGLV+dnnL2ZNDb35RyPmQV6swNwOCWmqnlzT+0Ad9zJWBIg1LajC2zOFGC4NK+/ai bEwA8+Mgsg4LA1BxIjaFg1z56PxK+5rIRJpPw2Q1e8ehtHd9wSgAQAczfi/jp7Vf5ec2 8FecSkE6Um+UgBXR+ayQGN/j5E78AtGooAZYk6gQfoGEmig6lXoSXyf0ca6RlPD0gebM eWwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YuOYb2pk; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id h186si1294229ite.120.2018.03.09.07.14.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 07:14:07 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YuOYb2pk; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1euJgT-0005pc-Hk; Fri, 09 Mar 2018 15:11:49 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1euJgS-0005pD-Lf for xen-devel@lists.xenproject.org; Fri, 09 Mar 2018 15:11:48 +0000 X-Inumbo-ID: 046a333e-23ac-11e8-ba59-bc764e045a96 Received: from mail-wr0-x242.google.com (unknown [2a00:1450:400c:c0c::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 046a333e-23ac-11e8-ba59-bc764e045a96; Fri, 09 Mar 2018 16:10:35 +0100 (CET) Received: by mail-wr0-x242.google.com with SMTP id v18so9340805wrv.0 for ; Fri, 09 Mar 2018 07:11:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5rf0DZRXfQYkfOVKisBs6qRjE6Ppw/uZhP1tWnw4+Eo=; b=YuOYb2pkboFUNYtz2jQpzMCGVRZx53wlHhUa1rtSerxnTvrSBpJ8kjrk+qT0yApSob JfOCiM44EZv442qu3w8jDJPug86kkPW6W5ikY4jg0upwMzQ8Xc3KMvot+CZ0wb3eCPSx w6GyffepFDFwh3e6nt1z07PUG9LODd2Rx1qPY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5rf0DZRXfQYkfOVKisBs6qRjE6Ppw/uZhP1tWnw4+Eo=; b=TBRQKz6lh/lVC45asJiUmwNXJl60Rsjwq+XezF3h7rJ5eaYmNULX5CdrEzOcKQ2bk1 U+xOY11f8vTgI6vPIxgNT4DtNQfq/50OitKVsQFdUvovyd1Up1wK2LsYLQD4QsUM3PBs Mi5Ph6xPd7W5OTKb0yTsTbO/TDHr4kvTXX6JAW36Hd2m2NZgcjLdMDEKVAm+FeWWpZpv uuX7StwYgC7DFSKoWWRDaEwX5XFGsSkkzKsSdW6MXL2tr99UNiqoxclErXLvyPNIOeww 87fW5P/Tf/5K9bzF4tiXwn6AhJlUkglAFJJkKJyWevgeLmHj+KhX/KIBkOMsdriQRfwk NvgA== X-Gm-Message-State: APf1xPCNa/6Lq+NHgMtyYx1rNiBcdNm6GyXQcJwG2o7rHJl/Pm73Bvj+ 5IGYzEx/dKxXQ2Bsybz8PSgrCRfS5oc= X-Received: by 10.223.176.13 with SMTP id f13mr27973554wra.231.1520608306494; Fri, 09 Mar 2018 07:11:46 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id 1sm1721198wmj.35.2018.03.09.07.11.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Mar 2018 07:11:46 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Fri, 9 Mar 2018 15:11:19 +0000 Message-Id: <20180309151133.31371-4-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180309151133.31371-1-andre.przywara@linaro.org> References: <20180309151133.31371-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH 03/17] ARM: vGICv3: always use architected redist stride X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The redistributor-stride property in a GICv3 DT node is only there to cover broken platforms where this value deviates from the architected one. Since we emulate the GICv3 distributor even for Dom0, we don't need to copy the broken behaviour. All the special handling for Dom0s using GICv3 is just for using the hardware's memory map, which is unaffected by the redistributor stride - it can never be smaller than the architected two pages. Remove the redistributor-stride property from Dom0's DT node and also remove the code that tried to reuse the hardware value for Dom0's GICv3 emulation. Signed-off-by: Andre Przywara Acked-by: Julien Grall --- Changelog: - merge in GICV3_GICR_SIZE definition xen/arch/arm/gic-v3.c | 4 ---- xen/arch/arm/vgic-v3.c | 14 ++++++-------- xen/include/asm-arm/gic_v3_defs.h | 5 +++++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index b1f8a86409..047af691b1 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1162,10 +1162,6 @@ static int gicv3_make_hwdom_dt_node(const struct domain *d, if ( res ) return res; - res = fdt_property_cell(fdt, "redistributor-stride", gicv3.rdist_stride); - if ( res ) - return res; - res = fdt_property_cell(fdt, "#redistributor-regions", gicv3.rdist_count); if ( res ) return res; diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index d5b34a7d0f..56cc38ffcc 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -1024,10 +1024,9 @@ static struct vcpu *get_vcpu_from_rdist(struct domain *d, paddr_t gpa, uint32_t *offset) { struct vcpu *v; - uint32_t stride = d->arch.vgic.rdist_stride; unsigned int vcpu_id; - vcpu_id = region->first_cpu + ((gpa - region->base) / stride); + vcpu_id = region->first_cpu + ((gpa - region->base) / GICV3_GICR_SIZE); if ( unlikely(vcpu_id >= d->max_vcpus) ) return NULL; @@ -1586,7 +1585,6 @@ static int vgic_v3_vcpu_init(struct vcpu *v) /* Convenient alias */ struct domain *d = v->domain; - uint32_t rdist_stride = d->arch.vgic.rdist_stride; /* * Find the region where the re-distributor lives. For this purpose, @@ -1602,11 +1600,11 @@ static int vgic_v3_vcpu_init(struct vcpu *v) /* Get the base address of the redistributor */ rdist_base = region->base; - rdist_base += (v->vcpu_id - region->first_cpu) * rdist_stride; + rdist_base += (v->vcpu_id - region->first_cpu) * GICV3_GICR_SIZE; /* Check if a valid region was found for the re-distributor */ if ( (rdist_base < region->base) || - ((rdist_base + rdist_stride) > (region->base + region->size)) ) + ((rdist_base + GICV3_GICR_SIZE) > (region->base + region->size)) ) { dprintk(XENLOG_ERR, "d%u: Unable to find a re-distributor for VCPU %u\n", @@ -1622,7 +1620,7 @@ static int vgic_v3_vcpu_init(struct vcpu *v) * VGIC_V3_RDIST_LAST flags. * Note that we are assuming max_vcpus will never change. */ - last_cpu = (region->size / rdist_stride) + region->first_cpu - 1; + last_cpu = (region->size / GICV3_GICR_SIZE) + region->first_cpu - 1; if ( v->vcpu_id == last_cpu || (v->vcpu_id == (d->max_vcpus - 1)) ) v->arch.vgic.flags |= VGIC_V3_RDIST_LAST; @@ -1693,7 +1691,7 @@ static int vgic_v3_domain_init(struct domain *d) /* Set the first CPU handled by this region */ d->arch.vgic.rdist_regions[i].first_cpu = first_cpu; - first_cpu += size / d->arch.vgic.rdist_stride; + first_cpu += size / GICV3_GICR_SIZE; } d->arch.vgic.intid_bits = vgic_v3_hw.intid_bits; @@ -1708,7 +1706,7 @@ static int vgic_v3_domain_init(struct domain *d) d->arch.vgic.rdist_stride = GUEST_GICV3_RDIST_STRIDE; /* The first redistributor should contain enough space for all CPUs */ - BUILD_BUG_ON((GUEST_GICV3_GICR0_SIZE / GUEST_GICV3_RDIST_STRIDE) < MAX_VIRT_CPUS); + BUILD_BUG_ON((GUEST_GICV3_GICR0_SIZE / GICV3_GICR_SIZE) < MAX_VIRT_CPUS); d->arch.vgic.rdist_regions[0].base = GUEST_GICV3_GICR0_BASE; d->arch.vgic.rdist_regions[0].size = GUEST_GICV3_GICR0_SIZE; d->arch.vgic.rdist_regions[0].first_cpu = 0; diff --git a/xen/include/asm-arm/gic_v3_defs.h b/xen/include/asm-arm/gic_v3_defs.h index 65c9dc47cf..bb34d17eca 100644 --- a/xen/include/asm-arm/gic_v3_defs.h +++ b/xen/include/asm-arm/gic_v3_defs.h @@ -18,6 +18,8 @@ #ifndef __ASM_ARM_GIC_V3_DEFS_H__ #define __ASM_ARM_GIC_V3_DEFS_H__ +#include + /* * Additional registers defined in GIC v3. * Common GICD registers are defined in gic.h @@ -68,6 +70,9 @@ #define GICV3_GICD_IIDR_VAL 0x34c #define GICV3_GICR_IIDR_VAL GICV3_GICD_IIDR_VAL +/* Two pages for the RD_base and SGI_base register frame. */ +#define GICV3_GICR_SIZE (2 * SZ_64K) + #define GICR_CTLR (0x0000) #define GICR_IIDR (0x0004) #define GICR_TYPER (0x0008)