aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrish Sadhukhan <krish.sadhukhan@oracle.com>2020-04-20 18:58:25 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2020-04-21 12:16:07 -0400
commit5c052c904ded7ecd80d8f7efe2803821b45ce483 (patch)
treea9277e276364387684e35787810535be92e7c183
parent9870fcb67257874f0b67b8dd433741c1b1b23067 (diff)
downloadkvm-unit-tests-5c052c904ded7ecd80d8f7efe2803821b45ce483.tar.gz
kvm-unit-tests: nSVM: Test that CR0[63:32] are not set on VMRUN of nested guests
According to section "Canonicalization and Consistency Checks" in APM vol. 2, the following guest state is illegal: "CR0[63:32] are not zero." Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com> Message-Id: <20200420225825.3184-2-krish.sadhukhan@oracle.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--x86/svm_tests.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/x86/svm_tests.c b/x86/svm_tests.c
index 3f18d37..5a571eb 100644
--- a/x86/svm_tests.c
+++ b/x86/svm_tests.c
@@ -1633,6 +1633,20 @@ static void svm_guest_state_test(void)
vmcb->save.cr0 = cr0;
report (svm_vmrun() == SVM_EXIT_ERR, "CR0: %lx", cr0);
vmcb->save.cr0 = cr0_saved;
+
+ /*
+ * CR0[63:32] are not zero
+ */
+ int i;
+
+ cr0 = cr0_saved;
+ for (i = 32; i < 63; i = i + 4) {
+ cr0 = cr0_saved | (1ull << i);
+ vmcb->save.cr0 = cr0;
+ report (svm_vmrun() == SVM_EXIT_ERR, "CR0[63:32]: %lx",
+ cr0 >> 32);
+ }
+ vmcb->save.cr0 = cr0_saved;
}
struct svm_test svm_tests[] = {