All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] x86: nVMX: Print more (accurate) info if RDTSC diff test fails
@ 2020-01-24 23:46 Sean Christopherson
  2020-01-26  7:16 ` Krish Sadhukhan
  0 siblings, 1 reply; 5+ messages in thread
From: Sean Christopherson @ 2020-01-24 23:46 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Nadav Amit, Aaron Lewis

Snapshot the delta of the last run and display it in the report if the
test fails.  Abort the run loop as soon as the threshold is reached so
that the displayed delta is guaranteed to a failed delta.  Displaying
the delta helps triage failures, e.g. is my system completely broken or
did I get unlucky, and aborting the loop early saves 99900 runs when
the system is indeed broken.

Cc: Nadav Amit <nadav.amit@gmail.com>
Cc: Aaron Lewis <aaronlewis@google.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 x86/vmx_tests.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index b31c360..4049dec 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -9204,6 +9204,7 @@ static unsigned long long rdtsc_vmexit_diff_test_iteration(void)
 
 static void rdtsc_vmexit_diff_test(void)
 {
+	unsigned long long delta;
 	int fail = 0;
 	int i;
 
@@ -9226,17 +9227,17 @@ static void rdtsc_vmexit_diff_test(void)
 	vmcs_write(EXI_MSR_ST_CNT, 1);
 	vmcs_write(EXIT_MSR_ST_ADDR, virt_to_phys(exit_msr_store));
 
-	for (i = 0; i < RDTSC_DIFF_ITERS; i++) {
-		if (rdtsc_vmexit_diff_test_iteration() >=
-		    HOST_CAPTURED_GUEST_TSC_DIFF_THRESHOLD)
+	for (i = 0; i < RDTSC_DIFF_ITERS && fail < RDTSC_DIFF_FAILS; i++) {
+		delta = rdtsc_vmexit_diff_test_iteration();
+		if (delta >= HOST_CAPTURED_GUEST_TSC_DIFF_THRESHOLD)
 			fail++;
 	}
 
 	enter_guest();
 
 	report(fail < RDTSC_DIFF_FAILS,
-	       "RDTSC to VM-exit delta too high in %d of %d iterations",
-	       fail, RDTSC_DIFF_ITERS);
+	       "RDTSC to VM-exit delta too high in %d of %d iterations, last = %llu",
+	       fail, i, delta);
 }
 
 static int invalid_msr_init(struct vmcs *vmcs)
-- 
2.24.1


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

* Re: [kvm-unit-tests PATCH] x86: nVMX: Print more (accurate) info if RDTSC diff test fails
  2020-01-24 23:46 [kvm-unit-tests PATCH] x86: nVMX: Print more (accurate) info if RDTSC diff test fails Sean Christopherson
@ 2020-01-26  7:16 ` Krish Sadhukhan
  2020-01-27 14:30   ` Aaron Lewis
  0 siblings, 1 reply; 5+ messages in thread
From: Krish Sadhukhan @ 2020-01-26  7:16 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, Nadav Amit, Aaron Lewis


On 1/24/20 3:46 PM, Sean Christopherson wrote:
> Snapshot the delta of the last run and display it in the report if the
> test fails.  Abort the run loop as soon as the threshold is reached so
> that the displayed delta is guaranteed to a failed delta.  Displaying
> the delta helps triage failures, e.g. is my system completely broken or
> did I get unlucky, and aborting the loop early saves 99900 runs when
> the system is indeed broken.
>
> Cc: Nadav Amit <nadav.amit@gmail.com>
> Cc: Aaron Lewis <aaronlewis@google.com>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>   x86/vmx_tests.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index b31c360..4049dec 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -9204,6 +9204,7 @@ static unsigned long long rdtsc_vmexit_diff_test_iteration(void)
>   
>   static void rdtsc_vmexit_diff_test(void)
>   {
> +	unsigned long long delta;
>   	int fail = 0;
>   	int i;
>   
> @@ -9226,17 +9227,17 @@ static void rdtsc_vmexit_diff_test(void)
>   	vmcs_write(EXI_MSR_ST_CNT, 1);
>   	vmcs_write(EXIT_MSR_ST_ADDR, virt_to_phys(exit_msr_store));
>   
> -	for (i = 0; i < RDTSC_DIFF_ITERS; i++) {
> -		if (rdtsc_vmexit_diff_test_iteration() >=
> -		    HOST_CAPTURED_GUEST_TSC_DIFF_THRESHOLD)
> +	for (i = 0; i < RDTSC_DIFF_ITERS && fail < RDTSC_DIFF_FAILS; i++) {
> +		delta = rdtsc_vmexit_diff_test_iteration();
> +		if (delta >= HOST_CAPTURED_GUEST_TSC_DIFF_THRESHOLD)
>   			fail++;
>   	}
>   
>   	enter_guest();
>   
>   	report(fail < RDTSC_DIFF_FAILS,
> -	       "RDTSC to VM-exit delta too high in %d of %d iterations",
> -	       fail, RDTSC_DIFF_ITERS);
> +	       "RDTSC to VM-exit delta too high in %d of %d iterations, last = %llu",
> +	       fail, i, delta);
>   }
>   
>   static int invalid_msr_init(struct vmcs *vmcs)
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>

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

* Re: [kvm-unit-tests PATCH] x86: nVMX: Print more (accurate) info if RDTSC diff test fails
  2020-01-26  7:16 ` Krish Sadhukhan
