From patchwork Mon Aug 14 14:24:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 110026 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp4282162obb; Mon, 14 Aug 2017 07:26:49 -0700 (PDT) X-Received: by 10.107.132.233 with SMTP id o102mr22300579ioi.214.1502720809738; Mon, 14 Aug 2017 07:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502720809; cv=none; d=google.com; s=arc-20160816; b=qFVSVCOvkARaYJu29MWyJtsPx0Ivy7Nt4PoYl1ASMy/5ZC2rP6YCGhViOtUkyDTMbi Qhxds78vF6lX3SnHm3YF6L9BdpbBLlVTwcd3J1c53peMQf/s2bPHALl0Es6pWIW8MImy +44ID21GL6SPDnXM6apU5Hh0x+rt3RPZgTJEAD9fOfJd5WkKBF+hKQJFSyU/mi9gLXyZ jefGRiERK7ilxoNxkyX8iOqD9fTTgIxQlZE06Pw9te0oo8eKvL37IOtwlkRXBGkyqRVm FCNbUR+pIT8TjKtXCs01PW3w5gArFlOXW9gnwpCPiHI+55DVeDyOV38iu1N8qUtl7slY Tm3A== 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:arc-authentication-results; bh=si/0J6OAeio+dBQ8noZePGwwmvW4kvOsB6+rcmOhX3Y=; b=WoKKnkgKVPJXxNzp7t/hj59fx/wgcFOKNamOaq5uWImhL5O8O6Pazz59zKALTLf3iP pwM/fDA/ZrsfDPVDtXRWprnu7UUtvXjS5Oz/uO8z79iNYsHbItG/Sqm2n5MXLEiiVCBz Llr6+4pLhQHPGNF93+SL0VN874SYefaLPwdDdlewCJBNBO2y3u6iyYdMiP7MdHKanQEP +65lKmZgNnOwMLijkzMIc5Hu+4hNBzGnNv3YWbqfXZdE8iuUzNLFIN3d1Vp3uIJlwoG7 LzZHWaI2fhUL1j2FYnt/dVDpILAUdZ5zQXEAJD1EkrVU6HbjC3g6lxEgOZw+a015CcBF Cu/Q== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id r81si5425371itc.28.2017.08.14.07.26.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Aug 2017 07:26:49 -0700 (PDT) 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 1dhGIW-0000Uz-Fx; Mon, 14 Aug 2017 14:24:52 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhGIV-0000Sa-6F for xen-devel@lists.xen.org; Mon, 14 Aug 2017 14:24:51 +0000 Received: from [85.158.143.35] by server-6.bemta-6.messagelabs.com id 68/EE-03937-2B2B1995; Mon, 14 Aug 2017 14:24:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTXfjpom RBot+WFos+biYxYHR4+ju30wBjFGsmXlJ+RUJrBnvFuxjKvjKX/H45zvmBsYXPF2MXBxCApsZ JSbcbWWFcE4zSpy51s/SxcjJwSagKXHn8ycmEFtEQFri2ufLjCA2s0CkxOEPP9hBbGGBeImD8 /cCNXNwsAioSsye7Q0S5hWwkni67wzYGAkBeYldbRdZQWxOoHjn3Z1gcSEBS4kTq2ezTWDkXs DIsIpRvTi1qCy1SNdIL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMj0LsMQLCDcdl fp0OMkhxMSqK8CT69kUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeFM3TowUEixKTU+tSMvMAYYZ TFqCg0dJhHftBqA0b3FBYm5xZjpE6hSjLserCf+/MQmx5OXnpUqJ85aDzBAAKcoozYMbAQv5S 4yyUsK8jEBHCfEUpBblZpagyr9iFOdgVBLmdQKZwpOZVwK36RXQEUxAR/SB3M9bXJKIkJJqYC zoSFZz7c/wOM8l+Clna2D2Ve8FHC3C/sHt1xyPhQV8v7O06Tav39nEiq6t92tK5NLTPsVnPNx yfJf03U0ci/Qr2h+4M5+Ys2NPe47yn+ylf6647T+z6PSjVjuj6Bc39QI5tv7urvii4lKhc/n1 gcJ37x9t56+7/O7OKYMJKZuu75avXRvhr63EUpyRaKjFXFScCAAaWVtTdAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1502720689!71982749!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.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29437 invoked from network); 14 Aug 2017 14:24:49 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-21.messagelabs.com with SMTP; 14 Aug 2017 14:24:49 -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 3FCEA1713; Mon, 14 Aug 2017 07:24:49 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 543503F483; Mon, 14 Aug 2017 07:24:48 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 14 Aug 2017 15:24:04 +0100 Message-Id: <20170814142418.13267-14-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170814142418.13267-1-julien.grall@arm.com> References: <20170814142418.13267-1-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH 13/27] xen/arm: traps: Introduce a helper to read the hypersivor fault register 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" While ARM32 has 2 distinct registers for the hypervisor fault register (one for prefetch abort, the other for data abort), AArch64 has only one. Currently, the logic is open-code but a follow-up patch will require to read it too. So move the logic in a separate helper and use it instead of open-coding it. Signed-off-by: Julien Grall Reviewed-by: Andre Przywara --- xen/arch/arm/traps.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 498d8c594a..819bdbc69e 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2530,6 +2530,28 @@ done: if (first) unmap_domain_page(first); } +/* + * Return the value of the hypervisor fault address register. + * + * On ARM32, the register will be different depending whether the + * fault is a prefetch abort or data abort. + */ +static inline vaddr_t get_hfar(bool is_data) +{ + vaddr_t gva; + +#ifdef CONFIG_ARM_32 + if ( is_data ) + gva = READ_CP32(HDFAR); + else + gva = READ_CP32(HIFAR); +#else + gva = READ_SYSREG(FAR_EL2); +#endif + + return gva; +} + static inline paddr_t get_faulting_ipa(vaddr_t gva) { register_t hpfar = READ_SYSREG(HPFAR_EL2); @@ -2565,11 +2587,7 @@ static void do_trap_instr_abort_guest(struct cpu_user_regs *regs, paddr_t gpa; mfn_t mfn; -#ifdef CONFIG_ARM_32 - gva = READ_CP32(HIFAR); -#else - gva = READ_SYSREG64(FAR_EL2); -#endif + gva = get_hfar(false /* is_data */); /* * If this bit has been set, it means that this instruction abort is caused @@ -2711,11 +2729,8 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, return __do_trap_serror(regs, true); info.dabt = dabt; -#ifdef CONFIG_ARM_32 - info.gva = READ_CP32(HDFAR); -#else - info.gva = READ_SYSREG64(FAR_EL2); -#endif + + info.gva = get_hfar(true /* is_data */); if ( hpfar_is_valid(dabt.s1ptw, fsc) ) info.gpa = get_faulting_ipa(info.gva);