Skip to content

Commit

Permalink
hw debug api: modify single stepping checks
Browse files Browse the repository at this point in the history
On aarch32, single stepping is configured by setting an instruction
breakpoint to mismatch mode. The way that it is checked whether a
given breakpoint is being used as a normal breakpoint or for
single-stepping is by checking if it has been configured to mismatch.
This works because the HW debug API does not currently provide a way
to otherwise configure mismatch breakpoints, but seems like an
unsatisfactory solution. Whether single-stepping is enabled, and
the breakpoint that is being used for it is already stored in the
TCB of a thread, and this commit changes checks related to
single-stepping to use this information instead.

Signed-off-by: Alwin Joshy <[email protected]>
  • Loading branch information
alwin-joshy authored and lsf37 committed Jul 18, 2024
1 parent 28ffc62 commit b397473
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
4 changes: 1 addition & 3 deletions include/arch/arm/arch/machine/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,12 @@ static inline syscall_error_t Arch_decodeUnsetBreakpoint(tcb_t *t, uint16_t bp_n
}

word_t type;
dbg_bcr_t bcr;

type = getTypeFromBpNum(bp_num);
bp_num = convertBpNumToArch(bp_num);

bcr.words[0] = t->tcbArch.tcbContext.breakpointState.breakpoint[bp_num].cr;
if (type == seL4_InstructionBreakpoint) {
if (Arch_breakpointIsMismatch(bcr) == true && dbg_bcr_get_enabled(bcr)) {
if (Arch_breakpointIsSingleStepping(t, bp_num)) {
userError("Rejecting call to unsetBreakpoint on breakpoint configured "
"for single-stepping (hwid %u).", bp_num);
ret.type = seL4_IllegalOperation;
Expand Down
12 changes: 5 additions & 7 deletions include/arch/arm/armv/armv7-a/armv/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,11 @@ static inline dbg_wcr_t Arch_setupWcr(dbg_wcr_t in_val)
return wcr;
}

static inline bool_t Arch_breakpointIsMismatch(dbg_bcr_t in_val)
{
/* Detect if the register is set up for mismatch (single-step). */
if (dbg_bcr_get_breakpointType(in_val) == DBGBCR_TYPE_UNLINKED_INSTRUCTION_MISMATCH) {
return true;
}
return false;
static inline bool_t Arch_breakpointIsSingleStepping(tcb_t *t, uint16_t bp_num) {
/* Detect if the bp is set up for single stepping */

return (t->tcbArch.tcbContext.breakpointState.single_step_enabled &&
t->tcbArch.tcbContext.breakpointState.single_step_hw_bp_num == bp_num);
}

#endif /* CONFIG_HARDWARE_DEBUG_API */
Expand Down
2 changes: 1 addition & 1 deletion src/arch/arm/machine/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ getBreakpoint_t getBreakpoint(tcb_t *t, uint16_t bp_num)
dbg_bcr_t bcr;

bcr.words[0] = readBcrContext(t, bp_num);
if (Arch_breakpointIsMismatch(bcr) == true) {
if (Arch_breakpointIsSingleStepping(t, bp_num)) {
ret.type = seL4_SingleStep;
};
ret.size = 0;
Expand Down

0 comments on commit b397473

Please sign in to comment.