Skip to content

Commit 0f09885

Browse files
committed
Add isb and prevent CPU from postponing threadOnException memory writes
1 parent a4634c0 commit 0f09885

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

libctru/include/3ds/synchronization.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ static inline void __dmb(void)
4242
__asm__ __volatile__("mcr p15, 0, %[val], c7, c10, 5" :: [val] "r" (0) : "memory");
4343
}
4444

45+
/// Performs an Instruction Synchronization Barrier (officially "flush prefetch buffer") operation.
46+
static inline void __isb(void)
47+
{
48+
__asm__ __volatile__("mcr p15, 0, %[val], c7, c5, 4" :: [val] "r" (0) : "memory");
49+
}
50+
4551
/// Performs a clrex operation.
4652
static inline void __clrex(void)
4753
{

libctru/include/3ds/thread.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,7 @@ static inline void threadOnException(ExceptionHandler handler, void* stack_top,
117117
*(u32*)(tls + 0x40) = (u32)handler;
118118
*(u32*)(tls + 0x44) = (u32)stack_top;
119119
*(u32*)(tls + 0x48) = (u32)exception_data;
120+
121+
__dsb();
122+
__isb();
120123
}

0 commit comments

Comments
 (0)