hi,
When I do the kvm test in kernel v5.15 by "make run_tests -C tools/testing/selftests/kvm" get following error.
# selftests: kvm: tsc_msrs_test
# ==== Test Assertion Failure ====
# x86_64/tsc_msrs_test.c:88: false
# pid=10432 tid=10432 errno=4 - Interrupted system call
# 1 0x0000000000403168: run_vcpu at tsc_msrs_test.c:86
# 2 0x000000000040297a: main at tsc_msrs_test.c:150
# 3 0x00007f064f88509a: ?? ??:0
# 4 0x0000000000402a89: _start at ??:?
# Failed guest assert: rounded_rdmsr(MSR_IA32_TSC) == val at x86_64/tsc_msrs_test.c:63
# values: 0x1200000000, 0x400000000
The MSR_IA32_TSC register can not be set correctly in guest mode in some machine.
But MSR_IA32_TSC register can be set correctly in host mode in that machine.
Although there are two CPU mode machines both support following function.
IA32_TSC_ADJUST MSR supported = true
TSC: time stamp counter = true
Test passed in cpu mode: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
Test failed in cpu mode: Intel(R) Core(TM) i7-6770HQ CPU @ 2.60GHz.
Add print code to check MSR_IA32_TSC value.
tools/testing/selftests/kvm/x86_64/tsc_msrs_test.c
@@ -151,6 +151,7 @@ int main(void)
val = 4ull * GUEST_STEP;
- ASSERT_EQ(rounded_host_rdmsr(MSR_IA32_TSC), val);
ASSERT_EQ(rounded_host_rdmsr(MSR_IA32_TSC_ADJUST), val - HOST_ADJUST);
+ printf("MSR_IA32_TSC: %llx, MSR_IA32_TSC_ADJUST: %llx, TSC_val: %llx, ADJUST_val: %llx\n\n", rounded_host_rdmsr(MSR_IA32_TSC), rounded_host_rdmsr(MSR_IA32_TSC_ADJUST), val, val - HOST_ADJUST);
In test passed machine(i7-6700) set MSR_IA32_TSC to 0x400000000 and get 0x400000000.
./kvm/x86_64/tsc_msrs_test
MSR_IA32_TSC: 400000000, MSR_IA32_TSC_ADJUST: fffffff400000000, TSC_val: 400000000, ADJUST_val: fffffff400000000
In test failed machine(i7-6770HQ) set MSR_IA32_TSC to 0x400000000 but get 0x1200000000.
./kvm/x86_64/tsc_msrs_test
MSR_IA32_TSC: 1200000000, MSR_IA32_TSC_ADJUST: fffffff400000000, TSC_val: 400000000, ADJUST_val: fffffff400000000
Try to set MSR_IA32_TSC in host mode in test failed machine(i7-6770HQ).
tools/testing/selftests/kvm/x86_64/tsc_msrs_test.c
@@ -151,6 +151,7 @@ int main(void)
val = 4ull * GUEST_STEP;
+ vcpu_set_msr(vm, 0, MSR_IA32_TSC, val);
+ vcpu_set_msr(vm, 0, MSR_IA32_TSC_ADJUST, val - HOST_ADJUST);
ASSERT_EQ(rounded_host_rdmsr(MSR_IA32_TSC), val);
ASSERT_EQ(rounded_host_rdmsr(MSR_IA32_TSC_ADJUST), val - HOST_ADJUST);
+ printf("MSR_IA32_TSC: %llx, MSR_IA32_TSC_ADJUST: %llx, TSC_val: %llx, ADJUST_val: %llx\n\n", rounded_host_rdmsr(MSR_IA32_TSC), rounded_host_rdmsr(MSR_IA32_TSC_ADJUST), val, val - HOST_ADJUST);
The output show MSR_IA32_TSC value is set correctly.
MSR_IA32_TSC: 400000000, MSR_IA32_TSC_ADJUST: fffffff400000000, TSC_val: 400000000, ADJUST_val: fffffff400000000
Why the MSR_IA32_TSC register can not be set correctly in guest mode in test failed machine(i7-6770HQ)?
best regards,
This series of patches fixes two issues with TPM2 selftest.
- Probes for available PCR banks
- Resets DA lock on TPM2 to avoid subsequent test failures
It also extends the test cases with support for SHA-384 and SHA-512
PCR banks.
Stefan
v2:
- Clarified patch 1 description
- Added patch 3 with support for SHA-384 and SHA-512
Stefan Berger (3):
selftests: tpm2: Probe for available PCR bank
selftests: tpm2: Reset the dictionary attack lock
selftests: tpm2: Add support for SHA-384 and SHA-512
tools/testing/selftests/tpm2/tpm2.py | 12 ++++++-
tools/testing/selftests/tpm2/tpm2_tests.py | 37 +++++++++++++++++-----
2 files changed, 40 insertions(+), 9 deletions(-)
--
2.31.1
From: "Maciej S. Szmigiero" <maciej.szmigiero(a)oracle.com>
A kvm_page_table_test run with its default settings fails on VMX due to
memory region add failure:
> ==== Test Assertion Failure ====
> lib/kvm_util.c:952: ret == 0
> pid=10538 tid=10538 errno=17 - File exists
> 1 0x00000000004057d1: vm_userspace_mem_region_add at kvm_util.c:947
> 2 0x0000000000401ee9: pre_init_before_test at kvm_page_table_test.c:302
> 3 (inlined by) run_test at kvm_page_table_test.c:374
> 4 0x0000000000409754: for_each_guest_mode at guest_modes.c:53
> 5 0x0000000000401860: main at kvm_page_table_test.c:500
> 6 0x00007f82ae2d8554: ?? ??:0
> 7 0x0000000000401894: _start at ??:?
> KVM_SET_USER_MEMORY_REGION IOCTL failed,
> rc: -1 errno: 17
> slot: 1 flags: 0x0
> guest_phys_addr: 0xc0000000 size: 0x40000000
This is because the memory range that this test is trying to add
(0x0c0000000 - 0x100000000) conflicts with LAPIC mapping at 0x0fee00000.
Looking at the code it seems that guest_test_*phys*_mem variable gets
mistakenly overwritten with guest_test_*virt*_mem while trying to adjust
the former for alignment.
With the correct variable adjusted this test runs successfully.
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero(a)oracle.com>
---
tools/testing/selftests/kvm/kvm_page_table_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/kvm_page_table_test.c b/tools/testing/selftests/kvm/kvm_page_table_test.c
index 3836322add00..ba1fdc3dcf4a 100644
--- a/tools/testing/selftests/kvm/kvm_page_table_test.c
+++ b/tools/testing/selftests/kvm/kvm_page_table_test.c
@@ -280,7 +280,7 @@ static struct kvm_vm *pre_init_before_test(enum vm_guest_mode mode, void *arg)
#ifdef __s390x__
alignment = max(0x100000, alignment);
#endif
- guest_test_phys_mem = align_down(guest_test_virt_mem, alignment);
+ guest_test_phys_mem = align_down(guest_test_phys_mem, alignment);
/* Set up the shared data structure test_args */
test_args.vm = vm;
When a vDSO symbol is not found, all the testcases in vdso_test_abi usually
report a SKIP, which, in turn, is reported back to Kselftest as a PASS.
Testcase vdso_test_time, instead, reporting a SKIP, causes the whole set of
tests within vdso_test_abi to be considered FAIL when symbol is not found.
Fix it reporting a PASS when vdso_test_time cannot find the vdso symbol.
Signed-off-by: Cristian Marussi <cristian.marussi(a)arm.com>
---
Seen as a failure on both a JUNO and a Dragonboard on both recent and old
kernels/testruns:
root@deb-buster-arm64:~# /opt/ksft/vDSO/vdso_test_abi
[vDSO kselftest] VDSO_VERSION: LINUX_2.6.39
The time is 1637922136.675304
The time is 1637922136.675361000
The resolution is 0 1
clock_id: CLOCK_REALTIME [PASS]
The time is 1927.760604900
The resolution is 0 1
clock_id: CLOCK_BOOTTIME [PASS]
The time is 1637922136.675649700
The resolution is 0 1
clock_id: CLOCK_TAI [PASS]
The time is 1637922136.672000000
The resolution is 0 4000000
clock_id: CLOCK_REALTIME_COARSE [PASS]
The time is 1927.761005600
The resolution is 0 1
clock_id: CLOCK_MONOTONIC [PASS]
The time is 1927.761132780
The resolution is 0 1
clock_id: CLOCK_MONOTONIC_RAW [PASS]
The time is 1927.757093740
The resolution is 0 4000000
clock_id: CLOCK_MONOTONIC_COARSE [PASS]
Could not find __kernel_time <<< This caused a FAIL as a whole
root@deb-buster-arm64:~# echo $?
1
e.g.: https://lkft.validation.linaro.org/scheduler/job/2192570#L27778
---
tools/testing/selftests/vDSO/vdso_test_abi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/vDSO/vdso_test_abi.c b/tools/testing/selftests/vDSO/vdso_test_abi.c
index 3d603f1394af..7dcc66d1cecf 100644
--- a/tools/testing/selftests/vDSO/vdso_test_abi.c
+++ b/tools/testing/selftests/vDSO/vdso_test_abi.c
@@ -90,8 +90,9 @@ static int vdso_test_time(void)
(vdso_time_t)vdso_sym(version, name[2]);
if (!vdso_time) {
+ /* Skip if symbol not found: consider skipped tests as passed */
printf("Could not find %s\n", name[2]);
- return KSFT_SKIP;
+ return KSFT_PASS;
}
long ret = vdso_time(NULL);
--
2.17.1
There might be an arbitrary free open fd slot when we run the addfd
sub-test, so checking for progressive numbers of file descriptors
starting from memfd is not always a reliable check and we could get the
following failure:
# RUN global.user_notification_addfd ...
# seccomp_bpf.c:3989:user_notification_addfd:Expected listener (18) == nextfd++ (9)
# user_notification_addfd: Test terminated by assertion
Simply check if memfd and listener are valid file descriptors and start
counting for progressive file checking with the listener fd.
Fixes: 93e720d710df ("selftests/seccomp: More closely track fds being assigned")
Signed-off-by: Andrea Righi <andrea.righi(a)canonical.com>
---
tools/testing/selftests/seccomp/seccomp_bpf.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index d425688cf59c..4f37153378a1 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -3975,18 +3975,17 @@ TEST(user_notification_addfd)
/* There may be arbitrary already-open fds at test start. */
memfd = memfd_create("test", 0);
ASSERT_GE(memfd, 0);
- nextfd = memfd + 1;
ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
ASSERT_EQ(0, ret) {
TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
}
- /* fd: 4 */
/* Check that the basic notification machinery works */
listener = user_notif_syscall(__NR_getppid,
SECCOMP_FILTER_FLAG_NEW_LISTENER);
- ASSERT_EQ(listener, nextfd++);
+ ASSERT_GE(listener, 0);
+ nextfd = listener + 1;
pid = fork();
ASSERT_GE(pid, 0);
--
2.32.0
As I work my way to unlocked and zero-copy TLS Rx the obvious bugs
in the splice_read implementation get harder and harder to ignore.
This is to say the fixes here are discovered by code inspection,
I'm not aware of anyone actually using splice_read.
Jakub Kicinski (9):
selftests: tls: add helper for creating sock pairs
selftests: tls: factor out cmsg send/receive
selftests: tls: add tests for handling of bad records
tls: splice_read: fix record type check
selftests: tls: test splicing cmsgs
tls: splice_read: fix accessing pre-processed records
selftests: tls: test splicing decrypted records
tls: fix replacing proto_ops
selftests: tls: test for correct proto_ops
net/tls/tls_main.c | 47 ++-
net/tls/tls_sw.c | 40 ++-
tools/testing/selftests/net/tls.c | 521 ++++++++++++++++++++++--------
3 files changed, 456 insertions(+), 152 deletions(-)
--
2.31.1