public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 0/4] selftests: riscv: Fix compilation issues for v_ptrace and cfi
@ 2026-03-05  8:11 Charlie Jenkins via B4 Relay
  2026-03-05  8:11 ` [PATCH 1/4] selftests: riscv: Add definition of BIT() macro Charlie Jenkins via B4 Relay
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Charlie Jenkins via B4 Relay @ 2026-03-05  8:11 UTC (permalink / raw)
  To: Shuah Khan, Paul Walmsley, Palmer Dabbelt, Sergey Matyukevich,
	Andy Chiu, Deepak Gupta
  Cc: linux-kselftest, linux-riscv, linux-kernel, Charlie Jenkins

There are a couple of compilation issues of the riscv selftests.
Coincidentally two of the issues are independent problems with not
including the header that includes the BIT() macro and the other issue
is from checkpatch incorrectly suggesting to remove non-redundant
braces.

Signed-off-by: Charlie Jenkins <thecharlesjenkins@gmail.com>
---
Charlie Jenkins (4):
      selftests: riscv: Add definition of BIT() macro
      selftests: riscv: Add braces around EXPECT_EQ()
      riscv: ptrace: Fix BIT() compilation issues
      selftests: riscv: Add license to cfi selftest

 arch/riscv/include/uapi/asm/ptrace.h                     |  1 +
 tools/testing/selftests/riscv/cfi/Makefile               |  2 ++
 tools/testing/selftests/riscv/vector/Makefile            |  2 ++
 tools/testing/selftests/riscv/vector/validate_v_ptrace.c | 16 ++++++++++------
 4 files changed, 15 insertions(+), 6 deletions(-)
---
base-commit: c107785c7e8dbabd1c18301a1c362544b5786282
change-id: 20260304-fix_selftests-c3f0ae46b3c7

Best regards,
-- 
Charlie Jenkins <thecharlesjenkins@gmail.com>



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

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

* [PATCH 1/4] selftests: riscv: Add definition of BIT() macro
  2026-03-05  8:11 [PATCH 0/4] selftests: riscv: Fix compilation issues for v_ptrace and cfi Charlie Jenkins via B4 Relay
@ 2026-03-05  8:11 ` Charlie Jenkins via B4 Relay
  2026-03-05 16:10   ` kernel test robot
  2026-03-05  8:11 ` [PATCH 2/4] selftests: riscv: Add braces around EXPECT_EQ() Charlie Jenkins via B4 Relay
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Charlie Jenkins via B4 Relay @ 2026-03-05  8:11 UTC (permalink / raw)
  To: Shuah Khan, Paul Walmsley, Palmer Dabbelt, Sergey Matyukevich,
	Andy Chiu, Deepak Gupta
  Cc: linux-kselftest, linux-riscv, linux-kernel, Charlie Jenkins

From: Charlie Jenkins <thecharlesjenkins@gmail.com>

The BIT() macros is used by the validate_v_ptrace() test case, but not
defined. Include linux/bits.h to pull in this definition. To ensure that
the header in the kernel source is used, add tools/include to the header
search path.

Fixes: 30eb191c895b ("selftests: riscv: verify ptrace rejects invalid vector csr inputs")
Signed-off-by: Charlie Jenkins <thecharlesjenkins@gmail.com>
---
 tools/testing/selftests/riscv/vector/Makefile            | 2 ++
 tools/testing/selftests/riscv/vector/validate_v_ptrace.c | 1 +
 2 files changed, 3 insertions(+)

diff --git a/tools/testing/selftests/riscv/vector/Makefile b/tools/testing/selftests/riscv/vector/Makefile
index 326dafd739bf..92c4cfe5f34d 100644
--- a/tools/testing/selftests/riscv/vector/Makefile
+++ b/tools/testing/selftests/riscv/vector/Makefile
@@ -2,6 +2,8 @@
 # Copyright (C) 2021 ARM Limited
 # Originally tools/testing/arm64/abi/Makefile
 
+CFLAGS += -I$(top_srcdir)/tools/include
+
 TEST_GEN_PROGS := v_initval vstate_prctl vstate_ptrace validate_v_ptrace
 TEST_GEN_PROGS_EXTENDED := vstate_exec_nolibc v_exec_initval_nolibc
 TEST_GEN_LIBS := v_helpers.c sys_hwprobe.c
