xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: xen-devel@lists.xen.org
Cc: sstabellini@kernel.org, steve.capper@arm.com,
	andre.przywara@arm.com, Julien Grall <julien.grall@arm.com>,
	Tamas K Lengyel <tamas@tklengyel.com>,
	wei.chen@linaro.org
Subject: [PATCH 2/9] xen/arm: traps: Second attempt to correctly use the content of HPFAR_EL2
Date: Wed, 22 Jun 2016 14:21:02 +0100	[thread overview]
Message-ID: <1466601669-25398-3-git-send-email-julien.grall@arm.com> (raw)
In-Reply-To: <1466601669-25398-1-git-send-email-julien.grall@arm.com>

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 <julien.grall@arm.com>

---

Cc: Tamas K Lengyel <tamas@tklengyel.com>

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);
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-06-22 13:21 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-22 13:21 [PATCH 0/9] xen/arm: Simplify do_trap_*_abort_guest Julien Grall
2016-06-22 13:21 ` [PATCH 1/9] xen/arm: Simply the definition of PAGE_SIZE by using the macro _AC Julien Grall
2016-07-14 11:02   ` Stefano Stabellini
2016-06-22 13:21 ` Julien Grall [this message]
2016-07-14 11:05   ` [PATCH 2/9] xen/arm: traps: Second attempt to correctly use the content of HPFAR_EL2 Stefano Stabellini
2016-06-22 13:21 ` [PATCH 3/9] xen/arm: traps: Data Abort are always unconditional Julien Grall
2016-07-14 11:06   ` Stefano Stabellini
2016-06-22 13:21 ` [PATCH 4/9] xen/arm: traps: Simplify the switch in do_trap_*_abort_guest Julien Grall
2016-07-14 11:12   ` Stefano Stabellini
2016-07-14 11:17     ` Julien Grall
2016-07-14 13:43       ` Stefano Stabellini
2016-06-22 13:21 ` [PATCH 5/9] xen/arm: Provide macros to help creating workaround helpers Julien Grall
2016-07-14 13:57   ` Stefano Stabellini
2016-07-20 12:43     ` Julien Grall
2016-07-22 15:05       ` Konrad Rzeszutek Wilk
2016-06-22 13:21 ` [PATCH 6/9] xen/arm: Use check_workaround to handle the erratum 766422 Julien Grall
2016-07-14 14:34   ` Stefano Stabellini
2016-07-14 14:39     ` Julien Grall
2016-06-22 13:21 ` [PATCH 7/9] xen/arm: traps: MMIO should only be emulated for fault translation Julien Grall
2016-07-14 15:06   ` Stefano Stabellini
2016-07-14 15:23     ` Julien Grall
2016-07-14 15:28       ` Stefano Stabellini
2016-07-14 15:29         ` Julien Grall
2016-06-22 13:21 ` [PATCH 8/9] xen/arm: traps: Avoid unnecessary VA -> IPA translation in abort handlers Julien Grall
2016-07-14 15:27   ` Stefano Stabellini
2016-07-14 15:31     ` Julien Grall
2016-07-14 15:35       ` Stefano Stabellini
2016-06-22 13:21 ` [PATCH 9/9] xen/arm: arm64: Add Cortex-A57 erratum 834220 workaround Julien Grall
2016-07-14 15:31   ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466601669-25398-3-git-send-email-julien.grall@arm.com \
    --to=julien.grall@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=steve.capper@arm.com \
    --cc=tamas@tklengyel.com \
    --cc=wei.chen@linaro.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).