All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] kselftest/arm64: Build fixes for clang
@ 2023-01-12 19:51 ` Mark Brown
  0 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

This series provides a few small build fixes and Makefile tweaks which
allow us to build the arm64 selftests using clang as well as GCC.  I
also fixed one minor issue I noticed in the MTE Makefile while doing the
updates there.

To: Catalin Marinas <catalin.marinas@arm.com>
To: Will Deacon <will@kernel.org>
To: Shuah Khan <shuah@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>
To: Nick Desaulniers <ndesaulniers@google.com>
To: Tom Rix <trix@redhat.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kselftest@vger.kernel.org
Cc: llvm@lists.linux.dev
Signed-off-by: Mark Brown <broonie@kernel.org>

---
Mark Brown (6):
      kselftest/arm64: Fix .pushsection for strings in FP tests
      kselftest/arm64: Remove redundant _start labels from FP tests
      kselftest/arm64: Don't pass headers to the compiler as source
      kselftest/arm64: Initialise current at build time in signal tests
      kselftest/arm64: Support build of MTE tests with clang
      kselftest/arm64: Remove spurious comment from MTE test Makefile

 tools/testing/selftests/arm64/fp/assembler.h        |  2 +-
 tools/testing/selftests/arm64/fp/fp-pidbench.S      |  1 -
 tools/testing/selftests/arm64/fp/fpsimd-test.S      |  1 -
 tools/testing/selftests/arm64/fp/sve-test.S         |  1 -
 tools/testing/selftests/arm64/fp/za-test.S          |  1 -
 tools/testing/selftests/arm64/mte/Makefile          | 21 +++++++++++++++------
 tools/testing/selftests/arm64/signal/Makefile       |  8 ++++++--
 tools/testing/selftests/arm64/signal/test_signals.c |  4 +---
 8 files changed, 23 insertions(+), 16 deletions(-)
---
base-commit: b7bfaa761d760e72a969d116517eaa12e404c262
change-id: 20230111-arm64-kselftest-clang-f734b6b0c057

Best regards,
-- 
Mark Brown <broonie@kernel.org>

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

* [PATCH 1/6] kselftest/arm64: Fix .pushsection for strings in FP tests
  2023-01-12 19:51 ` Mark Brown
@ 2023-01-12 19:51   ` Mark Brown
  -1 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

The .pushsection directive used to store the strings used with the .puts
macro in the floating point helpers does not provide a section type but
according to the gas documentation this should be mandatory and with the
clang built in as it actually is. Provide one so that we can build these
tests with LLVM=1.

No functional change.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/fp/assembler.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/arm64/fp/assembler.h b/tools/testing/selftests/arm64/fp/assembler.h
index 90bd433d2665..9b38a0da407d 100644
--- a/tools/testing/selftests/arm64/fp/assembler.h
+++ b/tools/testing/selftests/arm64/fp/assembler.h
@@ -57,7 +57,7 @@ endfunction
 // Utility macro to print a literal string
 // Clobbers x0-x4,x8
 .macro puts string
-	.pushsection .rodata.str1.1, "aMS", 1
+	.pushsection .rodata.str1.1, "aMS", @progbits, 1
 .L__puts_literal\@: .string "\string"
 	.popsection
 

-- 
2.30.2

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

* [PATCH 0/6] kselftest/arm64: Build fixes for clang
@ 2023-01-12 19:51 ` Mark Brown
  0 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

This series provides a few small build fixes and Makefile tweaks which
allow us to build the arm64 selftests using clang as well as GCC.  I
also fixed one minor issue I noticed in the MTE Makefile while doing the
updates there.

To: Catalin Marinas <catalin.marinas@arm.com>
To: Will Deacon <will@kernel.org>
To: Shuah Khan <shuah@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>
To: Nick Desaulniers <ndesaulniers@google.com>
To: Tom Rix <trix@redhat.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kselftest@vger.kernel.org
Cc: llvm@lists.linux.dev
Signed-off-by: Mark Brown <broonie@kernel.org>

---
Mark Brown (6):
      kselftest/arm64: Fix .pushsection for strings in FP tests
      kselftest/arm64: Remove redundant _start labels from FP tests
      kselftest/arm64: Don't pass headers to the compiler as source
      kselftest/arm64: Initialise current at build time in signal tests
      kselftest/arm64: Support build of MTE tests with clang
      kselftest/arm64: Remove spurious comment from MTE test Makefile

 tools/testing/selftests/arm64/fp/assembler.h        |  2 +-
 tools/testing/selftests/arm64/fp/fp-pidbench.S      |  1 -
 tools/testing/selftests/arm64/fp/fpsimd-test.S      |  1 -
 tools/testing/selftests/arm64/fp/sve-test.S         |  1 -
 tools/testing/selftests/arm64/fp/za-test.S          |  1 -
 tools/testing/selftests/arm64/mte/Makefile          | 21 +++++++++++++++------
 tools/testing/selftests/arm64/signal/Makefile       |  8 ++++++--
 tools/testing/selftests/arm64/signal/test_signals.c |  4 +---
 8 files changed, 23 insertions(+), 16 deletions(-)
