All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests/powerpc: Fix compilation issue due to asm label
@ 2018-10-31 17:18 Naveen N. Rao
  2018-10-31 17:24 ` Naveen N. Rao
  2018-11-01 12:46 ` Michael Ellerman
  0 siblings, 2 replies; 4+ messages in thread
From: Naveen N. Rao @ 2018-10-31 17:18 UTC (permalink / raw)
  To: Michael Ellerman, Breno Leitao; +Cc: linuxppc-dev

We are using 'dscr_insn' as a label in inline asm to identify if a
SIGILL was generated by the mtspr instruction at that point. However,
with inline assembly, the compiler is still free to duplicate the asm
statement for optimization purposes, which results in the label being
defined twice with the error:
	/tmp/ccerQCql.s:874: Error: symbol `dscr_insn' is already defined

With different compiler versions, we may also see:
	/tmp/ccJzLDlN.o:(.toc+0x0): undefined reference to `dscr_insn'

Remove the use of the label in the inline assembly. Instead, just look
for the offending instruction in the signal handler.

Reported-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
 tools/testing/selftests/powerpc/utils.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/powerpc/utils.c b/tools/testing/selftests/powerpc/utils.c
index 43c342845be0..ed62f4153d3e 100644
--- a/tools/testing/selftests/powerpc/utils.c
+++ b/tools/testing/selftests/powerpc/utils.c
@@ -25,7 +25,6 @@
 #include "utils.h"
 
 static char auxv[4096];
-extern unsigned int dscr_insn[];
 
 int read_auxv(char *buf, ssize_t buf_size)
 {
@@ -247,7 +246,8 @@ static void sigill_handler(int signr, siginfo_t *info, void *unused)
 	ucontext_t *ctx = (ucontext_t *)unused;
 	unsigned long *pc = &UCONTEXT_NIA(ctx);
 
-	if (*pc == (unsigned long)&dscr_insn) {
+	/* mtspr 3,RS to check for move to DSCR below */
+	if ((*((unsigned int *)*pc) & 0xfc1fffff) == 0x7c0303a6) {
 		if (!warned++)
 			printf("WARNING: Skipping over dscr setup. Consider running 'ppc64_cpu --dscr=1' manually.\n");
 		*pc += 4;
@@ -271,5 +271,5 @@ void set_dscr(unsigned long val)
 		init = 1;
 	}
 
-	asm volatile("dscr_insn: mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR));
+	asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR));
 }
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests/powerpc: Fix compilation issue due to asm label
  2018-10-31 17:18 [PATCH] selftests/powerpc: Fix compilation issue due to asm label Naveen N. Rao
@ 2018-10-31 17:24 ` Naveen N. Rao
  2018-10-31 19:05   ` Breno Leitao
  2018-11-01 12:46 ` Michael Ellerman
  1 sibling, 1 reply; 4+ messages in thread
From: Naveen N. Rao @ 2018-10-31 17:24 UTC (permalink / raw)
  To: Breno Leitao, Michael Ellerman; +Cc: linuxppc-dev

Naveen N. Rao wrote:
> We are using 'dscr_insn' as a label in inline asm to identify if a
> SIGILL was generated by the mtspr instruction at that point. However,
> with inline assembly, the compiler is still free to duplicate the asm
> statement for optimization purposes, which results in the label being
> defined twice with the error:
> 	/tmp/ccerQCql.s:874: Error: symbol `dscr_insn' is already defined
> 
> With different compiler versions, we may also see:
> 	/tmp/ccJzLDlN.o:(.toc+0x0): undefined reference to `dscr_insn'
> 
> Remove the use of the label in the inline assembly. Instead, just look
> for the offending instruction in the signal handler.
> 
> Reported-by: Breno Leitao <leitao@debian.org>
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> ---

Missed adding:
Fixes: d2bf793237b3aa9c ("selftests/powerpc: Add test to verify rfi flush across a system call")

- Naveen



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests/powerpc: Fix compilation issue due to asm label
  2018-10-31 17:24 ` Naveen N. Rao
@ 2018-10-31 19:05   ` Breno Leitao
  0 siblings, 0 replies; 4+ messages in thread
From: Breno Leitao @ 2018-10-31 19:05 UTC (permalink / raw)
  To: Naveen N. Rao, Michael Ellerman; +Cc: linuxppc-dev

hi Naveen,

On 10/31/18 2:24 PM, Naveen N. Rao wrote:
> Naveen N. Rao wrote:
>> We are using 'dscr_insn' as a label in inline asm to identify if a
>> SIGILL was generated by the mtspr instruction at that point. However,
>> with inline assembly, the compiler is still free to duplicate the asm
>> statement for optimization purposes, which results in the label being
>> defined twice with the error:
>>     /tmp/ccerQCql.s:874: Error: symbol `dscr_insn' is already defined
>>
>> With different compiler versions, we may also see:
>>     /tmp/ccJzLDlN.o:(.toc+0x0): undefined reference to `dscr_insn'
>>
>> Remove the use of the label in the inline assembly. Instead, just look
>> for the offending instruction in the signal handler.

Cool, I've tested this patch on my mainline tree and selftests are being
able to build again. I also tested the rfi_flush_test selftest as other
tests (ptrace/ and tm/) and everything seems to be normal again.

Thank you!

>> Reported-by: Breno Leitao <leitao@debian.org>
>> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>

Tested-by: Breno Leitao <leitao@debian.org>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: selftests/powerpc: Fix compilation issue due to asm label
  2018-10-31 17:18 [PATCH] selftests/powerpc: Fix compilation issue due to asm label Naveen N. Rao
  2018-10-31 17:24 ` Naveen N. Rao
@ 2018-11-01 12:46 ` Michael Ellerman
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2018-11-01 12:46 UTC (permalink / raw)
  To: Naveen N. Rao, Breno Leitao; +Cc: linuxppc-dev

On Wed, 2018-10-31 at 17:18:13 UTC, "Naveen N. Rao" wrote:
> We are using 'dscr_insn' as a label in inline asm to identify if a
> SIGILL was generated by the mtspr instruction at that point. However,
> with inline assembly, the compiler is still free to duplicate the asm
> statement for optimization purposes, which results in the label being
> defined twice with the error:
> 	/tmp/ccerQCql.s:874: Error: symbol `dscr_insn' is already defined
> 
> With different compiler versions, we may also see:
> 	/tmp/ccJzLDlN.o:(.toc+0x0): undefined reference to `dscr_insn'
> 
> Remove the use of the label in the inline assembly. Instead, just look
> for the offending instruction in the signal handler.
> 
> Reported-by: Breno Leitao <leitao@debian.org>
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> Tested-by: Breno Leitao <leitao@debian.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/1936f094e164cc13ebf17aba1d6b34

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-11-01 12:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-31 17:18 [PATCH] selftests/powerpc: Fix compilation issue due to asm label Naveen N. Rao
2018-10-31 17:24 ` Naveen N. Rao
2018-10-31 19:05   ` Breno Leitao
2018-11-01 12:46 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.