Skip to content

Commit b37c10d

Browse files
powerpc: Fix ABIv2 issues with stack offsets in assembly code
Fix STK_PARAM and use it instead of hardcoding ABIv1 offsets. Signed-off-by: Anton Blanchard <anton@samba.org>
1 parent 7cedd60 commit b37c10d

5 files changed

Lines changed: 34 additions & 30 deletions

File tree

‎arch/powerpc/include/asm/ppc_asm.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
189189
#define __STK_REG(i) (112 + ((i)-14)*8)
190190
#define STK_REG(i) __STK_REG(__REG_##i)
191191

192+
#if defined(_CALL_ELF) && _CALL_ELF == 2
193+
#define __STK_PARAM(i) (32 + ((i)-3)*8)
194+
#else
192195
#define __STK_PARAM(i) (48 + ((i)-3)*8)
196+
#endif
193197
#define STK_PARAM(i) __STK_PARAM(__REG_##i)
194198

195199
#if defined(_CALL_ELF) && _CALL_ELF == 2

‎arch/powerpc/lib/copypage_power7.S‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ _GLOBAL(copypage_power7)
5656

5757
#ifdef CONFIG_ALTIVEC
5858
mflr r0
59-
std r3,48(r1)
60-
std r4,56(r1)
59+
std r3,STK_PARAM(R3)(r1)
60+
std r4,STK_PARAM(R4)(r1)
6161
std r0,16(r1)
6262
stdu r1,-STACKFRAMESIZE(r1)
6363
bl enter_vmx_copy
6464
cmpwi r3,0
6565
ld r0,STACKFRAMESIZE+16(r1)
66-
ld r3,STACKFRAMESIZE+48(r1)
67-
ld r4,STACKFRAMESIZE+56(r1)
66+
ld r3,STACKFRAMESIZE+STK_PARAM(R3)(r1)
67+
ld r4,STACKFRAMESIZE+STK_PARAM(R4)(r1)
6868
mtlr r0
6969

7070
li r0,(PAGE_SIZE/128)

‎arch/powerpc/lib/copyuser_power7.S‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@
8585
.Lexit:
8686
addi r1,r1,STACKFRAMESIZE
8787
.Ldo_err1:
88-
ld r3,48(r1)
89-
ld r4,56(r1)
90-
ld r5,64(r1)
88+
ld r3,STK_PARAM(R3)(r1)
89+
ld r4,STK_PARAM(R4)(r1)
90+
ld r5,STK_PARAM(R5)(r1)
9191
b __copy_tofrom_user_base
9292

9393

@@ -96,18 +96,18 @@ _GLOBAL(__copy_tofrom_user_power7)
9696
cmpldi r5,16
9797
cmpldi cr1,r5,4096
9898

99-
std r3,48(r1)
100-
std r4,56(r1)
101-
std r5,64(r1)
99+
std r3,STK_PARAM(R3)(r1)
100+
std r4,STK_PARAM(R4)(r1)
101+
std r5,STK_PARAM(R5)(r1)
102102

103103
blt .Lshort_copy
104104
bgt cr1,.Lvmx_copy
105105
#else
106106
cmpldi r5,16
107107

108-
std r3,48(r1)
109-
std r4,56(r1)
110-
std r5,64(r1)
108+
std r3,STK_PARAM(R3)(r1)
109+
std r4,STK_PARAM(R4)(r1)
110+
std r5,STK_PARAM(R5)(r1)
111111

112112
blt .Lshort_copy
113113
#endif
@@ -298,9 +298,9 @@ err1; stb r0,0(r3)
298298
bl enter_vmx_usercopy
299299
cmpwi cr1,r3,0
300300
ld r0,STACKFRAMESIZE+16(r1)
301-
ld r3,STACKFRAMESIZE+48(r1)
302-
ld r4,STACKFRAMESIZE+56(r1)
303-
ld r5,STACKFRAMESIZE+64(r1)
301+
ld r3,STACKFRAMESIZE+STK_PARAM(R3)(r1)
302+
ld r4,STACKFRAMESIZE+STK_PARAM(R4)(r1)
303+
ld r5,STACKFRAMESIZE+STK_PARAM(R5)(r1)
304304
mtlr r0
305305