---
base-commit: b7bfaa761d760e72a969d116517eaa12e404c262
change-id: 20230111-arm64-kselftest-clang-f734b6b0c057

Best regards,
-- 
Mark Brown <broonie@kernel.org>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/6] kselftest/arm64: Fix .pushsection for strings in FP tests
@ 2023-01-12 19:51   ` Mark Brown
  0 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

The .pushsection directive used to store the strings used with the .puts
macro in the floating point helpers does not provide a section type but
according to the gas documentation this should be mandatory and with the
clang built in as it actually is. Provide one so that we can build these
tests with LLVM=1.

No functional change.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/fp/assembler.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/arm64/fp/assembler.h b/tools/testing/selftests/arm64/fp/assembler.h
index 90bd433d2665..9b38a0da407d 100644
--- a/tools/testing/selftests/arm64/fp/assembler.h
+++ b/tools/testing/selftests/arm64/fp/assembler.h
@@ -57,7 +57,7 @@ endfunction
 // Utility macro to print a literal string
 // Clobbers x0-x4,x8
 .macro puts string
-	.pushsection .rodata.str1.1, "aMS", 1
+	.pushsection .rodata.str1.1, "aMS", @progbits, 1
 .L__puts_literal\@: .string "\string"
 	.popsection
 

-- 
2.30.2

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/6] kselftest/arm64: Remove redundant _start labels from FP tests
  2023-01-12 19:51 ` Mark Brown
@ 2023-01-12 19:51   ` Mark Brown
  -1 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

There are a number of freestanding static executables used in floating
point testing that have no runtime at all. These all define the main entry
point as:

   .globl _start
   function _start
   _start:

but clang's integrated assembler complains that:

  error: symbol '_start' is already defined

due to having both a label and function directive. Remove the label to
allow building with clang.

No functional change.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/fp/fp-pidbench.S | 1 -
 tools/testing/selftests/arm64/fp/fpsimd-test.S | 1 -
 tools/testing/selftests/arm64/fp/sve-test.S    | 1 -
 tools/testing/selftests/arm64/fp/za-test.S     | 1 -
 4 files changed, 4 deletions(-)

diff --git a/tools/testing/selftests/arm64/fp/fp-pidbench.S b/tools/testing/selftests/arm64/fp/fp-pidbench.S
index 16a436389bfc..73830f6bc99b 100644
--- a/tools/testing/selftests/arm64/fp/fp-pidbench.S
+++ b/tools/testing/selftests/arm64/fp/fp-pidbench.S
@@ -31,7 +31,6 @@
 // Main program entry point
 .globl _start
 function _start
-_start:
 	puts	"Iterations per test: "
 	mov	x20, #10000
 	lsl	x20, x20, #8
diff --git a/tools/testing/selftests/arm64/fp/fpsimd-test.S b/tools/testing/selftests/arm64/fp/fpsimd-test.S
index 918d04885a33..8b960d01ed2e 100644
--- a/tools/testing/selftests/arm64/fp/fpsimd-test.S
+++ b/tools/testing/selftests/arm64/fp/fpsimd-test.S
@@ -215,7 +215,6 @@ endfunction
 // Main program entry point
 .globl _start
 function _start
-_start:
 	mov	x23, #0		// signal count
 
 	mov	w0, #SIGINT
diff --git a/tools/testing/selftests/arm64/fp/sve-test.S b/tools/testing/selftests/arm64/fp/sve-test.S
index 2a18cb4c528c..4328895dfc87 100644
--- a/tools/testing/selftests/arm64/fp/sve-test.S
+++ b/tools/testing/selftests/arm64/fp/sve-test.S
@@ -378,7 +378,6 @@ endfunction
 // Main program entry point
 .globl _start
 function _start
-_start:
 	mov	x23, #0		// Irritation signal count
 
 	mov	w0, #SIGINT
diff --git a/tools/testing/selftests/arm64/fp/za-test.S b/tools/testing/selftests/arm64/fp/za-test.S
index 53c54af65704..9dcd70911397 100644
--- a/tools/testing/selftests/arm64/fp/za-test.S
+++ b/tools/testing/selftests/arm64/fp/za-test.S
@@ -231,7 +231,6 @@ endfunction
 // Main program entry point
 .globl _start
 function _start
-_start:
 	mov	x23, #0		// signal count
 
 	mov	w0, #SIGINT

-- 
2.30.2

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

* [PATCH 2/6] kselftest/arm64: Remove redundant _start labels from FP tests
@ 2023-01-12 19:51   ` Mark Brown
  0 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

