[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH 3/4] arm/traps: Allow trapping on single-step events
This commit concludes the single-stepping functionality on ARM by adding trapping on and setting up single-stepping events of the architecture. Signed-off-by: Sergej Proskurin <proskurin@xxxxxxxxxxxxx> --- Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx> Cc: Julien Grall <julien.grall@xxxxxxx> --- xen/arch/arm/arm64/entry.S | 2 ++ xen/arch/arm/traps.c | 50 +++++++++++++++++++++++++++++++++++++++- xen/include/asm-arm/perfc_defn.h | 1 + xen/include/asm-arm/processor.h | 2 ++ 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index 6d99e46f0f..5e89f24494 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -138,6 +138,8 @@ lr .req x30 /* link register */ bl leave_hypervisor_tail /* Disables interrupts on return */ + bl setup_single_step + exit_guest \compat .endif diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index aa838e8e77..9c45b0706e 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -163,7 +163,7 @@ void init_traps(void) WRITE_SYSREG((vaddr_t)hyp_traps_vector, VBAR_EL2); /* Trap Debug and Performance Monitor accesses */ - WRITE_SYSREG(HDCR_TDRA|HDCR_TDOSA|HDCR_TDA|HDCR_TPM|HDCR_TPMCR, + WRITE_SYSREG(HDCR_TDRA|HDCR_TDOSA|HDCR_TDA|HDCR_TPM|HDCR_TPMCR|HDCR_TDE, MDCR_EL2); /* Trap CP15 c15 used for implementation defined registers */ @@ -1332,6 +1332,20 @@ int do_bug_frame(struct cpu_user_regs *regs, vaddr_t pc) } #ifdef CONFIG_ARM_64 +static void do_trap_ss(struct cpu_user_regs *regs, const union hsr hsr) +{ + int rc = 0; + + /* XXX: We do not support single-stepping of EL2, yet. */ + BUG_ON(hyp_mode(regs)); + + if ( current->domain->arch.monitor.single_step_enabled ) + rc = monitor_ss(); + + if ( rc != 1 ) + inject_undef_exception(regs, hsr); +} + static void do_trap_brk(struct cpu_user_regs *regs, const union hsr hsr) { /* HCR_EL2.TGE and MDCR_EL2.TDE are not set so we never receive @@ -2943,6 +2957,12 @@ asmlinkage void do_trap_guest_sync(struct cpu_user_regs *regs) perfc_incr(trap_dabt); do_trap_data_abort_guest(regs, hsr); break; +#ifdef CONFIG_ARM_64 + case HSR_EC_SS_LOWER_EL: + perfc_incr(trap_ss); + do_trap_ss(regs, hsr); + break; +#endif default: gprintk(XENLOG_WARNING, @@ -2999,6 +3019,34 @@ asmlinkage void do_trap_fiq(struct cpu_user_regs *regs) gic_interrupt(regs, 1); } +asmlinkage void setup_single_step(void) +{ + uint32_t mdscr, mdcr; + struct vcpu *v = current; + struct cpu_user_regs *regs = guest_cpu_user_regs(); + +#define MDSCR_EL1_SS (_AC(1,U) << 0) +#define SPSR_EL2_SS (_AC(1,U) << 21) + + mdscr = READ_SYSREG(MDSCR_EL1); + mdcr = READ_SYSREG(MDCR_EL2); + + if ( unlikely(v->arch.single_step) ) + { + mdcr |= HDCR_TDE; + mdscr |= MDSCR_EL1_SS; + regs->cpsr |= SPSR_EL2_SS; + } + else + { + mdcr &= ~HDCR_TDE; + mdscr &= ~MDSCR_EL1_SS; + } + + WRITE_SYSREG(mdscr, MDSCR_EL1); + WRITE_SYSREG(mdcr, MDCR_EL2); +} + asmlinkage void leave_hypervisor_tail(void) { while (1) diff --git a/xen/include/asm-arm/perfc_defn.h b/xen/include/asm-arm/perfc_defn.h index 5f957ee6ec..46b82e4fee 100644 --- a/xen/include/asm-arm/perfc_defn.h +++ b/xen/include/asm-arm/perfc_defn.h @@ -18,6 +18,7 @@ PERFCOUNTER(trap_hvc32, "trap: 32-bit hvc") PERFCOUNTER(trap_smc64, "trap: 64-bit smc") PERFCOUNTER(trap_hvc64, "trap: 64-bit hvc") PERFCOUNTER(trap_sysreg, "trap: sysreg access") +PERFCOUNTER(trap_ss, "trap: software step") #endif PERFCOUNTER(trap_iabt, "trap: guest instr abort") PERFCOUNTER(trap_dabt, "trap: guest data abort") diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h index 9f7a42f86b..3e0ec4f537 100644 --- a/xen/include/asm-arm/processor.h +++ b/xen/include/asm-arm/processor.h @@ -323,6 +323,8 @@ #define HSR_EC_DATA_ABORT_LOWER_EL 0x24 #define HSR_EC_DATA_ABORT_CURR_EL 0x25 #ifdef CONFIG_ARM_64 +#define HSR_EC_SS_LOWER_EL 0x32 +#define HSR_EC_SS_CURR_EL 0x33 #define HSR_EC_BRK 0x3c #endif -- 2.13.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |