Skip to content

Commit

Permalink
ARM: 6655/1: Correct WFE() in asm/spinlock.h for Thumb-2
Browse files Browse the repository at this point in the history
The content for ALT_SMP() in the definition of WFE() expands to 6
bytes (IT cc ; WFEcc.W), which breaks the assumptions of the fixup
code, leading to lockups when the affected code gets run.

This patch works around the problem by explicitly using an
IT + WFEcc.N pair.

Signed-off-by: Dave Martin <dave.martin@linaro.org>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Dave Martin authored and Russell King committed Feb 10, 2011
1 parent 774c096 commit 917692f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion arch/arm/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,23 @@

#ifdef CONFIG_THUMB2_KERNEL
#define SEV ALT_SMP("sev.w", "nop.w")
#define WFE(cond) ALT_SMP("wfe" cond ".w", "nop.w")
/*
* For Thumb-2, special care is needed to ensure that the conditional WFE
* instruction really does assemble to exactly 4 bytes (as required by
* the SMP_ON_UP fixup code). By itself "wfene" might cause the
* assembler to insert a extra (16-bit) IT instruction, depending on the
* presence or absence of neighbouring conditional instructions.
*
* To avoid this unpredictableness, an approprite IT is inserted explicitly:
* the assembler won't change IT instructions which are explicitly present
* in the input.
*/
#define WFE(cond) ALT_SMP( \
"it " cond "\n\t" \
"wfe" cond ".n", \
\
"nop.w" \
)
#else
#define SEV ALT_SMP("sev", "nop")
#define WFE(cond) ALT_SMP("wfe" cond, "nop")
Expand Down

0 comments on commit 917692f

Please sign in to comment.