From: "André Przywara" <andre.przywara@arm.com>
To: Julien Grall <julien.grall@arm.com>, xen-devel@lists.xen.org
Cc: sstabellini@kernel.org, tamas@tklengyel.com
Subject: Re: [for-4.7 2/2] xen/arm: traps: Correctly interpret the content of the register HPFAR_EL2
Date: Wed, 13 Apr 2016 21:33:35 +0100 [thread overview]
Message-ID: <570EAD1F.1040004@arm.com> (raw)
In-Reply-To: <1460562931-19858-3-git-send-email-julien.grall@arm.com>
On 13/04/16 16:55, Julien Grall wrote:
> The register HPFAR_EL2 (resp. HPFAR on arm32) contains the bits [47:12]
> (resp. [39:12]) of the faulting IPA. Unlike other registers that represent
> an address, the upper bits of the IPA are stored in the register bits
> [4:39] (resp. [4:21]).
>
> However, Xen assumes that the register contains the faulting IPA correctly
> offsetted. This will result to get a wrong IPA when the fault is happening
> during a translation table walk. Note this is only affecting memaccess.
>
> Introduce a new helper to get the faulting IPA from HPFAR_EL2 and
> replace direct read from the register by the helper.
>
> Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Thanks for the catch!
Cheers,
Andre.
>
> ---
> Cc: tamas@tklengyel.com
>
> This is a bug fix for Xen 4.7 and should also be backported to Xen 4.6.
> Without this patch, the faulting IPA reported to memaccess may be wrong.
>
> ---
> xen/arch/arm/traps.c | 11 +++++++++--
> xen/include/asm-arm/processor.h | 7 +++++++
> 2 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
> index 1516abd..5e865cf 100644
> --- a/xen/arch/arm/traps.c
> +++ b/xen/arch/arm/traps.c
> @@ -2363,6 +2363,13 @@ done:
> if (first) unmap_domain_page(first);
> }
>
> +static inline paddr_t get_faulting_ipa(void)
> +{
> + register_t hpfar = READ_SYSREG(HPFAR_EL2);
> +
> + return ((paddr_t)(hpfar & HPFAR_MASK) << (12 - 4));
> +}
> +
> static void do_trap_instr_abort_guest(struct cpu_user_regs *regs,
> const union hsr hsr)
> {
> @@ -2381,7 +2388,7 @@ static void do_trap_instr_abort_guest(struct cpu_user_regs *regs,
> };
>
> if ( hsr.iabt.s1ptw )
> - gpa = READ_SYSREG(HPFAR_EL2);
> + gpa = get_faulting_ipa();
> else
> {
> /*
> @@ -2431,7 +2438,7 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs,
> #endif
>
> if ( dabt.s1ptw )
> - info.gpa = READ_SYSREG(HPFAR_EL2);
> + info.gpa = get_faulting_ipa();
> else
> {
> rc = gva_to_ipa(info.gva, &info.gpa, GV2M_READ);
> diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h
> index 7e6eb66..6789cd0 100644
> --- a/xen/include/asm-arm/processor.h
> +++ b/xen/include/asm-arm/processor.h
> @@ -565,6 +565,13 @@ union hsr {
>
> #define FSC_LL_MASK (_AC(0x03,U)<<0)
>
> +/* HPFAR_EL2: Hypervisor IPA Fault Address Register */
> +#ifdef CONFIG_ARM_64
> +#define HPFAR_MASK GENMASK(39, 4)
> +#else
> +#define HPFAR_MASK GENMASK(31, 4)
> +#endif
> +
> /* Time counter hypervisor control register */
> #define CNTHCTL_EL2_EL1PCTEN (1u<<0) /* Kernel/user access to physical counter */
> #define CNTHCTL_EL2_EL1PCEN (1u<<1) /* Kernel/user access to CNTP timer regs */
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-04-13 20:33 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-13 15:55 [for-4.7 0/2] xen/arm: traps: Correctly interpret the content of the register HPFAR_EL2 Julien Grall
2016-04-13 15:55 ` [for-4.7 1/2] xen/bitops: Introduce macros to generate mask Julien Grall
2016-04-13 18:07 ` Stefano Stabellini
2016-04-13 18:14 ` Andrew Cooper
2016-04-14 8:47 ` Julien Grall
2016-04-14 4:01 ` Jan Beulich
2016-04-14 8:55 ` Julien Grall
2016-04-14 14:56 ` Jan Beulich
2016-04-14 15:08 ` Julien Grall
2016-04-14 15:23 ` Jan Beulich
2016-04-20 12:35 ` Julien Grall
2016-04-20 16:43 ` Jan Beulich
2016-04-22 11:33 ` Julien Grall
2016-04-22 11:49 ` Stefano Stabellini
2016-04-22 15:33 ` Julien Grall
2016-04-22 15:42 ` Stefano Stabellini
2016-04-13 15:55 ` [for-4.7 2/2] xen/arm: traps: Correctly interpret the content of the register HPFAR_EL2 Julien Grall
2016-04-13 18:17 ` Stefano Stabellini
2016-04-13 19:11 ` Tamas K Lengyel
2016-04-13 20:33 ` André Przywara [this message]
2016-04-14 17:47 ` [for-4.7 0/2] " Wei Liu
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=570EAD1F.1040004@arm.com \
--to=andre.przywara@arm.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=tamas@tklengyel.com \
--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).