@ 2020-01-27 14:30   ` Aaron Lewis
  2020-06-30 19:35     ` Sean Christopherson
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Lewis @ 2020-01-27 14:30 UTC (permalink / raw)
  To: Krish Sadhukhan; +Cc: Sean Christopherson, Paolo Bonzini, kvm, Nadav Amit

On Sat, Jan 25, 2020 at 11:16 PM Krish Sadhukhan
<krish.sadhukhan@oracle.com> wrote:
>
>
> On 1/24/20 3:46 PM, Sean Christopherson wrote:
> > Snapshot the delta of the last run and display it in the report if the
> > test fails.  Abort the run loop as soon as the threshold is reached so
> > that the displayed delta is guaranteed to a failed delta.  Displaying
> > the delta helps triage failures, e.g. is my system completely broken or
> > did I get unlucky, and aborting the loop early saves 99900 runs when
> > the system is indeed broken.
> >
> > Cc: Nadav Amit <nadav.amit@gmail.com>
> > Cc: Aaron Lewis <aaronlewis@google.com>
> > Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> > ---
> >   x86/vmx_tests.c | 11 ++++++-----
> >   1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> > index b31c360..4049dec 100644
> > --- a/x86/vmx_tests.c
> > +++ b/x86/vmx_tests.c
> > @@ -9204,6 +9204,7 @@ static unsigned long long rdtsc_vmexit_diff_test_iteration(void)
> >
> >   static void rdtsc_vmexit_diff_test(void)
> >   {
> > +     unsigned long long delta;
> >       int fail = 0;
> >       int i;
> >
> > @@ -9226,17 +9227,17 @@ static void rdtsc_vmexit_diff_test(void)
> >       vmcs_write(EXI_MSR_ST_CNT, 1);
> >       vmcs_write(EXIT_MSR_ST_ADDR, virt_to_phys(exit_msr_store));
> >
> > -     for (i = 0; i < RDTSC_DIFF_ITERS; i++) {
> > -             if (rdtsc_vmexit_diff_test_iteration() >=
> > -                 HOST_CAPTURED_GUEST_TSC_DIFF_THRESHOLD)
> > +     for (i = 0; i < RDTSC_DIFF_ITERS && fail < RDTSC_DIFF_FAILS; i++) {
> > +             delta = rdtsc_vmexit_diff_test_iteration();
> > +             if (delta >= HOST_CAPTURED_GUEST_TSC_DIFF_THRESHOLD)
> >                       fail++;
> >       }
> >
> >       enter_guest();
> >
> >       report(fail < RDTSC_DIFF_FAILS,
> > -            "RDTSC to VM-exit delta too high in %d of %d iterations",
> > -            fail, RDTSC_DIFF_ITERS);
> > +            "RDTSC to VM-exit delta too high in %d of %d iterations, last = %llu",
> > +            fail, i, delta);
> >   }
> >
> >   static int invalid_msr_init(struct vmcs *vmcs)
> Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>

Reviewed-by: Aaron Lewis <aaronlewis@google.com>

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

* Re: [kvm-unit-tests PATCH] x86: nVMX: Print more (accurate) info if RDTSC diff test fails
  2020-01-27 14:30   ` Aaron Lewis
@ 2020-06-30 19:35     ` Sean Christopherson
  2020-07-01 16:00       ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Sean Christopherson @ 2020-06-30 19:35 UTC (permalink / raw)
  To: Aaron Lewis; +Cc: Krish Sadhukhan, Paolo Bonzini, kvm, Nadav Amit

Ping.

On Mon, Jan 27, 2020 at 06:30:11AM -0800, Aaron Lewis wrote:
> On Sat, Jan 25, 2020 at 11:16 PM Krish Sadhukhan
> <krish.sadhukhan@oracle.com> wrote:
> >
> >
> > On 1/24/20 3:46 PM, Sean Christopherson wrote:
> > > Snapshot the delta of the last run and display it in the report if the
> > > test fails.  Abort the run loop as soon as the threshold is reached so
> > > that the displayed delta is guaranteed to a failed delta.  Displaying
> > > the delta helps triage failures, e.g. is my system completely broken or
> > > did I get unlucky, and aborting the loop early saves 99900 runs when
> > > the system is indeed broken.
> > >
> > > Cc: Nadav Amit <nadav.amit@gmail.com>
> > > Cc: Aaron Lewis <aaronlewis@google.com>
> > > Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> > > ---
> > >   x86/vmx_tests.c | 11 ++++++-----
> > >   1 file changed, 6 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> > > index b31c360..4049dec 100644
> > > --- a/x86/vmx_tests.c
> > > +++ b/x86/vmx_tests.c
> > > @@ -9204,6 +9204,7 @@ static unsigned long long rdtsc_vmexit_diff_test_iteration(void)
> > >
> > >   static void rdtsc_vmexit_diff_test(void)
> > >   {
> > > +     unsigned long long delta;
> > >       int fail = 0;
> > >       int i;
> > >
> > > @@ -9226,17 +9227,17 @@ static void rdtsc_vmexit_diff_test(void)
> > >       vmcs_write(EXI_MSR_ST_CNT, 1);
> > >       vmcs_write(EXIT_MSR_ST_ADDR, virt_to_phys(exit_msr_store));
> > >
> > > -     for (i = 0; i < RDTSC_DIFF_ITERS; i++) {
> > > -             if (rdtsc_vmexit_diff_test_iteration() >=
> > > -                 HOST_CAPTURED_GUEST_TSC_DIFF_THRESHOLD)
> > > +     for (i = 0; i < RDTSC_DIFF_ITERS && fail < RDTSC_DIFF_FAILS; i++) {
> > > +             delta = rdtsc_vmexit_diff_test_iteration();
> > > +             if (delta >= HOST_CAPTURED_GUEST_TSC_DIFF_THRESHOLD)
> > >                       fail++;
> > >       }
> > >
> > >       enter_guest();
> > >
> > >       report(fail < RDTSC_DIFF_FAILS,
> > > -            "RDTSC to VM-exit delta too high in %d of %d iterations",
> > > -            fail, RDTSC_DIFF_ITERS);
> > > +            "RDTSC to VM-exit delta too high in %d of %d iterations, last = %llu",
> > > +            fail, i, delta);
> > >   }
> > >
> > >   static int invalid_msr_init(struct vmcs *vmcs)
> > Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
> 
> Reviewed-by: Aaron Lewis <aaronlewis@google.com>

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

* Re: [kvm-unit-tests PATCH] x86: nVMX: Print more (accurate) info if RDTSC diff test fails
  2020-06-30 19:35     ` Sean Christopherson
@ 2020-07-01 16:00       ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2020-07-01 16:00 UTC (permalink / raw)
  To: Sean Christopherson, Aaron Lewis; +Cc: Krish Sadhukhan, kvm, Nadav Amit

On 30/06/20 21:35, Sean Christopherson wrote:
> Ping.
> 
> On Mon, Jan 27, 2020 at 06:30:11AM -0800, Aaron Lewis wrote:
>> On Sat, Jan 25, 2020 at 11:16 PM Krish Sadhukhan
>> <krish.sadhukhan@oracle.com> wrote:
>>>
>>>
>>> On 1/24/20 3:46 PM, Sean Christopherson wrote:
>>>> Snapshot the delta of the last run and display it in the report if the
>>>> test fails.  Abort the run loop as soon as the threshold is reached so
>>>> that the displayed delta is guaranteed to a failed delta.  Displaying
>>>> the delta helps triage failures, e.g. is my system completely broken or
>>>> did I get unlucky, and aborting the loop early saves 99900 runs when
>>>> the system is indeed broken.
>>>>
>>>> Cc: Nadav Amit <nadav.amit@gmail.com>
>>>> Cc: Aaron Lewis <aaronlewis@google.com>
>>>> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
>>>> ---
>>>>   x86/vmx_tests.c | 11 ++++++-----
>>>>   1 file changed, 6 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
>>>> index b31c360..4049dec 100644
>>>> --- a/x86/vmx_tests.c
>>>> +++ b/x86/vmx_tests.c
>>>> @@ -9204,6 +9204,7 @@ static unsigned long long rdtsc_vmexit_diff_test_iteration(void)
>>>>
>>>>   static void rdtsc_vmexit_diff_test(void)
>>>>   {
>>>> +     unsigned long long delta;
>>>>       int fail = 0;
>>>>       int i;
>>>>
>>>> @@ -9226,17 +9227,17 @@ static void rdtsc_vmexit_diff_test(void)
>>>>       vmcs_write(EXI_MSR_ST_CNT, 1);
>>>>       vmcs_write(EXIT_MSR_ST_ADDR, virt_to_phys(exit_msr_store));
>>>>
>>>> -     for (i = 0; i < RDTSC_DIFF_ITERS; i++) {
>>>> -             if (rdtsc_vmexit_diff_test_iteration() >=
>>>> -                 HOST_CAPTURED_GUEST_TSC_DIFF_THRESHOLD)
>>>> +     for (i = 0; i < RDTSC_DIFF_ITERS && fail < RDTSC_DIFF_FAILS; i++) {
>>>> +             delta = rdtsc_vmexit_diff_test_iteration();
>>>> +             if (delta >= HOST_CAPTURED_GUEST_TSC_DIFF_THRESHOLD)
>>>>                       fail++;
>>>>       }
>>>>
>>>>       enter_guest();
>>>>
>>>>       report(fail < RDTSC_DIFF_FAILS,
>>>> -            "RDTSC to VM-exit delta too high in %d of %d iterations",
>>>> -            fail, RDTSC_DIFF_ITERS);
>>>> +            "RDTSC to VM-exit delta too high in %d of %d iterations, last = %llu",
>>>> +            fail, i, delta);
>>>>   }
>>>>
>>>>   static int invalid_msr_init(struct vmcs *vmcs)
>>> Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
>>
>> Reviewed-by: Aaron Lewis <aaronlewis@google.com>
> 

Queued, thanks.

Paolo


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

end of thread, other threads:[~2020-07-01 16:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-24 23:46 [kvm-unit-tests PATCH] x86: nVMX: Print more (accurate) info if RDTSC diff test fails Sean Christopherson
2020-01-26  7:16 ` Krish Sadhukhan
2020-01-27 14:30   ` Aaron Lewis
2020-06-30 19:35     ` Sean Christopherson
2020-07-01 16:00       ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.