There are a number of freestanding static executables used in floating
point testing that have no runtime at all. These all define the main entry
point as:

   .globl _start
   function _start
   _start:

but clang's integrated assembler complains that:

  error: symbol '_start' is already defined

due to having both a label and function directive. Remove the label to
allow building with clang.

No functional change.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/fp/fp-pidbench.S | 1 -
 tools/testing/selftests/arm64/fp/fpsimd-test.S | 1 -
 tools/testing/selftests/arm64/fp/sve-test.S    | 1 -
 tools/testing/selftests/arm64/fp/za-test.S     | 1 -
 4 files changed, 4 deletions(-)

diff --git a/tools/testing/selftests/arm64/fp/fp-pidbench.S b/tools/testing/selftests/arm64/fp/fp-pidbench.S
index 16a436389bfc..73830f6bc99b 100644
--- a/tools/testing/selftests/arm64/fp/fp-pidbench.S
+++ b/tools/testing/selftests/arm64/fp/fp-pidbench.S
@@ -31,7 +31,6 @@
 // Main program entry point
 .globl _start
 function _start
-_start:
 	puts	"Iterations per test: "
 	mov	x20, #10000
 	lsl	x20, x20, #8
diff --git a/tools/testing/selftests/arm64/fp/fpsimd-test.S b/tools/testing/selftests/arm64/fp/fpsimd-test.S
index 918d04885a33..8b960d01ed2e 100644
--- a/tools/testing/selftests/arm64/fp/fpsimd-test.S
+++ b/tools/testing/selftests/arm64/fp/fpsimd-test.S
@@ -215,7 +215,6 @@ endfunction
 // Main program entry point
 .globl _start
 function _start
-_start:
 	mov	x23, #0		// signal count
 
 	mov	w0, #SIGINT
diff --git a/tools/testing/selftests/arm64/fp/sve-test.S b/tools/testing/selftests/arm64/fp/sve-test.S
index 2a18cb4c528c..4328895dfc87 100644
--- a/tools/testing/selftests/arm64/fp/sve-test.S
+++ b/tools/testing/selftests/arm64/fp/sve-test.S
@@ -378,7 +378,6 @@ endfunction
 // Main program entry point
 .globl _start
 function _start
-_start:
 	mov	x23, #0		// Irritation signal count
 
 	mov	w0, #SIGINT
diff --git a/tools/testing/selftests/arm64/fp/za-test.S b/tools/testing/selftests/arm64/fp/za-test.S
index 53c54af65704..9dcd70911397 100644
--- a/tools/testing/selftests/arm64/fp/za-test.S
+++ b/tools/testing/selftests/arm64/fp/za-test.S
@@ -231,7 +231,6 @@ endfunction
 // Main program entry point
 .globl _start
 function _start
-_start:
 	mov	x23, #0		// signal count
 
 	mov	w0, #SIGINT

-- 
2.30.2

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 3/6] kselftest/arm64: Don't pass headers to the compiler as source
  2023-01-12 19:51 ` Mark Brown
@ 2023-01-12 19:51   ` Mark Brown
  -1 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

The signal Makefile rules pass all the dependencies for each executable,
including headers, to the compiler which GCC is happy enough with but
clang rejects:

   clang --target=aarch64-none-linux-gnu -fintegrated-as -Wall -O2 -g -I/home/broonie/git/linux/tools/testing/selftests/ -isystem /home/broonie/git/linux/usr/include -D_GNU_SOURCE -std=gnu99 -I.  test_signals.c test_signals_utils.c testcases/testcases.c signals.S testcases/fake_sigreturn_bad_magic.c test_signals.h test_signals_utils.h testcases/testcases.h -o testcases/fake_sigreturn_bad_magic
  clang: error: cannot specify -o when generating multiple output files

This happens because clang gets confused about what to do with the
header files, failing to identify them as source.  This is not amazing
behaviour on clang's part and should ideally be fixed but even if that
happens we'd still need a new clang release so let's instead rework the
Makefile so we use variables for the lists of header and source files,
allowing us to only pass the source files to the compiler and keep clang
happy.

As a bonus the resulting Makefile is a bit easier to read.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/signal/Makefile | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/arm64/signal/Makefile b/tools/testing/selftests/arm64/signal/Makefile
index be7520a863b0..8f5febaf1a9a 100644
--- a/tools/testing/selftests/arm64/signal/Makefile
+++ b/tools/testing/selftests/arm64/signal/Makefile
@@ -22,6 +22,10 @@ $(TEST_GEN_PROGS): $(PROGS)
 
 # Common test-unit targets to build common-layout test-cases executables
 # Needs secondary expansion to properly include the testcase c-file in pre-reqs
