diff --git a/thermosphere/src/breakpoints.c b/thermosphere/src/breakpoints.c index b9c068fcd..bd4b0b971 100644 --- a/thermosphere/src/breakpoints.c +++ b/thermosphere/src/breakpoints.c @@ -49,6 +49,7 @@ static void commitAndBroadcastBreakpointHandler(void *p) static inline void commitAndBroadcastBreakpoints(void) { + __dmb_sy(); executeFunctionOnAllCores(commitAndBroadcastBreakpointHandler, NULL, true); } @@ -157,4 +158,4 @@ int removeAllBreakpoints(void) recursiveSpinlockUnlock(&g_breakpointManager.lock); return 0; -} \ No newline at end of file +} diff --git a/thermosphere/src/breakpoints_watchpoints_load.s b/thermosphere/src/breakpoints_watchpoints_load.s index d3efb7ede..856dcd5ca 100644 --- a/thermosphere/src/breakpoints_watchpoints_load.s +++ b/thermosphere/src/breakpoints_watchpoints_load.s @@ -23,6 +23,8 @@ .cfi_startproc loadBreakpointRegs: // x1 = number + dmb sy + adr x16, 1f add x0, x0, #(16 * 8) mov x4, #(16 * 12) @@ -51,6 +53,8 @@ loadBreakpointRegs: .cfi_startproc loadWatchpointRegs: // x1 = number + dmb sy + adr x16, 1f add x0, x0, #(16 * 8) mov x4, #(16 * 12) diff --git a/thermosphere/src/single_step.c b/thermosphere/src/single_step.c index 4e647aaa7..e4ffa9a99 100644 --- a/thermosphere/src/single_step.c +++ b/thermosphere/src/single_step.c @@ -56,6 +56,7 @@ void singleStepSetNextState(ExceptionStackFrame *frame, SingleStepState state) } SET_SYSREG(mdscr_el1, mdscr); + __isb(); // TRM-mandated } void handleSingleStep(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr) diff --git a/thermosphere/src/software_breakpoints.c b/thermosphere/src/software_breakpoints.c index bf9d9f014..0ba74a6f4 100644 --- a/thermosphere/src/software_breakpoints.c +++ b/thermosphere/src/software_breakpoints.c @@ -74,12 +74,14 @@ static inline bool doApplySoftwareBreakpoint(size_t id) static void applySoftwareBreakpointHandler(void *p) { u64 flags = maskIrq(); + __dmb_sy(); doApplySoftwareBreakpoint(*(size_t *)p); restoreInterruptFlags(flags); } static void applySoftwareBreakpoint(size_t id) { + __dmb_sy(); executeFunctionOnAllCores(applySoftwareBreakpointHandler, &id, true); } @@ -101,12 +103,14 @@ static inline bool doRevertSoftwareBreakpoint(size_t id) static void revertSoftwareBreakpointHandler(void *p) { u64 flags = maskIrq(); + __dmb_sy(); doRevertSoftwareBreakpoint(*(size_t *)p); restoreInterruptFlags(flags); } static void revertSoftwareBreakpoint(size_t id) { + __dmb_sy(); executeFunctionOnAllCores(revertSoftwareBreakpointHandler, &id, true); } @@ -223,4 +227,4 @@ int removeAllSoftwareBreakpoints(bool keepPersistent) recursiveSpinlockUnlock(&g_softwareBreakpointManager.lock); return ret; -} \ No newline at end of file +} diff --git a/thermosphere/src/utils.h b/thermosphere/src/utils.h index 98655d30a..5ff5a2909 100644 --- a/thermosphere/src/utils.h +++ b/thermosphere/src/utils.h @@ -56,6 +56,11 @@ static inline u##sz __##op##sz(u##sz n)\ _DECLARE_ASM_ARITHMETIC_UNARY_HELPER64(rbit) _DECLARE_ASM_ARITHMETIC_UNARY_HELPER32(rbit) +static inline void __dmb_sy(void) +{ + __asm__ __volatile__ ("dmb sy" ::: "memory"); +} + static inline void __dsb_sy(void) { __asm__ __volatile__ ("dsb sy" ::: "memory"); diff --git a/thermosphere/src/watchpoints.c b/thermosphere/src/watchpoints.c index c8dd0abb9..090bcc185 100644 --- a/thermosphere/src/watchpoints.c +++ b/thermosphere/src/watchpoints.c @@ -56,6 +56,7 @@ static void commitAndBroadcastWatchpointHandler(void *p) static inline void commitAndBroadcastWatchpoints(void) { + __dmb_sy(); executeFunctionOnAllCores(commitAndBroadcastWatchpointHandler, NULL, true); } @@ -331,4 +332,4 @@ int removeAllWatchpoints(void) recursiveSpinlockUnlock(&g_watchpointManager.lock); return 0; -} \ No newline at end of file +}