Skip to content

Commit 91f34aa

Browse files
author
Alexei Starovoitov
committed
Merge branch 'bpf-reject-bpf_timer-for-preempt_rt'
Leon Hwang says: ==================== bpf: Reject bpf_timer for PREEMPT_RT While running './test_progs -t timer' to validate the test case from "selftests/bpf: Introduce experimental bpf_in_interrupt()"[0] for PREEMPT_RT, I encountered a kernel warning: BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48 To address this, reject bpf_timer usage in the verifier when PREEMPT_RT is enabled, and skip the corresponding timer selftests. Changes: v2 -> v3: * Drop skipping test case 'timer_interrupt'. * Address comments from Alexei: * Respin targeting bpf tree. * Trim commit log. v1 -> v2: * Skip test case 'timer_interrupt'. Links: [0] https://lore.kernel.org/bpf/[email protected]/ ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
2 parents a3967ba + fbdd61c commit 91f34aa

File tree

6 files changed

+24
-0
lines changed

6 files changed

+24
-0
lines changed

kernel/bpf/verifier.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8547,6 +8547,10 @@ static int process_timer_func(struct bpf_verifier_env *env, int regno,
85478547
verifier_bug(env, "Two map pointers in a timer helper");
85488548
return -EFAULT;
85498549
}
8550+
if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
8551+
verbose(env, "bpf_timer cannot be used for PREEMPT_RT.\n");
8552+
return -EOPNOTSUPP;
8553+
}
85508554
meta->map_uid = reg->map_uid;
85518555
meta->map_ptr = map;
85528556
return 0;

tools/testing/selftests/bpf/prog_tests/free_timer.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ void test_free_timer(void)
124124
int err;
125125

126126
skel = free_timer__open_and_load();
127+
if (!skel && errno == EOPNOTSUPP) {
128+
test__skip();
129+
return;
130+
}
127131
if (!ASSERT_OK_PTR(skel, "open_load"))
128132
return;
129133

tools/testing/selftests/bpf/prog_tests/timer.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ void serial_test_timer(void)
8686
int err;
8787

8888
timer_skel = timer__open_and_load();
89+
if (!timer_skel && errno == EOPNOTSUPP) {
90+
test__skip();
91+
return;
92+
}
8993
if (!ASSERT_OK_PTR(timer_skel, "timer_skel_load"))
9094
return;
9195

tools/testing/selftests/bpf/prog_tests/timer_crash.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ static void test_timer_crash_mode(int mode)
1212
struct timer_crash *skel;
1313

1414
skel = timer_crash__open_and_load();
15+
if (!skel && errno == EOPNOTSUPP) {
16+
test__skip();
17+
return;
18+
}
1519
if (!ASSERT_OK_PTR(skel, "timer_crash__open_and_load"))
1620
return;
1721
skel->bss->pid = getpid();

tools/testing/selftests/bpf/prog_tests/timer_lockup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ void test_timer_lockup(void)
5959
}
6060

6161
skel = timer_lockup__open_and_load();
62+
if (!skel && errno == EOPNOTSUPP) {
63+
test__skip();
64+
return;
65+
}
6266
if (!ASSERT_OK_PTR(skel, "timer_lockup__open_and_load"))
6367
return;
6468

tools/testing/selftests/bpf/prog_tests/timer_mim.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ void serial_test_timer_mim(void)
6565
goto cleanup;
6666

6767
timer_skel = timer_mim__open_and_load();
68+
if (!timer_skel && errno == EOPNOTSUPP) {
69+
test__skip();
70+
return;
71+
}
6872
if (!ASSERT_OK_PTR(timer_skel, "timer_skel_load"))
6973
goto cleanup;
7074

0 commit comments

Comments
 (0)