From patchwork Mon Feb 16 14:50:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 44713 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 6A5E321544 for ; Mon, 16 Feb 2015 14:53:06 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id r20sf16027064wiv.3 for ; Mon, 16 Feb 2015 06:53:05 -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=nWWXyH9KQa2eYmVeYv8ANzNd5GWbwCOuQX2OxrJbx5U=; b=PdueCHHDkaMTZ78PnNDE/LT58kiHfho2ZQbkKZ6HADZznQ04nalXsxM2wDYUK7jL8c f3cP+oh4WacpV+29TPC3REZeiPmUSlftyDTYrHxi0APyrqSUzYb3dEy4qYcuJd8GZKFa t+RMYTphL8RS8QoCyiEXx0T1eOud66nbTm/KRi1MOgdZAw267btalY/WAuMSwbV40dC2 UD3B8JU+PBwM59J69mf8Nn1y5s3POJdN05BOOCEgMwRw6ReeuOjhNCZb4PetWpKxqGGq Y8zNcpoyYdWYOiUwmIjfHcTgIC+gQvoY+OvG7dBuMdcAbiC55AkfsAErr0KsDWAkoabD Gwlg== X-Gm-Message-State: ALoCoQnEAP4fWsm71pJvre230+0UBuJfOL5oYQzKPRdjuBOhiTjknmUmHRVpG4zmt0/9N2Tks428 X-Received: by 10.180.72.44 with SMTP id a12mr2013615wiv.0.1424098385652; Mon, 16 Feb 2015 06:53:05 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.74 with SMTP id j10ls581730lag.7.gmail; Mon, 16 Feb 2015 06:53:05 -0800 (PST) X-Received: by 10.112.73.104 with SMTP id k8mr22401060lbv.120.1424098385472; Mon, 16 Feb 2015 06:53:05 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id o6si7773707lbw.88.2015.02.16.06.53.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Feb 2015 06:53:05 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lams18 with SMTP id s18so29319387lam.13 for ; Mon, 16 Feb 2015 06:53:05 -0800 (PST) X-Received: by 10.112.14.196 with SMTP id r4mr19637862lbc.86.1424098385362; Mon, 16 Feb 2015 06:53:05 -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 h5csp1629596lbj; Mon, 16 Feb 2015 06:53:04 -0800 (PST) X-Received: by 10.229.201.1 with SMTP id ey1mr382677qcb.10.1424098383911; Mon, 16 Feb 2015 06:53:03 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id d6si14303817qcq.10.2015.02.16.06.53.02 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 16 Feb 2015 06:53:03 -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 1YNN1r-0002I6-Cs; Mon, 16 Feb 2015 14:52:07 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YNN1q-0002G2-1R for xen-devel@lists.xenproject.org; Mon, 16 Feb 2015 14:52:06 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id 00/1A-03004-51402E45; Mon, 16 Feb 2015 14:52:05 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-14.tower-21.messagelabs.com!1424098305!12213074!1 X-Originating-IP: [209.85.212.176] 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 18777 invoked from network); 16 Feb 2015 14:52:02 -0000 Received: from mail-wi0-f176.google.com (HELO mail-wi0-f176.google.com) (209.85.212.176) by server-14.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 16 Feb 2015 14:52:02 -0000 Received: by mail-wi0-f176.google.com with SMTP id h11so26543114wiw.3 for ; Mon, 16 Feb 2015 06:51:42 -0800 (PST) X-Received: by 10.180.79.1 with SMTP id f1mr35608587wix.24.1424098300685; Mon, 16 Feb 2015 06:51:40 -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.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Feb 2015 06:51:39 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 16 Feb 2015 14:50:51 +0000 Message-Id: <1424098255-22490-12-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 11/15] xen/arm: vgic-v2: Correctly handle RAZ/WI registers 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.46 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: All the GICv2 registers are word-accessible. Some them are also byte-accessible (see GICD_IPRIORITYR*). Those registers are incorrectly implemented when they should be RAZ. Only word-access size are currently allowed for them. To avoid further issues, introduce different label following the access-size of the registers: - read_as_zero_32 and write_ignore_32: Used for registers accessible via a word. - read_as_zero: Used when we don't have to check the access size. The latter is used when the access size has already been checked in the register emulation and/or when the register offset is reserved/implementation defined. Note that, only used labels has been introduced. Signed-off-by: Julien Grall --- This patch should be backported to Xen 4.4 and 4.5 as it fixes byte-access to GICD_ITARGET0. Although, this patch won't apply directly to Xen 4.4. Changes in v3: - Update commit message Changes in v2: - This patch replaces https://patches.linaro.org/43318/. A new approach has been taken to explicitly use the size in the goto label and have one version which don't check the access size. It's useful for reserved registers and register we already check the access size. --- xen/arch/arm/vgic-v2.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c index 5faef12..6530ecc 100644 --- a/xen/arch/arm/vgic-v2.c +++ b/xen/arch/arm/vgic-v2.c @@ -74,7 +74,7 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info) case GICD_IGROUPR ... GICD_IGROUPRN: /* We do not implement security extensions for guests, read zero */ - goto read_as_zero; + goto read_as_zero_32; case GICD_ISENABLER ... GICD_ISENABLERN: if ( dabt.size != DABT_WORD ) goto bad_width; @@ -166,7 +166,7 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info) case GICD_NSACR ... GICD_NSACRN: /* We do not implement security extensions for guests, read zero */ - goto read_as_zero; + goto read_as_zero_32; case GICD_SGIR: if ( dabt.size != DABT_WORD ) goto bad_width; @@ -226,8 +226,9 @@ bad_width: domain_crash_synchronous(); return 0; -read_as_zero: +read_as_zero_32: if ( dabt.size != DABT_WORD ) goto bad_width; +read_as_zero: *r = 0; return 1; } @@ -286,7 +287,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info) /* R/O -- write ignored */ case GICD_TYPER: case GICD_IIDR: - goto write_ignore; + goto write_ignore_32; /* Implementation defined -- write ignored */ case 0x020 ... 0x03c: @@ -294,7 +295,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info) case GICD_IGROUPR ... GICD_IGROUPRN: /* We do not implement security extensions for guests, write ignore */ - goto write_ignore; + goto write_ignore_32; case GICD_ISENABLER ... GICD_ISENABLERN: if ( dabt.size != DABT_WORD ) goto bad_width; @@ -360,7 +361,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info) case GICD_ITARGETSR ... GICD_ITARGETSR + 7: /* SGI/PPI target is read only */ - goto write_ignore; + goto write_ignore_32; case GICD_ITARGETSR + 8 ... GICD_ITARGETSRN: { @@ -433,10 +434,10 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info) return 1; case GICD_ICFGR: /* SGIs */ - goto write_ignore; + goto write_ignore_32; case GICD_ICFGR + 1: /* PPIs */ /* It is implementation defined if these are writeable. We chose not */ - goto write_ignore; + goto write_ignore_32; case GICD_ICFGR + 2 ... GICD_ICFGRN: /* SPIs */ if ( dabt.size != DABT_WORD ) goto bad_width; rank = vgic_rank_offset(v, 2, gicd_reg - GICD_ICFGR, DABT_WORD); @@ -448,7 +449,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info) case GICD_NSACR ... GICD_NSACRN: /* We do not implement security extensions for guests, write ignore */ - goto write_ignore; + goto write_ignore_32; case GICD_SGIR: if ( dabt.size != DABT_WORD ) goto bad_width; @@ -474,7 +475,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info) /* R/O -- write ignore */ case GICD_ICPIDR2: - goto write_ignore; + goto write_ignore_32; /* Implementation defined -- write ignored */ case 0xfec ... 0xffc: @@ -503,8 +504,9 @@ bad_width: domain_crash_synchronous(); return 0; -write_ignore: +write_ignore_32: if ( dabt.size != DABT_WORD ) goto bad_width; +write_ignore: return 1; }