Skip to content

Commit

Permalink
Hexagon: add support for single-stepping (v4+)
Browse files Browse the repository at this point in the history
Hardware single-step is only available on v4 and later
architectures.

Signed-off-by: Richard Kuo <rkuo@codeaurora.org>
  • Loading branch information
Richard Kuo committed May 1, 2013
1 parent f8722a4 commit 7777746
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 1 deletion.
5 changes: 5 additions & 0 deletions arch/hexagon/include/uapi/asm/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ extern const char *regs_query_register_name(unsigned int offset);
((struct pt_regs *) \
((unsigned long)current_thread_info() + THREAD_SIZE) - 1)

#if CONFIG_HEXAGON_ARCH_VERSION >= 4
#define arch_has_single_step() (1)
#endif


#endif
3 changes: 3 additions & 0 deletions arch/hexagon/include/uapi/asm/registers.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ struct pt_regs {
#define pt_psp(regs) ((regs)->hvmer.vmpsp)
#define pt_badva(regs) ((regs)->hvmer.vmbadva)

#define pt_set_singlestep(regs) ((regs)->hvmer.vmest |= (1<<HVM_VMEST_SS_SFT))
#define pt_clr_singlestep(regs) ((regs)->hvmer.vmest &= ~(1<<HVM_VMEST_SS_SFT))

#define pt_set_rte_sp(regs, sp) do {\
pt_psp(regs) = (sp);\
(regs)->SP = (unsigned long) &((regs)->hvmer);\
Expand Down
15 changes: 15 additions & 0 deletions arch/hexagon/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@

#include <asm/user.h>

#if arch_has_single_step()
/* Both called from ptrace_resume */
void user_enable_single_step(struct task_struct *child)
{
pt_set_singlestep(task_pt_regs(child));
set_tsk_thread_flag(child, TIF_SINGLESTEP);
}

void user_disable_single_step(struct task_struct *child)
{
pt_clr_singlestep(task_pt_regs(child));
clear_tsk_thread_flag(child, TIF_SINGLESTEP);
}
#endif

static int genregs_get(struct task_struct *target,
const struct user_regset *regset,
unsigned int pos, unsigned int count,
Expand Down
11 changes: 11 additions & 0 deletions arch/hexagon/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,14 @@ void do_machcheck(struct pt_regs *regs)
/* Halt and catch fire */
__vmstop();
}

/*
* Treat this like the old 0xdb trap.
*/

void do_debug_exception(struct pt_regs *regs)
{
regs->hvmer.vmest &= ~HVM_VMEST_CAUSE_MSK;
regs->hvmer.vmest |= (TRAP_DEBUG << HVM_VMEST_CAUSE_SFT);
do_trap0(regs);
}
3 changes: 3 additions & 0 deletions arch/hexagon/kernel/vm_entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ _K_enter_trap0:
_K_enter_machcheck:
vm_event_entry(do_machcheck)

.globl _K_enter_debug
_K_enter_debug:
vm_event_entry(do_debug_exception)

.globl ret_from_fork
ret_from_fork:
Expand Down
2 changes: 1 addition & 1 deletion arch/hexagon/kernel/vm_vectors.S
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ _K_VM_event_vector:
jump 1b; /* Reset */
jump _K_enter_machcheck;
jump _K_enter_genex;
jump 1b; /* 3 Rsvd */
jump _K_enter_debug;
jump 1b; /* 4 Rsvd */
jump _K_enter_trap0;
jump 1b; /* 6 Rsvd */
Expand Down

0 comments on commit 7777746

Please sign in to comment.