From patchwork Wed Jun 22 13:21:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9192767 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 00A7960890 for ; Wed, 22 Jun 2016 13:23:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E61FD283F7 for ; Wed, 22 Jun 2016 13:23:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAE7928406; Wed, 22 Jun 2016 13:23:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 676E428402 for ; Wed, 22 Jun 2016 13:23:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFi5s-00017d-IX; Wed, 22 Jun 2016 13:21:24 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFi5q-00017K-U4 for xen-devel@lists.xen.org; Wed, 22 Jun 2016 13:21:23 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id 9A/E1-28758-2D09A675; Wed, 22 Jun 2016 13:21:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTffihKx wg8WLtSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1ox7V7+wFuzkr2jd6t3AuJCni5GLQ0hgE6PE nQ0/GCGc04wS735MZu9i5ORgE9CUuPP5ExOILSIgLXHt82WwImaBdYwSX2YuAUpwcAgLxEqcf pkPUsMioCqx7dVKFhCbV8BF4u+27YwgtoSAnMTJY5NZQWxOAVeJ/+ebwGwhoJp1n8+zTmDkXs DIsIpRvTi1qCy1SNdUL6koMz2jJDcxM0fX0MBYLze1uDgxPTUnMalYLzk/dxMj0Lv1DAyMOxg vf3U6xCjJwaQkyiuvnBUuxJeUn1KZkVicEV9UmpNafIhRhoNDSYLXtR8oJ1iUmp5akZaZAwwz mLQEB4+SCO8MkDRvcUFibnFmOkTqFKOilDhvDUhCACSRUZoH1wYL7UuMslLCvIwMDAxCPAWpR bmZJajyrxjFORiVhHnngEzhycwrgZv+CmgxE9DiZf3pIItLEhFSUg2Ml+6d7Nzzdt9po8Lf6o W658zrjqznDxLtf3hyw6ZnO/dyf7r+6rHl451OfNff9Fl1ZUg5//HUZr7ytVTuZrXys/oLjXl nt3Es4Enn4py3UZhbVaW5z+XgEb/umMfnVebrbWsQnp74b37YjPzfMtP350Zp1XP07FHUeHVs udwfQ7XzlnlaboaNSizFGYmGWsxFxYkAnoFhv2gCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1466601681!46043094!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23034 invoked from network); 22 Jun 2016 13:21:21 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-31.messagelabs.com with SMTP; 22 Jun 2016 13:21:21 -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 9222C46E; Wed, 22 Jun 2016 06:22:07 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 57BE03F21A; Wed, 22 Jun 2016 06:21:19 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 22 Jun 2016 14:21:02 +0100 Message-Id: <1466601669-25398-3-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466601669-25398-1-git-send-email-julien.grall@arm.com> References: <1466601669-25398-1-git-send-email-julien.grall@arm.com> Cc: sstabellini@kernel.org, steve.capper@arm.com, andre.przywara@arm.com, Julien Grall , Tamas K Lengyel , wei.chen@linaro.org Subject: [Xen-devel] [PATCH 2/9] xen/arm: traps: Second attempt to correctly use the content of HPFAR_EL2 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" X-Virus-Scanned: ClamAV using ClamSMTP Commit c051618 "xen/arm: traps: Correctly interpret the content of the register HPFAR_EL2" attempted to fix the interpretation of HPFAR_EL2. However, the register contains a 4KB-aligned address. This means that the reported address is not directly usable to know the faulting IPA. The offset in the 4KB page can be found by looking at the associated virtual address (FAR_EL2/HDFAR). Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Cc: Tamas K Lengyel I overlooked the usage of HPFAR_EL2. This is currently only affecting memaccess. Rather that return that exact address, the address will always be the base addres of the 4KB page. This would need to be backported up to Xen 4.6. --- xen/arch/arm/traps.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 0709deb..742f7d3 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2371,11 +2371,15 @@ done: if (first) unmap_domain_page(first); } -static inline paddr_t get_faulting_ipa(void) +static inline paddr_t get_faulting_ipa(vaddr_t gva) { register_t hpfar = READ_SYSREG(HPFAR_EL2); + paddr_t ipa; - return ((paddr_t)(hpfar & HPFAR_MASK) << (12 - 4)); + ipa = (paddr_t)(hpfar & HPFAR_MASK) << (12 - 4); + ipa |= gva & ~PAGE_MASK; + + return ipa; } static void do_trap_instr_abort_guest(struct cpu_user_regs *regs, @@ -2396,7 +2400,7 @@ static void do_trap_instr_abort_guest(struct cpu_user_regs *regs, }; if ( hsr.iabt.s1ptw ) - gpa = get_faulting_ipa(); + gpa = get_faulting_ipa(gva); else { /* @@ -2445,7 +2449,7 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, #endif if ( dabt.s1ptw ) - info.gpa = get_faulting_ipa(); + info.gpa = get_faulting_ipa(info.gva); else { rc = gva_to_ipa(info.gva, &info.gpa, GV2M_READ);