[PATCH v2 1/4] selftests: riscv: Add definition of BIT() macro

Charlie Jenkins via B4 Relay posted 4 patches 1 month ago
[PATCH v2 1/4] selftests: riscv: Add definition of BIT() macro
Posted by Charlie Jenkins via B4 Relay 1 month ago
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            | 7 +++++--
 tools/testing/selftests/riscv/vector/validate_v_ptrace.c | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/riscv/vector/Makefile b/tools/testing/selftests/riscv/vector/Makefile
index 326dafd739bf..f74a3aa63c87 100644
--- a/tools/testing/selftests/riscv/vector/Makefile
+++ b/tools/testing/selftests/riscv/vector/Makefile
@@ -2,6 +2,9 @@
 # Copyright (C) 2021 ARM Limited
 # Originally tools/testing/arm64/abi/Makefile
 
+NO_LIBC_CFLAGS := $(CFLAGS)
+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
@@ -21,14 +24,14 @@ $(OUTPUT)/vstate_prctl: vstate_prctl.c $(OUTPUT)/sys_hwprobe.o $(OUTPUT)/v_helpe
 
 $(OUTPUT)/vstate_exec_nolibc: vstate_exec_nolibc.c
 	$(CC) -nostdlib -static -include ../../../../include/nolibc/nolibc.h \
-		-Wall $(CFLAGS) $(LDFLAGS) $^ -o $@ -lgcc
+		-Wall $(NO_LIBC_CFLAGS) $(LDFLAGS) $^ -o $@ -lgcc
 
 $(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
+		-Wall $(NO_LIBC_CFLAGS) $(LDFLAGS) $^ -o $@ -lgcc
 
 $(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/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
Re: [PATCH v2 1/4] selftests: riscv: Add definition of BIT() macro
Posted by Paul Walmsley 2 weeks, 5 days ago
On Mon, 9 Mar 2026, Charlie Jenkins via B4 Relay wrote:

> 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>

Thanks, queued for v7.0-rc.


- Paul
Re: [PATCH v2 1/4] selftests: riscv: Add definition of BIT() macro
Posted by Sergey Matyukevich 1 month ago
On Mon, Mar 09, 2026 at 06:52:10PM -0700, Charlie Jenkins via B4 Relay wrote:
> 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            | 7 +++++--
>  tools/testing/selftests/riscv/vector/validate_v_ptrace.c | 1 +
>  2 files changed, 6 insertions(+), 2 deletions(-)
 
Reviewed-and-Tested-by: Sergey Matyukevich <geomatsi@gmail.com>

Thanks,
Sergey
Re: [PATCH v2 1/4] selftests: riscv: Add definition of BIT() macro
Posted by Paul Walmsley 2 weeks, 5 days ago
On Tue, 10 Mar 2026, Sergey Matyukevich wrote:

> On Mon, Mar 09, 2026 at 06:52:10PM -0700, Charlie Jenkins via B4 Relay wrote:
> > 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            | 7 +++++--
> >  tools/testing/selftests/riscv/vector/validate_v_ptrace.c | 1 +
> >  2 files changed, 6 insertions(+), 2 deletions(-)
>  
> Reviewed-and-Tested-by: Sergey Matyukevich <geomatsi@gmail.com>

Thanks for reviewing and testing but please use "Reviewed-and-tested-by" 
next time so I don't have to fix it up by hand.


- Paul


$ scripts/checkpatch.pl --strict 0001-selftests-riscv-Add-definition-of-BIT-macro.patch
WARNING: 'Reviewed-and-tested-by:' is the preferred signature form
#13: 
Reviewed-and-Tested-by: Sergey Matyukevich <geomatsi@gmail.com>