+COMMON_SOURCES := test_signals.c test_signals_utils.c testcases/testcases.c \
+	signals.S
+COMMON_HEADERS := test_signals.h test_signals_utils.h testcases/testcases.h
+
 .SECONDEXPANSION:
-$(PROGS): test_signals.c test_signals_utils.c testcases/testcases.c signals.S $$@.c test_signals.h test_signals_utils.h testcases/testcases.h
-	$(CC) $(CFLAGS) $^ -o $@
+$(PROGS): $$@.c ${COMMON_SOURCES} ${COMMON_HEADERS}
+	$(CC) $(CFLAGS) ${@}.c ${COMMON_SOURCES} -o $@

-- 
2.30.2

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

* [PATCH 3/6] kselftest/arm64: Don't pass headers to the compiler as source
@ 2023-01-12 19:51   ` Mark Brown
  0 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

The signal Makefile rules pass all the dependencies for each executable,
including headers, to the compiler which GCC is happy enough with but
clang rejects:

   clang --target=aarch64-none-linux-gnu -fintegrated-as -Wall -O2 -g -I/home/broonie/git/linux/tools/testing/selftests/ -isystem /home/broonie/git/linux/usr/include -D_GNU_SOURCE -std=gnu99 -I.  test_signals.c test_signals_utils.c testcases/testcases.c signals.S testcases/fake_sigreturn_bad_magic.c test_signals.h test_signals_utils.h testcases/testcases.h -o testcases/fake_sigreturn_bad_magic
  clang: error: cannot specify -o when generating multiple output files

This happens because clang gets confused about what to do with the
header files, failing to identify them as source.  This is not amazing
behaviour on clang's part and should ideally be fixed but even if that
happens we'd still need a new clang release so let's instead rework the
Makefile so we use variables for the lists of header and source files,
allowing us to only pass the source files to the compiler and keep clang
happy.

As a bonus the resulting Makefile is a bit easier to read.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/signal/Makefile | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/arm64/signal/Makefile b/tools/testing/selftests/arm64/signal/Makefile
index be7520a863b0..8f5febaf1a9a 100644
--- a/tools/testing/selftests/arm64/signal/Makefile
+++ b/tools/testing/selftests/arm64/signal/Makefile
@@ -22,6 +22,10 @@ $(TEST_GEN_PROGS): $(PROGS)
 
 # Common test-unit targets to build common-layout test-cases executables
 # Needs secondary expansion to properly include the testcase c-file in pre-reqs
+COMMON_SOURCES := test_signals.c test_signals_utils.c testcases/testcases.c \
+	signals.S
+COMMON_HEADERS := test_signals.h test_signals_utils.h testcases/testcases.h
+
 .SECONDEXPANSION:
-$(PROGS): test_signals.c test_signals_utils.c testcases/testcases.c signals.S $$@.c test_signals.h test_signals_utils.h testcases/testcases.h
-	$(CC) $(CFLAGS) $^ -o $@
+$(PROGS): $$@.c ${COMMON_SOURCES} ${COMMON_HEADERS}
+	$(CC) $(CFLAGS) ${@}.c ${COMMON_SOURCES} -o $@

-- 
2.30.2

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 4/6] kselftest/arm64: Initialise current at build time in signal tests
  2023-01-12 19:51 ` Mark Brown
@ 2023-01-12 19:51   ` Mark Brown
  -1 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

When building with clang the toolchain refuses to link the signals
testcases since the assembly code has a reference to current which has
no initialiser so is placed in the BSS:

  /tmp/signals-af2042.o: in function `fake_sigreturn':
  <unknown>:51:(.text+0x40): relocation truncated to fit: R_AARCH64_LD_PREL_LO19 against symbol `current' defined in .bss section in /tmp/test_signals-ec1160.o

Since the first statement in main() initialises current we may as well
fix this by moving the initialisation to build time so the variable
doesn't end up in the BSS.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/signal/test_signals.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/testing/selftests/arm64/signal/test_signals.c b/tools/testing/selftests/arm64/signal/test_signals.c
index 416b1ff43199..00051b40d71e 100644
--- a/tools/testing/selftests/arm64/signal/test_signals.c
+++ b/tools/testing/selftests/arm64/signal/test_signals.c
@@ -12,12 +12,10 @@
 #include "test_signals.h"
 #include "test_signals_utils.h"
 
-struct tdescr *current;
+struct tdescr *current = &tde;
 
 int main(int argc, char *argv[])
 {
-	current = &tde;
-
 	ksft_print_msg("%s :: %s\n", current->name, current->descr);
 	if (test_setup(current) && test_init(current)) {
 		test_run(current);

-- 
2.30.2

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

* [PATCH 4/6] kselftest/arm64: Initialise current at build time in signal tests
@ 2023-01-12 19:51   ` Mark Brown
  0 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