diff --git a/tools/testing/selftests/riscv/vector/validate_v_ptrace.c b/tools/testing/selftests/riscv/vector/validate_v_ptrace.c
index 3589549f7228..257de36274e9 100644
--- a/tools/testing/selftests/riscv/vector/validate_v_ptrace.c
+++ b/tools/testing/selftests/riscv/vector/validate_v_ptrace.c
@@ -6,6 +6,7 @@
 #include <unistd.h>
 #include <errno.h>
 
+#include <linux/bits.h>
 #include <linux/ptrace.h>
 #include <linux/elf.h>
 

-- 
2.52.0



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

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

* [PATCH 2/4] selftests: riscv: Add braces around EXPECT_EQ()
  2026-03-05  8:11 [PATCH 0/4] selftests: riscv: Fix compilation issues for v_ptrace and cfi Charlie Jenkins via B4 Relay
  2026-03-05  8:11 ` [PATCH 1/4] selftests: riscv: Add definition of BIT() macro Charlie Jenkins via B4 Relay
@ 2026-03-05  8:11 ` Charlie Jenkins via B4 Relay
  2026-03-05  8:11 ` [PATCH 3/4] riscv: ptrace: Fix BIT() compilation issues Charlie Jenkins via B4 Relay
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Charlie Jenkins via B4 Relay @ 2026-03-05  8:11 UTC (permalink / raw)
  To: Shuah Khan, Paul Walmsley, Palmer Dabbelt, Sergey Matyukevich,
	Andy Chiu, Deepak Gupta
  Cc: linux-kselftest, linux-riscv, linux-kernel, Charlie Jenkins

From: Charlie Jenkins <thecharlesjenkins@gmail.com>

EXPECT_EQ() expands to multiple lines, breaking up one-line if
statements. This issue was not present in the patch on the mailing list
but was instead introduced by the maintainer when attempting to fix up
checkpatch warnings. Add braces around EXPECT_EQ() to avoid the error
even though checkpatch suggests them to be removed:

validate_v_ptrace.c:626:17: error: ‘else’ without a previous ‘if’

Fixes: 3789d5eecd5a ("selftests: riscv: verify syscalls discard vector context")
Fixes: 30eb191c895b ("selftests: riscv: verify ptrace rejects invalid vector csr inputs")
Fixes: 849f05ae1ea6 ("selftests: riscv: verify ptrace accepts valid vector csr values")
Signed-off-by: Charlie Jenkins <thecharlesjenkins@gmail.com>
---
 tools/testing/selftests/riscv/vector/validate_v_ptrace.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/riscv/vector/validate_v_ptrace.c b/tools/testing/selftests/riscv/vector/validate_v_ptrace.c
index 257de36274e9..5724e6eb3309 100644
--- a/tools/testing/selftests/riscv/vector/validate_v_ptrace.c
+++ b/tools/testing/selftests/riscv/vector/validate_v_ptrace.c
@@ -291,10 +291,11 @@ TEST(ptrace_v_syscall_clobbering)
 
 		/* verify initial vsetvli settings */
 
-		if (is_xtheadvector_supported())
+		if (is_xtheadvector_supported()) {
 			EXPECT_EQ(5UL, regset_data->vtype);
-		else
+		} else {
 			EXPECT_EQ(9UL, regset_data->vtype);
+		}
 
 		EXPECT_EQ(regset_data->vlenb, regset_data->vl);
 		EXPECT_EQ(vlenb, regset_data->vlenb);
@@ -620,10 +621,11 @@ TEST_F(v_csr_invalid, ptrace_v_invalid_values)
 
 		/* verify initial vsetvli settings */
 
-		if (is_xtheadvector_supported())
+		if (is_xtheadvector_supported()) {
 			EXPECT_EQ(5UL, regset_data->vtype);
-		else
+		} else {
 			EXPECT_EQ(9UL, regset_data->vtype);
+		}
 
 		EXPECT_EQ(regset_data->vlenb, regset_data->vl);
 		EXPECT_EQ(vlenb, regset_data->vlenb);
@@ -828,10 +830,11 @@ TEST_F(v_csr_valid, ptrace_v_valid_values)
 
 		/* verify initial vsetvli settings */
 
-		if (is_xtheadvector_supported())
+		if (is_xtheadvector_supported()) {
 			EXPECT_EQ(5UL, regset_data->vtype);
-		else
+		} else {
 			EXPECT_EQ(9UL, regset_data->vtype);
+		}
 
 		EXPECT_EQ(regset_data->vlenb, regset_data->vl);
 		EXPECT_EQ(vlenb, regset_data->vlenb);

-- 
2.52.0



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

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

* [PATCH 3/4] riscv: ptrace: Fix BIT() compilation issues
  2026-03-05  8:11 [PATCH 0/4] selftests: riscv: Fix compilation issues for v_ptrace and cfi Charlie Jenkins via B4 Relay
  2026-03-05  8:11 ` [PATCH 1/4] selftests: riscv: Add definition of BIT() macro Charlie Jenkins via B4 Relay
  2026-03-05  8:11 ` [PATCH 2/4] selftests: riscv: Add braces around EXPECT_EQ() Charlie Jenkins via B4 Relay
@ 2026-03-05  8:11 ` Charlie Jenkins via B4 Relay
  2026-03-05  8:11 ` [PATCH 4/4] selftests: riscv: Add license to cfi selftest Charlie Jenkins via B4 Relay
  2026-03-09 21:21 ` [PATCH 0/4] selftests: riscv: Fix compilation issues for v_ptrace and cfi Sergey Matyukevich
  4 siblings, 0 replies; 8+ messages in thread
