linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* kernel-selftests/kvm: kvm.tsc_msrs_test.fail
@ 2021-11-23 10:42 Zhou, Jie2X
  2021-11-28 11:55 ` Zhou, Jie2X
  0 siblings, 1 reply; 2+ messages in thread
From: Zhou, Jie2X @ 2021-11-23 10:42 UTC (permalink / raw)
  To: pbonzini
  Cc: shuah, maz, ricarkol, drjones, kvm, linux-kselftest,
	linux-kernel, Li, Philip, Li, ZhijianX

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,

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: kernel-selftests/kvm: kvm.tsc_msrs_test.fail
  2021-11-23 10:42 kernel-selftests/kvm: kvm.tsc_msrs_test.fail Zhou, Jie2X
@ 2021-11-28 11:55 ` Zhou, Jie2X
  0 siblings, 0 replies; 2+ messages in thread
From: Zhou, Jie2X @ 2021-11-28 11:55 UTC (permalink / raw)
  To: pbonzini
  Cc: shuah, maz, ricarkol, drjones, kvm, linux-kselftest,
	linux-kernel, Li, Philip, Li, ZhijianX

ping

________________________________________
From: Zhou, Jie2X
Sent: Tuesday, November 23, 2021 6:42 PM
To: pbonzini@redhat.com
Cc: shuah@kernel.org; maz@kernel.org; ricarkol@google.com; drjones@redhat.com; kvm@vger.kernel.org; linux-kselftest@vger.kernel.org; linux-kernel@vger.kernel.org; Li, Philip; Li, ZhijianX
Subject: kernel-selftests/kvm: kvm.tsc_msrs_test.fail

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,

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-28 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23 10:42 kernel-selftests/kvm: kvm.tsc_msrs_test.fail Zhou, Jie2X
2021-11-28 11:55 ` Zhou, Jie2X

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).