When building with clang the toolchain refuses to link the signals
testcases since the assembly code has a reference to current which has
no initialiser so is placed in the BSS:

  /tmp/signals-af2042.o: in function `fake_sigreturn':
  <unknown>:51:(.text+0x40): relocation truncated to fit: R_AARCH64_LD_PREL_LO19 against symbol `current' defined in .bss section in /tmp/test_signals-ec1160.o

Since the first statement in main() initialises current we may as well
fix this by moving the initialisation to build time so the variable
doesn't end up in the BSS.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/signal/test_signals.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/testing/selftests/arm64/signal/test_signals.c b/tools/testing/selftests/arm64/signal/test_signals.c
index 416b1ff43199..00051b40d71e 100644
--- a/tools/testing/selftests/arm64/signal/test_signals.c
+++ b/tools/testing/selftests/arm64/signal/test_signals.c
@@ -12,12 +12,10 @@
 #include "test_signals.h"
 #include "test_signals_utils.h"
 
-struct tdescr *current;
+struct tdescr *current = &tde;
 
 int main(int argc, char *argv[])
 {
-	current = &tde;
-
 	ksft_print_msg("%s :: %s\n", current->name, current->descr);
 	if (test_setup(current) && test_init(current)) {
 		test_run(current);

-- 
2.30.2

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 5/6] kselftest/arm64: Support build of MTE tests with clang
  2023-01-12 19:51 ` Mark Brown
@ 2023-01-12 19:51   ` Mark Brown
  -1 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

The assembly portions of the MTE selftests need to be built with a
toolchain supporting MTE.  Since we support GCC versions that lack MTE
support we have logic to suppress build of these tests when using such a
toolchain but that logic is broken for LLVM=1 builds, it uses CC but CC
is only set for LLVM builds in libs.mk which needs to be included after
we have selected which test programs to build.

Since all supported LLVM versions support MTE we can simply assume MTE
support when LLVM is set.  This is not a thing of beauty but it does the
job.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/mte/Makefile | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/arm64/mte/Makefile b/tools/testing/selftests/arm64/mte/Makefile
index 037046f5784e..fdb9acdca42b 100644
--- a/tools/testing/selftests/arm64/mte/Makefile
+++ b/tools/testing/selftests/arm64/mte/Makefile
@@ -1,19 +1,29 @@
 # SPDX-License-Identifier: GPL-2.0
 # Copyright (C) 2020 ARM Limited
 
-# preserve CC value from top level Makefile
-ifeq ($(CC),cc)
-CC := $(CROSS_COMPILE)gcc
-endif
-
 CFLAGS += -std=gnu99 -I. -pthread
 LDFLAGS += -pthread
 SRCS := $(filter-out mte_common_util.c,$(wildcard *.c))
 PROGS := $(patsubst %.c,%,$(SRCS))
 
+ifeq ($(LLVM),)
+# For GCC check that the toolchain has MTE support.
+
+# preserve CC value from top level Makefile
+ifeq ($(CC),cc)
+CC := $(CROSS_COMPILE)gcc
+endif
+
 #check if the compiler works well
 mte_cc_support := $(shell if ($(CC) $(CFLAGS) -march=armv8.5-a+memtag -E -x c /dev/null -o /dev/null 2>&1) then echo "1"; fi)
 
+else
+
+# All supported clang versions also support MTE.
+mte_cc_support := 1
+
+endif
+
 ifeq ($(mte_cc_support),1)
 # Generated binaries to be installed by top KSFT script
 TEST_GEN_PROGS := $(PROGS)

-- 
2.30.2

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

* [PATCH 5/6] kselftest/arm64: Support build of MTE tests with clang
@ 2023-01-12 19:51   ` Mark Brown
  0 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

The assembly portions of the MTE selftests need to be built with a
toolchain supporting MTE.  Since we support GCC versions that lack MTE
support we have logic to suppress build of these tests when using such a
toolchain but that logic is broken for LLVM=1 builds, it uses CC but CC
is only set for LLVM builds in libs.mk which needs to be included after
we have selected which test programs to build.

Since all supported LLVM versions support MTE we can simply assume MTE
support when LLVM is set.  This is not a thing of beauty but it does the
job.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/mte/Makefile | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/arm64/mte/Makefile b/tools/testing/selftests/arm64/mte/Makefile
index 037046f5784e..fdb9acdca42b 100644
--- a/tools/testing/selftests/arm64/mte/Makefile
+++ b/tools/testing/selftests/arm64/mte/Makefile
@@ -1,19 +1,29 @@
 # SPDX-License-Identifier: GPL-2.0
 # Copyright (C) 2020 ARM Limited
 
-# preserve CC value from top level Makefile
-ifeq ($(CC),cc)
-CC := $(CROSS_COMPILE)gcc
-endif
-
 CFLAGS += -std=gnu99 -I. -pthread
 LDFLAGS += -pthread
 SRCS := $(filter-out mte_common_util.c,$(wildcard *.c))
 PROGS := $(patsubst %.c,%,$(SRCS))
 
+ifeq ($(LLVM),)
+# For GCC check that the toolchain has MTE support.
+
+# preserve CC value from top level Makefile
+ifeq ($(CC),cc)
+CC := $(CROSS_COMPILE)gcc
+endif
+
 #check if the compiler works well
 mte_cc_support := $(shell if ($(CC) $(CFLAGS) -march=armv8.5-a+memtag -E -x c /dev/null -o /dev/null 2>&1) then echo "1"; fi)
 
+else
+
+# All supported clang versions also support MTE.
+mte_cc_support := 1
+
+endif
+
 ifeq ($(mte_cc_support),1)
 # Generated binaries to be installed by top KSFT script
 TEST_GEN_PROGS := $(PROGS)

-- 
2.30.2

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 6/6] kselftest/arm64: Remove spurious comment from MTE test Makefile
  2023-01-12 19:51 ` Mark Brown
@ 2023-01-12 19:51   ` Mark Brown
  -1 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

There's a stray comment in the MTE test Makefile which documents
something that's since been removed, delete it.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/mte/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/arm64/mte/Makefile b/tools/testing/selftests/arm64/mte/Makefile
index fdb9acdca42b..0d7ac3db8390 100644
--- a/tools/testing/selftests/arm64/mte/Makefile
+++ b/tools/testing/selftests/arm64/mte/Makefile
@@ -28,7 +28,6 @@ ifeq ($(mte_cc_support),1)
 # Generated binaries to be installed by top KSFT script
 TEST_GEN_PROGS := $(PROGS)
 
-# Get Kernel headers installed and use them.
 else
     $(warning compiler "$(CC)" does not support the ARMv8.5 MTE extension.)
     $(warning test program "mte" will not be created.)

-- 
2.30.2

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

* [PATCH 6/6] kselftest/arm64: Remove spurious comment from MTE test Makefile
@ 2023-01-12 19:51   ` Mark Brown
  0 siblings, 0 replies; 18+ messages in thread
From: Mark Brown @ 2023-01-12 19:51 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: linux-arm-kernel, linux-kselftest, llvm, Mark Brown

There's a stray comment in the MTE test Makefile which documents
something that's since been removed, delete it.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/mte/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/arm64/mte/Makefile b/tools/testing/selftests/arm64/mte/Makefile
index fdb9acdca42b..0d7ac3db8390 100644
--- a/tools/testing/selftests/arm64/mte/Makefile
+++ b/tools/testing/selftests/arm64/mte/Makefile
@@ -28,7 +28,6 @@ ifeq ($(mte_cc_support),1)
 # Generated binaries to be installed by top KSFT script
 TEST_GEN_PROGS := $(PROGS)
 
-# Get Kernel headers installed and use them.
 else
     $(warning compiler "$(CC)" does not support the ARMv8.5 MTE extension.)
     $(warning test program "mte" will not be created.)

-- 
2.30.2

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 0/6] kselftest/arm64: Build fixes for clang
  2023-01-12 19:51 ` Mark Brown
@ 2023-01-12 20:20   ` Nick Desaulniers
  -1 siblings, 0 replies; 18+ messages in thread
