Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: End spinlocks with .insn

When building for microMIPS we need to ensure that the assembler always
knows that there is code at the target of a branch or jump. Recent
toolchains will fail to link a microMIPS kernel when this isn't the case
due to what it thinks is a branch to non-microMIPS code.

mips-mti-linux-gnu-ld kernel/built-in.o: .spinlock.text+0x2fc: Unsupported branch between ISA modes.
mips-mti-linux-gnu-ld final link failed: Bad value

This is due to inline assembly labels in spinlock.h not being followed
by an instruction mnemonic, either due to a .subsection pseudo-op or the
end of the inline asm block.

Fix this with a .insn direction after such labels.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Maciej W. Rozycki <macro@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Cc: <stable@vger.kernel.org>
Patchwork: https://patchwork.linux-mips.org/patch/15325/
Signed-off-by: James Hogan <james.hogan@imgtec.com>

authored by

Paul Burton and committed by
Ralf Baechle
4b5347a2 2e6c7747

+4 -4
+4 -4
arch/mips/include/asm/spinlock.h
··· 127 127 " andi %[ticket], %[ticket], 0xffff \n" 128 128 " bne %[ticket], %[my_ticket], 4f \n" 129 129 " subu %[ticket], %[my_ticket], %[ticket] \n" 130 - "2: \n" 130 + "2: .insn \n" 131 131 " .subsection 2 \n" 132 132 "4: andi %[ticket], %[ticket], 0xffff \n" 133 133 " sll %[ticket], 5 \n" ··· 202 202 " sc %[ticket], %[ticket_ptr] \n" 203 203 " beqz %[ticket], 1b \n" 204 204 " li %[ticket], 1 \n" 205 - "2: \n" 205 + "2: .insn \n" 206 206 " .subsection 2 \n" 207 207 "3: b 2b \n" 208 208 " li %[ticket], 0 \n" ··· 382 382 " .set reorder \n" 383 383 __WEAK_LLSC_MB 384 384 " li %2, 1 \n" 385 - "2: \n" 385 + "2: .insn \n" 386 386 : "=" GCC_OFF_SMALL_ASM() (rw->lock), "=&r" (tmp), "=&r" (ret) 387 387 : GCC_OFF_SMALL_ASM() (rw->lock) 388 388 : "memory"); ··· 422 422 " lui %1, 0x8000 \n" 423 423 " sc %1, %0 \n" 424 424 " li %2, 1 \n" 425 - "2: \n" 425 + "2: .insn \n" 426 426 : "=" GCC_OFF_SMALL_ASM() (rw->lock), "=&r" (tmp), 427 427 "=&r" (ret) 428 428 : GCC_OFF_SMALL_ASM() (rw->lock)