Index: sys/arm64/arm64/swtch.S =================================================================== --- sys/arm64/arm64/swtch.S +++ sys/arm64/arm64/swtch.S @@ -41,6 +41,8 @@ * void cpu_throw(struct thread *old, struct thread *new) */ ENTRY(cpu_throw) + clrex + #ifdef VFP /* Backup the new thread pointer around a call to C code */ mov x19, x1 @@ -98,6 +100,8 @@ * x3 to x7, x16 and x17 are caller saved */ ENTRY(cpu_switch) + clrex + /* Store the new curthread */ str x1, [x18, #PC_CURTHREAD] /* And the new pcb */ Index: sys/arm64/arm64/trap.c =================================================================== --- sys/arm64/arm64/trap.c +++ sys/arm64/arm64/trap.c @@ -156,5 +156,7 @@ int error, sig, ucode; + clrex(); + #ifdef KDB if (kdb_active) { kdb_reenter(); Index: sys/arm64/include/cpufunc.h =================================================================== --- sys/arm64/include/cpufunc.h +++ sys/arm64/include/cpufunc.h @@ -108,6 +108,17 @@ return (mpidr); } +static __inline void +clrex(void) +{ + + /* + * Ensure compiler barrier, otherwise the monitor clear might + * occur too late for us ? + */ + __asm __volatile("clrex" : : : "memory"); +} + #define cpu_nullop() arm64_nullop() #define cpufunc_nullop() arm64_nullop() #define cpu_setttb(a) arm64_setttb(a)