Skip to content

Commit 4f02588

Browse files
luisgerhorstKernel Patches Daemon
authored andcommitted
selftests/bpf: Fix SPEC_V1/V4 for other archs
Currently, SPEC_V1/V4 is not defined for architectures except x86/arm64 even though bpf_jit_bypass_spec_v1/v4 is usually false (the default) there. To avoid triggering tests failures on these other archs when adding the missing SPEC_V1-ifdefs, set it there (and on all other archs) to put it in sync with bpf_jit_bypass_spec_v1/v4. For PowerPC, setting the value correctly is complicated because it depends on the exact CPU and security config. Instead, skip unpriv tests there. Signed-off-by: Luis Gerhorst <[email protected]>
1 parent caedc19 commit 4f02588

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

tools/testing/selftests/bpf/progs/bpf_misc.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,15 @@
258258
#define CAN_USE_LOAD_ACQ_STORE_REL
259259
#endif
260260

261-
#if defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86)
261+
/* Add architectures that always set bpf_jit_bypass_spec_v1/v4 here. If the
262+
* value is determined at runtime, it is best to skip unpriv tests by adding a
263+
* case for your architecture in get_mitigations_off().
264+
*/
265+
#if !defined(__TARGET_ARCH_loongarch)
262266
#define SPEC_V1
263267
#endif
264268

265-
#if defined(__TARGET_ARCH_x86)
269+
#if !defined(__TARGET_ARCH_arm64) && !defined(__TARGET_ARCH_loongarch)
266270
#define SPEC_V4
267271
#endif
268272

tools/testing/selftests/bpf/unpriv_helpers.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ static bool cmdline_contains(const char *pat)
100100

101101
static int get_mitigations_off(void)
102102
{
103+
#if defined(__TARGET_ARCH_powerpc)
104+
/* Unknown, depends on return value of PowerPC's
105+
* bpf_jit_bypass_spec_v1/v4(). For simplicity, skip unpriv tests.
106+
*/
107+
return -1;
108+
#else
103109
int enabled_in_config;
104110

105111
if (cmdline_contains("mitigations=off"))
@@ -108,6 +114,7 @@ static int get_mitigations_off(void)
108114
if (enabled_in_config < 0)
109115
return -1;
110116
return !enabled_in_config;
117+
#endif
111118
}
112119

113120
bool get_unpriv_disabled(void)

0 commit comments

Comments
 (0)