[PATCH 05/12] KVM: selftests: Remove invalid CR3 test from vmx_tsc_adjust_test

Yosry Ahmed posted 12 patches 4 months, 1 week ago
There is a newer version of this series
[PATCH 05/12] KVM: selftests: Remove invalid CR3 test from vmx_tsc_adjust_test
Posted by Yosry Ahmed 4 months, 1 week ago
From: Yosry Ahmed <yosryahmed@google.com>

Checking that VMLAUNCH fails with an invalid CR3 is irrelevant to this
test. Remove it to simplify the test a little bit before generalizing it
to cover SVM.

Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
---
 tools/testing/selftests/kvm/x86/vmx_tsc_adjust_test.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/tools/testing/selftests/kvm/x86/vmx_tsc_adjust_test.c b/tools/testing/selftests/kvm/x86/vmx_tsc_adjust_test.c
index 2ceb5c78c4427..2dcc0306a0d9b 100644
--- a/tools/testing/selftests/kvm/x86/vmx_tsc_adjust_test.c
+++ b/tools/testing/selftests/kvm/x86/vmx_tsc_adjust_test.c
@@ -77,7 +77,6 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
 #define L2_GUEST_STACK_SIZE 64
 	unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
 	uint32_t control;
-	uintptr_t save_cr3;
 
 	GUEST_ASSERT(rdtsc() < TSC_ADJUST_VALUE);
 	wrmsr(MSR_IA32_TSC, rdtsc() - TSC_ADJUST_VALUE);
@@ -94,15 +93,6 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
 	vmwrite(CPU_BASED_VM_EXEC_CONTROL, control);
 	vmwrite(TSC_OFFSET, TSC_OFFSET_VALUE);
 
-	/* Jump into L2.  First, test failure to load guest CR3.  */
-	save_cr3 = vmreadz(GUEST_CR3);
-	vmwrite(GUEST_CR3, -1ull);
-	GUEST_ASSERT(!vmlaunch());
-	GUEST_ASSERT(vmreadz(VM_EXIT_REASON) ==
-		     (EXIT_REASON_FAILED_VMENTRY | EXIT_REASON_INVALID_STATE));
-	check_ia32_tsc_adjust(-1 * TSC_ADJUST_VALUE);
-	vmwrite(GUEST_CR3, save_cr3);
-
 	GUEST_ASSERT(!vmlaunch());
 	GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
 
-- 
2.51.0.618.g983fd99d29-goog
Re: [PATCH 05/12] KVM: selftests: Remove invalid CR3 test from vmx_tsc_adjust_test
Posted by Jim Mattson 4 months ago
On Wed, Oct 1, 2025 at 8:02 AM Yosry Ahmed <yosry.ahmed@linux.dev> wrote:
>
> From: Yosry Ahmed <yosryahmed@google.com>
>
> Checking that VMLAUNCH fails with an invalid CR3 is irrelevant to this
> test. Remove it to simplify the test a little bit before generalizing it
> to cover SVM.
>
> Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>

Is there value in moving the invalid CR3 test elsewhere, rather than
just eliminating it?
Re: [PATCH 05/12] KVM: selftests: Remove invalid CR3 test from vmx_tsc_adjust_test
Posted by Yosry Ahmed 4 months ago
On Thu, Oct 09, 2025 at 03:55:32PM -0700, Jim Mattson wrote:
> On Wed, Oct 1, 2025 at 8:02 AM Yosry Ahmed <yosry.ahmed@linux.dev> wrote:
> >
> > From: Yosry Ahmed <yosryahmed@google.com>
> >
> > Checking that VMLAUNCH fails with an invalid CR3 is irrelevant to this
> > test. Remove it to simplify the test a little bit before generalizing it
> > to cover SVM.
> >
> > Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
> 
> Is there value in moving the invalid CR3 test elsewhere, rather than
> just eliminating it?

It's a very basic test, but yeah we can keep it. I was doing the lazy
thing by just dropping it to see if anyone will comment.

I will find a new home for it (or keep it here out of more laziness).