Skip to content

Commit 5b6d749

Browse files
ardbiesheuvelpelwell
authored andcommitted
ARM: kernel: use relative references for UP/SMP alternatives
commit 450abd3 upstream. Currently, the .alt.smp.init section contains the virtual addresses of the patch sites. Since patching may occur both before and after switching into virtual mode, this requires some manual handling of the address when applying the UP alternative. Let's simplify this by using relative offsets in the table entries: this allows us to simply add each entry's address to its contents, regardless of whether we are running in virtual mode or not. Reviewed-by: Nicolas Pitre <nico@fluxnic.net> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent 3b36518 commit 5b6d749

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎arch/arm/include/asm/assembler.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@
259259
*/
260260
#define ALT_UP(instr...) \
261261
.pushsection ".alt.smp.init", "a" ;\
262-
.long 9998b ;\
262+
.long 9998b - . ;\
263263
9997: instr ;\
264264
.if . - 9997b == 2 ;\
265265
nop ;\
@@ -270,7 +270,7 @@
270270
.popsection
271271
#define ALT_UP_B(label) \
272272
.pushsection ".alt.smp.init", "a" ;\
273-
.long 9998b ;\
273+
.long 9998b - . ;\
274274
W(b) . + (label - 9998b) ;\
275275
.popsection
276276
#else

‎arch/arm/include/asm/processor.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ unsigned long get_wchan(struct task_struct *p);
9696
#define __ALT_SMP_ASM(smp, up) \
9797
"9998: " smp "\n" \
9898
" .pushsection \".alt.smp.init\", \"a\"\n" \
99-
" .long 9998b\n" \
99+
" .long 9998b - .\n" \
100100
" " up "\n" \
101101
" .popsection\n"
102102
#else

‎arch/arm/kernel/head.S‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,14 +545,15 @@ smp_on_up:
545545
__do_fixup_smp_on_up:
546546
cmp r4, r5
547547
reths lr
548-
ldmia r4!, {r0, r6}
549-
ARM( str r6, [r0, r3] )
550-
THUMB( add r0, r0, r3 )
548+
ldmia r4, {r0, r6}
549+
ARM( str r6, [r0, r4] )
550+
THUMB( add r0, r0, r4 )
551+
add r4, r4, #8
551552
#ifdef __ARMEB__
552553
THUMB( mov r6, r6, ror #16 ) @ Convert word order for big-endian.
553554
#endif
554555
THUMB( strh r6, [r0], #2 ) @ For Thumb-2, store as two halfwords
555-
THUMB( mov r6, r6, lsr #16 ) @ to be robust against misaligned r3.
556+
THUMB( mov r6, r6, lsr #16 ) @ to be robust against misaligned r0.
556557
THUMB( strh r6, [r0] )
557558
b __do_fixup_smp_on_up
558559
ENDPROC(__do_fixup_smp_on_up)
@@ -561,7 +562,6 @@ ENTRY(fixup_smp)
561562
stmfd sp!, {r4 - r6, lr}
562563
mov r4, r0
563564
add r5, r0, r1
564-
mov r3, #0
565565
bl __do_fixup_smp_on_up
566566
ldmfd sp!, {r4 - r6, pc}
567567
ENDPROC(fixup_smp)

0 commit comments

Comments
 (0)