From: Charlie Jenkins via B4 Relay @ 2026-03-05  8:11 UTC (permalink / raw)
  To: Shuah Khan, Paul Walmsley, Palmer Dabbelt, Sergey Matyukevich,
	Andy Chiu, Deepak Gupta
  Cc: linux-kselftest, linux-riscv, linux-kernel, Charlie Jenkins

From: Charlie Jenkins <thecharlesjenkins@gmail.com>

BIT() is being used in ptrace.h without a definition, resulting in
compilation errors in tools/testing/selftests/riscv/cfi/cfitests.c:

cfitests.c:101:60: error: implicit declaration of function ‘BIT’ [-Wimplicit-function-declaration]
  101 |                      if ((cfi_reg.cfi_status.cfi_state & CFI_ENABLE_MASK) != CFI_ENABLE_MASK)

Include linux/bits.h to resolve this issue.

Fixes: 2af7c9cf021c ("riscv/ptrace: expose riscv CFI status and state via ptrace and in core files")
Signed-off-by: Charlie Jenkins <thecharlesjenkins@gmail.com>
---
 arch/riscv/include/uapi/asm/ptrace.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/include/uapi/asm/ptrace.h b/arch/riscv/include/uapi/asm/ptrace.h
index 18988a5f1a63..5b53cea14355 100644
--- a/arch/riscv/include/uapi/asm/ptrace.h
+++ b/arch/riscv/include/uapi/asm/ptrace.h
@@ -8,6 +8,7 @@
 
 #ifndef __ASSEMBLER__
 
+#include <linux/bits.h>
 #include <linux/types.h>
 
 #define PTRACE_GETFDPIC		33

-- 
2.52.0



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

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

* [PATCH 4/4] selftests: riscv: Add license to cfi selftest
  2026-03-05  8:11 [PATCH 0/4] selftests: riscv: Fix compilation issues for v_ptrace and cfi Charlie Jenkins via B4 Relay
                   ` (2 preceding siblings ...)
  2026-03-05  8:11 ` [PATCH 3/4] riscv: ptrace: Fix BIT() compilation issues Charlie Jenkins via B4 Relay
@ 2026-03-05  8:11 ` Charlie Jenkins via B4 Relay
  2026-03-09 21:21 ` [PATCH 0/4] selftests: riscv: Fix compilation issues for v_ptrace and cfi Sergey Matyukevich
  4 siblings, 0 replies; 8+ messages in thread
From: Charlie Jenkins via B4 Relay @ 2026-03-05  8:11 UTC (permalink / raw)
  To: Shuah Khan, Paul Walmsley, Palmer Dabbelt, Sergey Matyukevich,
	Andy Chiu, Deepak Gupta
  Cc: linux-kselftest, linux-riscv, linux-kernel, Charlie Jenkins

From: Charlie Jenkins <thecharlesjenkins@gmail.com>

The cfi selftest was missing a license so add it.

