forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kselftests-bpf: update for kernel 6.6
Enable building multiple test programs and related kernel modules, with initial support for the bpf_testmod.ko module required since kernel 6.4. Explicitly disable LTO and clean up makefile variables and formatting. Fix a musl-related build failure by adding a kernel 6.6 patch: 360-selftests-bpf-portability-of-unprivileged-tests.patch Signed-off-by: Tony Ambardar <[email protected]>
- Loading branch information
1 parent
6a05d84
commit 8ee5ca2
Showing
2 changed files
with
51 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ PKG_VERSION:=$(LINUX_VERSION) | |
PKG_RELEASE:=1 | ||
PKG_MAINTAINER:=Tony Ambardar <[email protected]> | ||
|
||
PKG_BUILD_FLAGS:=gc-sections lto | ||
PKG_BUILD_FLAGS:=no-lto | ||
PKG_BUILD_PARALLEL:=1 | ||
PKG_FLAGS:=nonshared | ||
|
||
|
@@ -23,8 +23,9 @@ include $(INCLUDE_DIR)/nls.mk | |
define Package/kselftests-bpf | ||
SECTION:=devel | ||
CATEGORY:=Development | ||
DEPENDS:= +libelf +zlib +libpthread +librt @!IN_SDK \ | ||
@KERNEL_DEBUG_FS @KERNEL_DEBUG_INFO_BTF @KERNEL_BPF_EVENTS | ||
DEPENDS:= \ | ||
+libelf +zlib +libpthread +librt @!IN_SDK \ | ||
@KERNEL_DEBUG_FS @KERNEL_DEBUG_INFO_BTF @KERNEL_BPF_EVENTS | ||
TITLE:=Linux Kernel Selftests (BPF) | ||
URL:=http://www.kernel.org | ||
endef | ||
|
@@ -33,31 +34,40 @@ define Package/kselftests-bpf/description | |
kselftests-bpf is the Linux kernel BPF test suite | ||
endef | ||
|
||
TEST_TARGET = test_verifier | ||
EXE_TARGETS = test_verifier | ||
|
||
MOD_TARGETS = $(if $(call kernel_patchver_ge,6.4),bpf_testmod.ko) | ||
|
||
MAKE_PATH:=tools/testing/selftests/bpf | ||
|
||
MAKE_VARS = \ | ||
ARCH="$(LINUX_KARCH)" \ | ||
CROSS_COMPILE="$(TARGET_CROSS)" \ | ||
SAN_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \ | ||
EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \ | ||
LDLIBS="$(TARGET_LDFLAGS)" \ | ||
TOOLCHAIN_INCLUDE="$(TOOLCHAIN_INC_DIRS)" \ | ||
VMLINUX_BTF="$(LINUX_DIR)/vmlinux" | ||
KBUILD_OUTPUT="$(LINUX_DIR)" | ||
|
||
MAKE_FLAGS = \ | ||
$(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \ | ||
O=$(PKG_BUILD_DIR) | ||
OUTPUT=$(PKG_BUILD_DIR) | ||
|
||
define Build/Compile | ||
+$(MAKE_VARS) \ | ||
$(MAKE) $(PKG_JOBS) -C $(LINUX_DIR)/$(MAKE_PATH) \ | ||
$(MAKE_FLAGS) $(TEST_TARGET) ; | ||
$(MAKE_FLAGS) $(EXE_TARGETS) $(MOD_TARGETS) ; | ||
endef | ||
|
||
define Package/kselftests-bpf/install | ||
$(INSTALL_DIR) $(1)/usr/bin | ||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(TEST_TARGET) $(1)/usr/bin/ | ||
$(INSTALL_DIR) $(1)/usr/libexec/$(PKG_NAME) | ||
$(foreach tgt,$(MOD_TARGETS), \ | ||
$(INSTALL_DATA) \ | ||
$(PKG_BUILD_DIR)/$(tgt) $(1)/usr/libexec/$(PKG_NAME); \ | ||
) | ||
$(foreach tgt,$(EXE_TARGETS), \ | ||
$(INSTALL_BIN) \ | ||
$(PKG_BUILD_DIR)/$(tgt) $(1)/usr/libexec/$(PKG_NAME); \ | ||
) | ||
endef | ||
|
||
$(eval $(call BuildPackage,kselftests-bpf)) |
31 changes: 31 additions & 0 deletions
31
target/linux/generic/pending-6.6/360-selftests-bpf-portability-of-unprivileged-tests.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
From ecb8f9a7d69698ce20fc6f4d107718d56fa861df Mon Sep 17 00:00:00 2001 | ||
From: Tony Ambardar <[email protected]> | ||
Date: Sat, 9 Mar 2024 16:44:53 -0800 | ||
Subject: [PATCH] selftests/bpf: Improve portability of unprivileged tests | ||
|
||
The addition of general support for unprivileged tests in test_loader.c | ||
breaks building test_verifier on non-glibc (e.g. musl) systems, due to the | ||
inclusion of glibc extension '<error.h>' in 'unpriv_helpers.c'. However, | ||
the header is actually not needed, so remove it to restore building. | ||
|
||
Fixes: 1d56ade032a4 ("selftests/bpf: Unprivileged tests for test_loader.c") | ||
Signed-off-by: Tony Ambardar <[email protected]> | ||
--- | ||
tools/testing/selftests/bpf/unpriv_helpers.c | 1 - | ||
1 file changed, 1 deletion(-) | ||
|
||
diff --git a/tools/testing/selftests/bpf/unpriv_helpers.c b/tools/testing/selftests/bpf/unpriv_helpers.c | ||
index 2a6efbd0401e..762e4b5ec955 100644 | ||
--- a/tools/testing/selftests/bpf/unpriv_helpers.c | ||
+++ b/tools/testing/selftests/bpf/unpriv_helpers.c | ||
@@ -2,7 +2,6 @@ | ||
|
||
#include <stdbool.h> | ||
#include <stdlib.h> | ||
-#include <error.h> | ||
#include <stdio.h> | ||
|
||
#include "unpriv_helpers.h" | ||
-- | ||
2.34.1 | ||
|