Skip to content

Commit 87ad7cc

Browse files
author
Paul Walmsley
committed
riscv: use _BITUL macro rather than BIT() in ptrace uapi and kselftests
Fix the build of non-kernel code that includes the RISC-V ptrace uapi header, and the RISC-V validate_v_ptrace.c kselftest, by using the _BITUL() macro rather than BIT(). BIT() is not available outside the kernel. Based on patches and comments from Charlie Jenkins, Michael Neuling, and Andreas Schwab. Fixes: 30eb191 ("selftests: riscv: verify ptrace rejects invalid vector csr inputs") Fixes: 2af7c9c ("riscv/ptrace: expose riscv CFI status and state via ptrace and in core files") Cc: Andreas Schwab <schwab@suse.de> Cc: Michael Neuling <mikey@neuling.org> Cc: Charlie Jenkins <thecharlesjenkins@gmail.com> Link: https://patch.msgid.link/20260330024248.449292-1-mikey@neuling.org Link: https://lore.kernel.org/linux-riscv/20260309-fix_selftests-v2-1-9d5a553a531e@gmail.com/ Link: https://lore.kernel.org/linux-riscv/20260309-fix_selftests-v2-3-9d5a553a531e@gmail.com/ Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent 3033b2b commit 87ad7cc

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

arch/riscv/include/uapi/asm/ptrace.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef __ASSEMBLER__
1010

1111
#include <linux/types.h>
12+
#include <linux/const.h>
1213

1314
#define PTRACE_GETFDPIC 33
1415

@@ -138,12 +139,12 @@ struct __sc_riscv_cfi_state {
138139
#define PTRACE_CFI_SS_LOCK_BIT 4
139140
#define PTRACE_CFI_SS_PTR_BIT 5
140141

141-
#define PTRACE_CFI_LP_EN_STATE BIT(PTRACE_CFI_LP_EN_BIT)
142-
#define PTRACE_CFI_LP_LOCK_STATE BIT(PTRACE_CFI_LP_LOCK_BIT)
143-
#define PTRACE_CFI_ELP_STATE BIT(PTRACE_CFI_ELP_BIT)
144-
#define PTRACE_CFI_SS_EN_STATE BIT(PTRACE_CFI_SS_EN_BIT)
145-
#define PTRACE_CFI_SS_LOCK_STATE BIT(PTRACE_CFI_SS_LOCK_BIT)
146-
#define PTRACE_CFI_SS_PTR_STATE BIT(PTRACE_CFI_SS_PTR_BIT)
142+
#define PTRACE_CFI_LP_EN_STATE _BITUL(PTRACE_CFI_LP_EN_BIT)
143+
#define PTRACE_CFI_LP_LOCK_STATE _BITUL(PTRACE_CFI_LP_LOCK_BIT)
144+
#define PTRACE_CFI_ELP_STATE _BITUL(PTRACE_CFI_ELP_BIT)
145+
#define PTRACE_CFI_SS_EN_STATE _BITUL(PTRACE_CFI_SS_EN_BIT)
146+
#define PTRACE_CFI_SS_LOCK_STATE _BITUL(PTRACE_CFI_SS_LOCK_BIT)
147+
#define PTRACE_CFI_SS_PTR_STATE _BITUL(PTRACE_CFI_SS_PTR_BIT)
147148

148149
#define PRACE_CFI_STATE_INVALID_MASK ~(PTRACE_CFI_LP_EN_STATE | \
149150
PTRACE_CFI_LP_LOCK_STATE | \

tools/testing/selftests/riscv/vector/validate_v_ptrace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ FIXTURE_TEARDOWN(v_csr_invalid)
346346
{
347347
}
348348

349-
#define VECTOR_1_0 BIT(0)
350-
#define XTHEAD_VECTOR_0_7 BIT(1)
349+
#define VECTOR_1_0 _BITUL(0)
350+
#define XTHEAD_VECTOR_0_7 _BITUL(1)
351351

352352
#define vector_test(x) ((x) & VECTOR_1_0)
353353
#define xthead_test(x) ((x) & XTHEAD_VECTOR_0_7)

0 commit comments

Comments
 (0)