From: Nick Desaulniers @ 2023-01-12 20:20 UTC (permalink / raw)
  To: Mark Brown
  Cc: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Tom Rix, linux-arm-kernel, linux-kselftest, llvm

On Thu, Jan 12, 2023 at 11:52 AM Mark Brown <broonie@kernel.org> wrote:
>
> This series provides a few small build fixes and Makefile tweaks which
> allow us to build the arm64 selftests using clang as well as GCC.  I
> also fixed one minor issue I noticed in the MTE Makefile while doing the
> updates there.
>
> To: Catalin Marinas <catalin.marinas@arm.com>
> To: Will Deacon <will@kernel.org>
> To: Shuah Khan <shuah@kernel.org>
> To: Nathan Chancellor <nathan@kernel.org>
> To: Nick Desaulniers <ndesaulniers@google.com>
> To: Tom Rix <trix@redhat.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kselftest@vger.kernel.org
> Cc: llvm@lists.linux.dev
> Signed-off-by: Mark Brown <broonie@kernel.org>

Thanks for the patches! They LGTM! For the series:
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> ---
> Mark Brown (6):
>       kselftest/arm64: Fix .pushsection for strings in FP tests
>       kselftest/arm64: Remove redundant _start labels from FP tests
>       kselftest/arm64: Don't pass headers to the compiler as source
>       kselftest/arm64: Initialise current at build time in signal tests
>       kselftest/arm64: Support build of MTE tests with clang
>       kselftest/arm64: Remove spurious comment from MTE test Makefile
>
>  tools/testing/selftests/arm64/fp/assembler.h        |  2 +-
>  tools/testing/selftests/arm64/fp/fp-pidbench.S      |  1 -
>  tools/testing/selftests/arm64/fp/fpsimd-test.S      |  1 -
>  tools/testing/selftests/arm64/fp/sve-test.S         |  1 -
>  tools/testing/selftests/arm64/fp/za-test.S          |  1 -
>  tools/testing/selftests/arm64/mte/Makefile          | 21 +++++++++++++++------
>  tools/testing/selftests/arm64/signal/Makefile       |  8 ++++++--
>  tools/testing/selftests/arm64/signal/test_signals.c |  4 +---
>  8 files changed, 23 insertions(+), 16 deletions(-)
> ---
> base-commit: b7bfaa761d760e72a969d116517eaa12e404c262
> change-id: 20230111-arm64-kselftest-clang-f734b6b0c057
>
> Best regards,
> --
> Mark Brown <broonie@kernel.org>



-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH 0/6] kselftest/arm64: Build fixes for clang
@ 2023-01-12 20:20   ` Nick Desaulniers
  0 siblings, 0 replies; 18+ messages in thread
From: Nick Desaulniers @ 2023-01-12 20:20 UTC (permalink / raw)
  To: Mark Brown
  Cc: Catalin Marinas, Will Deacon, Shuah Khan, Nathan Chancellor,
	Tom Rix, linux-arm-kernel, linux-kselftest, llvm

On Thu, Jan 12, 2023 at 11:52 AM Mark Brown <broonie@kernel.org> wrote:
>
> This series provides a few small build fixes and Makefile tweaks which
> allow us to build the arm64 selftests using clang as well as GCC.  I
> also fixed one minor issue I noticed in the MTE Makefile while doing the
> updates there.
>
> To: Catalin Marinas <catalin.marinas@arm.com>
> To: Will Deacon <will@kernel.org>
> To: Shuah Khan <shuah@kernel.org>
> To: Nathan Chancellor <nathan@kernel.org>
> To: Nick Desaulniers <ndesaulniers@google.com>
> To: Tom Rix <trix@redhat.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kselftest@vger.kernel.org
> Cc: llvm@lists.linux.dev
> Signed-off-by: Mark Brown <broonie@kernel.org>

Thanks for the patches! They LGTM! For the series:
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> ---
> Mark Brown (6):
>       kselftest/arm64: Fix .pushsection for strings in FP tests
>       kselftest/arm64: Remove redundant _start labels from FP tests
>       kselftest/arm64: Don't pass headers to the compiler as source
>       kselftest/arm64: Initialise current at build time in signal tests
>       kselftest/arm64: Support build of MTE tests with clang
>       kselftest/arm64: Remove spurious comment from MTE test Makefile
>
>  tools/testing/selftests/arm64/fp/assembler.h        |  2 +-
>  tools/testing/selftests/arm64/fp/fp-pidbench.S      |  1 -
>  tools/testing/selftests/arm64/fp/fpsimd-test.S      |  1 -
>  tools/testing/selftests/arm64/fp/sve-test.S         |  1 -
>  tools/testing/selftests/arm64/fp/za-test.S          |  1 -
>  tools/testing/selftests/arm64/mte/Makefile          | 21 +++++++++++++++------
>  tools/testing/selftests/arm64/signal/Makefile       |  8 ++++++--
>  tools/testing/selftests/arm64/signal/test_signals.c |  4 +---
>  8 files changed, 23 insertions(+), 16 deletions(-)
> ---
> base-commit: b7bfaa761d760e72a969d116517eaa12e404c262
> change-id: 20230111-arm64-kselftest-clang-f734b6b0c057
>
> Best regards,
> --
> Mark Brown <broonie@kernel.org>



-- 
Thanks,
~Nick Desaulniers

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 0/6] kselftest/arm64: Build fixes for clang
  2023-01-12 19:51 ` Mark Brown