Signed-off-by: Charlie Jenkins <thecharlesjenkins@gmail.com>
---
 tools/testing/selftests/riscv/cfi/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/riscv/cfi/Makefile b/tools/testing/selftests/riscv/cfi/Makefile
index 96a4dc4b69c3..93b4738c0e2e 100644
--- a/tools/testing/selftests/riscv/cfi/Makefile
+++ b/tools/testing/selftests/riscv/cfi/Makefile
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
 CFLAGS += $(KHDR_INCLUDES)
 CFLAGS += -I$(top_srcdir)/tools/include
 

-- 
2.52.0



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

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

* Re: [PATCH 1/4] selftests: riscv: Add definition of BIT() macro
  2026-03-05  8:11 ` [PATCH 1/4] selftests: riscv: Add definition of BIT() macro Charlie Jenkins via B4 Relay
@ 2026-03-05 16:10   ` kernel test robot
  0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2026-03-05 16:10 UTC (permalink / raw)
  To: Charlie Jenkins via B4 Relay, Shuah Khan, Paul Walmsley,
	Palmer Dabbelt, Sergey Matyukevich, Andy Chiu, Deepak Gupta
  Cc: oe-kbuild-all, linux-kselftest, linux-riscv, linux-kernel,
	Charlie Jenkins

Hi Charlie,

kernel test robot noticed the following build errors:

[auto build test ERROR on c107785c7e8dbabd1c18301a1c362544b5786282]

