From: Clément Léger <cleger(a)rivosinc.com>
[ Upstream commit 17c67ed752d6a456602b3dbb25c5ae4d3de5deab ]
Currently, the sud_test expects the emulated syscall to return the
emulated syscall number. This assumption only works on architectures
were the syscall calling convention use the same register for syscall
number/syscall return value. This is not the case for RISC-V and thus
the return value must be also emulated using the provided ucontext.
Signed-off-by: Clément Léger <cleger(a)rivosinc.com>
Reviewed-by: Palmer Dabbelt <palmer(a)rivosinc.com>
Acked-by: Palmer Dabbelt <palmer(a)rivosinc.com>
Link: https://lore.kernel.org/r/20231206134438.473166-1-cleger@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer(a)rivosinc.com>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
.../selftests/syscall_user_dispatch/sud_test.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/tools/testing/selftests/syscall_user_dispatch/sud_test.c b/tools/testing/selftests/syscall_user_dispatch/sud_test.c
index b5d592d4099e8..d975a67673299 100644
--- a/tools/testing/selftests/syscall_user_dispatch/sud_test.c
+++ b/tools/testing/selftests/syscall_user_dispatch/sud_test.c
@@ -158,6 +158,20 @@ static void handle_sigsys(int sig, siginfo_t *info, void *ucontext)
/* In preparation for sigreturn. */
SYSCALL_DISPATCH_OFF(glob_sel);
+
+ /*
+ * The tests for argument handling assume that `syscall(x) == x`. This
+ * is a NOP on x86 because the syscall number is passed in %rax, which
+ * happens to also be the function ABI return register. Other
+ * architectures may need to swizzle the arguments around.
+ */
+#if defined(__riscv)
+/* REG_A7 is not defined in libc headers */
+# define REG_A7 (REG_A0 + 7)
+
+ ((ucontext_t *)ucontext)->uc_mcontext.__gregs[REG_A0] =
+ ((ucontext_t *)ucontext)->uc_mcontext.__gregs[REG_A7];
+#endif
}
TEST(dispatch_and_return)
--
2.43.0
From: Clément Léger <cleger(a)rivosinc.com>
[ Upstream commit 17c67ed752d6a456602b3dbb25c5ae4d3de5deab ]
Currently, the sud_test expects the emulated syscall to return the
emulated syscall number. This assumption only works on architectures
were the syscall calling convention use the same register for syscall
number/syscall return value. This is not the case for RISC-V and thus
the return value must be also emulated using the provided ucontext.
Signed-off-by: Clément Léger <cleger(a)rivosinc.com>
Reviewed-by: Palmer Dabbelt <palmer(a)rivosinc.com>
Acked-by: Palmer Dabbelt <palmer(a)rivosinc.com>
Link: https://lore.kernel.org/r/20231206134438.473166-1-cleger@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer(a)rivosinc.com>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
.../selftests/syscall_user_dispatch/sud_test.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/tools/testing/selftests/syscall_user_dispatch/sud_test.c b/tools/testing/selftests/syscall_user_dispatch/sud_test.c
index b5d592d4099e8..d975a67673299 100644
--- a/tools/testing/selftests/syscall_user_dispatch/sud_test.c
+++ b/tools/testing/selftests/syscall_user_dispatch/sud_test.c
@@ -158,6 +158,20 @@ static void handle_sigsys(int sig, siginfo_t *info, void *ucontext)
/* In preparation for sigreturn. */
SYSCALL_DISPATCH_OFF(glob_sel);
+
+ /*
+ * The tests for argument handling assume that `syscall(x) == x`. This
+ * is a NOP on x86 because the syscall number is passed in %rax, which
+ * happens to also be the function ABI return register. Other
+ * architectures may need to swizzle the arguments around.
+ */
+#if defined(__riscv)
+/* REG_A7 is not defined in libc headers */
+# define REG_A7 (REG_A0 + 7)
+
+ ((ucontext_t *)ucontext)->uc_mcontext.__gregs[REG_A0] =
+ ((ucontext_t *)ucontext)->uc_mcontext.__gregs[REG_A7];
+#endif
}
TEST(dispatch_and_return)
--
2.43.0
Hi, all,
With the latest 6.9-rc7 torvalds tree kernel, the "make kselftest"
always hangs in the following
./pidfd_setns_test.
Symptoms are that all ./pidfd_netne_test processes end up in pause()
syscalls, with
nothing to wake them up.
Please find the config attached. All the options from the
selftests/pidfdconfig are on (verified):
CONFIG_UTS_NS=y
CONFIG_IPC_NS=y
CONFIG_USER_NS=y
CONFIG_PID_NS=y
CONFIG_NET_NS=y
CONFIG_CGROUPS=y
CONFIG_CHECKPOINT_RESTORE=y
root 2090101 5211 0 21:53 pts/1 00:00:00 make
OUTPUT=/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/pidfd
-C pidfd run_tests
SRC_PATH=/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests
OB
root 2090102 2090101 0 21:53 pts/1 00:00:00 /bin/sh -c
BASE_DIR="/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests";
. /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/kselftest/runner.sh;
if
root 2133026 2090102 0 21:54 pts/1 00:00:00 /bin/sh -c
BASE_DIR="/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests";
. /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/kselftest/runner.sh;
if
root 2133027 2133026 0 21:54 pts/1 00:00:00 /bin/sh -c
BASE_DIR="/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests";
. /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/kselftest/runner.sh;
if
root 2133028 2133027 0 21:54 pts/1 00:00:00 /bin/sh -c
BASE_DIR="/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests";
. /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/kselftest/runner.sh;
if
root 2133031 2133028 0 21:54 pts/1 00:00:00 /bin/sh -c
BASE_DIR="/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests";
. /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/kselftest/runner.sh;
if
root 2133033 2133031 0 21:54 pts/1 00:00:00 perl
/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/kselftest/prefix.pl
root 2133050 2887 0 21:54 pts/1 00:00:00 ./pidfd_setns_test
root 2133051 2887 0 21:54 pts/1 00:00:00 ./pidfd_setns_test
root 2133056 2887 0 21:54 pts/1 00:00:00 ./pidfd_setns_test
root 2133057 2887 0 21:54 pts/1 00:00:00 ./pidfd_setns_test
root 2133062 2887 0 21:54 pts/1 00:00:00 ./pidfd_setns_test
root 2133063 2887 0 21:54 pts/1 00:00:00 ./pidfd_setns_test
root 2133068 2887 0 21:54 pts/1 00:00:00 ./pidfd_setns_test
root 2133069 2887 0 21:54 pts/1 00:00:00 ./pidfd_setns_test
.
.
.
marvin@defiant:~/linux/kernel/linux_torvalds$ sudo bash
[sudo] password for marvin:
root@defiant:/home/marvin/linux/kernel/linux_torvalds# strace -p 2133050
strace: Process 2133050 attached
pause(^Cstrace: Process 2133050 detached
<detached ...>
root@defiant:/home/marvin/linux/kernel/linux_torvalds# strace -p 2133051
strace: Process 2133051 attached
pause(^Cstrace: Process 2133051 detached
<detached ...>
root@defiant:/home/marvin/linux/kernel/linux_torvalds# strace -p 2133056
strace: Process 2133056 attached
pause(^Cstrace: Process 2133056 detached
<detached ...>
root@defiant:/home/marvin/linux/kernel/linux_torvalds# strace -p 2133057
strace: Process 2133057 attached
pause(^Cstrace: Process 2133057 detached
<detached ...>
root@defiant:/home/marvin/linux/kernel/linux_torvalds# strace -p 2133062
strace: Process 2133062 attached
pause(^Cstrace: Process 2133062 detached
<detached ...>
root@defiant:/home/marvin/linux/kernel/linux_torvalds# strace -p 2133063
strace: Process 2133063 attached
pause(^Cstrace: Process 2133063 detached
<detached ...>
root@defiant:/home/marvin/linux/kernel/linux_torvalds#
root@defiant:/home/marvin/linux/kernel/linux_torvalds#
root@defiant:/home/marvin/linux/kernel/linux_torvalds# strace -p 2133068
strace: Process 2133068 attached
pause(^Cstrace: Process 2133068 detached
<detached ...>
root@defiant:/home/marvin/linux/kernel/linux_torvalds# strace -p 2133069
strace: Process 2133069 attached
pause(^Cstrace: Process 2133069 detached
<detached ...>
root@defiant:/home/marvin/linux/kernel/linux_torvalds#
The output log is:
# selftests: pidfd: pidfd_setns_test
# TAP version 13
# 1..7
# # Starting 7 tests from 2 test cases.
# # RUN global.setns_einval ...
# # OK global.setns_einval
# ok 1 global.setns_einval
# # RUN current_nsset.invalid_flags ...
# # pidfd_setns_test.c:161:invalid_flags:Expected
self->child_pid_exited (0) > 0 (0)
# # OK current_nsset.invalid_flags
# ok 2 current_nsset.invalid_flags
# # RUN current_nsset.pidfd_exited_child ...
# # pidfd_setns_test.c:161:pidfd_exited_child:Expected
self->child_pid_exited (0) > 0 (0)
# # OK current_nsset.pidfd_exited_child
# ok 3 current_nsset.pidfd_exited_child
# # RUN current_nsset.pidfd_incremental_setns ...
# # pidfd_setns_test.c:161:pidfd_incremental_setns:Expected
self->child_pid_exited (0) > 0 (0)
# # pidfd_setns_test.c:408:pidfd_incremental_setns:Managed to
correctly setns to user namespace of 2133050 via pidfd 20
# # pidfd_setns_test.c:408:pidfd_incremental_setns:Managed to
correctly setns to mnt namespace of 2133050 via pidfd 20
# # pidfd_setns_test.c:408:pidfd_incremental_setns:Managed to
correctly setns to pid namespace of 2133050 via pidfd 20
# # pidfd_setns_test.c:408:pidfd_incremental_setns:Managed to
correctly setns to uts namespace of 2133050 via pidfd 20
# # pidfd_setns_test.c:408:pidfd_incremental_setns:Managed to
correctly setns to ipc namespace of 2133050 via pidfd 20
# # pidfd_setns_test.c:408:pidfd_incremental_setns:Managed to
correctly setns to net namespace of 2133050 via pidfd 20
# # pidfd_setns_test.c:408:pidfd_incremental_setns:Managed to
correctly setns to cgroup namespace of 2133050 via pidfd 20
# # pidfd_setns_test.c:408:pidfd_incremental_setns:Managed to
correctly setns to pid_for_children namespace of 2133050 via pidfd 20
# # pidfd_setns_test.c:391:pidfd_incremental_setns:Expected
setns(self->child_pidfd1, info->flag) (-1) == 0 (0)
# # pidfd_setns_test.c:392:pidfd_incremental_setns:Too many users -
Failed to setns to time namespace of 2133050 via pidfd 20
# # pidfd_incremental_setns: Test terminated by assertion
# # FAIL current_nsset.pidfd_incremental_setns
# not ok 4 current_nsset.pidfd_incremental_setns
# # RUN current_nsset.nsfd_incremental_setns ...
# # pidfd_setns_test.c:161:nsfd_incremental_setns:Expected
self->child_pid_exited (0) > 0 (0)
# # pidfd_setns_test.c:444:nsfd_incremental_setns:Managed to correctly
setns to user namespace of 2133056 via nsfd 19
# # pidfd_setns_test.c:444:nsfd_incremental_setns:Managed to correctly
setns to mnt namespace of 2133056 via nsfd 24
# # pidfd_setns_test.c:444:nsfd_incremental_setns:Managed to correctly
setns to pid namespace of 2133056 via nsfd 27
# # pidfd_setns_test.c:444:nsfd_incremental_setns:Managed to correctly
setns to uts namespace of 2133056 via nsfd 30
# # pidfd_setns_test.c:444:nsfd_incremental_setns:Managed to correctly
setns to ipc namespace of 2133056 via nsfd 33
# # pidfd_setns_test.c:444:nsfd_incremental_setns:Managed to correctly
setns to net namespace of 2133056 via nsfd 36
# # pidfd_setns_test.c:444:nsfd_incremental_setns:Managed to correctly
setns to cgroup namespace of 2133056 via nsfd 39
# # pidfd_setns_test.c:444:nsfd_incremental_setns:Managed to correctly
setns to pid_for_children namespace of 2133056 via nsfd 42
# # pidfd_setns_test.c:427:nsfd_incremental_setns:Expected
setns(self->child_nsfds1[i], info->flag) (-1) == 0 (0)
# # pidfd_setns_test.c:428:nsfd_incremental_setns:Too many users -
Failed to setns to time namespace of 2133056 via nsfd 45
# # nsfd_incremental_setns: Test terminated by assertion
# # FAIL current_nsset.nsfd_incremental_setns
# not ok 5 current_nsset.nsfd_incremental_setns
# # RUN current_nsset.pidfd_one_shot_setns ...
# # pidfd_setns_test.c:161:pidfd_one_shot_setns:Expected
self->child_pid_exited (0) > 0 (0)
# # pidfd_setns_test.c:462:pidfd_one_shot_setns:Adding user namespace
of 2133062 to list of namespaces to attach to
# # pidfd_setns_test.c:462:pidfd_one_shot_setns:Adding mnt namespace
of 2133062 to list of namespaces to attach to
# # pidfd_setns_test.c:462:pidfd_one_shot_setns:Adding pid namespace
of 2133062 to list of namespaces to attach to
# # pidfd_setns_test.c:462:pidfd_one_shot_setns:Adding uts namespace
of 2133062 to list of namespaces to attach to
# # pidfd_setns_test.c:462:pidfd_one_shot_setns:Adding ipc namespace
of 2133062 to list of namespaces to attach to
# # pidfd_setns_test.c:462:pidfd_one_shot_setns:Adding net namespace
of 2133062 to list of namespaces to attach to
# # pidfd_setns_test.c:462:pidfd_one_shot_setns:Adding cgroup
namespace of 2133062 to list of namespaces to attach to
# # pidfd_setns_test.c:462:pidfd_one_shot_setns:Adding
pid_for_children namespace of 2133062 to list of namespaces to attach
to
# # pidfd_setns_test.c:462:pidfd_one_shot_setns:Adding time namespace
of 2133062 to list of namespaces to attach to
# # pidfd_setns_test.c:466:pidfd_one_shot_setns:Expected
setns(self->child_pidfd1, flags) (-1) == 0 (0)
# # pidfd_setns_test.c:467:pidfd_one_shot_setns:Too many users -
Failed to setns to namespaces of 2133062
# # pidfd_one_shot_setns: Test terminated by assertion
# # FAIL current_nsset.pidfd_one_shot_setns
# not ok 6 current_nsset.pidfd_one_shot_setns
# # RUN current_nsset.no_foul_play ...
# # pidfd_setns_test.c:161:no_foul_play:Expected
self->child_pid_exited (0) > 0 (0)
# # pidfd_setns_test.c:506:no_foul_play:Adding user namespace of
2133068 to list of namespaces to attach to
# # pidfd_setns_test.c:506:no_foul_play:Adding mnt namespace of
2133068 to list of namespaces to attach to
# # pidfd_setns_test.c:506:no_foul_play:Adding pid namespace of
2133068 to list of namespaces to attach to
# # pidfd_setns_test.c:506:no_foul_play:Adding uts namespace of
2133068 to list of namespaces to attach to
# # pidfd_setns_test.c:506:no_foul_play:Adding ipc namespace of
2133068 to list of namespaces to attach to
# # pidfd_setns_test.c:506:no_foul_play:Adding net namespace of
2133068 to list of namespaces to attach to
# # pidfd_setns_test.c:506:no_foul_play:Adding cgroup namespace of
2133068 to list of namespaces to attach to
# # pidfd_setns_test.c:506:no_foul_play:Adding time namespace of
2133068 to list of namespaces to attach to
# # pidfd_setns_test.c:510:no_foul_play:Expected
setns(self->child_pidfd1, flags) (-1) == 0 (0)
# # pidfd_setns_test.c:511:no_foul_play:Too many users - Failed to
setns to namespaces of 2133068 vid pidfd 20
# # no_foul_play: Test terminated by assertion
# # FAIL current_nsset.no_foul_play
# not ok 7 current_nsset.no_foul_play
# # FAILED: 3 / 7 tests passed.
# # Totals: pass:3 fail:4 xfail:0 xpass:0 skip:0 error:0
Thanks for your time and patience for reviewing this BUG report.
Best regards,
Mirsad Todorovac
P.S.
I have changed the email address because of the uncertainty whether the employer
would continue to support my work on the Linux kernel testing as the
part of my work
research.
Thank you.
809216233555 ("selftests/harness: remove use of LINE_MAX") introduced
asprintf into kselftest_harness.h, which is a GNU extension and needs
_GNU_SOURCE to either be defined prior to including headers or with the
-D_GNU_SOURCE flag passed to the compiler.
Edward Liaw (10):
selftests/sgx: Compile with -D_GNU_SOURCE
selftests/alsa: Compile with -D_GNU_SOURCE
selftests/hid: Compile with -D_GNU_SOURCE
selftests/kvm: Define _GNU_SOURCE
selftests/nci: Compile with -D_GNU_SOURCE
selftests/net: Define _GNU_SOURCE
selftests/prctl: Compile with -D_GNU_SOURCE
selftests/rtc: Compile with -D_GNU_SOURCE
selftests/tdx: Compile with -D_GNU_SOURCE
selftests/user_events: Compiled with -D_GNU_SOURCE
tools/testing/selftests/alsa/Makefile | 1 +
tools/testing/selftests/hid/Makefile | 2 +-
tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c | 2 ++
tools/testing/selftests/nci/Makefile | 2 +-
tools/testing/selftests/net/bind_wildcard.c | 1 +
tools/testing/selftests/net/ip_local_port_range.c | 1 +
tools/testing/selftests/net/reuseaddr_ports_exhausted.c | 2 ++
tools/testing/selftests/prctl/Makefile | 1 +
tools/testing/selftests/rtc/Makefile | 2 +-
tools/testing/selftests/sgx/Makefile | 2 +-
tools/testing/selftests/sgx/sigstruct.c | 2 --
tools/testing/selftests/tdx/Makefile | 2 +-
tools/testing/selftests/user_events/Makefile | 2 +-
tools/testing/selftests/user_events/abi_test.c | 1 -
14 files changed, 14 insertions(+), 9 deletions(-)
--
2.45.0.rc0.197.gbae5840b3b-goog
The cb fields network_offset and inner_network_offset are used instead of
skb->network_header throughout GRO.
These fields are then leveraged in the next commit to remove flush_id state
from napi_gro_cb, and stateful code in {ipv6,inet}_gro_receive which may be
unnecessarily complicated due to encapsulation support in GRO. These fields
are checked in L4 instead.
3rd patch adds tests for different flush_id flows in GRO.
v7 -> v8:
- Remove network_header use in gro
- Re-send commits after the dependent patch to net was applied
- v7:
https://lore.kernel.org/all/20240412155533.115507-1-richardbgobert@gmail.co…
v6 -> v7:
- Moved bug fixes to a separate submission in net
- Added UDP fwd benchmark
- v6:
https://lore.kernel.org/all/20240410153423.107381-1-richardbgobert@gmail.co…
v5 -> v6:
- Write inner_network_offset in vxlan and geneve
- Ignore is_atomic when DF=0
- v5:
https://lore.kernel.org/all/20240408141720.98832-1-richardbgobert@gmail.com/
v4 -> v5:
- Add 1st commit - flush id checks in udp_gro_receive segment which can be
backported by itself
- Add TCP measurements for the 5th commit
- Add flush id tests to ensure flush id logic is preserved in GRO
- Simplify gro_inet_flush by removing a branch
- v4:
https://lore.kernel.org/all/202420325182543.87683-1-richardbgobert@gmail.co…
v3 -> v4:
- Fix code comment and commit message typos
- v3:
https://lore.kernel.org/all/f939c84a-2322-4393-a5b0-9b1e0be8ed8e@gmail.com/
v2 -> v3:
- Use napi_gro_cb instead of skb->{offset}
- v2:
https://lore.kernel.org/all/2ce1600b-e733-448b-91ac-9d0ae2b866a4@gmail.com/
v1 -> v2:
- Pass p_off in *_gro_complete to fix UDP bug
- Remove more conditionals and memory fetches from inet_gro_flush
- v1:
https://lore.kernel.org/netdev/e1d22505-c5f8-4c02-a997-64248480338b@gmail.c…
Richard Gobert (3):
net: gro: use cb instead of skb->network_header
net: gro: move L3 flush checks to tcp_gro_receive and udp_gro_receive_segment
selftests/net: add flush id selftests
include/net/gro.h | 75 +++++++++++++--
net/core/gro.c | 3 -
net/ipv4/af_inet.c | 45 +--------
net/ipv4/tcp_offload.c | 18 +---
net/ipv4/udp_offload.c | 10 +-
net/ipv6/ip6_offload.c | 16 +---
net/ipv6/tcpv6_offload.c | 3 +-
tools/testing/selftests/net/gro.c | 147 ++++++++++++++++++++++++++++++
8 files changed, 225 insertions(+), 92 deletions(-)
--
2.36.1
Hi,
This sixth series just update the last patch description.
Shuah, I think this should be in -next really soon to make sure
everything works fine for the v6.9 release, which is not currently the
case. I cannot test against all kselftests though. I would prefer to
let you handle this, but I guess you're not able to do so and I'll push
it on my branch without reply from you. Even if I push it on my branch,
please push it on yours too as soon as you see this and I'll remove it
from mine.
Mark, Jakub, could you please test this series?
As reported by Kernel Test Robot [1] and Sean Christopherson [2], some
tests fail since v6.9-rc1 . This is due to the use of vfork() which
introduced some side effects. Similarly, while making it more generic,
a previous commit made some Landlock file system tests flaky, and
subject to the host's file system mount configuration.
This series fixes all these side effects by replacing vfork() with
clone3() and CLONE_VFORK, which is cleaner (no arbitrary shared memory)
and makes the Kselftest framework more robust.
I tried different approaches and I found this one to be the cleaner and
less invasive for current test cases.
I successfully ran the following tests (using TEST_F and
fork/clone/clone3, and KVM_ONE_VCPU_TEST) with this series:
- kvm:fix_hypercall_test
- kvm:sync_regs_test
- kvm:userspace_msr_exit_test
- kvm:vmx_pmu_caps_test
- landlock:fs_test
- landlock:net_test
- landlock:ptrace_test
- move_mount_set_group:move_mount_set_group_test
- net/af_unix:scm_pidfd
- perf_events:remove_on_exec
- pidfd:pidfd_getfd_test
- pidfd:pidfd_setns_test
- seccomp:seccomp_bpf
- user_events:abi_test
[1] https://lore.kernel.org/oe-lkp/202403291015.1fcfa957-oliver.sang@intel.com
[2] https://lore.kernel.org/r/ZjPelW6-AbtYvslu@google.com
Previous versions:
v1: https://lore.kernel.org/r/20240426172252.1862930-1-mic@digikod.net
v2: https://lore.kernel.org/r/20240429130931.2394118-1-mic@digikod.net
v3: https://lore.kernel.org/r/20240429191911.2552580-1-mic@digikod.net
v4: https://lore.kernel.org/r/20240502210926.145539-1-mic@digikod.net
v5: https://lore.kernel.org/r/20240503105820.300927-1-mic@digikod.net
Regards,
Mickaël Salaün (10):
selftests/pidfd: Fix config for pidfd_setns_test
selftests/landlock: Fix FS tests when run on a private mount point
selftests/harness: Fix fixture teardown
selftests/harness: Fix interleaved scheduling leading to race
conditions
selftests/landlock: Do not allocate memory in fixture data
selftests/harness: Constify fixture variants
selftests/pidfd: Fix wrong expectation
selftests/harness: Share _metadata between forked processes
selftests/harness: Fix vfork() side effects
selftests/harness: Handle TEST_F()'s explicit exit codes
tools/testing/selftests/kselftest_harness.h | 122 +++++++++++++-----
tools/testing/selftests/landlock/fs_test.c | 83 +++++++-----
tools/testing/selftests/pidfd/config | 2 +
.../selftests/pidfd/pidfd_setns_test.c | 2 +-
4 files changed, 143 insertions(+), 66 deletions(-)
base-commit: e67572cd2204894179d89bd7b984072f19313b03
--
2.45.0
When I introduced HID-BPF, I mentioned that we should ship the HID-BPF
programs in the kernel when they are fixes so that everybody can benefit
from them.
I tried multiple times to do so but I was confronted to a tough problem:
how can I make the kernel load them automatically?
I went over a few solutions, but it always came down to something either
ugly, or either not satisfying (like forcing `bpftool` to be compiled
first, or not being able to insert them as a module).
OTOH, I was working with Peter on `udev-hid-bpf`[0] as a proof of
concept on how a minimal loader should look like. This allowed me to
experiment on the BPF files and how they should look like.
And after further thoughts, I realized that `udev-hid-bpf` could very
well be the `kmod load` that we currently have:
- the kernel handles the device normally
- a udev event is emitted
- a udev rule fires `udev-hid-bpf` and load the appropriate HID-BPF
file(s) based on the modalias
Given that most HID devices are supposed to work to a minimal level when
connected without any driver, this makes the whole HID-BPF programs nice
to have but not critical. We can then postpone the HID-BPF loading when
userspace is ready.
Working with HID-BPF is also a much better user experience for end users
(as I predicted). All they have to do is to go to the `udev-hid-bpf`
project, fetch an artifact from the MR that concerns them, run
`install.sh` (no compilation required), and their devices are fixed
(minus some back and forth when the HID-BPF program needs some changes).
So I already have that loader available, and it works well enough for
our users. But the missing point was still how to "upstream" those BPF
fixes?
That's where this patch series comes in: we simply store the fixes in
the kernel under `drivers/hid/bpf/progs`, provide a way to compile them,
but also add tests for them in the selftests dir.
Once a program is accepted here, for convenience, the same program will
move from a "testing" directory to a "stable" directory on
`udev-hid-bpf`. This way, distributions don't need to follow when there
is a new program added here, they can just ship the "stable" ones from
`udev-hid-bpf`.
Signed-off-by: Benjamin Tissoires <bentiss(a)kernel.org>
[0] https://gitlab.freedesktop.org/libevdev/udev-hid-bpf/
---
Benjamin Tissoires (18):
HID: do not assume HAT Switch logical max < 8
HID: bpf: add first in-tree HID-BPF fix for the XPPen Artist 24
HID: bpf: add in-tree HID-BPF fix for the XPPen Artist 16
HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse
HID: bpf: add in-tree HID-BPF fix for the IOGear Kaliber Gaming MMOmentum mouse
HID: bpf: add in-tree HID-BPF fix for the Wacom ArtPen
HID: bpf: add in-tree HID-BPF fix for the XBox Elite 2 over Bluetooth
HID: bpf: add in-tree HID-BPF fix for the Huion Kamvas Pro 19
HID: bpf: add in-tree HID-BPF fix for the Raptor Mach 2
selftests/hid: import base_device.py from hid-tools
selftests/hid: add support for HID-BPF pre-loading before starting a test
selftests/hid: tablets: reduce the number of pen state
selftests/hid: tablets: add a couple of XP-PEN tablets
selftests/hid: tablets: also check for XP-Pen offset correction
selftests/hid: add Huion Kamvas Pro 19 tests
selftests/hid: import base_gamepad.py from hid-tools
selftests/hid: move the gamepads definitions in the test file
selftests/hid: add tests for the Raptor Mach 2 joystick
drivers/hid/bpf/progs/FR-TEC__Raptor-Mach-2.bpf.c | 185 ++++++
drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c | 58 ++
drivers/hid/bpf/progs/Huion__Kamvas-Pro-19.bpf.c | 290 +++++++++
.../hid/bpf/progs/IOGEAR__Kaliber-MMOmentum.bpf.c | 59 ++
drivers/hid/bpf/progs/Makefile | 91 +++
.../hid/bpf/progs/Microsoft__XBox-Elite-2.bpf.c | 133 ++++
drivers/hid/bpf/progs/README | 102 +++
drivers/hid/bpf/progs/Wacom__ArtPen.bpf.c | 173 +++++
drivers/hid/bpf/progs/XPPen__Artist24.bpf.c | 229 +++++++
drivers/hid/bpf/progs/XPPen__ArtistPro16Gen2.bpf.c | 274 ++++++++
drivers/hid/bpf/progs/hid_bpf.h | 15 +
drivers/hid/bpf/progs/hid_bpf_helpers.h | 170 +++++
include/linux/hid.h | 6 +-
tools/testing/selftests/hid/tests/base.py | 87 ++-
tools/testing/selftests/hid/tests/base_device.py | 421 ++++++++++++
tools/testing/selftests/hid/tests/base_gamepad.py | 238 +++++++
tools/testing/selftests/hid/tests/test_gamepad.py | 457 ++++++++++++-
tools/testing/selftests/hid/tests/test_tablet.py | 723 +++++++++++++++------
18 files changed, 3507 insertions(+), 204 deletions(-)
---
base-commit: 3e78a6c0d3e02e4cf881dc84c5127e9990f939d6
change-id: 20240328-bpf_sources-be1f3c617c5e
Best regards,
--
Benjamin Tissoires <bentiss(a)kernel.org>
Add several new test cases which assert corner cases on the eventfd
mechanism, for example, the supplied buffer is less than 8 bytes,
attempting to write a value that is too large, etc.
./eventfd_test
# Starting 9 tests from 1 test cases.
# RUN global.eventfd01 ...
# OK global.eventfd01
ok 1 global.eventfd01
# RUN global.eventfd02 ...
# OK global.eventfd02
ok 2 global.eventfd02
# RUN global.eventfd03 ...
# OK global.eventfd03
ok 3 global.eventfd03
# RUN global.eventfd04 ...
# OK global.eventfd04
ok 4 global.eventfd04
# RUN global.eventfd05 ...
# OK global.eventfd05
ok 5 global.eventfd05
# RUN global.eventfd06 ...
# OK global.eventfd06
ok 6 global.eventfd06
# RUN global.eventfd07 ...
# OK global.eventfd07
ok 7 global.eventfd07
# RUN global.eventfd08 ...
# OK global.eventfd08
ok 8 global.eventfd08
# RUN global.eventfd09 ...
# OK global.eventfd09
ok 9 global.eventfd09
# PASSED: 9 / 9 tests passed.
# Totals: pass:9 fail:0 xfail:0 xpass:0 skip:0 error:0
Signed-off-by: Wen Yang <wen.yang(a)linux.dev>
Cc: SShuah Khan <shuah(a)kernel.org>
Cc: Christian Brauner <brauner(a)kernel.org>
Cc: Andrei Vagin <avagin(a)google.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers(a)efficios.com>
Cc: Steven Rostedt <rostedt(a)goodmis.org>
Cc: Andrew Morton <akpm(a)linux-foundation.org>
Cc: Dave Young <dyoung(a)redhat.com>
Cc: linux-kselftest(a)vger.kernel.org
Cc: linux-kernel(a)vger.kernel.org
---
.../filesystems/eventfd/eventfd_test.c | 116 ++++++++++++++++++
1 file changed, 116 insertions(+)
diff --git a/tools/testing/selftests/filesystems/eventfd/eventfd_test.c b/tools/testing/selftests/filesystems/eventfd/eventfd_test.c
index f142a137526c..eeab8df5b1b5 100644
--- a/tools/testing/selftests/filesystems/eventfd/eventfd_test.c
+++ b/tools/testing/selftests/filesystems/eventfd/eventfd_test.c
@@ -183,4 +183,120 @@ TEST(eventfd05)
close(fd);
}
+/*
+ * A write(2) fails with the error EINVAL if the size of the supplied buffer
+ * is less than 8 bytes, or if an attempt is made to write the value
+ * 0xffffffffffffffff.
+ */
+TEST(eventfd06)
+{
+ uint64_t value = 1;
+ ssize_t size;
+ int fd;
+
+ fd = sys_eventfd2(0, 0);
+ ASSERT_GE(fd, 0);
+
+ size = write(fd, &value, sizeof(int));
+ EXPECT_EQ(size, -1);
+ EXPECT_EQ(errno, EINVAL);
+
+ value = (uint64_t)-1;
+ size = write(fd, &value, sizeof(value));
+ EXPECT_EQ(size, -1);
+ EXPECT_EQ(errno, EINVAL);
+
+ close(fd);
+}
+
+/*
+ * A read(2) fails with the error EINVAL if the size of the supplied buffer is
+ * less than 8 bytes.
+ */
+TEST(eventfd07)
+{
+ int value = 0;
+ ssize_t size;
+ int fd;
+
+ fd = sys_eventfd2(0, 0);
+ ASSERT_GE(fd, 0);
+
+ size = write(fd, &value, sizeof(value));
+ EXPECT_EQ(size, -1);
+ EXPECT_EQ(errno, EINVAL);
+
+ close(fd);
+}
+
+/*
+ * If EFD_SEMAPHORE was not specified and the eventfd counter has a nonzero
+ * value, then a read(2) returns 8 bytes containing that value, and the
+ * counter's value is reset to zero.
+ * If the eventfd counter is zero at the time of the call to read(2), then the
+ * call fails with the error EAGAIN if the file descriptor has been made nonblocking.
+ */
+TEST(eventfd08)
+{
+ uint64_t value;
+ ssize_t size;
+ int fd;
+ int i;
+
+ fd = sys_eventfd2(0, EFD_NONBLOCK);
+ ASSERT_GE(fd, 0);
+
+ value = 1;
+ for (i = 0; i < 10000000; i++) {
+ size = write(fd, &value, sizeof(value));
+ EXPECT_EQ(size, sizeof(value));
+ }
+
+ size = read(fd, &value, sizeof(value));
+ EXPECT_EQ(size, sizeof(uint64_t));
+ EXPECT_EQ(value, 10000000);
+
+ size = read(fd, &value, sizeof(value));
+ EXPECT_EQ(size, -1);
+ EXPECT_EQ(errno, EAGAIN);
+
+ close(fd);
+}
+
+/*
+ * If EFD_SEMAPHORE was specified and the eventfd counter has a nonzero value,
+ * then a read(2) returns 8 bytes containing the value 1, and the counter's
+ * value is decremented by 1.
+ * If the eventfd counter is zero at the time of the call to read(2), then the
+ * call fails with the error EAGAIN if the file descriptor has been made nonblocking.
+ */
+TEST(eventfd09)
+{
+ uint64_t value;
+ ssize_t size;
+ int fd;
+ int i;
+
+ fd = sys_eventfd2(0, EFD_SEMAPHORE|EFD_NONBLOCK);
+ ASSERT_GE(fd, 0);
+
+ value = 1;
+ for (i = 0; i < 10000000; i++) {
+ size = write(fd, &value, sizeof(value));
+ EXPECT_EQ(size, sizeof(value));
+ }
+
+ for (i = 0; i < 10000000; i++) {
+ size = read(fd, &value, sizeof(value));
+ EXPECT_EQ(size, sizeof(value));
+ EXPECT_EQ(value, 1);
+ }
+
+ size = read(fd, &value, sizeof(value));
+ EXPECT_EQ(size, -1);
+ EXPECT_EQ(errno, EAGAIN);
+
+ close(fd);
+}
+
TEST_HARNESS_MAIN
--
2.25.1