@ 2023-01-20 16:59   ` Catalin Marinas
  -1 siblings, 0 replies; 18+ messages in thread
From: Catalin Marinas @ 2023-01-20 16:59 UTC (permalink / raw)
  To: Will Deacon, Shuah Khan, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Mark Brown
  Cc: linux-arm-kernel, linux-kselftest, llvm

On Thu, 12 Jan 2023 19:51:47 +0000, Mark Brown wrote:
> This series provides a few small build fixes and Makefile tweaks which
> allow us to build the arm64 selftests using clang as well as GCC.  I
> also fixed one minor issue I noticed in the MTE Makefile while doing the
> updates there.
> 
> 

Applied to arm64 (for-next/kselftest), thanks!

[1/6] kselftest/arm64: Fix .pushsection for strings in FP tests
      https://git.kernel.org/arm64/c/aa58ace3499a
[2/6] kselftest/arm64: Remove redundant _start labels from FP tests
      https://git.kernel.org/arm64/c/cd57a6584fe5
[3/6] kselftest/arm64: Don't pass headers to the compiler as source
      https://git.kernel.org/arm64/c/a884f7970e57
[4/6] kselftest/arm64: Initialise current at build time in signal tests
      https://git.kernel.org/arm64/c/6e4b4f0eca88
[5/6] kselftest/arm64: Support build of MTE tests with clang
      https://git.kernel.org/arm64/c/343d59119e77
[6/6] kselftest/arm64: Remove spurious comment from MTE test Makefile
      https://git.kernel.org/arm64/c/89d72c035f88

-- 
Catalin


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

* Re: [PATCH 0/6] kselftest/arm64: Build fixes for clang
@ 2023-01-20 16:59   ` Catalin Marinas
  0 siblings, 0 replies; 18+ messages in thread
From: Catalin Marinas @ 2023-01-20 16:59 UTC (permalink / raw)
  To: Will Deacon, Shuah Khan, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Mark Brown
  Cc: linux-arm-kernel, linux-kselftest, llvm

On Thu, 12 Jan 2023 19:51:47 +0000, Mark Brown wrote:
> This series provides a few small build fixes and Makefile tweaks which
> allow us to build the arm64 selftests using clang as well as GCC.  I
> also fixed one minor issue I noticed in the MTE Makefile while doing the
> updates there.
> 
> 

Applied to arm64 (for-next/kselftest), thanks!

[1/6] kselftest/arm64: Fix .pushsection for strings in FP tests
      https://git.kernel.org/arm64/c/aa58ace3499a
[2/6] kselftest/arm64: Remove redundant _start labels from FP tests
      https://git.kernel.org/arm64/c/cd57a6584fe5
[3/6] kselftest/arm64: Don't pass headers to the compiler as source
      https://git.kernel.org/arm64/c/a884f7970e57
[4/6] kselftest/arm64: Initialise current at build time in signal tests
      https://git.kernel.org/arm64/c/6e4b4f0eca88
[5/6] kselftest/arm64: Support build of MTE tests with clang
      https://git.kernel.org/arm64/c/343d59119e77
[6/6] kselftest/arm64: Remove spurious comment from MTE test Makefile
      https://git.kernel.org/arm64/c/89d72c035f88

-- 
Catalin


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-01-20 17:00 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-12 19:51 [PATCH 0/6] kselftest/arm64: Build fixes for clang Mark Brown
2023-01-12 19:51 ` Mark Brown
2023-01-12 19:51 ` [PATCH 1/6] kselftest/arm64: Fix .pushsection for strings in FP tests Mark Brown
2023-01-12 19:51   ` Mark Brown
2023-01-12 19:51 ` [PATCH 2/6] kselftest/arm64: Remove redundant _start labels from " Mark Brown
2023-01-12 19:51   ` Mark Brown
2023-01-12 19:51 ` [PATCH 3/6] kselftest/arm64: Don't pass headers to the compiler as source Mark Brown
2023-01-12 19:51   ` Mark Brown
2023-01-12 19:51 ` [PATCH 4/6] kselftest/arm64: Initialise current at build time in signal tests Mark Brown
2023-01-12 19:51   ` Mark Brown
2023-01-12 19:51 ` [PATCH 5/6] kselftest/arm64: Support build of MTE tests with clang Mark Brown
2023-01-12 19:51   ` Mark Brown
2023-01-12 19:51 ` [PATCH 6/6] kselftest/arm64: Remove spurious comment from MTE test Makefile Mark Brown
2023-01-12 19:51   ` Mark Brown
2023-01-12 20:20 ` [PATCH 0/6] kselftest/arm64: Build fixes for clang Nick Desaulniers
2023-01-12 20:20   ` Nick Desaulniers
2023-01-20 16:59 ` Catalin Marinas
2023-01-20 16:59   ` Catalin Marinas

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.