[TEST PATCH 5/5] nSVM: Test optional commands and reserved encodings of TLB_CONTROL in nested VMCB

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

 



According to section "TLB Flush" in APM vol 2,

    "Support for TLB_CONTROL commands, other than 0x0 and 0x1, is optional
     and is indicated by CPUID Fn8000_000A_EDX[FlushByAsid].

     All encodings of TLB_CONTROL not defined in the APM are reserved."

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

diff --git a/x86/svm_tests.c b/x86/svm_tests.c
index b998b24..fa1bb89 100644
--- a/x86/svm_tests.c
+++ b/x86/svm_tests.c
@@ -2562,6 +2562,41 @@ static void guest_rflags_test_db_handler(struct ex_regs *r)
 	r->rflags &= ~X86_EFLAGS_TF;
 }
 
+/*
+ * Support for TLB_CONTROL commands, other than 0x0 and 0x1, is optional
+ * and is indicated by CPUID Fn8000_000A_EDX[FlushByAsid].
+ * All encodings of TLB_CONTROL not defined in the APM are reserved.
+ */
+static void test_tlb_ctl(void)
+{
+	u64 tlb_ctl_saved = vmcb->control.tlb_ctl;
+	u64 i;
+
+	if (!this_cpu_has(X86_FEATURE_FLUSHBYASID)) {
+		int ret;
+		vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ASID;
+		ret = svm_vmrun();
+		report(ret == SVM_EXIT_ERR, "Test TLB_CONTROL: %x, CPU doesn't support FLUSH_ASID (encoding 0x3), VMRUN failure expected",
+		    vmcb->control.tlb_ctl);
+
+		vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ASID_LOCAL;
+		report(svm_vmrun() == SVM_EXIT_ERR, "Test TLB_CONTROL: %x, CPU doesn't support FLUSH_ASID_LOCAL (encoding 0x7), VMRUN failure expected",
+		    vmcb->control.tlb_ctl);
+	}
+
+	/*
+	 * Test reserved encodings up to 0xf only
+	 */
+	for (i = 0; i <= 0xf; i++) {
+		if (i == 0x2 || (i > 3 && i < 7) || i > 7) {
+			vmcb->control.tlb_ctl = i;
+			report(svm_vmrun() == SVM_EXIT_ERR, "Test TLB_CONTROL: %x, reserved encoding used, VMRUN failure expected", vmcb->control.tlb_ctl);
+		}
+	}
+
+	vmcb->control.tlb_ctl = tlb_ctl_saved;
+}
+
 static void svm_guest_state_test(void)
 {
 	test_set_guest(basic_guest_main);
@@ -2572,6 +2607,7 @@ static void svm_guest_state_test(void)
 	test_dr();
 	test_msrpm_iopm_bitmap_addrs();
 	test_canonicalization();
+	test_tlb_ctl();
 }
 
 extern void guest_rflags_test_guest(struct svm_test *test);
-- 
2.27.0




[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