]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
fix(console): fix crash on spin_unlock with cache disabled
authorBaruch Siach <baruch@tkos.co.il>
Thu, 24 Nov 2022 08:34:06 +0000 (10:34 +0200)
committerJulius Werner <jwerner@chromium.org>
Tue, 29 Nov 2022 02:35:23 +0000 (03:35 +0100)
Current code skips load of spinlock address when cache is disabled. The
following call to spin_unlock stores into the random location that x0
points to.

Move spinlock address load earlier so that x0 is always valid on
spin_unlock call.

Change-Id: Iac640289725dce2518f2fed483d7d36ca748ffe8
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
plat/common/aarch64/crash_console_helpers.S

index e2950f5f7c55d87a8b9f90bb71a462df422bb1e5..75b4208933254fff1e04c3dabe7edcc53efebfb2 100644 (file)
@@ -68,12 +68,12 @@ func plat_crash_console_init
        mov     x4, x30         /* x3 and x4 are not clobbered by spin_lock() */
        mov     x3, #0          /* return value */
 
+       adrp    x0, crash_console_spinlock
+       add     x0, x0, :lo12:crash_console_spinlock
+
        mrs     x1, sctlr_el3
        tst     x1, #SCTLR_C_BIT
        beq     skip_spinlock   /* can't synchronize when cache disabled */
-
-       adrp    x0, crash_console_spinlock
-       add     x0, x0, :lo12:crash_console_spinlock
        bl      spin_lock
 
 skip_spinlock: