From: Oliver Upton <oupton@google.com>
To: kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Jim Mattson <jmattson@google.com>,
Oliver Upton <oupton@google.com>,
Aaron Lewis <aaronlewis@google.com>
Subject: [kvm-unit-tests PATCH] x86: VMX: Check preconditions for RDTSC test
Date: Tue, 21 Jan 2020 23:39:59 -0800 [thread overview]
Message-ID: <20200122073959.192050-1-oupton@google.com> (raw)
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>
Signed-off-by: Oliver Upton <oupton@google.com>
---
x86/vmx_tests.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 3b150323b325..de9a931216e2 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,11 @@ static void rdtsc_vmexit_diff_test(void)
int fail = 0;
int i;
+ if (!(ctrl_cpu_rev[0].clr & CPU_USE_TSC_OFFSET)) {
+ printf("CPU doesn't support the 'use TSC offsetting' processor-based VM-execution control.\n");
+ return;
+ }
+
test_set_guest(rdtsc_vmexit_diff_test_guest);
reset_guest_tsc_to_zero();
--
2.25.0.341.g760bfbb309-goog
next reply other threads:[~2020-01-22 7:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-22 7:39 Oliver Upton [this message]
2020-01-22 9:47 ` [kvm-unit-tests PATCH] x86: VMX: Check preconditions for RDTSC test Vitaly Kuznetsov
2020-01-22 9:51 ` Oliver Upton
2020-01-22 14:26 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200122073959.192050-1-oupton@google.com \
--to=oupton@google.com \
--cc=aaronlewis@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox