mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-15 09:36:35 +00:00
thermosphere: add proper memory/instruction barriers for breakpoint stuff
This commit is contained in:
parent
1eb60a2a52
commit
a6d191bf4b
6 changed files with 19 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -56,6 +56,7 @@ void singleStepSetNextState(ExceptionStackFrame *frame, SingleStepState state)
|
|||
}
|
||||
|
||||
SET_SYSREG(mdscr_el1, mdscr);
|
||||
__isb(); // TRM-mandated
|
||||
}
|
||||
|
||||
void handleSingleStep(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue