From patchwork Mon Feb 16 14:50:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 44717 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CBC1C21544 for ; Mon, 16 Feb 2015 14:53:30 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id r20sf16028812wiv.3 for ; Mon, 16 Feb 2015 06:53:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=bbqhNPA3x5L3qMkPPHmnSXx1/m/p2ZgyA8oX3i8pjfI=; b=l4kBDKsMdMjhl4vybDFr+tN272pSDac3jDK2wHl/YIdpCWT4UxayYyF+4/rGb14O1R Rm1Qfm4s011gytrxvMnw5yzIrvcpjh/tVpzJTjTB2/mbg3ZgxvUO8XTH82fKq1VeDrVI q3aobowcLNHClesLne0v0qzW62CFXqfgqTnUX14Fqzi2I09KRFie9PpSsrDoc9YgaFZE tdh5uYDKgNJ74mu0y3w75U3q5U8sYoOVXONCaArLqJWAaA+jkFUvrpgUAeg9INCx+mf2 reW/2NzWlVDqI9wNCDOrvjTcRSUvULpOG/EykcmxglhRjJtw4sZ2k6fn8YCr61sTcXSq ktxQ== X-Gm-Message-State: ALoCoQlKiEJCd2Zpcz6utj1ZkYlSSwxVDpZXio/8z5XA0qZotC05SmKZRGXkuRhClNN391lQnbt/ X-Received: by 10.152.26.74 with SMTP id j10mr2986824lag.10.1424098410129; Mon, 16 Feb 2015 06:53:30 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.70 with SMTP id be6ls576355lab.41.gmail; Mon, 16 Feb 2015 06:53:29 -0800 (PST) X-Received: by 10.112.39.69 with SMTP id n5mr20390293lbk.1.1424098409919; Mon, 16 Feb 2015 06:53:29 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id n20si7513471lbl.99.2015.02.16.06.53.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Feb 2015 06:53:29 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by labpv20 with SMTP id pv20so29050064lab.8 for ; Mon, 16 Feb 2015 06:53:29 -0800 (PST) X-Received: by 10.112.37.197 with SMTP id a5mr23070213lbk.19.1424098409831; Mon, 16 Feb 2015 06:53:29 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1629825lbj; Mon, 16 Feb 2015 06:53:28 -0800 (PST) X-Received: by 10.140.86.233 with SMTP id p96mr1472949qgd.49.1424098405936; Mon, 16 Feb 2015 06:53:25 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id a10si6463500qac.24.2015.02.16.06.53.24 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 16 Feb 2015 06:53:25 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YNN1O-0001eQ-Iy; Mon, 16 Feb 2015 14:51:38 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YNN1M-0001bz-Dm for xen-devel@lists.xenproject.org; Mon, 16 Feb 2015 14:51:36 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 57/C3-03164-7F302E45; Mon, 16 Feb 2015 14:51:35 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-10.tower-31.messagelabs.com!1424098294!11972469!1 X-Originating-IP: [209.85.212.175] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9558 invoked from network); 16 Feb 2015 14:51:35 -0000 Received: from mail-wi0-f175.google.com (HELO mail-wi0-f175.google.com) (209.85.212.175) by server-10.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 16 Feb 2015 14:51:35 -0000 Received: by mail-wi0-f175.google.com with SMTP id r20so26581089wiv.2 for ; Mon, 16 Feb 2015 06:51:34 -0800 (PST) X-Received: by 10.194.110.137 with SMTP id ia9mr51932852wjb.153.1424098293379; Mon, 16 Feb 2015 06:51:33 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id dj5sm23172398wjb.28.2015.02.16.06.51.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Feb 2015 06:51:32 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 16 Feb 2015 14:50:46 +0000 Message-Id: <1424098255-22490-7-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1424098255-22490-1-git-send-email-julien.grall@linaro.org> References: <1424098255-22490-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Vijaya.Kumar@caviumnetworks.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v3 06/15] xen/arm: vgic-v3: Set stride during domain initialization X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: The stride may not be set if the hardware GIC is using the default layout. It happens on the Foundation model. On GICv3, the default stride is 2 * 64K. Therefore it's possible to avoid checking at every redistributor MMIO access if the stride is not set. Because domU uses a static stride configuration this only happens for dom0, so we can move this code in gicv_v3_init. Take the opportunity to move the stride setting a bit earlier because the loop to set regions will require the stride. Also, use 2 * 64K rather than 128K and explain the reason. Signed-off-by: Julien Grall --- I wasn't not sure where to move this code. I find very confusion the splitting between vgic and gicv. Maybe we should introduce a hwdom_gicv_init and giccc_map callbacks. Then move most of the initialization in the vgic one. Changes in v3: - Fix typoes and update commit message - Forgot to remove the check on the stride the rdist write Changes in v2: - Patch added --- xen/arch/arm/gic-v3.c | 11 ++++++++++- xen/arch/arm/vgic-v3.c | 12 ++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index 47452ca..7b33ff7 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -897,12 +897,21 @@ static int gicv_v3_init(struct domain *d) { d->arch.vgic.dbase = gicv3.dbase; d->arch.vgic.dbase_size = gicv3.dbase_size; + + d->arch.vgic.rdist_stride = gicv3.rdist_stride; + /* + * If the stride is not set, the default stride for GICv3 is 2 * 64K: + * - first 64k page for Control and Physical LPIs + * - second 64k page for Control and Generation of SGIs + */ + if ( !d->arch.vgic.rdist_stride ) + d->arch.vgic.rdist_stride = 2 * SZ_64K; + for ( i = 0; i < gicv3.rdist_count; i++ ) { d->arch.vgic.rbase[i] = gicv3.rdist_regions[i].base; d->arch.vgic.rbase_size[i] = gicv3.rdist_regions[i].size; } - d->arch.vgic.rdist_stride = gicv3.rdist_stride; d->arch.vgic.rdist_count = gicv3.rdist_count; } else diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index 2c14717..c5a743a 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -625,11 +625,7 @@ static int vgic_v3_rdistr_mmio_read(struct vcpu *v, mmio_info_t *info) perfc_incr(vgicr_reads); - if ( v->domain->arch.vgic.rdist_stride != 0 ) - offset = info->gpa & (v->domain->arch.vgic.rdist_stride - 1); - else - /* If stride is not set. Default 128K */ - offset = info->gpa & (SZ_128K - 1); + offset = info->gpa & (v->domain->arch.vgic.rdist_stride - 1); if ( offset < SZ_64K ) return __vgic_v3_rdistr_rd_mmio_read(v, info, offset); @@ -649,11 +645,7 @@ static int vgic_v3_rdistr_mmio_write(struct vcpu *v, mmio_info_t *info) perfc_incr(vgicr_writes); - if ( v->domain->arch.vgic.rdist_stride != 0 ) - offset = info->gpa & (v->domain->arch.vgic.rdist_stride - 1); - else - /* If stride is not set. Default 128K */ - offset = info->gpa & (SZ_128K - 1); + offset = info->gpa & (v->domain->arch.vgic.rdist_stride - 1); if ( offset < SZ_64K ) return __vgic_v3_rdistr_rd_mmio_write(v, info, offset);