Hello,
The aim of this series is to make resctrl_tests run by using
kselftest framework.
- I modify resctrl_test Makefile and kselftest Makefile,
to enable build/run resctrl_tests by using kselftest framework.
Of course, users can also build/run resctrl_tests without
using framework as before.
- I change the default limited time for resctrl_tests to 120 seconds, to
ensure the resctrl_tests finish in limited time on different
environments.
- When resctrl file system is not supported by environment or
resctrl_tests is not run as root, return skip code of kselftest
framework.
- If resctrl_tests does not finish in limited time, terminate it as
same as executing ctrl+c that kills parent process and child process.
Difference from v4:
- Add comment for settings file. [PATCH v5 2/6]
- Improved README of resctrl_tests and rewirte changelog. [PATCH v5 5/6]
https://lore.kernel.org/lkml/20220304103834.486892-1-tan.shaopeng@jp.fujits… [PATCH V4]
This patch series is based on v5.17-rc7.
Shaopeng Tan (6):
selftests/resctrl: Kill child process before parent process terminates
if SIGTERM is received
selftests/resctrl: Change the default limited time to 120 seconds
selftests/resctrl: Fix resctrl_tests' return code to work with
selftest framework
selftests/resctrl: Make resctrl_tests run using kselftest framework
selftests/resctrl: Update README about using kselftest framework to
build/run resctrl_tests
selftests/resctrl: Add missing SPDX license to Makefile
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/resctrl/Makefile | 18 ++------
tools/testing/selftests/resctrl/README | 43 +++++++++++++++----
.../testing/selftests/resctrl/resctrl_tests.c | 4 +-
tools/testing/selftests/resctrl/resctrl_val.c | 1 +
tools/testing/selftests/resctrl/settings | 3 ++
6 files changed, 45 insertions(+), 25 deletions(-)
create mode 100644 tools/testing/selftests/resctrl/settings
--
2.27.0
The first patch of this series is an improvement to the existing
syncookie BPF helper. The second patch is a documentation fix.
The third patch allows BPF helpers to accept memory regions of fixed
size without doing runtime size checks.
The two last patches add new functionality that allows XDP to
accelerate iptables synproxy.
v1 of this series [1] used to include a patch that exposed conntrack
lookup to BPF using stable helpers. It was superseded by series [2] by
Kumar Kartikeya Dwivedi, which implements this functionality using
unstable helpers.
The fourth patch adds new helpers to issue and check SYN cookies without
binding to a socket, which is useful in the synproxy scenario.
The fifth patch adds a selftest, which consists of a script, an XDP
program and a userspace control application. The XDP program uses
socketless SYN cookie helpers and queries conntrack status instead of
socket status. The userspace control application allows to tune
parameters of the XDP program. This program also serves as a minimal
example of usage of the new functionality.
The draft of the new functionality was presented on Netdev 0x15 [3].
v2 changes:
Split into two series, submitted bugfixes to bpf, dropped the conntrack
patches, implemented the timestamp cookie in BPF using bpf_loop, dropped
the timestamp cookie patch.
v3 changes:
Moved some patches from bpf to bpf-next, dropped the patch that changed
error codes, split the new helpers into IPv4/IPv6, added verifier
functionality to accept memory regions of fixed size.
v4 changes:
Converted the selftest to the test_progs runner. Replaced some
deprecated functions in xdp_synproxy userspace helper.
[1]: https://lore.kernel.org/bpf/20211020095815.GJ28644@breakpoint.cc/t/
[2]: https://lore.kernel.org/bpf/20220114163953.1455836-1-memxor@gmail.com/
[3]: https://netdevconf.info/0x15/session.html?Accelerating-synproxy-with-XDP
Maxim Mikityanskiy (5):
bpf: Use ipv6_only_sock in bpf_tcp_gen_syncookie
bpf: Fix documentation of th_len in bpf_tcp_{gen,check}_syncookie
bpf: Allow helpers to accept pointers with a fixed size
bpf: Add helpers to issue and check SYN cookies in XDP
bpf: Add selftests for raw syncookie helpers
include/linux/bpf.h | 10 +
include/net/tcp.h | 1 +
include/uapi/linux/bpf.h | 100 ++-
kernel/bpf/verifier.c | 26 +-
net/core/filter.c | 128 ++-
net/ipv4/tcp_input.c | 3 +-
scripts/bpf_doc.py | 4 +
tools/include/uapi/linux/bpf.h | 100 ++-
tools/testing/selftests/bpf/.gitignore | 1 +
tools/testing/selftests/bpf/Makefile | 2 +-
.../selftests/bpf/prog_tests/xdp_synproxy.c | 101 +++
.../selftests/bpf/progs/xdp_synproxy_kern.c | 750 ++++++++++++++++++
tools/testing/selftests/bpf/xdp_synproxy.c | 418 ++++++++++
13 files changed, 1622 insertions(+), 22 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/xdp_synproxy.c
create mode 100644 tools/testing/selftests/bpf/progs/xdp_synproxy_kern.c
create mode 100644 tools/testing/selftests/bpf/xdp_synproxy.c
--
2.30.2
This series is just a set of minor tweaks and improvements for the MTE
tests that I did while working on the asymmetric mode support for
userspace which seemed like they might be worth keeping even though the
prctl() for asymmetric mode got removed.
v2:
- Also log PC and fault address on unexpected async faults.
- Remove redundant system_has_mte variable.
Mark Brown (4):
kselftest/arm64: Handle more kselftest result codes in MTE helpers
kselftest/arm64: Log unexpected asynchronous MTE faults
kselftest/arm64: Refactor parameter checking in mte_switch_mode()
kselftest/arm64: Add simple test for MTE prctl
tools/testing/selftests/arm64/mte/.gitignore | 1 +
.../testing/selftests/arm64/mte/check_prctl.c | 119 ++++++++++++++++++
.../selftests/arm64/mte/mte_common_util.c | 19 ++-
.../selftests/arm64/mte/mte_common_util.h | 15 ++-
4 files changed, 149 insertions(+), 5 deletions(-)
create mode 100644 tools/testing/selftests/arm64/mte/check_prctl.c
base-commit: dfd42facf1e4ada021b939b4e19c935dcdd55566
--
2.30.2
Add support for a new kind of kunit_suite registration macro called
kunit_test_init_suite(); this new registration macro allows the
registration of kunit_suites that reference functions marked __init and
data marked __initdata.
Signed-off-by: Brendan Higgins <brendanhiggins(a)google.com>
---
This patch is in response to a KUnit user issue[1] in which the user was
attempting to test some init functions; although this is a functional
solution as long as KUnit tests only run during the init phase, we will
need to do more work if we ever allow tests to run after the init phase
is over; it is for this reason that this patch adds a new registration
macro rather than simply modifying the existing macros.
[1] https://groups.google.com/g/kunit-dev/c/XDjieRHEneg/m/D0rFCwVABgAJ
---
include/kunit/test.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/include/kunit/test.h b/include/kunit/test.h
index b26400731c02..1878e585f6d3 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -379,6 +379,27 @@ static inline int kunit_run_all_tests(void)
#define kunit_test_suite(suite) kunit_test_suites(&suite)
+/**
+ * kunit_test_init_suites() - used to register one or more &struct kunit_suite
+ * containing init functions or init data.
+ *
+ * @__suites: a statically allocated list of &struct kunit_suite.
+ *
+ * This functions identically as &kunit_test_suites() except that it suppresses
+ * modpost warnings for referencing functions marked __init or data marked
+ * __initdata; this is OK because currently KUnit only runs tests upon boot
+ * during the init phase or upon loading a module during the init phase.
+ *
+ * NOTE TO KUNIT DEVS: If we ever allow KUnit tests to be run after boot, these
+ * tests must be excluded.
+ */
+#define kunit_test_init_suites(__suites...) \
+ __kunit_test_suites(CONCATENATE(__UNIQUE_ID(array), _probe), \
+ CONCATENATE(__UNIQUE_ID(suites), _probe), \
+ ##__suites)
+
+#define kunit_test_init_suite(suite) kunit_test_init_suites(&suite)
+
#define kunit_suite_for_each_test_case(suite, test_case) \
for (test_case = suite->test_cases; test_case->run_case; test_case++)
base-commit: 330f4c53d3c2d8b11d86ec03a964b86dc81452f5
--
2.35.1.723.g4982287a31-goog
Extend the interoperability with IMA, to give wider flexibility for the
implementation of integrity-focused LSMs based on eBPF.
Patch 1 fixes some style issues.
Patches 2-6 give the ability to eBPF-based LSMs to take advantage of the
measurement capability of IMA without needing to setup a policy in IMA
(those LSMs might implement the policy capability themselves).
Patches 7-9 allow eBPF-based LSMs to evaluate files read by the kernel.
Changelog
v2:
- Add better description to patch 1 (suggested by Shuah)
- Recalculate digest if it is not fresh (when IMA_COLLECTED flag not set)
- Move declaration of bpf_ima_file_hash() at the end (suggested by
Yonghong)
- Add tests to check if the digest has been recalculated
- Add deny test for bpf_kernel_read_file()
- Add description to tests
v1:
- Modify ima_file_hash() only and allow the usage of the function with the
modified behavior by eBPF-based LSMs through the new function
bpf_ima_file_hash() (suggested by Mimi)
- Make bpf_lsm_kernel_read_file() sleepable so that bpf_ima_inode_hash()
and bpf_ima_file_hash() can be called inside the implementation of
eBPF-based LSMs for this hook
Roberto Sassu (9):
ima: Fix documentation-related warnings in ima_main.c
ima: Always return a file measurement in ima_file_hash()
bpf-lsm: Introduce new helper bpf_ima_file_hash()
selftests/bpf: Move sample generation code to ima_test_common()
selftests/bpf: Add test for bpf_ima_file_hash()
selftests/bpf: Check if the digest is refreshed after a file write
bpf-lsm: Make bpf_lsm_kernel_read_file() as sleepable
selftests/bpf: Add test for bpf_lsm_kernel_read_file()
selftests/bpf: Check that bpf_kernel_read_file() denies reading IMA
policy
include/uapi/linux/bpf.h | 11 ++
kernel/bpf/bpf_lsm.c | 21 +++
security/integrity/ima/ima_main.c | 57 ++++---
tools/include/uapi/linux/bpf.h | 11 ++
tools/testing/selftests/bpf/ima_setup.sh | 35 +++-
.../selftests/bpf/prog_tests/test_ima.c | 149 +++++++++++++++++-
tools/testing/selftests/bpf/progs/ima.c | 66 +++++++-
7 files changed, 321 insertions(+), 29 deletions(-)
--
2.32.0
According to "Intel Resource Director Technology (Intel RDT) on
2nd Generation Intel Xeon Scalable Processors Reference Manual",
When the Intel Sub-NUMA Clustering(SNC) feature is enabled,
Intel CMT and MBM counters may not be accurate.
However, there does not seem to be an architectural way to detect
if SNC is enabled.
If the result of MBM&CMT test fails on Intel CPU,
print a message to let users know a possible cause of failure.
Signed-off-by: Shaopeng Tan <tan.shaopeng(a)jp.fujitsu.com>
---
Hello,
In PATCH V2, I tried to detect whether SNC is enabled by NUMA info and
cpuinfo(socket_num), but it is not reliable and no future-proof.
I just print a message to let users know a possible cause of "not ok",
When CMT or MBM test runs on Intel CPU, and the result is "not ok".
This patch is based on v5.16.
tools/testing/selftests/resctrl/resctrl_tests.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c
index 973f09a66e1e..ec2bdce7b85f 100644
--- a/tools/testing/selftests/resctrl/resctrl_tests.c
+++ b/tools/testing/selftests/resctrl/resctrl_tests.c
@@ -14,8 +14,9 @@
#define BENCHMARK_ARG_SIZE 64
bool is_amd;
+bool is_intel;
-void detect_amd(void)
+void detect_vendor(void)
{
FILE *inf = fopen("/proc/cpuinfo", "r");
char *res;
@@ -29,6 +30,7 @@ void detect_amd(void)
char *s = strchr(res, ':');
is_amd = s && !strcmp(s, ": AuthenticAMD\n");
+ is_intel = s && !strcmp(s, ": GenuineIntel\n");
free(res);
}
fclose(inf);
@@ -70,6 +72,8 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span,
sprintf(benchmark_cmd[5], "%s", MBA_STR);
res = mbm_bw_change(span, cpu_no, bw_report, benchmark_cmd);
ksft_test_result(!res, "MBM: bw change\n");
+ if (is_intel && res)
+ ksft_print_msg("Intel CMT and MBM counters may be inaccurate when Sub-NUMA Clustering (SNC) is enabled. Ensure SNC is disabled in the BIOS if this system supports SNC.\n");
mbm_test_cleanup();
}
@@ -106,6 +110,8 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no)
sprintf(benchmark_cmd[5], "%s", CMT_STR);
res = cmt_resctrl_val(cpu_no, 5, benchmark_cmd);
ksft_test_result(!res, "CMT: test\n");
+ if (is_intel && res)
+ ksft_print_msg("Intel CMT and MBM counters may be inaccurate when Sub-NUMA Clustering (SNC) is enabled. Ensure SNC is disabled in the BIOS if this system supports SNC.\n");
cmt_test_cleanup();
}
@@ -207,8 +213,8 @@ int main(int argc, char **argv)
if (geteuid() != 0)
return ksft_exit_fail_msg("Not running as root, abort testing.\n");
- /* Detect AMD vendor */
- detect_amd();
+ /* Detect AMD/INTEL vendor */
+ detect_vendor();
if (has_ben) {
/* Extract benchmark command from command line. */
--
2.27.0
This series is just a set of minor tweaks and improvements for the MTE
tests that I did while working on the asymmetric mode support for
userspace which seemed like they might be worth keeping even though the
prctl() for asymmetric mode got removed.
Mark Brown (4):
kselftest/arm64: Handle more kselftest result codes in MTE helpers
kselftest/arm64: Log unexpected asynchronous MTE faults
kselftest/arm64: Refactor parameter checking in mte_switch_mode()
kselftest/arm64: Add simple test for MTE prctl
tools/testing/selftests/arm64/mte/.gitignore | 1 +
.../testing/selftests/arm64/mte/check_prctl.c | 123 ++++++++++++++++++
.../selftests/arm64/mte/mte_common_util.c | 17 ++-
.../selftests/arm64/mte/mte_common_util.h | 15 ++-
4 files changed, 151 insertions(+), 5 deletions(-)
create mode 100644 tools/testing/selftests/arm64/mte/check_prctl.c
base-commit: dfd42facf1e4ada021b939b4e19c935dcdd55566
--
2.30.2
This series is to fix UAF when running kfence test case test_gfpzero,
which is time costly. This UAF bug can be easily triggered by setting
CONFIG_KFENCE_NUM_OBJECTS = 65535. Furthermore, some optimization for
kunit tests has been done.
v1->v2:
Change log is updated.
Peng Liu (3):
kunit: fix UAF when run kfence test case test_gfpzero
kunit: make kunit_test_timeout compatible with comment
kfence: test: try to avoid test_gfpzero trigger rcu_stall
lib/kunit/try-catch.c | 3 ++-
mm/kfence/kfence_test.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
--
2.18.0.huawei.25
kernel/dma/map_benchmark.c and selftests/dma/dma_map_benchmark.c
have duplicate map_benchmark definitions, which tends to lead to
inconsistent changes to map_benchmark on both sides, extract a
common header file to avoid this problem.
Signed-off-by: Tian Tao <tiantao6(a)hisilicon.com>
Acked-by: Barry Song <song.bao.hua(a)hisilicon.com>
Reviewed-by: Shuah Khan <skhan(a)linuxfoundation.org>
---
v2:
move map_benchmark.h in a more appropriate directory
---
include/linux/map_benchmark.h | 31 +++++++++++++++++++
kernel/dma/map_benchmark.c | 25 +--------------
.../testing/selftests/dma/dma_map_benchmark.c | 25 +--------------
3 files changed, 33 insertions(+), 48 deletions(-)
create mode 100644 include/linux/map_benchmark.h
diff --git a/include/linux/map_benchmark.h b/include/linux/map_benchmark.h
new file mode 100644
index 000000000000..62674c83bde4
--- /dev/null
+++ b/include/linux/map_benchmark.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2022 HiSilicon Limited.
+ */
+
+#ifndef _KERNEL_DMA_BENCHMARK_H
+#define _KERNEL_DMA_BENCHMARK_H
+
+#define DMA_MAP_BENCHMARK _IOWR('d', 1, struct map_benchmark)
+#define DMA_MAP_MAX_THREADS 1024
+#define DMA_MAP_MAX_SECONDS 300
+#define DMA_MAP_MAX_TRANS_DELAY (10 * NSEC_PER_MSEC)
+
+#define DMA_MAP_BIDIRECTIONAL 0
+#define DMA_MAP_TO_DEVICE 1
+#define DMA_MAP_FROM_DEVICE 2
+
+struct map_benchmark {
+ __u64 avg_map_100ns; /* average map latency in 100ns */
+ __u64 map_stddev; /* standard deviation of map latency */
+ __u64 avg_unmap_100ns; /* as above */
+ __u64 unmap_stddev;
+ __u32 threads; /* how many threads will do map/unmap in parallel */
+ __u32 seconds; /* how long the test will last */
+ __s32 node; /* which numa node this benchmark will run on */
+ __u32 dma_bits; /* DMA addressing capability */
+ __u32 dma_dir; /* DMA data direction */
+ __u32 dma_trans_ns; /* time for DMA transmission in ns */
+ __u32 granule; /* how many PAGE_SIZE will do map/unmap once a time */
+};
+#endif /* _KERNEL_DMA_BENCHMARK_H */
diff --git a/kernel/dma/map_benchmark.c b/kernel/dma/map_benchmark.c
index 9b9af1bd6be3..0520a8f4fb1d 100644
--- a/kernel/dma/map_benchmark.c
+++ b/kernel/dma/map_benchmark.c
@@ -11,6 +11,7 @@
#include <linux/dma-mapping.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
+#include <linux/map_benchmark.h>
#include <linux/math64.h>
#include <linux/module.h>
#include <linux/pci.h>
@@ -18,30 +19,6 @@
#include <linux/slab.h>
#include <linux/timekeeping.h>
-#define DMA_MAP_BENCHMARK _IOWR('d', 1, struct map_benchmark)
-#define DMA_MAP_MAX_THREADS 1024
-#define DMA_MAP_MAX_SECONDS 300
-#define DMA_MAP_MAX_TRANS_DELAY (10 * NSEC_PER_MSEC)
-
-#define DMA_MAP_BIDIRECTIONAL 0
-#define DMA_MAP_TO_DEVICE 1
-#define DMA_MAP_FROM_DEVICE 2
-
-struct map_benchmark {
- __u64 avg_map_100ns; /* average map latency in 100ns */
- __u64 map_stddev; /* standard deviation of map latency */
- __u64 avg_unmap_100ns; /* as above */
- __u64 unmap_stddev;
- __u32 threads; /* how many threads will do map/unmap in parallel */
- __u32 seconds; /* how long the test will last */
- __s32 node; /* which numa node this benchmark will run on */
- __u32 dma_bits; /* DMA addressing capability */
- __u32 dma_dir; /* DMA data direction */
- __u32 dma_trans_ns; /* time for DMA transmission in ns */
- __u32 granule; /* how many PAGE_SIZE will do map/unmap once a time */
- __u8 expansion[76]; /* For future use */
-};
-
struct map_benchmark_data {
struct map_benchmark bparam;
struct device *dev;
diff --git a/tools/testing/selftests/dma/dma_map_benchmark.c b/tools/testing/selftests/dma/dma_map_benchmark.c
index 485dff51bad2..c3b3c09e995e 100644
--- a/tools/testing/selftests/dma/dma_map_benchmark.c
+++ b/tools/testing/selftests/dma/dma_map_benchmark.c
@@ -10,40 +10,17 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
+#include <linux/map_benchmark.h>
#include <linux/types.h>
#define NSEC_PER_MSEC 1000000L
-#define DMA_MAP_BENCHMARK _IOWR('d', 1, struct map_benchmark)
-#define DMA_MAP_MAX_THREADS 1024
-#define DMA_MAP_MAX_SECONDS 300
-#define DMA_MAP_MAX_TRANS_DELAY (10 * NSEC_PER_MSEC)
-
-#define DMA_MAP_BIDIRECTIONAL 0
-#define DMA_MAP_TO_DEVICE 1
-#define DMA_MAP_FROM_DEVICE 2
-
static char *directions[] = {
"BIDIRECTIONAL",
"TO_DEVICE",
"FROM_DEVICE",
};
-struct map_benchmark {
- __u64 avg_map_100ns; /* average map latency in 100ns */
- __u64 map_stddev; /* standard deviation of map latency */
- __u64 avg_unmap_100ns; /* as above */
- __u64 unmap_stddev;
- __u32 threads; /* how many threads will do map/unmap in parallel */
- __u32 seconds; /* how long the test will last */
- __s32 node; /* which numa node this benchmark will run on */
- __u32 dma_bits; /* DMA addressing capability */
- __u32 dma_dir; /* DMA data direction */
- __u32 dma_trans_ns; /* time for DMA transmission in ns */
- __u32 granule; /* how many PAGE_SIZE will do map/unmap once a time */
- __u8 expansion[76]; /* For future use */
-};
-
int main(int argc, char **argv)
{
struct map_benchmark map;
--
2.33.0