mbox series

[0/5] KVM: selftests: Fix clocksource requirements in tests

Message ID 20240109141121.1619463-1-vkuznets@redhat.com (mailing list archive)
Headers show
Series KVM: selftests: Fix clocksource requirements in tests | expand

Message

Vitaly Kuznetsov Jan. 9, 2024, 2:11 p.m. UTC
It was discovered that 'hyperv_clock' fails miserably when the system is
using an unsupported (by KVM) clocksource, e.g. 'kvm-clock'. The root cause
of the failure is that 'hyperv_clock' doesn't actually check which clocksource
is currently in use. Other tests (kvm_clock_test, vmx_nested_tsc_scaling_test)
have the required check but each test does it on its own.

Generalize clocksource checking infrastructure, make all three clocksource
dependent tests run with 'tsc' and 'hyperv_clocksource_tsc_page', and skip
gracefully when run in an unsupported configuration.

The last patch of the series is a loosely related minor nitpick for KVM
code itself.

Vitaly Kuznetsov (5):
  KVM: selftests: Generalize check_clocksource() from kvm_clock_test
  KVM: selftests: Use generic sys_clocksource_is_tsc() in
    vmx_nested_tsc_scaling_test
  KVM: selftests: Run clocksource dependent tests with
    hyperv_clocksource_tsc_page too
  KVM: selftests: Make hyperv_clock require TSC based system clocksource
  KVM: x86: Make gtod_is_based_on_tsc() return 'bool'

 arch/x86/kvm/x86.c                            |  2 +-
 .../testing/selftests/kvm/include/test_util.h |  2 +
 .../selftests/kvm/include/x86_64/processor.h  |  2 +
 tools/testing/selftests/kvm/lib/test_util.c   | 25 ++++++++++++
 .../selftests/kvm/lib/x86_64/processor.c      | 15 ++++++++
 .../selftests/kvm/x86_64/hyperv_clock.c       |  1 +
 .../selftests/kvm/x86_64/kvm_clock_test.c     | 38 +------------------
 .../kvm/x86_64/vmx_nested_tsc_scaling_test.c  | 19 +---------
 8 files changed, 48 insertions(+), 56 deletions(-)


base-commit: 7f26fea9bc085290e3731501f4f8fc5b82b9d615

Comments

Vitaly Kuznetsov Jan. 29, 2024, 9:03 a.m. UTC | #1
Vitaly Kuznetsov <vkuznets@redhat.com> writes:

> It was discovered that 'hyperv_clock' fails miserably when the system is
> using an unsupported (by KVM) clocksource, e.g. 'kvm-clock'. The root cause
> of the failure is that 'hyperv_clock' doesn't actually check which clocksource
> is currently in use. Other tests (kvm_clock_test, vmx_nested_tsc_scaling_test)
> have the required check but each test does it on its own.
>
> Generalize clocksource checking infrastructure, make all three clocksource
> dependent tests run with 'tsc' and 'hyperv_clocksource_tsc_page', and skip
> gracefully when run in an unsupported configuration.
>
> The last patch of the series is a loosely related minor nitpick for KVM
> code itself.
>
> Vitaly Kuznetsov (5):
>   KVM: selftests: Generalize check_clocksource() from kvm_clock_test
>   KVM: selftests: Use generic sys_clocksource_is_tsc() in
>     vmx_nested_tsc_scaling_test
>   KVM: selftests: Run clocksource dependent tests with
>     hyperv_clocksource_tsc_page too
>   KVM: selftests: Make hyperv_clock require TSC based system clocksource
>   KVM: x86: Make gtod_is_based_on_tsc() return 'bool'

Ping)
Sean Christopherson Jan. 31, 2024, 12:59 a.m. UTC | #2
On Tue, 09 Jan 2024 15:11:16 +0100, Vitaly Kuznetsov wrote:
> It was discovered that 'hyperv_clock' fails miserably when the system is
> using an unsupported (by KVM) clocksource, e.g. 'kvm-clock'. The root cause
> of the failure is that 'hyperv_clock' doesn't actually check which clocksource
> is currently in use. Other tests (kvm_clock_test, vmx_nested_tsc_scaling_test)
> have the required check but each test does it on its own.
> 
> Generalize clocksource checking infrastructure, make all three clocksource
> dependent tests run with 'tsc' and 'hyperv_clocksource_tsc_page', and skip
> gracefully when run in an unsupported configuration.
> 
> [...]

Applied to kvm-x86 selftests, thanks!

[1/5] KVM: selftests: Generalize check_clocksource() from kvm_clock_test
      https://github.com/kvm-x86/linux/commit/449d0d6ccf55
[2/5] KVM: selftests: Use generic sys_clocksource_is_tsc() in vmx_nested_tsc_scaling_test
      https://github.com/kvm-x86/linux/commit/a79036441a68
[3/5] KVM: selftests: Run clocksource dependent tests with hyperv_clocksource_tsc_page too
      https://github.com/kvm-x86/linux/commit/436e6e541cb2
[4/5] KVM: selftests: Make hyperv_clock require TSC based system clocksource
      https://github.com/kvm-x86/linux/commit/14fce852a14b
[5/5] KVM: x86: Make gtod_is_based_on_tsc() return 'bool'
      https://github.com/kvm-x86/linux/commit/57cc53712934

--
https://github.com/kvm-x86/linux/tree/next
Sean Christopherson Feb. 1, 2024, 5 p.m. UTC | #3
On Tue, Jan 30, 2024, Sean Christopherson wrote:
> On Tue, 09 Jan 2024 15:11:16 +0100, Vitaly Kuznetsov wrote:
> > It was discovered that 'hyperv_clock' fails miserably when the system is
> > using an unsupported (by KVM) clocksource, e.g. 'kvm-clock'. The root cause
> > of the failure is that 'hyperv_clock' doesn't actually check which clocksource
> > is currently in use. Other tests (kvm_clock_test, vmx_nested_tsc_scaling_test)
> > have the required check but each test does it on its own.
> > 
> > Generalize clocksource checking infrastructure, make all three clocksource
> > dependent tests run with 'tsc' and 'hyperv_clocksource_tsc_page', and skip
> > gracefully when run in an unsupported configuration.
> > 
> > [...]
> 
> Applied to kvm-x86 selftests, thanks!
> 
> [1/5] KVM: selftests: Generalize check_clocksource() from kvm_clock_test
>       https://github.com/kvm-x86/linux/commit/449d0d6ccf55
> [2/5] KVM: selftests: Use generic sys_clocksource_is_tsc() in vmx_nested_tsc_scaling_test
>       https://github.com/kvm-x86/linux/commit/a79036441a68
> [3/5] KVM: selftests: Run clocksource dependent tests with hyperv_clocksource_tsc_page too
>       https://github.com/kvm-x86/linux/commit/436e6e541cb2
> [4/5] KVM: selftests: Make hyperv_clock require TSC based system clocksource
>       https://github.com/kvm-x86/linux/commit/14fce852a14b
> [5/5] KVM: x86: Make gtod_is_based_on_tsc() return 'bool'
>       https://github.com/kvm-x86/linux/commit/57cc53712934

FYI, I dropped the xen_shinfo patch, and past me wasn't clever enough to make sure
that patch was applied last.  New hashes are:

[1/5] KVM: selftests: Generalize check_clocksource() from kvm_clock_test
      https://github.com/kvm-x86/linux/commit/e440c5f2e3e6
[2/5] KVM: selftests: Use generic sys_clocksource_is_tsc() in vmx_nested_tsc_scaling_test
      https://github.com/kvm-x86/linux/commit/410cb01ead5b
[3/5] KVM: selftests: Run clocksource dependent tests with hyperv_clocksource_tsc_page too
      https://github.com/kvm-x86/linux/commit/09951bf2cbb3
[4/5] KVM: selftests: Make hyperv_clock require TSC based system clocksource
      https://github.com/kvm-x86/linux/commit/b6831a108be1
[5/5] KVM: x86: Make gtod_is_based_on_tsc() return 'bool'
      https://github.com/kvm-x86/linux/commit/9e62797fd7e8