306306
/*

‎arch/powerpc/lib/memcpy_64.S‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
.align 7
1313
_GLOBAL(memcpy)
1414
BEGIN_FTR_SECTION
15-
std r3,48(r1) /* save destination pointer for return value */
15+
std r3,STK_PARAM(R3)(r1) /* save destination pointer for return value */
1616
FTR_SECTION_ELSE
1717
#ifndef SELFTEST
1818
b memcpy_power7
@@ -73,7 +73,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_UNALIGNED_LD_STD)
7373
2: bf cr7*4+3,3f
7474
lbz r9,8(r4)
7575
stb r9,0(r3)
76-
3: ld r3,48(r1) /* return dest pointer */
76+
3: ld r3,STK_PARAM(R3)(r1) /* return dest pointer */
7777
blr
7878

7979
.Lsrc_unaligned:
@@ -156,7 +156,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_UNALIGNED_LD_STD)
156156
2: bf cr7*4+3,3f
157157
rotldi r9,r9,8
158158
stb r9,0(r3)
159-
3: ld r3,48(r1) /* return dest pointer */
159+
3: ld r3,STK_PARAM(R3)(r1) /* return dest pointer */
160160
blr
161161

162162
.Ldst_unaligned:
@@ -201,5 +201,5 @@ END_FTR_SECTION_IFCLR(CPU_FTR_UNALIGNED_LD_STD)
201201
3: bf cr7*4+3,4f
202202
lbz r0,0(r4)
203203
stb r0,0(r3)
204-
4: ld r3,48(r1) /* return dest pointer */
204+
4: ld r3,STK_PARAM(R3)(r1) /* return dest pointer */
205205
blr

‎arch/powerpc/lib/memcpy_power7.S‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ _GLOBAL(memcpy_power7)
3333
cmpldi r5,16
3434
cmpldi cr1,r5,4096
3535

36-
std r3,48(r1)
36+
std r3,STK_PARAM(R1)(r1)
3737

3838
blt .Lshort_copy
3939
bgt cr1,.Lvmx_copy
4040
#else
4141
cmpldi r5,16
4242

43-
std r3,48(r1)
43+
std r3,STK_PARAM(R1)(r1)
4444

4545
blt .Lshort_copy
4646
#endif
@@ -216,7 +216,7 @@ _GLOBAL(memcpy_power7)
216216
lbz r0,0(r4)
217217
stb r0,0(r3)
218218

219-
15: ld r3,48(r1)
219+
15: ld r3,STK_PARAM(R3)(r1)
220220
blr
221221

222222
.Lunwind_stack_nonvmx_copy:
@@ -226,16 +226,16 @@ _GLOBAL(memcpy_power7)
226226
#ifdef CONFIG_ALTIVEC
227227
.Lvmx_copy:
228228
mflr r0
229-
std r4,56(r1)
230-
std r5,64(r1)
229+
std r4,STK_PARAM(R4)(r1)
230+
std r5,STK_PARAM(R5)(r1)
231231
std r0,16(r1)
232232
stdu r1,-STACKFRAMESIZE(r1)
233233
bl enter_vmx_copy
234234
cmpwi cr1,r3,0
235235
ld r0,STACKFRAMESIZE+16(r1)
236-
ld r3,STACKFRAMESIZE+48(r1)
237-
ld r4,STACKFRAMESIZE+56(r1)
238-
ld r5,STACKFRAMESIZE+64(r1)
236+
ld r3,STACKFRAMESIZE+STK_PARAM(R3)(r1)
237+
ld r4,STACKFRAMESIZE+STK_PARAM(R4)(r1)
238+
ld r5,STACKFRAMESIZE+STK_PARAM(R5)(r1)
239239
mtlr r0
240240

241241
/*
@@ -447,7 +447,7 @@ _GLOBAL(memcpy_power7)
447447
stb r0,0(r3)
448448

449449
15: addi r1,r1,STACKFRAMESIZE
450-
ld r3,48(r1)
450+
ld r3,STK_PARAM(R3)(r1)
451451
b exit_vmx_copy /* tail call optimise */
452452

453453
.Lvmx_unaligned_copy:
@@ -651,6 +651,6 @@ _GLOBAL(memcpy_power7)
651651
stb r0,0(r3)
652652

653653
15: addi r1,r1,STACKFRAMESIZE
654-
ld r3,48(r1)
654+
ld r3,STK_PARAM(R3)(r1)
655655
b exit_vmx_copy /* tail call optimise */
656656
#endif /* CONFiG_ALTIVEC */

0 commit comments

Comments
 (0)