[PATCH 3/3] kvm-unit-tests: nSVM: Test CR0.CD and CR0.NW combination on VMRUN of nested guests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



According to section "Canonicalization and Consistency Checks" in APM vol. 2,
the following guest state combination is illegal:

        "CR0.CD is zero and CR0.NW is set"

Signed-off-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx>
---
 x86/svm_tests.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/x86/svm_tests.c b/x86/svm_tests.c
index 16b9dfd..8bdefc5 100644
--- a/x86/svm_tests.c
+++ b/x86/svm_tests.c
@@ -1352,15 +1352,41 @@ static void basic_guest_main(struct svm_test *test)
 
 static void svm_guest_state_test(void)
 {
+	test_set_guest(basic_guest_main);
+
+	/*
+	 * Un-setting EFER.SVME is illegal
+	 */
 	u64 efer_saved = vmcb->save.efer;
 	u64 efer = efer_saved;
 
-	test_set_guest(basic_guest_main);
 	report (svm_vmrun() == SVM_EXIT_VMMCALL, "EFER.SVME: %lx", efer);
 	efer &= ~EFER_SVME;
 	vmcb->save.efer = efer;
 	report (svm_vmrun() == SVM_EXIT_ERR, "EFER.SVME: %lx", efer);
 	vmcb->save.efer = efer_saved;
+
+	/*
+	 * Un-setting CR0.CD and setting CR0.NW is illegal combination
+	 */
+	u64 cr0_saved = vmcb->save.cr0;
+	u64 cr0 = cr0_saved;
+
+	cr0 |= X86_CR0_CD;
+	cr0 &= ~X86_CR0_NW;
+	vmcb->save.cr0 = cr0;
+	report (svm_vmrun() == SVM_EXIT_VMMCALL, "CR0: %lx", cr0);
+	cr0 |= X86_CR0_NW;
+	vmcb->save.cr0 = cr0;
+	report (svm_vmrun() == SVM_EXIT_VMMCALL, "CR0: %lx", cr0);
+	cr0 &= ~X86_CR0_NW;
+	cr0 &= ~X86_CR0_CD;
+	vmcb->save.cr0 = cr0;
+	report (svm_vmrun() == SVM_EXIT_VMMCALL, "CR0: %lx", cr0);
+	cr0 |= X86_CR0_NW;
+	vmcb->save.cr0 = cr0;
+	report (svm_vmrun() == SVM_EXIT_ERR, "CR0: %lx", cr0);
+	vmcb->save.cr0 = cr0_saved;
 }
 
 struct svm_test svm_tests[] = {
-- 
1.8.3.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux