Message ID | 20200122100356.240412-1-oupton@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [kvm-unit-tests,v2] x86: VMX: Check precondition for RDTSC test | expand |
Oliver Upton <oupton@google.com> writes: > The RDTSC VM-exit test requires the 'use TSC offsetting' processor-based > VM-execution control be allowed on the host. Check this precondition > before running the test rather than asserting it later on to avoid > erroneous failures on a host without TSC offsetting. > > Cc: Aaron Lewis <aaronlewis@google.com> > Cc: Vitaly Kuznetsov <vkuznets@redhat.com> > Signed-off-by: Oliver Upton <oupton@google.com> > --- > x86/vmx_tests.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c > index 3b150323b325..b31c360c5f3c 100644 > --- a/x86/vmx_tests.c > +++ b/x86/vmx_tests.c > @@ -9161,9 +9161,6 @@ static void vmx_vmcs_shadow_test(void) > */ > static void reset_guest_tsc_to_zero(void) > { > - TEST_ASSERT_MSG(ctrl_cpu_rev[0].clr & CPU_USE_TSC_OFFSET, > - "Expected support for 'use TSC offsetting'"); > - > vmcs_set_bits(CPU_EXEC_CTRL0, CPU_USE_TSC_OFFSET); > vmcs_write(TSC_OFFSET, -rdtsc()); > } > @@ -9210,6 +9207,9 @@ static void rdtsc_vmexit_diff_test(void) > int fail = 0; > int i; > > + if (!(ctrl_cpu_rev[0].clr & CPU_USE_TSC_OFFSET)) > + test_skip("CPU doesn't support the 'use TSC offsetting' processor-based VM-execution control.\n"); > + > test_set_guest(rdtsc_vmexit_diff_test_guest); > > reset_guest_tsc_to_zero(); Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
On 22/01/20 11:03, Oliver Upton wrote: > The RDTSC VM-exit test requires the 'use TSC offsetting' processor-based > VM-execution control be allowed on the host. Check this precondition > before running the test rather than asserting it later on to avoid > erroneous failures on a host without TSC offsetting. > > Cc: Aaron Lewis <aaronlewis@google.com> > Cc: Vitaly Kuznetsov <vkuznets@redhat.com> > Signed-off-by: Oliver Upton <oupton@google.com> > --- > x86/vmx_tests.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c > index 3b150323b325..b31c360c5f3c 100644 > --- a/x86/vmx_tests.c > +++ b/x86/vmx_tests.c > @@ -9161,9 +9161,6 @@ static void vmx_vmcs_shadow_test(void) > */ > static void reset_guest_tsc_to_zero(void) > { > - TEST_ASSERT_MSG(ctrl_cpu_rev[0].clr & CPU_USE_TSC_OFFSET, > - "Expected support for 'use TSC offsetting'"); > - > vmcs_set_bits(CPU_EXEC_CTRL0, CPU_USE_TSC_OFFSET); > vmcs_write(TSC_OFFSET, -rdtsc()); > } > @@ -9210,6 +9207,9 @@ static void rdtsc_vmexit_diff_test(void) > int fail = 0; > int i; > > + if (!(ctrl_cpu_rev[0].clr & CPU_USE_TSC_OFFSET)) > + test_skip("CPU doesn't support the 'use TSC offsetting' processor-based VM-execution control.\n"); > + > test_set_guest(rdtsc_vmexit_diff_test_guest); > > reset_guest_tsc_to_zero(); > Queued this one now, thanks. Paolo
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 3b150323b325..b31c360c5f3c 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -9161,9 +9161,6 @@ static void vmx_vmcs_shadow_test(void) */ static void reset_guest_tsc_to_zero(void) { - TEST_ASSERT_MSG(ctrl_cpu_rev[0].clr & CPU_USE_TSC_OFFSET, - "Expected support for 'use TSC offsetting'"); - vmcs_set_bits(CPU_EXEC_CTRL0, CPU_USE_TSC_OFFSET); vmcs_write(TSC_OFFSET, -rdtsc()); } @@ -9210,6 +9207,9 @@ static void rdtsc_vmexit_diff_test(void) int fail = 0; int i; + if (!(ctrl_cpu_rev[0].clr & CPU_USE_TSC_OFFSET)) + test_skip("CPU doesn't support the 'use TSC offsetting' processor-based VM-execution control.\n"); + test_set_guest(rdtsc_vmexit_diff_test_guest); reset_guest_tsc_to_zero();
The RDTSC VM-exit test requires the 'use TSC offsetting' processor-based VM-execution control be allowed on the host. Check this precondition before running the test rather than asserting it later on to avoid erroneous failures on a host without TSC offsetting. Cc: Aaron Lewis <aaronlewis@google.com> Cc: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Oliver Upton <oupton@google.com> --- x86/vmx_tests.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)