Commit 7faa313f authored by Will Deacon's avatar Will Deacon

arm64: preempt: Fix big-endian when checking preempt count in assembly

Commit 39624469 ("arm64: preempt: Provide our own implementation of
asm/preempt.h") extended the preempt count field in struct thread_info
to 64 bits, so that it consists of a 32-bit count plus a 32-bit flag
indicating whether or not the current task needs rescheduling.

Whilst the asm-offsets definition of TSK_TI_PREEMPT was updated to point
to this new field, the assembly usage was left untouched meaning that a
32-bit load from TSK_TI_PREEMPT on a big-endian machine actually returns
the reschedule flag instead of the count.

Whilst we could fix this by pointing TSK_TI_PREEMPT at the count field,
we're actually better off reworking the two assembly users so that they
operate on the whole 64-bit value in favour of inspecting the thread
flags separately in order to determine whether a reschedule is needed.
Acked-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Reported-by: default avatar"kernelci.org bot" <bot@kernelci.org>
Tested-by: default avatarKevin Hilman <khilman@baylibre.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 732291c4
...@@ -722,11 +722,9 @@ USER(\label, ic ivau, \tmp2) // invalidate I line PoU ...@@ -722,11 +722,9 @@ USER(\label, ic ivau, \tmp2) // invalidate I line PoU
.macro if_will_cond_yield_neon .macro if_will_cond_yield_neon
#ifdef CONFIG_PREEMPT #ifdef CONFIG_PREEMPT
get_thread_info x0 get_thread_info x0
ldr w1, [x0, #TSK_TI_PREEMPT] ldr x0, [x0, #TSK_TI_PREEMPT]
ldr x0, [x0, #TSK_TI_FLAGS] sub x0, x0, #PREEMPT_DISABLE_OFFSET
cmp w1, #PREEMPT_DISABLE_OFFSET cbz x0, .Lyield_\@
csel x0, x0, xzr, eq
tbnz x0, #TIF_NEED_RESCHED, .Lyield_\@ // needs rescheduling?
/* fall through to endif_yield_neon */ /* fall through to endif_yield_neon */
.subsection 1 .subsection 1
.Lyield_\@ : .Lyield_\@ :
......
...@@ -619,10 +619,8 @@ el1_irq: ...@@ -619,10 +619,8 @@ el1_irq:
irq_handler irq_handler
#ifdef CONFIG_PREEMPT #ifdef CONFIG_PREEMPT
ldr w24, [tsk, #TSK_TI_PREEMPT] // get preempt count ldr x24, [tsk, #TSK_TI_PREEMPT] // get preempt count
cbnz w24, 1f // preempt count != 0 cbnz x24, 1f // preempt count != 0
ldr x0, [tsk, #TSK_TI_FLAGS] // get flags
tbz x0, #TIF_NEED_RESCHED, 1f // needs rescheduling?
bl el1_preempt bl el1_preempt
1: 1:
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment