From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, Sean Christopherson <seanjc@google.com>
Subject: [kvm-unit-tests PATCH 03/12] nSVM: Reset the VMCB before every v1 test
Date: Tue, 22 Jun 2021 14:00:38 -0700 [thread overview]
Message-ID: <20210622210047.3691840-4-seanjc@google.com> (raw)
In-Reply-To: <20210622210047.3691840-1-seanjc@google.com>
Refresh the VMCB before every v1 test to fix bugs where tests neglect to
initialize the VMCB and end up taking a dependency on previous tests,
e.g. looking at you mode_test and next_rip. This will also allow tests
to modify VMCB fields without having to do their own manual save/restore.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
x86/svm.c | 2 ++
x86/svm_tests.c | 13 -------------
2 files changed, 2 insertions(+), 13 deletions(-)
diff --git a/x86/svm.c b/x86/svm.c
index 9fbc0b2..6e5872d 100644
--- a/x86/svm.c
+++ b/x86/svm.c
@@ -250,6 +250,8 @@ static void test_run(struct svm_test *test)
u64 vmcb_phys = virt_to_phys(vmcb);
irq_disable();
+ vmcb_ident(vmcb);
+
test->prepare(test);
guest_main = test->guest_func;
vmcb->save.rip = (ulong)test_thunk;
diff --git a/x86/svm_tests.c b/x86/svm_tests.c
index 4bfde2c..aa74cfe 100644
--- a/x86/svm_tests.c
+++ b/x86/svm_tests.c
@@ -667,7 +667,6 @@ static bool check_asid_zero(struct svm_test *test)
static void sel_cr0_bug_prepare(struct svm_test *test)
{
- vmcb_ident(vmcb);
vmcb->control.intercept |= (1ULL << INTERCEPT_SELECTIVE_CR0);
}
@@ -704,7 +703,6 @@ static void npt_nx_prepare(struct svm_test *test)
u64 *pte;
- vmcb_ident(vmcb);
pte = npt_get_pte((u64)null_test);
*pte |= PT64_NX_MASK;
@@ -727,7 +725,6 @@ static void npt_np_prepare(struct svm_test *test)
u64 *pte;
scratch_page = alloc_page();
- vmcb_ident(vmcb);
pte = npt_get_pte((u64)scratch_page);
*pte &= ~1ULL;
@@ -753,7 +750,6 @@ static void npt_us_prepare(struct svm_test *test)
u64 *pte;
scratch_page = alloc_page();
- vmcb_ident(vmcb);
pte = npt_get_pte((u64)scratch_page);
*pte &= ~(1ULL << 2);
@@ -780,7 +776,6 @@ static void npt_rsvd_prepare(struct svm_test *test)
{
u64 *pde;
- vmcb_ident(vmcb);
pde = npt_get_pde((u64) null_test);
save_pde = *pde;
@@ -802,7 +797,6 @@ static void npt_rw_prepare(struct svm_test *test)
u64 *pte;
- vmcb_ident(vmcb);
pte = npt_get_pte(0x80000);
*pte &= ~(1ULL << 1);
@@ -830,7 +824,6 @@ static void npt_rw_pfwalk_prepare(struct svm_test *test)
u64 *pte;
- vmcb_ident(vmcb);
pte = npt_get_pte(read_cr3());
*pte &= ~(1ULL << 1);
@@ -850,7 +843,6 @@ static bool npt_rw_pfwalk_check(struct svm_test *test)
static void npt_rsvd_pfwalk_prepare(struct svm_test *test)
{
u64 *pdpe;
- vmcb_ident(vmcb);
pdpe = npt_get_pml4e();
pdpe[0] |= (1ULL << 8);
@@ -867,7 +859,6 @@ static bool npt_rsvd_pfwalk_check(struct svm_test *test)
static void npt_l1mmio_prepare(struct svm_test *test)
{
- vmcb_ident(vmcb);
}
u32 nested_apic_version1;
@@ -894,7 +885,6 @@ static void npt_rw_l1mmio_prepare(struct svm_test *test)
u64 *pte;
- vmcb_ident(vmcb);
pte = npt_get_pte(0xfee00080);
*pte &= ~(1ULL << 1);
@@ -1940,8 +1930,6 @@ static void init_startup_prepare(struct svm_test *test)
struct segment_desc64 *tss_entry;
int i;
- vmcb_ident(vmcb);
-
on_cpu(1, get_tss_entry, &tss_entry);
orig_cpu_count = cpu_online_count;
@@ -1976,7 +1964,6 @@ static volatile bool init_intercept;
static void init_intercept_prepare(struct svm_test *test)
{
init_intercept = false;
- vmcb_ident(vmcb);
vmcb->control.intercept |= (1ULL << INTERCEPT_INIT);
}
--
2.32.0.288.g62a8d224e6-goog
next prev parent reply other threads:[~2021-06-22 21:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-22 21:00 [kvm-unit-tests PATCH 00/12] nSVM: NPT improvements and cleanups Sean Christopherson
2021-06-22 21:00 ` [kvm-unit-tests PATCH 01/12] nSVM: Provide expected and actual exit codes on VMRUN test failure Sean Christopherson
2021-06-22 21:00 ` [kvm-unit-tests PATCH 02/12] nSVM: Replace open coded NX manipulation with appropriate macros Sean Christopherson
2021-06-22 21:00 ` Sean Christopherson [this message]
2021-06-22 21:00 ` [kvm-unit-tests PATCH 04/12] nSVM: Explicitly save/update/restore EFER.NX for NPT NX test Sean Christopherson
2021-06-22 21:00 ` [kvm-unit-tests PATCH 05/12] nSVM: Remove NPT reserved bits tests (new one on the way) Sean Christopherson
2021-06-24 11:06 ` Paolo Bonzini
2021-06-24 17:43 ` Sean Christopherson
2021-06-24 17:47 ` Paolo Bonzini
2021-06-24 18:16 ` Sean Christopherson
2021-08-12 7:58 ` Maxim Levitsky
2021-06-22 21:00 ` [kvm-unit-tests PATCH 06/12] nSVM: Stop forcing EFER.NX=1 for all tests Sean Christopherson
2021-06-22 21:00 ` [kvm-unit-tests PATCH 07/12] nSVM: Remove a superfluous modification of guest EFER.NX in NPT NX test Sean Christopherson
2021-06-22 21:00 ` [kvm-unit-tests PATCH 08/12] nSVM: Clear guest's " Sean Christopherson
2021-06-22 21:00 ` [kvm-unit-tests PATCH 09/12] lib/vmalloc: Let arch code pass a value to its setup_mmu() helper Sean Christopherson
2021-06-22 21:00 ` [kvm-unit-tests PATCH 10/12] x86: Let tests omit PT_USER_MASK when configuring virtual memory Sean Christopherson
2021-06-22 21:00 ` [kvm-unit-tests PATCH 11/12] x86: Add GBPAGES CPUID macro, clean up CPUID comments Sean Christopherson
2021-06-22 21:00 ` [kvm-unit-tests PATCH 12/12] nSVM: Add test for NPT reserved bit and #NPF error code behavior Sean Christopherson
2021-06-23 11:52 ` [kvm-unit-tests PATCH 00/12] nSVM: NPT improvements and cleanups 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=20210622210047.3691840-4-seanjc@google.com \
--to=seanjc@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