Update the rseq selftests to adapt to the userspace ABI chosen by glibc
(will be released in February 2022). Provide a fallback implementation
to work with older glibc as well.
Remove broken 32-bit little/big endian accessor fields in rseq uapi.
Integrate various fixes gathered from librseq, including work-around for
known gcc and clang compiler bugs with asm goto.
The uplift to glibc's userspace ABI means we can now use %fs/%gs segment
selectors directly in the inline assembler for accesses to the rseq
thread area on x86.
Feedback is welcome,
Thanks,
Mathieu
Mathieu Desnoyers (15):
selftests/rseq: introduce own copy of rseq uapi header
rseq: Remove broken uapi field layout on 32-bit little endian
selftests/rseq: Remove useless assignment to cpu variable
selftests/rseq: Remove volatile from __rseq_abi
selftests/rseq: Introduce rseq_get_abi() helper
selftests/rseq: Introduce thread pointer getters
selftests/rseq: Uplift rseq selftests for compatibility with
glibc-2.35
selftests/rseq: Fix ppc32: wrong rseq_cs 32-bit field pointer on big
endian
selftests/rseq: Fix ppc32 missing instruction selection "u" and "x"
for load/store
selftests/rseq: Fix ppc32 offsets by using long rather than off_t
selftests/rseq: Fix warnings about #if checks of undefined tokens
selftests/rseq: Remove arm/mips asm goto compiler work-around
selftests/rseq: Fix: work-around asm goto compiler bugs
selftests/rseq: x86-64: use %fs segment selector for accessing rseq
thread area
selftests/rseq: x86-32: use %gs segment selector for accessing rseq
thread area
include/uapi/linux/rseq.h | 17 +-
tools/testing/selftests/rseq/Makefile | 2 +-
.../selftests/rseq/basic_percpu_ops_test.c | 2 +-
tools/testing/selftests/rseq/compiler.h | 30 +++
tools/testing/selftests/rseq/param_test.c | 8 +-
tools/testing/selftests/rseq/rseq-abi.h | 151 +++++++++++++
tools/testing/selftests/rseq/rseq-arm.h | 110 +++++-----
tools/testing/selftests/rseq/rseq-arm64.h | 79 +++++--
.../rseq/rseq-generic-thread-pointer.h | 25 +++
tools/testing/selftests/rseq/rseq-mips.h | 71 ++-----
.../selftests/rseq/rseq-ppc-thread-pointer.h | 30 +++
tools/testing/selftests/rseq/rseq-ppc.h | 128 +++++++----
tools/testing/selftests/rseq/rseq-s390.h | 55 +++--
tools/testing/selftests/rseq/rseq-skip.h | 2 +-
.../selftests/rseq/rseq-thread-pointer.h | 19 ++
.../selftests/rseq/rseq-x86-thread-pointer.h | 40 ++++
tools/testing/selftests/rseq/rseq-x86.h | 200 ++++++++++++------
tools/testing/selftests/rseq/rseq.c | 163 +++++++-------
tools/testing/selftests/rseq/rseq.h | 29 ++-
19 files changed, 793 insertions(+), 368 deletions(-)
create mode 100644 tools/testing/selftests/rseq/compiler.h
create mode 100644 tools/testing/selftests/rseq/rseq-abi.h
create mode 100644 tools/testing/selftests/rseq/rseq-generic-thread-pointer.h
create mode 100644 tools/testing/selftests/rseq/rseq-ppc-thread-pointer.h
create mode 100644 tools/testing/selftests/rseq/rseq-thread-pointer.h
create mode 100644 tools/testing/selftests/rseq/rseq-x86-thread-pointer.h
--
2.17.1
The current kunit infrastructure defines its own module_init() when
built as a module, which conflicts with the mctp core's own.
So, only allow MCTP_TEST when both MCTP and KUNIT are built-in.
Reported-by: kernel test robot <lkp(a)intel.com>
Signed-off-by: Jeremy Kerr <jk(a)codeconstruct.com.au>
---
net/mctp/Kconfig | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/mctp/Kconfig b/net/mctp/Kconfig
index 15267a5043d9..868c92272cbd 100644
--- a/net/mctp/Kconfig
+++ b/net/mctp/Kconfig
@@ -13,6 +13,6 @@ menuconfig MCTP
channel.
config MCTP_TEST
- tristate "MCTP core tests" if !KUNIT_ALL_TESTS
- depends on MCTP && KUNIT
+ bool "MCTP core tests" if !KUNIT_ALL_TESTS
+ depends on MCTP=y && KUNIT=y
default KUNIT_ALL_TESTS
--
2.30.2
Since kernel commit 43209ea2d17a ("zram: remove max_comp_streams internals"), zram has
switched to per-cpu streams. Even kernel still keep this interface for some reasons, but
writing to max_comp_stream doesn't take any effect. So remove it.
Signed-off-by: Yang Xu <xuyang2018.jy(a)fujitsu.com>
---
tools/testing/selftests/zram/zram01.sh | 4 ----
tools/testing/selftests/zram/zram02.sh | 4 ----
tools/testing/selftests/zram/zram_lib.sh | 22 ----------------------
3 files changed, 30 deletions(-)
diff --git a/tools/testing/selftests/zram/zram01.sh b/tools/testing/selftests/zram/zram01.sh
index 114863d9fb87..28583e4ae546 100755
--- a/tools/testing/selftests/zram/zram01.sh
+++ b/tools/testing/selftests/zram/zram01.sh
@@ -15,9 +15,6 @@ ERR_CODE=0
# Test will create the following number of zram devices:
dev_num=1
-# This is a list of parameters for zram devices.
-# Number of items must be equal to 'dev_num' parameter.
-zram_max_streams="2"
# The zram sysfs node 'disksize' value can be either in bytes,
# or you can use mem suffixes. But in some old kernels, mem
@@ -72,7 +69,6 @@ zram_fill_fs()
check_prereqs
zram_load
-zram_max_streams
zram_compress_alg
zram_set_disksizes
zram_set_memlimit
diff --git a/tools/testing/selftests/zram/zram02.sh b/tools/testing/selftests/zram/zram02.sh
index e83b404807c0..d664974a1317 100755
--- a/tools/testing/selftests/zram/zram02.sh
+++ b/tools/testing/selftests/zram/zram02.sh
@@ -14,9 +14,6 @@ ERR_CODE=0
# Test will create the following number of zram devices:
dev_num=1
-# This is a list of parameters for zram devices.
-# Number of items must be equal to 'dev_num' parameter.
-zram_max_streams="2"
# The zram sysfs node 'disksize' value can be either in bytes,
# or you can use mem suffixes. But in some old kernels, mem
@@ -30,7 +27,6 @@ zram_mem_limits="1M"
check_prereqs
zram_load
-zram_max_streams
zram_set_disksizes
zram_set_memlimit
zram_makeswap
diff --git a/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh
index 6f872f266fd1..0c49f9d1d563 100755
--- a/tools/testing/selftests/zram/zram_lib.sh
+++ b/tools/testing/selftests/zram/zram_lib.sh
@@ -82,28 +82,6 @@ zram_load()
fi
}
-zram_max_streams()
-{
- echo "set max_comp_streams to zram device(s)"
-
- local i=0
- for max_s in $zram_max_streams; do
- local sys_path="/sys/block/zram${i}/max_comp_streams"
- echo $max_s > $sys_path || \
- echo "FAIL failed to set '$max_s' to $sys_path"
- sleep 1
- local max_streams=$(cat $sys_path)
-
- [ "$max_s" -ne "$max_streams" ] && \
- echo "FAIL can't set max_streams '$max_s', get $max_stream"
-
- i=$(($i + 1))
- echo "$sys_path = '$max_streams' ($i/$dev_num)"
- done
-
- echo "zram max streams: OK"
-}
-
zram_compress_alg()
{
echo "test that we can set compression algorithm"
--
2.23.0
Some testcases allow for optional commandline parameters but as of now
there is now way to provide such arguments to the runner script.
Add support to retrieve such optional command parameters fron environment
variables named so as to include the all-uppercase test executable name,
sanitized substituting any non-acceptable varname characters with "_",
following the pattern:
KSELFTEST_<UPPERCASE_SANITIZED_TEST_NAME>_ARGS="options"
Optional command parameters support is not available if 'tr' is not
installed on the test system.
Cc: Kees Cook <keescook(a)chromium.org>
Signed-off-by: Cristian Marussi <cristian.marussi(a)arm.com>
---
v3 --> v4
- rebased on v5.17-rc1
v2 --> v3
- improved varname sanitation
v1 --> v2
- using env vars instead of settings file
- added missing varname sanitation
Usage examples:
KSELFTEST_RTCTEST_ARGS="/dev/rtc1" /opt/ksft_fixes/run_kselftest.sh -c rtc
KSELFTEST_CPU_ON_OFF_TEST_SH_ARGS="-a -p 10" /opt/ksft_fixes/run_kselftest.sh -c cpu-hotplug
---
tools/testing/selftests/kselftest/runner.sh | 30 ++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh
index a9ba782d8ca0..294619ade49f 100644
--- a/tools/testing/selftests/kselftest/runner.sh
+++ b/tools/testing/selftests/kselftest/runner.sh
@@ -18,6 +18,8 @@ if [ -z "$BASE_DIR" ]; then
exit 1
fi
+TR_CMD=$(command -v tr)
+
# If Perl is unavailable, we must fall back to line-at-a-time prefixing
# with sed instead of unbuffered output.
tap_prefix()
@@ -49,6 +51,31 @@ run_one()
# Reset any "settings"-file variables.
export kselftest_timeout="$kselftest_default_timeout"
+
+ # Safe default if tr not available
+ kselftest_cmd_args_ref="KSELFTEST_ARGS"
+
+ # Optional arguments for this command, possibly defined as an
+ # environment variable built using the test executable in all
+ # uppercase and sanitized substituting non acceptable shell
+ # variable name characters with "_" as in:
+ #
+ # KSELFTEST_<UPPERCASE_SANITIZED_TESTNAME>_ARGS="<options>"
+ #
+ # e.g.
+ #
+ # rtctest --> KSELFTEST_RTCTEST_ARGS="/dev/rtc1"
+ #
+ # cpu-on-off-test.sh --> KSELFTEST_CPU_ON_OFF_TEST_SH_ARGS="-a -p 10"
+ #
+ if [ -n "$TR_CMD" ]; then
+ BASENAME_SANITIZED=$(echo "$BASENAME_TEST" | \
+ $TR_CMD -d "[:blank:][:cntrl:]" | \
+ $TR_CMD -c "[:alnum:]_" "_" | \
+ $TR_CMD [:lower:] [:upper:])
+ kselftest_cmd_args_ref="KSELFTEST_${BASENAME_SANITIZED}_ARGS"
+ fi
+
# Load per-test-directory kselftest "settings" file.
settings="$BASE_DIR/$DIR/settings"
if [ -r "$settings" ] ; then
@@ -69,7 +96,8 @@ run_one()
echo "# Warning: file $TEST is missing!"
echo "not ok $test_num $TEST_HDR_MSG"
else
- cmd="./$BASENAME_TEST"
+ eval kselftest_cmd_args="\$${kselftest_cmd_args_ref:-}"
+ cmd="./$BASENAME_TEST $kselftest_cmd_args"
if [ ! -x "$TEST" ]; then
echo "# Warning: file $TEST is not executable"
--
2.17.1
Recursive make commands should always use the variable MAKE, not the
explicit command name ‘make’. This has benefits and removes the
following warning when multiple jobs are used for the build:
make[2]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
Signed-off-by: Muhammad Usama Anjum <usama.anjum(a)collabora.com>
---
tools/testing/selftests/futex/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/futex/Makefile b/tools/testing/selftests/futex/Makefile
index 12631f0076a10..11e157d7533b8 100644
--- a/tools/testing/selftests/futex/Makefile
+++ b/tools/testing/selftests/futex/Makefile
@@ -11,7 +11,7 @@ all:
@for DIR in $(SUBDIRS); do \
BUILD_TARGET=$(OUTPUT)/$$DIR; \
mkdir $$BUILD_TARGET -p; \
- make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
+ $(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
if [ -e $$DIR/$(TEST_PROGS) ]; then \
rsync -a $$DIR/$(TEST_PROGS) $$BUILD_TARGET/; \
fi \
@@ -32,6 +32,6 @@ override define CLEAN
@for DIR in $(SUBDIRS); do \
BUILD_TARGET=$(OUTPUT)/$$DIR; \
mkdir $$BUILD_TARGET -p; \
- make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
+ $(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
done
endef
--
2.30.2
If the compiler doesn't optimize them away, each kunit assertion (use of
KUNIT_EXPECT_EQ, etc.) can use 88 bytes of stack space in the worst and
most common case. This has led to compiler warnings for certain configs
+ arches [1].
This series builds upon [2] which cut down kunit_assert from 48 => 24
bytes, but only reduced kunit_binary_assert (the most common one) from
88 => 48.
Now we have kunit_assert = 8 and kunit_binary_assert = 32.
The cost is we need to pass around another parameter to some functions
(struct va_format *), and we introduce a new type
(sturct kunit_binary_assert_text) for holding the textual representation
of the KUNIT_EXPECT_EQ arguments.
Note: it's possible to get kunit_assert = 0 and kunit_binary_assert =
24 by removing the `format` function pointer field from kunit_assert.
I think it's an improvement, but others might think that readability
suffers from doing so, so I'm leaving that off from this series.
Meta: this series applies on top of 5.17-rc1 + [2] and [3].
That should be available at in Shuah's kunit branch [4], but my version
of git is constantly segfaulting, so I can't try and rebase to verify.
[1] https://groups.google.com/g/kunit-dev/c/i3fZXgvBrfA/m/VULQg1z6BAAJ
[2] https://lore.kernel.org/linux-kselftest/20220113165931.451305-6-dlatypov@go…
[3] https://lore.kernel.org/linux-kselftest/20220118223506.1701553-1-dlatypov@g…
[4] https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/?…
Daniel Latypov (3):
kunit: remove va_format from kunit_assert
kunit: consolidate KUNIT_INIT_BINARY_ASSERT_STRUCT macros
kunit: factor out str constants from binary assertion structs
include/kunit/assert.h | 152 ++++++++++++-----------------------------
include/kunit/test.h | 32 +++++----
lib/kunit/assert.c | 65 ++++++++++--------
lib/kunit/test.c | 12 ++--
4 files changed, 104 insertions(+), 157 deletions(-)
--
2.35.0.rc2.247.g8bbb082509-goog
pipe named FIFO special file is being created in execveat.c to perform
some tests. Makefile doesn't need to do anything with the pipe. When it
isn't found, Makefile generates the following build error:
make: *** No rule to make target '/linux_mainline/tools/testing/selftests/exec/pipe', needed by 'all'. Stop.
Fixes: 61016db15b8e ("selftests/exec: Verify execve of non-regular files fail")
Signed-off-by: Muhammad Usama Anjum <usama.anjum(a)collabora.com>
---
tools/testing/selftests/exec/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index dd61118df66ed..12c5e27d32c16 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -5,7 +5,7 @@ CFLAGS += -D_GNU_SOURCE
TEST_PROGS := binfmt_script non-regular
TEST_GEN_PROGS := execveat load_address_4096 load_address_2097152 load_address_16777216
-TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir pipe
+TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
# Makefile is a run-time dependency, since it's accessed by the execveat test
TEST_FILES := Makefile
--
2.30.2
The arch_timer and vgic_irq kselftests assume that they can create a
vgic-v3, using the library function vgic_v3_setup() which aborts with a
test failure if it is not possible to do so. Since vgic-v3 can only be
instantiated on systems where the host has GICv3 this leads to false
positives on older systems where that is not the case.
Fix this by changing vgic_v3_setup() to return an error if the vgic can't
be instantiated and have the callers skip if this happens. We could also
exit flagging a skip in vgic_v3_setup() but this would prevent future test
cases conditionally deciding which GIC to use or generally doing more
complex output.
Signed-off-by: Mark Brown <broonie(a)kernel.org>
---
v3:
- Use custom print_skip() helper.
- Use internal version of _kvm_create_device.
v2:
- The test for being able to create the GIC doesn't actually
instantiate it, add a call doing so in that case.
tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++-
tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++
tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++-
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/aarch64/arch_timer.c b/tools/testing/selftests/kvm/aarch64/arch_timer.c
index 9ad38bd360a4..b08d30bf71c5 100644
--- a/tools/testing/selftests/kvm/aarch64/arch_timer.c
+++ b/tools/testing/selftests/kvm/aarch64/arch_timer.c
@@ -366,6 +366,7 @@ static struct kvm_vm *test_vm_create(void)
{
struct kvm_vm *vm;
unsigned int i;
+ int ret;
int nr_vcpus = test_args.nr_vcpus;
vm = vm_create_default_with_vcpus(nr_vcpus, 0, 0, guest_code, NULL);
@@ -382,7 +383,11 @@ static struct kvm_vm *test_vm_create(void)
ucall_init(vm, NULL);
test_init_timer_irq(vm);
- vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
+ ret = vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA);
+ if (ret < 0) {
+ print_skip("Failed to create vgic-v3");
+ exit(KSFT_SKIP);
+ }
/* Make all the test's cmdline args visible to the guest */
sync_global_to_guest(vm, test_args);
diff --git a/tools/testing/selftests/kvm/aarch64/vgic_irq.c b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
index e6c7d7f8fbd1..7eca97799917 100644
--- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
+++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
@@ -761,6 +761,10 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split)
gic_fd = vgic_v3_setup(vm, 1, nr_irqs,
GICD_BASE_GPA, GICR_BASE_GPA);
+ if (gic_fd < 0) {
+ print_skip("Failed to create vgic-v3, skipping");
+ exit(KSFT_SKIP);
+ }
vm_install_exception_handler(vm, VECTOR_IRQ_CURRENT,
guest_irq_handlers[args.eoi_split][args.level_sensitive]);
diff --git a/tools/testing/selftests/kvm/lib/aarch64/vgic.c b/tools/testing/selftests/kvm/lib/aarch64/vgic.c
index b3a0fca0d780..f5cd0c536d85 100644
--- a/tools/testing/selftests/kvm/lib/aarch64/vgic.c
+++ b/tools/testing/selftests/kvm/lib/aarch64/vgic.c
@@ -52,7 +52,9 @@ int vgic_v3_setup(struct kvm_vm *vm, unsigned int nr_vcpus, uint32_t nr_irqs,
nr_vcpus, nr_vcpus_created);
/* Distributor setup */
- gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, false);
+ if (_kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3,
+ false, &gic_fd) != 0)
+ return -1;
kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
0, &nr_irqs, true);
--
2.30.2
Currently sigaltstack() can return multiple flags, for example
SS_DISABLE|SS_AUTODISARM. This confuses libraries (including asan
runtime) and contradicts the man page.
Patch 1 fixes this problem by ignoring any flag passed with SS_DISABLE.
Patch 2 adds a test-case for that scenario.
Signed-off-by: Stas Sergeev <stsp2(a)yandex.ru>
CC: "Eric W. Biederman" <ebiederm(a)xmission.com>
CC: Kees Cook <keescook(a)chromium.org>
CC: Jens Axboe <axboe(a)kernel.dk>
CC: Peter Zijlstra <peterz(a)infradead.org>
CC: Marco Elver <elver(a)google.com>
CC: Thomas Gleixner <tglx(a)linutronix.de>
CC: Alexey Gladkov <legion(a)kernel.org>
CC: Andrew Lutomirski <luto(a)mit.edu>
CC: Shuah Khan <shuah(a)kernel.org>
CC: "Chang S. Bae" <chang.seok.bae(a)intel.com>
CC: Borislav Petkov <bp(a)suse.de>
CC: Thomas Gleixner <tglx(a)linutronix.de>
CC: Len Brown <len.brown(a)intel.com>
CC: linux-kselftest(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org
Stas Sergeev (2):
sigaltstack: ignore flags if SS_DISABLE is set
selftests: sigaltstack: add new SS_DISABLE test
kernel/signal.c | 1 +
tools/testing/selftests/sigaltstack/sas.c | 48 ++++++++++++-----------
2 files changed, 26 insertions(+), 23 deletions(-)
--
2.34.1