From: David Gow <davidgow(a)google.com>
[ Upstream commit 37dbb4c7c7442dbfc9b651e4ddd4afe30b26afc9 ]
It's possible that a parameterised test could end up with zero
parameters. At the moment, the test function will nevertheless be called
with NULL as the parameter. Instead, don't try to run the test code, and
just mark the test as SKIPped.
Reported-by: Daniel Latypov <dlatypov(a)google.com>
Signed-off-by: David Gow <davidgow(a)google.com>
Reviewed-by: Daniel Latypov <dlatypov(a)google.com>
Reviewed-by: Brendan Higgins <brendanhiggins(a)google.com>
Signed-off-by: Shuah Khan <skhan(a)linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
lib/kunit/test.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index 3bd741e50a2d3..f96498ede2cc5 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -504,16 +504,18 @@ int kunit_run_tests(struct kunit_suite *suite)
struct kunit_result_stats param_stats = { 0 };
test_case->status = KUNIT_SKIPPED;
- if (test_case->generate_params) {
+ if (!test_case->generate_params) {
+ /* Non-parameterised test. */
+ kunit_run_case_catch_errors(suite, test_case, &test);
+ kunit_update_stats(¶m_stats, test.status);
+ } else {
/* Get initial param. */
param_desc[0] = '\0';
test.param_value = test_case->generate_params(NULL, param_desc);
- }
- do {
- kunit_run_case_catch_errors(suite, test_case, &test);
+ while (test.param_value) {
+ kunit_run_case_catch_errors(suite, test_case, &test);
- if (test_case->generate_params) {
if (param_desc[0] == '\0') {
snprintf(param_desc, sizeof(param_desc),
"param-%d", test.param_index);
@@ -530,11 +532,11 @@ int kunit_run_tests(struct kunit_suite *suite)
param_desc[0] = '\0';
test.param_value = test_case->generate_params(test.param_value, param_desc);
test.param_index++;
- }
- kunit_update_stats(¶m_stats, test.status);
+ kunit_update_stats(¶m_stats, test.status);
+ }
+ }
- } while (test.param_value);
kunit_print_test_stats(&test, param_stats);
--
2.34.1
From: Heiko Carstens <hca(a)linux.ibm.com>
[ Upstream commit e5992f373c6eed6d09e5858e9623df1259b3ce30 ]
Commit 32f6e5da83c7 ("selftests/ftrace: Add kprobe profile testcase")
added a new kprobes testcase, but has a description which does not
describe what the test case is doing and is duplicating the description
of another test case.
Therefore change the test case description, so it is unique and then
allows easily to tell which test case actually passed or failed.
Reported-by: Alexander Egorenkov <egorenar(a)linux.ibm.com>
Signed-off-by: Heiko Carstens <hca(a)linux.ibm.com>
Acked-by: Masami Hiramatsu <mhiramat(a)kernel.org>
Signed-off-by: Shuah Khan <skhan(a)linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
tools/testing/selftests/ftrace/test.d/kprobe/profile.tc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/profile.tc b/tools/testing/selftests/ftrace/test.d/kprobe/profile.tc
index 98166fa3eb91c..34fb89b0c61fa 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/profile.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/profile.tc
@@ -1,6 +1,6 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
-# description: Kprobe dynamic event - adding and removing
+# description: Kprobe profile
# requires: kprobe_events
! grep -q 'myevent' kprobe_profile
--
2.34.1
[ I should really have CC'd the selftests maintainer and mailing list.
Adding them in Cc to patch 0/5 to bring this series to their attention. ]
----- On Jan 17, 2022, at 3:39 PM, Mathieu Desnoyers mathieu.desnoyers(a)efficios.com wrote:
> glibc-2.35 will be released on 2022-02-01. It introduces a user-space ABI
> based on the thread pointer to access a reserved area of the TCB.
>
> The rseq selftests originally expected the rseq thread data to sit in a
> __rseq_abi TLS variable.
>
> Considering that the rseq ABI only allows a single rseq registration per
> thread, both cannot actively coexist in a process.
>
> Adapt the selftests librseq implementation to become compatible with
> glibc-2.35. Keep a fallback implementation based on TLS available when
> an older glibc is detected.
>
> Feedback is welcome,
>
> Thanks,
>
> Mathieu
>
> Mathieu Desnoyers (5):
> 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
>
> tools/testing/selftests/rseq/Makefile | 2 +-
> tools/testing/selftests/rseq/param_test.c | 4 +-
> tools/testing/selftests/rseq/rseq-arm.h | 32 ++--
> tools/testing/selftests/rseq/rseq-arm64.h | 32 ++--
> .../rseq/rseq-generic-thread-pointer.h | 25 +++
> tools/testing/selftests/rseq/rseq-mips.h | 32 ++--
> .../selftests/rseq/rseq-ppc-thread-pointer.h | 30 ++++
> tools/testing/selftests/rseq/rseq-ppc.h | 32 ++--
> tools/testing/selftests/rseq/rseq-s390.h | 24 +--
> .../selftests/rseq/rseq-thread-pointer.h | 19 +++
> .../selftests/rseq/rseq-x86-thread-pointer.h | 40 +++++
> tools/testing/selftests/rseq/rseq-x86.h | 30 ++--
> tools/testing/selftests/rseq/rseq.c | 161 +++++++++---------
> tools/testing/selftests/rseq/rseq.h | 24 ++-
> 14 files changed, 302 insertions(+), 185 deletions(-)
> 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
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
From: Thadeu Lima de Souza Cascardo <cascardo(a)canonical.com>
[ Upstream commit 3c42e9542050d49610077e083c7c3f5fd5e26820 ]
A mis-match between reported and actual mitigation is not restricted to the
Vulnerable case. The guest might also report the mitigation as "Software
count cache flush" and the host will still mitigate with branch cache
disabled.
So, instead of skipping depending on the detected mitigation, simply skip
whenever the detected miss_percent is the expected one for a fully
mitigated system, that is, above 95%.
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo(a)canonical.com>
Signed-off-by: Michael Ellerman <mpe(a)ellerman.id.au>
Link: https://lore.kernel.org/r/20211207130557.40566-1-cascardo@canonical.com
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
tools/testing/selftests/powerpc/security/spectre_v2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/powerpc/security/spectre_v2.c b/tools/testing/selftests/powerpc/security/spectre_v2.c
index adc2b7294e5fd..83647b8277e7d 100644
--- a/tools/testing/selftests/powerpc/security/spectre_v2.c
+++ b/tools/testing/selftests/powerpc/security/spectre_v2.c
@@ -193,7 +193,7 @@ int spectre_v2_test(void)
* We are not vulnerable and reporting otherwise, so
* missing such a mismatch is safe.
*/
- if (state == VULNERABLE)
+ if (miss_percent > 95)
return 4;
return 1;
--
2.34.1
From: Thadeu Lima de Souza Cascardo <cascardo(a)canonical.com>
[ Upstream commit 3c42e9542050d49610077e083c7c3f5fd5e26820 ]
A mis-match between reported and actual mitigation is not restricted to the
Vulnerable case. The guest might also report the mitigation as "Software
count cache flush" and the host will still mitigate with branch cache
disabled.
So, instead of skipping depending on the detected mitigation, simply skip
whenever the detected miss_percent is the expected one for a fully
mitigated system, that is, above 95%.
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo(a)canonical.com>
Signed-off-by: Michael Ellerman <mpe(a)ellerman.id.au>
Link: https://lore.kernel.org/r/20211207130557.40566-1-cascardo@canonical.com
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
tools/testing/selftests/powerpc/security/spectre_v2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/powerpc/security/spectre_v2.c b/tools/testing/selftests/powerpc/security/spectre_v2.c
index adc2b7294e5fd..83647b8277e7d 100644
--- a/tools/testing/selftests/powerpc/security/spectre_v2.c
+++ b/tools/testing/selftests/powerpc/security/spectre_v2.c
@@ -193,7 +193,7 @@ int spectre_v2_test(void)
* We are not vulnerable and reporting otherwise, so
* missing such a mismatch is safe.
*/
- if (state == VULNERABLE)
+ if (miss_percent > 95)
return 4;
return 1;
--
2.34.1