Skip to content

Commit 6339f48

Browse files
ardbiesheuvelpelwell
authored andcommitted
ARM: sleep.S: use PC-relative insn sequence for sleep_save_sp/mpidr_hash
commit d74d2b2 upstream. Replace the open coded PC relative offset calculations with adr_l and ldr_l invocations. This removes some open coded PC relative arithmetic, avoids literal pools on v7+, and slightly reduces the footprint of the code. Note that ALT_SMP() expects a single instruction so move the macro invocation after it. Reviewed-by: Nicolas Pitre <nico@fluxnic.net> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent a50f65b commit 6339f48

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

‎arch/arm/kernel/sleep.S‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ ENTRY(__cpu_suspend)
7272
ldr r3, =sleep_save_sp
7373
stmfd sp!, {r0, r1} @ save suspend func arg and pointer
7474
ldr r3, [r3, #SLEEP_SAVE_SP_VIRT]
75-
ALT_SMP(ldr r0, =mpidr_hash)
75+
ALT_SMP(W(nop)) @ don't use adr_l inside ALT_SMP()
7676
ALT_UP_B(1f)
77+
adr_l r0, mpidr_hash
7778
/* This ldmia relies on the memory layout of the mpidr_hash struct */
7879
ldmia r0, {r1, r6-r8} @ r1 = mpidr mask (r6,r7,r8) = l[0,1,2] shifts
7980
compute_mpidr_hash r0, r6, r7, r8, r2, r1
@@ -147,20 +148,16 @@ no_hyp:
147148
mov r1, #0
148149
ALT_SMP(mrc p15, 0, r0, c0, c0, 5)
149150
ALT_UP_B(1f)
150-
adr r2, mpidr_hash_ptr
151-
ldr r3, [r2]
152-
add r2, r2, r3 @ r2 = struct mpidr_hash phys address
151+
adr_l r2, mpidr_hash @ r2 = struct mpidr_hash phys address
152+
153153
/*
154154
* This ldmia relies on the memory layout of the mpidr_hash
155155
* struct mpidr_hash.
156156
*/
157157
ldmia r2, { r3-r6 } @ r3 = mpidr mask (r4,r5,r6) = l[0,1,2] shifts
158158
compute_mpidr_hash r1, r4, r5, r6, r0, r3
159159
1:
160-
adr r0, _sleep_save_sp
161-
ldr r2, [r0]
162-
add r0, r0, r2
163-
ldr r0, [r0, #SLEEP_SAVE_SP_PHYS]
160+
ldr_l r0, sleep_save_sp + SLEEP_SAVE_SP_PHYS
164161
ldr r0, [r0, r1, lsl #2]
165162

166163
@ load phys pgd, stack, resume fn
@@ -177,12 +174,6 @@ ENDPROC(cpu_resume_arm)
177174
ENDPROC(cpu_resume_no_hyp)
178175
#endif
179176

180-
.align 2
181-
_sleep_save_sp:
182-
.long sleep_save_sp - .
183-
mpidr_hash_ptr:
184-
.long mpidr_hash - . @ mpidr_hash struct offset
185-
186177
.data
187178
.align 2
188179
.type sleep_save_sp, #object

0 commit comments

Comments
 (0)