Hello there,
I ran the static analyser cppcheck over the linux-6.2 source code and got this:
linux-6.2/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_thresh_marked_sample_test.c:68:10: style: Same expression '0x3' found multiple times in chain of '&' operators. [duplicateExpression]
Source code is
FAIL_IF(EV_CODE_EXTRACT(event.attr.config, sample & 0x3) !=
get_mmcra_sample_mode(get_reg_value(intr_regs, "MMCRA"), 4));
but
#define EV_CODE_EXTRACT(x, y) \
((x >> ev_shift_##y) & ev_mask_##y)
Given the token pasting, I very much doubt an expression like "sample & 0x3"
will work correctly. Same thing on the line above
FAIL_IF(EV_CODE_EXTRACT(event.attr.config, sample >> 2) !=
get_mmcra_rand_samp_elig(get_reg_value(intr_regs, "MMCRA"), 4));
"sample >> 2" doesn't look like a valid token to me.
Regards
David Binderman
KUnit's 'hooks.o' file need to be built-in whenever KUnit is enabled
(even if CONFIG_KUNIT=m). We'd previously attemtped to do this by adding
'kunit/hooks.o' to obj-y in lib/Makefile, but this caused hooks.c to be
rebuilt even when it was unchanged.
Instead, always recurse into lib/kunit using obj-y when KUnit is
enabled, and add the hooks there.
Fixes: 7170b7ed6acb ("kunit: Add "hooks" to call into KUnit when it's built as a module").
Reported-by: Linus Torvalds <torvalds(a)linux-foundation.org>
Link: https://lore.kernel.org/linux-kselftest/CAHk-=wiEf7irTKwPJ0jTMOF3CS-13UXmF6…
Signed-off-by: David Gow <davidgow(a)google.com>
---
I like this way of handling the makefiles much better. I had tried it
when originally writing the hooks patch and not managed to get it
working. Not sure what's changed now, but it works in all of the usual
cases (CONFIG_KUNIT={n,y,m}, kunit.py run, etc).
Linus, Shuah: Let me know if you want this to go via the KUnit branch,
or if you just want to apply it directly and get rid of the annoyances
ASAP.
---
lib/Makefile | 12 ++++--------
lib/kunit/Makefile | 2 +-
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/lib/Makefile b/lib/Makefile
index 469be6240523..baf2821f7a00 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -127,14 +127,10 @@ CFLAGS_test_fpu.o += $(FPU_CFLAGS)
obj-$(CONFIG_TEST_LIVEPATCH) += livepatch/
-obj-$(CONFIG_KUNIT) += kunit/
-# Include the KUnit hooks unconditionally. They'll compile to nothing if
-# CONFIG_KUNIT=n, otherwise will be a small table of static data (static key,
-# function pointers) which need to be built-in even when KUnit is a module.
-ifeq ($(CONFIG_KUNIT), m)
-obj-y += kunit/hooks.o
-else
-obj-$(CONFIG_KUNIT) += kunit/hooks.o
+# Some KUnit files (hooks.o) need to be built-in even when KUnit is a module,
+# so we can't just use obj-$(CONFIG_KUNIT).
+ifdef CONFIG_KUNIT
+obj-y += kunit/
endif
ifeq ($(CONFIG_DEBUG_KOBJECT),y)
diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile
index da665cd4ea12..cb417f504996 100644
--- a/lib/kunit/Makefile
+++ b/lib/kunit/Makefile
@@ -13,7 +13,7 @@ kunit-objs += debugfs.o
endif
# KUnit 'hooks' are built-in even when KUnit is built as a module.
-lib-y += hooks.o
+obj-y += hooks.o
obj-$(CONFIG_KUNIT_TEST) += kunit-test.o
--
2.39.2.637.g21b0678d19-goog
Dear maintainers,
This series is following up on the last fix [2]. I thought I could
forget about it with that. But, I was wrong because now this was
realized as an incomplete solution -- my bad. Here is some context for
this series:
The last fix [3] has resolved the case when copying the initialized
dynamic state from init_fpstate to the user buffer in
__copy_xstate_to_uabi_buf(). (This was intended to resolve the fallout
of the init_fpstate fix [1].)
But, when copying the *non-initialized* dynamic state from the task
xstate, the code [4] unconditionally retrieves the address in
init_fpstate which is needless. Consequently, this triggers a
false-positive warning as shown in [5] which meaninglessly confuses
users.
With these repetitive surgeries, a more solid and comprehensive
solution is more helpful I thought. Considerably removing init_fpstate
from this loop is not impossible here because dynamic states have an
all-zeros init state. Then, zeroing the user buffer instead of
retrieving init_fpstate resolves the issue and simplifies the code.
These issues were discovered from the KVM execution with launching a
guest and running the KVM self-test as __copy_xstate_to_uabi_buf() was
called. But, the negligibly missing ptrace test could have disclosed
them too. So that case is included here.
Thanks,
Chang
[1] https://lore.kernel.org/lkml/20220824191223.1248-1-chang.seok.bae@intel.com/
[2] https://lore.kernel.org/lkml/20221018221349.4196-1-chang.seok.bae@intel.com/
[3] https://lore.kernel.org/lkml/20221021185844.13472-1-chang.seok.bae@intel.co…
[4] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arc…
[5] https://lore.kernel.org/kvm/20230221163655.920289-2-mizhang@google.com/
Chang S. Bae (2):
x86/fpu/xstate: Prevent false-positive warning in
__copy_xstate_uabi_buf()
selftests/x86/amx: Add a ptrace test
arch/x86/kernel/fpu/xstate.c | 30 ++++-----
tools/testing/selftests/x86/amx.c | 108 +++++++++++++++++++++++++++++-
2 files changed, 119 insertions(+), 19 deletions(-)
base-commit: 7fa08de735e41001a70c8ca869b2b159d74c2339
--
2.17.1
From: Rong Tao <rongtao(a)cestc.cn>
commit bc292ab00f6c("mm: introduce vma->vm_flags wrapper functions")
turns the vm_flags into a const variable.
Added bpf_find_vma test in commit f108662b27c9("selftests/bpf: Add tests
for bpf_find_vma") to assign values to variables that declare const in
find_vma_fail1.c programs, which is an error to the compiler and does not
test BPF verifiers. It is better to replace 'const vm_flags_t vm_flags'
with 'unsigned long vm_start' for testing.
$ make -C tools/testing/selftests/bpf/ -j8
...
progs/find_vma_fail1.c:16:16: error: cannot assign to non-static data
member 'vm_flags' with const-qualified type 'const vm_flags_t' (aka
'const unsigned long')
vma->vm_flags |= 0x55;
~~~~~~~~~~~~~ ^
../tools/testing/selftests/bpf/tools/include/vmlinux.h:1898:20:
note: non-static data member 'vm_flags' declared const here
const vm_flags_t vm_flags;
~~~~~~~~~~~`~~~~~~^~~~~~~~
Signed-off-by: Rong Tao <rongtao(a)cestc.cn>
---
v2: Add more useful commit information
v1: https://lore.kernel.org/lkml/tencent_FC8827062142CF5936974B2A30AF6CA3C408@q…
---
tools/testing/selftests/bpf/progs/find_vma_fail1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/progs/find_vma_fail1.c b/tools/testing/selftests/bpf/progs/find_vma_fail1.c
index b3b326b8e2d1..47d5dedff554 100644
--- a/tools/testing/selftests/bpf/progs/find_vma_fail1.c
+++ b/tools/testing/selftests/bpf/progs/find_vma_fail1.c
@@ -13,7 +13,7 @@ static long write_vma(struct task_struct *task, struct vm_area_struct *vma,
struct callback_ctx *data)
{
/* writing to vma, which is illegal */
- vma->vm_flags |= 0x55;
+ vma->vm_start = 0xffffffffff600000;
return 0;
}
--
2.39.2
From: Chuck Lever <chuck.lever(a)oracle.com>
Allow the new GSS Kerberos encryption type test suites to run
outside of the kunit infrastructure. Replace the assertion that
fires when lookup_enctype() so that the case is skipped instead of
failing outright.
Reported-by: Geert Uytterhoeven <geert(a)linux-m68k.org>
Signed-off-by: Chuck Lever <chuck.lever(a)oracle.com>
---
Hey Geert -
This patch addresses part of your concern: with this patch applied,
you should be able to run only the tests that target the encryption
types that are enabled in your kernel. The other tests will be
skipped rather than fail outright.
net/sunrpc/auth_gss/gss_krb5_test.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/net/sunrpc/auth_gss/gss_krb5_test.c b/net/sunrpc/auth_gss/gss_krb5_test.c
index c287ce15c419..0a7c5280e4e3 100644
--- a/net/sunrpc/auth_gss/gss_krb5_test.c
+++ b/net/sunrpc/auth_gss/gss_krb5_test.c
@@ -49,7 +49,8 @@ static void kdf_case(struct kunit *test)
/* Arrange */
gk5e = gss_krb5_lookup_enctype(param->enctype);
- KUNIT_ASSERT_NOT_NULL(test, gk5e);
+ if (!gk5e)
+ kunit_skip(test, "Encryption type is not available");
derivedkey.data = kunit_kzalloc(test, param->expected_result->len,
GFP_KERNEL);
@@ -83,7 +84,8 @@ static void checksum_case(struct kunit *test)
/* Arrange */
gk5e = gss_krb5_lookup_enctype(param->enctype);
- KUNIT_ASSERT_NOT_NULL(test, gk5e);
+ if (!gk5e)
+ kunit_skip(test, "Encryption type is not available");
Kc.len = gk5e->Kc_length;
Kc.data = kunit_kzalloc(test, Kc.len, GFP_KERNEL);
@@ -725,7 +727,8 @@ static void rfc3962_encrypt_case(struct kunit *test)
/* Arrange */
gk5e = gss_krb5_lookup_enctype(param->enctype);
- KUNIT_ASSERT_NOT_NULL(test, gk5e);
+ if (!gk5e)
+ kunit_skip(test, "Encryption type is not available");
cbc_tfm = crypto_alloc_sync_skcipher(gk5e->aux_cipher, 0, 0);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, cbc_tfm);
@@ -1319,7 +1322,8 @@ static void rfc6803_encrypt_case(struct kunit *test)
/* Arrange */
gk5e = gss_krb5_lookup_enctype(param->enctype);
- KUNIT_ASSERT_NOT_NULL(test, gk5e);
+ if (!gk5e)
+ kunit_skip(test, "Encryption type is not available");
usage.data[3] = param->constant;
@@ -1810,7 +1814,8 @@ static void rfc8009_encrypt_case(struct kunit *test)
/* Arrange */
gk5e = gss_krb5_lookup_enctype(param->enctype);
- KUNIT_ASSERT_NOT_NULL(test, gk5e);
+ if (!gk5e)
+ kunit_skip(test, "Encryption type is not available");
*(__be32 *)usage.data = cpu_to_be32(2);
@@ -1975,7 +1980,8 @@ static void encrypt_selftest_case(struct kunit *test)
/* Arrange */
gk5e = gss_krb5_lookup_enctype(param->enctype);
- KUNIT_ASSERT_NOT_NULL(test, gk5e);
+ if (!gk5e)
+ kunit_skip(test, "Encryption type is not available");
cbc_tfm = crypto_alloc_sync_skcipher(gk5e->aux_cipher, 0, 0);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, cbc_tfm);
Add basic support to run m68k under QEMU via kunit_tool.
Signed-off-by: Geert Uytterhoeven <geert(a)linux-m68k.org>
---
Does this need CONFIG_VIRTIO_CONSOLE=y? It seems to work fine without.
drivers/clk/.kunitconfig:
Fails because m68k uses big-endian I/O ops
drivers/gpu/drm/tests/.kunitconfig
kernel BUG at drivers/gpu/drm/drm_buddy.c:21!
(also on arm, ignored)
drivers/gpu/drm/vc4/tests/.kunitconfig
Depends on arm, works on arm
drivers/hid/.kunitconfig
Unable to handle kernel NULL pointer dereference at virtual address (ptrval)
Oops: 00000000
PC: [<001d7380>] uclogic_params_ugee_v2_has_battery+0x6/0x68
(also on arm, ignored)
fs/ext4/.kunitconfig: OK
fs/fat/.kunitconfig: OK
kernel/kcsan/.kunitconfig
Needs HAVE_ARCH_KCSAN and SMP
(the former also on arm, ignored)
lib/kunit/.kunitconfig: OK
mm/kfence/.kunitconfig
Needs HAVE_ARCH_KFENCE
(fails on arm due to missing CONFIG_KFENCE_KUNIT_TEST=y, which
depends on TRACEPOINTS)
net/sunrpc/.kunitconfig
After dropping CONFIG_STACKTRACE=y (why is this needed?) from
net/sunrpc/.kunitconfig:
Unable to handle kernel NULL pointer dereference at virtual address (ptrval)
(also on arm, ignored)
---
tools/testing/kunit/qemu_configs/m68k.py | 10 ++++++++++
1 file changed, 10 insertions(+)
create mode 100644 tools/testing/kunit/qemu_configs/m68k.py
diff --git a/tools/testing/kunit/qemu_configs/m68k.py b/tools/testing/kunit/qemu_configs/m68k.py
new file mode 100644
index 0000000000000000..287fc386f8a7ff16
--- /dev/null
+++ b/tools/testing/kunit/qemu_configs/m68k.py
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0-only
+from ..qemu_config import QemuArchParams
+
+QEMU_ARCH = QemuArchParams(linux_arch='m68k',
+ kconfig='''
+CONFIG_VIRT=y''',
+ qemu_arch='m68k',
+ kernel_path='vmlinux',
+ kernel_command_line='console=hvc0',
+ extra_qemu_params=['-machine', 'virt'])
--
2.34.1
Fix spelling mistakes in run.sh "drvier" => "driver" and
in gitsource.sh "senconds" => "seconds".
Signed-off-by: Sukrut Bellary <sukrut.bellary(a)gmail.com>
---
tools/testing/selftests/amd-pstate/gitsource.sh | 4 ++--
tools/testing/selftests/amd-pstate/run.sh | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/amd-pstate/gitsource.sh b/tools/testing/selftests/amd-pstate/gitsource.sh
index dbc1fe45599d..5f2171f0116d 100755
--- a/tools/testing/selftests/amd-pstate/gitsource.sh
+++ b/tools/testing/selftests/amd-pstate/gitsource.sh
@@ -117,7 +117,7 @@ parse_gitsource()
printf "Gitsource-$1-#$2 power consumption(J): $en_sum\n" | tee -a $OUTFILE_GIT.result
# Permance is the number of run gitsource per second, denoted 1/t, where 1 is the number of run gitsource in t
- # senconds. It is well known that P=E/t, where P is power measured in watts(W), E is energy measured in joules(J),
+ # seconds. It is well known that P=E/t, where P is power measured in watts(W), E is energy measured in joules(J),
# and t is time measured in seconds(s). This means that performance per watt becomes
# 1/t 1/t 1
# ----- = ----- = ---
@@ -175,7 +175,7 @@ gather_gitsource()
printf "Gitsource-$1 avg power consumption(J): $avg_en\n" | tee -a $OUTFILE_GIT.result
# Permance is the number of run gitsource per second, denoted 1/t, where 1 is the number of run gitsource in t
- # senconds. It is well known that P=E/t, where P is power measured in watts(W), E is energy measured in joules(J),
+ # seconds. It is well known that P=E/t, where P is power measured in watts(W), E is energy measured in joules(J),
# and t is time measured in seconds(s). This means that performance per watt becomes
# 1/t 1/t 1
# ----- = ----- = ---
diff --git a/tools/testing/selftests/amd-pstate/run.sh b/tools/testing/selftests/amd-pstate/run.sh
index 57cad57e59c0..de4d8e9c9565 100755
--- a/tools/testing/selftests/amd-pstate/run.sh
+++ b/tools/testing/selftests/amd-pstate/run.sh
@@ -244,7 +244,7 @@ prerequisite()
if [ "$scaling_driver" != "$CURRENT_TEST" ]; then
echo "$0 # Skipped: Test can only run on $CURRENT_TEST driver or run comparative test."
echo "$0 # Please set X86_AMD_PSTATE enabled or run comparative test."
- echo "$0 # Current cpufreq scaling drvier is $scaling_driver."
+ echo "$0 # Current cpufreq scaling driver is $scaling_driver."
exit $ksft_skip
fi
else
@@ -252,7 +252,7 @@ prerequisite()
"tbench" | "gitsource")
if [ "$scaling_driver" != "$COMPARATIVE_TEST" ]; then
echo "$0 # Skipped: Comparison test can only run on $COMPARISON_TEST driver."
- echo "$0 # Current cpufreq scaling drvier is $scaling_driver."
+ echo "$0 # Current cpufreq scaling driver is $scaling_driver."
exit $ksft_skip
fi
;;
--
2.25.1
Hi Linus,
Please pull the following KUnit next update for Linux 6.3-rc1.
This KUnit update for Linux 6.3-rc1 consists of cleanups, new features,
and documentation updates:
-- adds Function Redirection API to isolate the code being tested from
other parts of the kernel. functionredirection.rst has the details.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit 4ec5183ec48656cec489c49f989c508b68b518e3:
Linux 6.2-rc7 (2023-02-05 13:13:28 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux-kselftest-kunit-6.3-rc1
for you to fetch changes up to 82649c7c0da431d147a75c6ae768ee42c1053f53:
kunit: Add printf attribute to fail_current_test_impl (2023-02-08 18:08:14 -0700)
----------------------------------------------------------------
linux-kselftest-kunit-6.3-rc1
This KUnit update for Linux 6.3-rc1 consists of cleanups, new features,
and documentation updates:
-- adds Function Redirection API to isolate the code being tested from
other parts of the kernel. functionredirection.rst has the details.
----------------------------------------------------------------
Alexander Pantyukhin (2):
tools/testing/kunit/kunit.py: remove redundant double check
kunit: kunit.py extract handlers
David Gow (3):
kunit: Add "hooks" to call into KUnit when it's built as a module
kunit: Expose 'static stub' API to redirect functions
kunit: Add printf attribute to fail_current_test_impl
Rae Moar (1):
lib/hashtable_test.c: add test for the hashtable structure
Sadiya Kazi (1):
Documentation: Add Function Redirection API docs
.../dev-tools/kunit/api/functionredirection.rst | 162 +++++++++++
Documentation/dev-tools/kunit/api/index.rst | 13 +-
Documentation/dev-tools/kunit/usage.rst | 15 +-
include/kunit/static_stub.h | 113 ++++++++
include/kunit/test-bug.h | 29 +-
lib/Kconfig.debug | 13 +
lib/Makefile | 9 +
lib/hashtable_test.c | 317 +++++++++++++++++++++
lib/kunit/Makefile | 4 +
lib/kunit/hooks-impl.h | 31 ++
lib/kunit/hooks.c | 21 ++
lib/kunit/kunit-example-test.c | 38 +++
lib/kunit/static_stub.c | 123 ++++++++
lib/kunit/test.c | 15 +-
tools/testing/kunit/kunit.py | 186 ++++++------
15 files changed, 966 insertions(+), 123 deletions(-)
create mode 100644 Documentation/dev-tools/kunit/api/functionredirection.rst
create mode 100644 include/kunit/static_stub.h
create mode 100644 lib/hashtable_test.c
create mode 100644 lib/kunit/hooks-impl.h
create mode 100644 lib/kunit/hooks.c
create mode 100644 lib/kunit/static_stub.c
----------------------------------------------------------------