From: Julien Grall Date: Wed, 22 Jun 2016 13:21:02 +0000 (+0100) Subject: xen/arm: traps: Second attempt to correctly use the content of HPFAR_EL2 X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~772 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=502c739d9bbaabbbe7c6968c7213f0ca8fcceeca;p=xen.git xen/arm: traps: Second attempt to correctly use the content of HPFAR_EL2 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 --- diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 42011c5905..f7edd23be4 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 { /* @@ -2446,7 +2450,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);