Commit 5249497a authored by Breno Leitao's avatar Breno Leitao Committed by Michael Ellerman

selftests/powerpc: Allocate base registers

Some ptrace selftests are passing input operands using a constraint that
can allocate any register for the operand, and using these registers on
load/store operations.

If the register allocated by the compiler happens to be zero (r0), it might
cause an invalid memory address access, since load and store operations
consider the content of 0x0 address if the base register is r0, instead of
the content of the r0 register. For example:

	r1 := 0xdeadbeef
	r0 := 0xdeadbeef

	ld r2, 0(1) /* will load into r2 the content of r1 address */
	ld r2, 0(0) /* will load into r2 the content of 0x0 */

In order to avoid this possible problem, the inline assembly constraint
should be aware that these registers will be used as a base register, thus,
r0 should not be allocated.

Other than that, this patch removes inline assembly operands that are not
used by the tests.
Signed-off-by: default avatarBreno Leitao <leitao@debian.org>
Reviewed-by: default avatarSegher Boessenkool <segher@kernel.crashing.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent bce85a16
...@@ -31,7 +31,7 @@ void gpr(void) ...@@ -31,7 +31,7 @@ void gpr(void)
ASM_LOAD_GPR_IMMED(gpr_1) ASM_LOAD_GPR_IMMED(gpr_1)
ASM_LOAD_FPR_SINGLE_PRECISION(flt_1) ASM_LOAD_FPR_SINGLE_PRECISION(flt_1)
: :
: [gpr_1]"i"(GPR_1), [flt_1] "r" (&a) : [gpr_1]"i"(GPR_1), [flt_1] "b" (&a)
: "memory", "r6", "r7", "r8", "r9", "r10", : "memory", "r6", "r7", "r8", "r9", "r10",
"r11", "r12", "r13", "r14", "r15", "r16", "r17", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
"r18", "r19", "r20", "r21", "r22", "r23", "r24", "r18", "r19", "r20", "r21", "r22", "r23", "r24",
......
...@@ -59,8 +59,8 @@ void tm_gpr(void) ...@@ -59,8 +59,8 @@ void tm_gpr(void)
"3: ;" "3: ;"
: [res] "=r" (result), [texasr] "=r" (texasr) : [res] "=r" (result), [texasr] "=r" (texasr)
: [gpr_1]"i"(GPR_1), [gpr_2]"i"(GPR_2), : [gpr_1]"i"(GPR_1), [gpr_2]"i"(GPR_2),
[sprn_texasr] "i" (SPRN_TEXASR), [flt_1] "r" (&a), [sprn_texasr] "i" (SPRN_TEXASR), [flt_1] "b" (&a),
[flt_2] "r" (&b), [cptr1] "r" (&cptr[1]) [flt_2] "b" (&b), [cptr1] "b" (&cptr[1])
: "memory", "r7", "r8", "r9", "r10", : "memory", "r7", "r8", "r9", "r10",
"r11", "r12", "r13", "r14", "r15", "r16", "r11", "r12", "r13", "r14", "r15", "r16",
"r17", "r18", "r19", "r20", "r21", "r22", "r17", "r18", "r19", "r20", "r21", "r22",
......
...@@ -72,7 +72,7 @@ void tm_spd_tar(void) ...@@ -72,7 +72,7 @@ void tm_spd_tar(void)
"3: ;" "3: ;"
: [res] "=r" (result), [texasr] "=r" (texasr) : [res] "=r" (result), [texasr] "=r" (texasr)
: [val] "r" (cptr[1]), [sprn_dscr]"i"(SPRN_DSCR), : [sprn_dscr]"i"(SPRN_DSCR),
[sprn_tar]"i"(SPRN_TAR), [sprn_ppr]"i"(SPRN_PPR), [sprn_tar]"i"(SPRN_TAR), [sprn_ppr]"i"(SPRN_PPR),
[sprn_texasr]"i"(SPRN_TEXASR), [tar_1]"i"(TAR_1), [sprn_texasr]"i"(SPRN_TEXASR), [tar_1]"i"(TAR_1),
[dscr_1]"i"(DSCR_1), [tar_2]"i"(TAR_2), [dscr_2]"i"(DSCR_2), [dscr_1]"i"(DSCR_1), [tar_2]"i"(TAR_2), [dscr_2]"i"(DSCR_2),
......
...@@ -77,8 +77,7 @@ void tm_spd_vsx(void) ...@@ -77,8 +77,7 @@ void tm_spd_vsx(void)
"3: ;" "3: ;"
: [res] "=r" (result), [texasr] "=r" (texasr) : [res] "=r" (result), [texasr] "=r" (texasr)
: [fp_load] "r" (fp_load), [fp_load_ckpt] "r" (fp_load_ckpt), : [sprn_texasr] "i" (SPRN_TEXASR)
[sprn_texasr] "i" (SPRN_TEXASR)
: "memory", "r0", "r1", "r3", "r4", : "memory", "r0", "r1", "r3", "r4",
"r7", "r8", "r9", "r10", "r11" "r7", "r8", "r9", "r10", "r11"
); );
......
...@@ -74,7 +74,7 @@ void tm_spr(void) ...@@ -74,7 +74,7 @@ void tm_spr(void)
"3: ;" "3: ;"
: [tfhar] "=r" (tfhar), [res] "=r" (result), : [tfhar] "=r" (tfhar), [res] "=r" (result),
[texasr] "=r" (texasr), [cptr1] "=r" (cptr1) [texasr] "=r" (texasr), [cptr1] "=b" (cptr1)
: [sprn_texasr] "i" (SPRN_TEXASR) : [sprn_texasr] "i" (SPRN_TEXASR)
: "memory", "r0", "r8", "r31" : "memory", "r0", "r8", "r31"
); );
......
...@@ -65,7 +65,7 @@ void tm_tar(void) ...@@ -65,7 +65,7 @@ void tm_tar(void)
: [sprn_dscr]"i"(SPRN_DSCR), [sprn_tar]"i"(SPRN_TAR), : [sprn_dscr]"i"(SPRN_DSCR), [sprn_tar]"i"(SPRN_TAR),
[sprn_ppr]"i"(SPRN_PPR), [sprn_texasr]"i"(SPRN_TEXASR), [sprn_ppr]"i"(SPRN_PPR), [sprn_texasr]"i"(SPRN_TEXASR),
[tar_1]"i"(TAR_1), [dscr_1]"i"(DSCR_1), [tar_2]"i"(TAR_2), [tar_1]"i"(TAR_1), [dscr_1]"i"(DSCR_1), [tar_2]"i"(TAR_2),
[dscr_2]"i"(DSCR_2), [cptr1] "r" (&cptr[1]) [dscr_2]"i"(DSCR_2), [cptr1] "b" (&cptr[1])
: "memory", "r0", "r1", "r3", "r4", "r5", "r6" : "memory", "r0", "r1", "r3", "r4", "r5", "r6"
); );
......
...@@ -65,8 +65,7 @@ void tm_vsx(void) ...@@ -65,8 +65,7 @@ void tm_vsx(void)
"3: ;" "3: ;"
: [res] "=r" (result), [texasr] "=r" (texasr) : [res] "=r" (result), [texasr] "=r" (texasr)
: [fp_load] "r" (fp_load), [fp_load_ckpt] "r" (fp_load_ckpt), : [sprn_texasr] "i" (SPRN_TEXASR), [cptr1] "b" (&cptr[1])
[sprn_texasr] "i" (SPRN_TEXASR), [cptr1] "r" (&cptr[1])
: "memory", "r0", "r1", "r3", "r4", : "memory", "r0", "r1", "r3", "r4",
"r7", "r8", "r9", "r10", "r11" "r7", "r8", "r9", "r10", "r11"
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment