1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-15 00:16:48 +00:00

thermosphere: add proper memory/instruction barriers for breakpoint stuff

This commit is contained in:
TuxSH 2020-01-09 22:47:22 +00:00
parent 1eb60a2a52
commit a6d191bf4b
6 changed files with 19 additions and 3 deletions

View file

@ -49,6 +49,7 @@ static void commitAndBroadcastBreakpointHandler(void *p)
static inline void commitAndBroadcastBreakpoints(void)
{
__dmb_sy();
executeFunctionOnAllCores(commitAndBroadcastBreakpointHandler, NULL, true);
}

View file

@ -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)

View file

@ -56,6 +56,7 @@ void singleStepSetNextState(ExceptionStackFrame *frame, SingleStepState state)
}
SET_SYSREG(mdscr_el1, mdscr);
__isb(); // TRM-mandated
}
void handleSingleStep(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr)

View file

@ -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);
}

View file

@ -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");

View file

@ -56,6 +56,7 @@ static void commitAndBroadcastWatchpointHandler(void *p)
static inline void commitAndBroadcastWatchpoints(void)
{
__dmb_sy();
executeFunctionOnAllCores(commitAndBroadcastWatchpointHandler, NULL, true);
}