url:    https://github.com/intel-lab-lkp/linux/commits/Charlie-Jenkins-via-B4-Relay/selftests-riscv-Add-definition-of-BIT-macro/20260305-164838
base:   c107785c7e8dbabd1c18301a1c362544b5786282
patch link:    https://lore.kernel.org/r/20260305-fix_selftests-v1-1-61b62d23500b%40gmail.com
patch subject: [PATCH 1/4] selftests: riscv: Add definition of BIT() macro
config: riscv-allnoconfig-bpf (https://download.01.org/0day-ci/archive/20260305/202603051713.xu4BUyLe-lkp@intel.com/config)
compiler: riscv64-linux-gnu-gcc (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260305/202603051713.xu4BUyLe-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603051713.xu4BUyLe-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from /usr/riscv64-linux-gnu/include/stdint.h:34,
                    from /usr/lib/gcc-cross/riscv64-linux-gnu/14/include/stdint.h:9,
                    from tools/testing/selftests/../../../tools/include/linux/types.h:7,
                    from ./../../../../include/nolibc/std.h:19,
                    from ./../../../../include/nolibc/nolibc.h:95,
                    from <command-line>:
>> /usr/riscv64-linux-gnu/include/bits/stdint-intn.h:27:19: error: conflicting types for 'int64_t'; have '__int64_t' {aka 'long int'}
      27 | typedef __int64_t int64_t;
         |                   ^~~~~~~
   In file included from ./../../../../include/nolibc/std.h:16:
   ./../../../../include/nolibc/stdint.h:17:29: note: previous declaration of 'int64_t' with type 'int64_t' {aka 'long long int'}
      17 | typedef   signed long long  int64_t;
         |                             ^~~~~~~
   In file included from /usr/riscv64-linux-gnu/include/stdint.h:37:
>> /usr/riscv64-linux-gnu/include/bits/stdint-uintn.h:27:20: error: conflicting types for 'uint64_t'; have '__uint64_t' {aka 'long unsigned int'}
      27 | typedef __uint64_t uint64_t;
         |                    ^~~~~~~~
   ./../../../../include/nolibc/stdint.h:16:28: note: previous declaration of 'uint64_t' with type 'uint64_t' {aka 'long long unsigned int'}
      16 | typedef unsigned long long uint64_t;
         |                            ^~~~~~~~
   In file included from /usr/riscv64-linux-gnu/include/stdint.h:41:
>> /usr/riscv64-linux-gnu/include/bits/stdint-least.h:28:25: error: conflicting types for 'int_least64_t'; have '__int_least64_t' {aka 'long int'}
      28 | typedef __int_least64_t int_least64_t;
         |                         ^~~~~~~~~~~~~
   ./../../../../include/nolibc/stdint.h:30:23: note: previous declaration of 'int_least64_t' with type 'int_least64_t' {aka 'long long int'}
      30 | typedef  int64_t      int_least64_t;
         |                       ^~~~~~~~~~~~~
>> /usr/riscv64-linux-gnu/include/bits/stdint-least.h:34:26: error: conflicting types for 'uint_least64_t'; have '__uint_least64_t' {aka 'long unsigned int'}
      34 | typedef __uint_least64_t uint_least64_t;
         |                          ^~~~~~~~~~~~~~
   ./../../../../include/nolibc/stdint.h:31:22: note: previous declaration of 'uint_least64_t' with type 'uint_least64_t' {aka 'long long unsigned int'}
      31 | typedef uint64_t     uint_least64_t;
         |                      ^~~~~~~~~~~~~~
>> /usr/riscv64-linux-gnu/include/stdint.h:51:33: error: conflicting types for 'int_fast64_t'; have 'long int'
      51 | typedef long int                int_fast64_t;
         |                                 ^~~~~~~~~~~~
   ./../../../../include/nolibc/stdint.h:39:24: note: previous declaration of 'int_fast64_t' with type 'int_fast64_t' {aka 'long long int'}
      39 | typedef  int64_t       int_fast64_t;
         |                        ^~~~~~~~~~~~
>> /usr/riscv64-linux-gnu/include/stdint.h:64:33: error: conflicting types for 'uint_fast64_t'; have 'long unsigned int'
      64 | typedef unsigned long int       uint_fast64_t;
         |                                 ^~~~~~~~~~~~~
   ./../../../../include/nolibc/stdint.h:40:23: note: previous declaration of 'uint_fast64_t' with type 'uint_fast64_t' {aka 'long long unsigned int'}
      40 | typedef uint64_t      uint_fast64_t;
         |                       ^~~~~~~~~~~~~

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

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

* Re: [PATCH 0/4] selftests: riscv: Fix compilation issues for v_ptrace and cfi
  2026-03-05  8:11 [PATCH 0/4] selftests: riscv: Fix compilation issues for v_ptrace and cfi Charlie Jenkins via B4 Relay
                   ` (3 preceding siblings ...)
  2026-03-05  8:11 ` [PATCH 4/4] selftests: riscv: Add license to cfi selftest Charlie Jenkins via B4 Relay
@ 2026-03-09 21:21 ` Sergey Matyukevich
  2026-03-10  1:45   ` Charlie Jenkins
  4 siblings, 1 reply; 8+ messages in thread
From: Sergey Matyukevich @ 2026-03-09 21:21 UTC (permalink / raw)
  To: thecharlesjenkins
  Cc: Shuah Khan, Paul Walmsley, Palmer Dabbelt, Andy Chiu,
	Deepak Gupta, linux-kselftest, linux-riscv, linux-kernel

Hello Charlie,

On Thu, Mar 05, 2026 at 12:11:28AM -0800, Charlie Jenkins via B4 Relay wrote:
> There are a couple of compilation issues of the riscv selftests.
> Coincidentally two of the issues are independent problems with not
> including the header that includes the BIT() macro and the other issue
> is from checkpatch incorrectly suggesting to remove non-redundant
> braces.
> 
> Signed-off-by: Charlie Jenkins <thecharlesjenkins@gmail.com>
> ---
> Charlie Jenkins (4):
>       selftests: riscv: Add definition of BIT() macro
>       selftests: riscv: Add braces around EXPECT_EQ()
>       riscv: ptrace: Fix BIT() compilation issues
>       selftests: riscv: Add license to cfi selftest
> 
>  arch/riscv/include/uapi/asm/ptrace.h                     |  1 +
>  tools/testing/selftests/riscv/cfi/Makefile               |  2 ++
>  tools/testing/selftests/riscv/vector/Makefile            |  2 ++
>  tools/testing/selftests/riscv/vector/validate_v_ptrace.c | 16 ++++++++++------
>  4 files changed, 15 insertions(+), 6 deletions(-)
> ---
> base-commit: c107785c7e8dbabd1c18301a1c362544b5786282
> change-id: 20260304-fix_selftests-c3f0ae46b3c7
> 
> Best regards,
> -- 
> Charlie Jenkins <thecharlesjenkins@gmail.com>

Thanks for catching this !

On rc3 I can also reproduce the issue reported by the kernel test robot
for v_exec_initval_nolibc.c and vstate_exec_nolibc.c. The following
addition to your fixes seems to resolve it:

diff --git a/tools/testing/selftests/riscv/vector/Makefile b/tools/testing/selftests/riscv/vector/Makefile
index 92c4cfe5f34d..48d6cd5e72f6 100644
--- a/tools/testing/selftests/riscv/vector/Makefile
+++ b/tools/testing/selftests/riscv/vector/Makefile
@@ -22,15 +22,13 @@ $(OUTPUT)/vstate_prctl: vstate_prctl.c $(OUTPUT)/sys_hwprobe.o $(OUTPUT)/v_helpe
 	$(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^
 
 $(OUTPUT)/vstate_exec_nolibc: vstate_exec_nolibc.c
-	$(CC) -nostdlib -static -include ../../../../include/nolibc/nolibc.h \
-		-Wall $(CFLAGS) $(LDFLAGS) $^ -o $@ -lgcc
+	$(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^
 
 $(OUTPUT)/v_initval: v_initval.c $(OUTPUT)/sys_hwprobe.o $(OUTPUT)/v_helpers.o
 	$(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^
 
 $(OUTPUT)/v_exec_initval_nolibc: v_exec_initval_nolibc.c
-	$(CC) -nostdlib -static -include ../../../../include/nolibc/nolibc.h \
-		-Wall $(CFLAGS) $(LDFLAGS) $^ -o $@ -lgcc
+	$(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^
 
 $(OUTPUT)/vstate_ptrace: vstate_ptrace.c $(OUTPUT)/sys_hwprobe.o $(OUTPUT)/v_helpers.o
 	$(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^
diff --git a/tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c b/tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c
index 4dde05e45a04..e3f062c85452 100644
--- a/tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c
+++ b/tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c
@@ -9,6 +9,10 @@
  * To be "clean" all values must be all zeroes.
  */
 
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
 #define __stringify_1(x...)	#x
 #define __stringify(x...)	__stringify_1(x)
 
diff --git a/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c b/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
index 12f1b1b1c7aa..ecd687bb8359 100644
--- a/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
+++ b/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
@@ -1,6 +1,12 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
-#include <linux/wait.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <sys/prctl.h>
+#include <sys/wait.h>
 
 #define THIS_PROGRAM "./vstate_exec_nolibc"


Regards,
Sergey

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

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

* Re: [PATCH 0/4] selftests: riscv: Fix compilation issues for v_ptrace and cfi
  2026-03-09 21:21 ` [PATCH 0/4] selftests: riscv: Fix compilation issues for v_ptrace and cfi Sergey Matyukevich
@ 2026-03-10  1:45   ` Charlie Jenkins
  0 siblings, 0 replies; 8+ messages in thread
From: Charlie Jenkins @ 2026-03-10  1:45 UTC (permalink / raw)
  To: Sergey Matyukevich
  Cc: Shuah Khan, Paul Walmsley, Palmer Dabbelt, Andy Chiu,
	Deepak Gupta, linux-kselftest, linux-riscv, linux-kernel

On Tue, Mar 10, 2026 at 12:21:14AM +0300, Sergey Matyukevich wrote:
> Hello Charlie,
> 
> On Thu, Mar 05, 2026 at 12:11:28AM -0800, Charlie Jenkins via B4 Relay wrote:
> > There are a couple of compilation issues of the riscv selftests.
> > Coincidentally two of the issues are independent problems with not
> > including the header that includes the BIT() macro and the other issue
> > is from checkpatch incorrectly suggesting to remove non-redundant
> > braces.
> > 
> > Signed-off-by: Charlie Jenkins <thecharlesjenkins@gmail.com>
> > ---
> > Charlie Jenkins (4):
> >       selftests: riscv: Add definition of BIT() macro
> >       selftests: riscv: Add braces around EXPECT_EQ()
> >       riscv: ptrace: Fix BIT() compilation issues
> >       selftests: riscv: Add license to cfi selftest
> > 
> >  arch/riscv/include/uapi/asm/ptrace.h                     |  1 +
> >  tools/testing/selftests/riscv/cfi/Makefile               |  2 ++
> >  tools/testing/selftests/riscv/vector/Makefile            |  2 ++
> >  tools/testing/selftests/riscv/vector/validate_v_ptrace.c | 16 ++++++++++------
> >  4 files changed, 15 insertions(+), 6 deletions(-)
> > ---
> > base-commit: c107785c7e8dbabd1c18301a1c362544b5786282
> > change-id: 20260304-fix_selftests-c3f0ae46b3c7
> > 
> > Best regards,
> > -- 
> > Charlie Jenkins <thecharlesjenkins@gmail.com>
> 
> Thanks for catching this !
> 
> On rc3 I can also reproduce the issue reported by the kernel test robot
> for v_exec_initval_nolibc.c and vstate_exec_nolibc.c. The following
> addition to your fixes seems to resolve it:

I missed that locally since those file compilations were cached for me!

I think we want to keep those as nolibc so instead we can only add the
header to the CFLAGS for only the tests that want libc, I'll send out an
updated version.

- Charlie

> 
> diff --git a/tools/testing/selftests/riscv/vector/Makefile b/tools/testing/selftests/riscv/vector/Makefile
> index 92c4cfe5f34d..48d6cd5e72f6 100644
> --- a/tools/testing/selftests/riscv/vector/Makefile
> +++ b/tools/testing/selftests/riscv/vector/Makefile
> @@ -22,15 +22,13 @@ $(OUTPUT)/vstate_prctl: vstate_prctl.c $(OUTPUT)/sys_hwprobe.o $(OUTPUT)/v_helpe
>  	$(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^
>  
>  $(OUTPUT)/vstate_exec_nolibc: vstate_exec_nolibc.c
> -	$(CC) -nostdlib -static -include ../../../../include/nolibc/nolibc.h \
> -		-Wall $(CFLAGS) $(LDFLAGS) $^ -o $@ -lgcc
> +	$(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^
>  
>  $(OUTPUT)/v_initval: v_initval.c $(OUTPUT)/sys_hwprobe.o $(OUTPUT)/v_helpers.o
>  	$(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^
>  
>  $(OUTPUT)/v_exec_initval_nolibc: v_exec_initval_nolibc.c
> -	$(CC) -nostdlib -static -include ../../../../include/nolibc/nolibc.h \
> -		-Wall $(CFLAGS) $(LDFLAGS) $^ -o $@ -lgcc
> +	$(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^
>  
>  $(OUTPUT)/vstate_ptrace: vstate_ptrace.c $(OUTPUT)/sys_hwprobe.o $(OUTPUT)/v_helpers.o
>  	$(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^
> diff --git a/tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c b/tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c
> index 4dde05e45a04..e3f062c85452 100644
> --- a/tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c
> +++ b/tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c
> @@ -9,6 +9,10 @@
>   * To be "clean" all values must be all zeroes.
>   */
>  
> +#include <stdlib.h>
> +#include <string.h>
> +#include <stdio.h>
> +
>  #define __stringify_1(x...)	#x
>  #define __stringify(x...)	__stringify_1(x)
>  
> diff --git a/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c b/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
> index 12f1b1b1c7aa..ecd687bb8359 100644
> --- a/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
> +++ b/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
> @@ -1,6 +1,12 @@
>  // SPDX-License-Identifier: GPL-2.0-only
>  
> -#include <linux/wait.h>
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <stdio.h>
> +
> +#include <sys/prctl.h>
> +#include <sys/wait.h>
>  
>  #define THIS_PROGRAM "./vstate_exec_nolibc"
> 
> 
> Regards,
> Sergey

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

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

end of thread, other threads:[~2026-03-10  1:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05  8:11 [PATCH 0/4] selftests: riscv: Fix compilation issues for v_ptrace and cfi Charlie Jenkins via B4 Relay
2026-03-05  8:11 ` [PATCH 1/4] selftests: riscv: Add definition of BIT() macro Charlie Jenkins via B4 Relay
2026-03-05 16:10   ` kernel test robot
2026-03-05  8:11 ` [PATCH 2/4] selftests: riscv: Add braces around EXPECT_EQ() Charlie Jenkins via B4 Relay
2026-03-05  8:11 ` [PATCH 3/4] riscv: ptrace: Fix BIT() compilation issues Charlie Jenkins via B4 Relay
2026-03-05  8:11 ` [PATCH 4/4] selftests: riscv: Add license to cfi selftest Charlie Jenkins via B4 Relay
2026-03-09 21:21 ` [PATCH 0/4] selftests: riscv: Fix compilation issues for v_ptrace and cfi Sergey Matyukevich
2026-03-10  1:45   ` Charlie Jenkins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox