From: Ian Campbell <ian.campbell@citrix.com>
To: Tamas K Lengyel <tklengyel@sec.in.tum.de>
Cc: wei.liu2@citrix.com, stefano.stabellini@eu.citrix.com,
ian.jackson@eu.citrix.com, julien.grall@linaro.org, tim@xen.org,
xen-devel@lists.xen.org, stefano.stabellini@citrix.com,
jbeulich@suse.com, keir@xen.org
Subject: Re: [PATCH V14 5/7] xen/arm: Instruction prefetch abort (X) mem_access event handling
Date: Fri, 27 Mar 2015 15:52:49 +0000 [thread overview]
Message-ID: <1427471569.13935.177.camel@citrix.com> (raw)
In-Reply-To: <1427407531-31694-6-git-send-email-tklengyel@sec.in.tum.de>
On Thu, 2015-03-26 at 23:05 +0100, Tamas K Lengyel wrote:
> Add missing structure definition for iabt and update the trap handling
> mechanism to only inject the exception if the mem_access checker
> decides to do so.
>
> Signed-off-by: Tamas K Lengyel <tklengyel@sec.in.tum.de>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
> Reviewed-by: Julien Grall <julien.grall@linaro.org>
> ---
> v14: - Query HPFAR_EL2 when valid in iabt handler
> - Flush TLB before doing GVA->IPA translation in iabt handler
> v10: - Minor comment fix for describing s1ptw.
> v8: - Revert to arch specific p2m_mem_access_check.
> - Retire iabt_fsc enum and use FSC_FLT instead.
> - Complete the struct definition of hsr_iabt.
> v7: - Use the new common mem_access_check.
> v6: - Make npfec a const.
> v4: - Don't mark instruction fetch violation as read violation.
> - Use new struct npfec to pass violation info.
> v2: - Add definition for instruction abort instruction fetch status codes
> (enum iabt_ifsc) and only call p2m_mem_access_check for traps triggered
> for permission violations.
> ---
> xen/arch/arm/traps.c | 46 +++++++++++++++++++++++++++++++++++++++--
> xen/include/asm-arm/processor.h | 11 ++++++++++
> 2 files changed, 55 insertions(+), 2 deletions(-)
>
> diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
> index e02c848..be90c9e 100644
> --- a/xen/arch/arm/traps.c
> +++ b/xen/arch/arm/traps.c
> @@ -40,6 +40,7 @@
> #include <asm/psci.h>
> #include <asm/mmio.h>
> #include <asm/cpufeature.h>
> +#include <asm/flushtlb.h>
>
> #include "decode.h"
> #include "vtimer.h"
> @@ -1961,8 +1962,49 @@ done:
> static void do_trap_instr_abort_guest(struct cpu_user_regs *regs,
> union hsr hsr)
> {
> - register_t addr = READ_SYSREG(FAR_EL2);
> - inject_iabt_exception(regs, addr, hsr.len);
> + struct hsr_iabt iabt = hsr.iabt;
> + int rc;
> + paddr_t gpa;
> + register_t gva = READ_SYSREG(FAR_EL2);
> +
> + if ( iabt.s1ptw )
> + gpa = READ_SYSREG(HPFAR_EL2);
> + else
Can you not avoid the else case entirely by extending the if to cover
the other cases where HPFAR is explicitly valid? I can't be bothered to
go look right now but IIRC it included at least stage 2 access
permissions related failures, which would cover more xenaccess
scenarios, no?
> + {
> + /*
> + * Flush the TLB to make sure the DTLB is clear before
> + * doing GVA->IPA translation. If we got here because of
> + * an entry only present in the ITLB, this translation may
> + * still be inaccurate.
> + */
> + flush_tlb_domain(current->domain);
> +
> + rc = gva_to_ipa(gva, &gpa, GV2M_READ);
> + if ( rc == -EFAULT )
> + goto bad_insn_abort;
> + }
> +
> + switch ( iabt.ifsc & 0x3f )
> + {
> + case FSC_FLT_PERM ... FSC_FLT_PERM + 3:
> + {
> + const struct npfec npfec = {
> + .insn_fetch = 1,
> + .gla_valid = 1,
> + .kind = iabt.s1ptw ? npfec_kind_in_gpt : npfec_kind_with_gla
> + };
> +
> + rc = p2m_mem_access_check(gpa, gva, npfec);
> +
> + /* Trap was triggered by mem_access, work here is done */
> + if ( !rc )
> + return;
> + }
> + break;
> + }
> +
> +bad_insn_abort:
> + inject_iabt_exception(regs, gva, hsr.len);
> }
>
> static void do_trap_data_abort_guest(struct cpu_user_regs *regs,
> diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h
> index cf7ab7c..db07fdd 100644
> --- a/xen/include/asm-arm/processor.h
> +++ b/xen/include/asm-arm/processor.h
> @@ -438,6 +438,17 @@ union hsr {
> } sysreg; /* HSR_EC_SYSREG */
> #endif
>
> + struct hsr_iabt {
> + unsigned long ifsc:6; /* Instruction fault status code */
> + unsigned long res0:1;
> + unsigned long s1ptw:1; /* Stage 2 fault during stage 1 translation */
> + unsigned long res1:1;
> + unsigned long eat:1; /* External abort type */
> + unsigned long res2:15;
> + unsigned long len:1; /* Instruction length */
> + unsigned long ec:6; /* Exception Class */
> + } iabt; /* HSR_EC_INSTR_ABORT_* */
> +
> struct hsr_dabt {
> unsigned long dfsc:6; /* Data Fault Status Code */
> unsigned long write:1; /* Write / not Read */
next prev parent reply other threads:[~2015-03-27 15:52 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 22:05 [PATCH V14 0/7] Mem_access for ARM Tamas K Lengyel
2015-03-26 22:05 ` [PATCH V14 1/7] xen/arm: groundwork for mem_access support on ARM Tamas K Lengyel
2015-04-15 13:39 ` Ian Campbell
2015-03-26 22:05 ` [PATCH V14 2/7] xen/arm: Implement domain_get_maximum_gpfn Tamas K Lengyel
2015-04-08 13:23 ` Julien Grall
2015-04-08 13:38 ` Tamas K Lengyel
2015-04-08 13:42 ` Julien Grall
2015-04-08 13:47 ` Tamas K Lengyel
2015-04-08 13:49 ` Julien Grall
2015-03-26 22:05 ` [PATCH V14 3/7] xen/arm: Allow hypervisor access to mem_access protected pages Tamas K Lengyel
2015-04-08 14:33 ` Julien Grall
2015-04-08 15:57 ` Tamas K Lengyel
2015-04-08 16:07 ` Julien Grall
2015-04-15 13:48 ` Ian Campbell
2015-04-15 15:36 ` Tamas K Lengyel
2015-04-15 15:45 ` Ian Campbell
2015-04-16 9:04 ` Tim Deegan
2015-03-26 22:05 ` [PATCH V14 4/7] xen/arm: Data abort exception (R/W) mem_access events Tamas K Lengyel
2015-04-08 15:26 ` Julien Grall
2015-04-08 15:45 ` Tamas K Lengyel
2015-04-15 13:53 ` Ian Campbell
2015-03-26 22:05 ` [PATCH V14 5/7] xen/arm: Instruction prefetch abort (X) mem_access event handling Tamas K Lengyel
2015-03-26 23:21 ` Julien Grall
2015-03-27 8:32 ` Tamas K Lengyel
2015-03-27 12:21 ` Julien Grall
2015-03-27 15:52 ` Ian Campbell [this message]
2015-03-27 22:18 ` Tamas K Lengyel
2015-03-30 9:41 ` Ian Campbell
2015-03-30 15:14 ` Tamas K Lengyel
2015-03-30 15:24 ` Ian Campbell
2015-03-30 15:28 ` Tamas K Lengyel
2015-03-26 22:05 ` [PATCH V14 6/7] xen/arm: Enable mem_access on ARM Tamas K Lengyel
2015-03-26 22:05 ` [PATCH V14 7/7] tools/libxc: Allocate magic page for mem access " Tamas K Lengyel
2015-04-15 13:36 ` [PATCH V14 0/7] Mem_access for ARM Ian Campbell
2015-04-15 14:47 ` Tamas K Lengyel
2015-04-15 15:04 ` Ian Campbell
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=1427471569.13935.177.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@linaro.org \
--cc=keir@xen.org \
--cc=stefano.stabellini@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--cc=tklengyel@sec.in.tum.de \
--cc=wei.liu2@citrix.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.