diff --git a/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S b/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S index 40efba6dcf46..2715a2b4cfce 100644 --- a/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S +++ b/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S @@ -42,9 +42,12 @@ /* * Macro to handle the cache. This takes the start address in x0, length - * in x1. It will corrupt x2-x5. + * in x1. It will corrupt x2-x7. */ .macro cache_handle_range dcop = "", icop = "" +0: mrs x6, tpidr_el1 /* x6 := curlwp */ + ldr x7, [x6, #L_NCSW] /* x7 := curlwp->l_ncsw */ + mrs x3, ctr_el0 mov x4, #4 /* size of word */ .ifnb \dcop @@ -80,6 +83,13 @@ dsb ish isb .endif + + ldr x6, [x6, #L_NCSW] /* x6 := curlwp->l_ncsw again */ + cmp x6, x7 /* retry if l_ncsw changed */ + b.ne 2f /* forward branch predict not-taken */ + b 3f +2: b 0b +3: .endm