diff mbox series

[kvm-unit-tests,v5,7/8] x86: VMX: Make guest_state_test_main() check state from nested VM

Message ID 20191114001722.173836-8-oupton@google.com (mailing list archive)
State New, archived
Headers show
Series KVM: nVMX: Add full nested support for "load IA32_PERF_GLOBAL_CTRL" VM-{Entry,Exit} control | expand

Commit Message

Oliver Upton Nov. 14, 2019, 12:17 a.m. UTC
Introduce the vmx_state_area_test_data struct for sharing test
expectation data with the nested VM.

Signed-off-by: Oliver Upton <oupton@google.com>
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
---
 x86/vmx_tests.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 1d8932fad12b..95c1c01d2966 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -5023,13 +5023,28 @@  static void test_entry_msr_load(void)
 	test_vmx_valid_controls();
 }
 
+static struct vmx_state_area_test_data {
+	u32 msr;
+	u64 exp;
+	bool enabled;
+} vmx_state_area_test_data;
+
 static void guest_state_test_main(void)
 {
+	u64 obs;
+	struct vmx_state_area_test_data *data = &vmx_state_area_test_data;
+
 	while (1) {
-		if (vmx_get_test_stage() != 2)
-			vmcall();
-		else
+		if (vmx_get_test_stage() == 2)
 			break;
+
+		if (data->enabled) {
+			obs = rdmsr(data->msr);
+			report("Guest state is 0x%lx (expected 0x%lx)",
+			       data->exp == obs, obs, data->exp);
+		}
+
+		vmcall();
 	}
 
 	asm volatile("fnop");