mirror of
https://github.com/opnsense/src.git
synced 2026-06-06 07:12:52 -04:00
arm64: Mask non-debug exceptions when single stepping
When an exception is pending when single stepping we may execute the handler for that exception rather than the single step handler. This could cause the scheduler to fire to run a new thread. This will mean we single step to a new thread causing unexpected results. Handle this by masking non-debug exceptions. This will cause issues when stepping over instructions that access the DAIF values so future work is needed to handle these cases, but for most code this now works as expected. Reviewed by: jhb Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D44350
This commit is contained in:
parent
12257233e8
commit
ed3c6cd76d
1 changed files with 12 additions and 0 deletions
|
|
@ -193,6 +193,15 @@ kdb_cpu_set_singlestep(void)
|
|||
("%s: debug exceptions are not masked", __func__));
|
||||
|
||||
kdb_frame->tf_spsr |= PSR_SS;
|
||||
|
||||
/*
|
||||
* TODO: Handle single stepping over instructions that access
|
||||
* the DAIF values. On a read the value will be incorrect.
|
||||
*/
|
||||
kernel_monitor.dbg_flags &= ~PSR_DAIF;
|
||||
kernel_monitor.dbg_flags |= kdb_frame->tf_spsr & PSR_DAIF;
|
||||
kdb_frame->tf_spsr |= (PSR_A | PSR_I | PSR_F);
|
||||
|
||||
WRITE_SPECIALREG(mdscr_el1, READ_SPECIALREG(mdscr_el1) |
|
||||
MDSCR_SS | MDSCR_KDE);
|
||||
|
||||
|
|
@ -214,6 +223,9 @@ kdb_cpu_clear_singlestep(void)
|
|||
KASSERT((READ_SPECIALREG(daif) & PSR_D) == PSR_D,
|
||||
("%s: debug exceptions are not masked", __func__));
|
||||
|
||||
kdb_frame->tf_spsr &= ~PSR_DAIF;
|
||||
kdb_frame->tf_spsr |= kernel_monitor.dbg_flags & PSR_DAIF;
|
||||
|
||||
WRITE_SPECIALREG(mdscr_el1, READ_SPECIALREG(mdscr_el1) &
|
||||
~(MDSCR_SS | MDSCR_KDE));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue