From patchwork Wed Dec 7 12:33:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 87088 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp291030qgi; Wed, 7 Dec 2016 04:36:03 -0800 (PST) X-Received: by 10.107.134.38 with SMTP id i38mr3592605iod.126.1481114162971; Wed, 07 Dec 2016 04:36:02 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id l1si17309067iof.242.2016.12.07.04.36.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Dec 2016 04:36:02 -0800 (PST) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.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 1cEbQM-0006FG-Dq; Wed, 07 Dec 2016 12:34:14 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cEbQL-0006D5-4y for xen-devel@lists.xen.org; Wed, 07 Dec 2016 12:34:13 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id B4/85-23231-4C108485; Wed, 07 Dec 2016 12:34:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTfcwo0e EwfdJ+hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aB/lOsBRv4Kz60VzQwfubuYuTiEBLYxCjx 9PxadgjnNKPEhgM/gRxODjYBTYk7nz8xgdgiAtIS1z5fZgSxmQUcJN58vMcCYgsLJEqcO/aUG cRmEVCVuP2vA6yeV8BVonfFLbB6CQE5iZPHJrOC2JxA8Vtf/4L1Cgm4SHxtWsYygZF7ASPDKk b14tSistQiXWO9pKLM9IyS3MTMHF1DA2O93NTi4sT01JzEpGK95PzcTYxA7zIAwQ7G5i9Ohxg lOZiURHl3TXCPEOJLyk+pzEgszogvKs1JLT7EKMPBoSTBu4jBI0JIsCg1PbUiLTMHGGYwaQkO HiUR3n3/gVp5iwsSc4sz0yFSpxgVpcR5OYDBKSQAksgozYNrg4X2JUZZKWFeRqBDhHgKUotyM 0tQ5V8xinMwKgnz/gbZzpOZVwI3/RXQYiagxfNugC0uSURISTUwznW4dPqix3Uex+bvnuJxa7 ve/mTeyFoS+STz6IHaSWtttoSfULzfc19M79W9laqrFiSfCN1hJdy8N0E/+eeP8EPlK4quvJy 4KusLX/PjK1cu7xF81vZmF1/Sp+hOW9m5WjsXre15OPWv0byqHTebTPYc040slX3IJ9m2sqXq 48bbLLc7NIt2NCmxFGckGmoxFxUnAgBUInOcaAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1481114051!16829737!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15942 invoked from network); 7 Dec 2016 12:34:11 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-31.messagelabs.com with SMTP; 7 Dec 2016 12:34:11 -0000 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 03FA0707; Wed, 7 Dec 2016 04:34:11 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.218.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 665593F477; Wed, 7 Dec 2016 04:34:10 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 7 Dec 2016 12:33:52 +0000 Message-Id: <1481114033-11024-13-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1481114033-11024-1-git-send-email-julien.grall@arm.com> References: <1481114033-11024-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH 12/13] xen/arm: vgic-v3: Move the emulation of ICC_SGI1R_EL1 in a separate helper X-BeenThere: xen-devel@lists.xen.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.xen.org Sender: "Xen-devel" The emulation of the co-processor register ICC_SGI1R is the same as the system register ICC_SGI1R_EL1. So move the emulation outside and use the newly introduced helper vreg_emulate_sysreg64 to abstract the access. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/vgic-v3.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index f3f0bd2..f23135d 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -31,6 +31,7 @@ #include #include #include +#include /* * PIDR2: Only bits[7:4] are not implementation defined. We are @@ -1300,9 +1301,21 @@ static bool vgic_v3_to_sgi(struct vcpu *v, register_t sgir) return vgic_to_sgi(v, sgir, sgi_mode, virq, &target); } +static bool vgic_v3_emulate_sgi1r(struct cpu_user_regs *regs, uint64_t *r, + bool read) +{ + /* WO */ + if ( !read ) + return vgic_v3_to_sgi(current, *r); + else + { + gdprintk(XENLOG_WARNING, "Reading SGI1R_EL1 - WO register\n"); + return false; + } +} + static bool vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr) { - struct vcpu *v = current; struct hsr_sysreg sysreg = hsr.sysreg; ASSERT (hsr.ec == HSR_EC_SYSREG); @@ -1315,14 +1328,8 @@ static bool vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr) switch ( hsr.bits & HSR_SYSREG_REGS_MASK ) { case HSR_SYSREG_ICC_SGI1R_EL1: - /* WO */ - if ( !sysreg.read ) - return vgic_v3_to_sgi(v, get_user_reg(regs, sysreg.reg)); - else - { - gprintk(XENLOG_WARNING, "Reading SGI1R_EL1 - WO register\n"); - return false; - } + return vreg_emulate_sysreg64(regs, hsr, vgic_v3_emulate_sgi1r); + default: return false; }