[PATCH 6/7] svm: Add test for RW bit check in emulated NPT

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

 



This patch adds a test to check if the RW bit is checked in
the NPT emulation of KVM.

Signed-off-by: Joerg Roedel <joerg.roedel@xxxxxxx>
---
 x86/svm.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/x86/svm.c b/x86/svm.c
index 03e07e2..3421736 100644
--- a/x86/svm.c
+++ b/x86/svm.c
@@ -532,6 +532,34 @@ static bool npt_rsvd_check(struct test *test)
             && (test->vmcb->control.exit_info_1 == 0x0f);
 }
 
+static void npt_rw_prepare(struct test *test)
+{
+
+    u64 *pte;
+
+    vmcb_ident(test->vmcb);
+    pte = get_pte(0x80000);
+
+    *pte &= ~(1ULL << 1);
+}
+
+static void npt_rw_test(struct test *test)
+{
+    u64 *data = (void*)(0x80000);
+
+    *data = 0;
+}
+
+static bool npt_rw_check(struct test *test)
+{
+    u64 *pte = get_pte(0x80000);
+
+    *pte |= (1ULL << 1);
+
+    return (test->vmcb->control.exit_code == SVM_EXIT_NPF)
+           && (test->vmcb->control.exit_info_1 == 0x07);
+}
+
 static struct test tests[] = {
     { "null", default_supported, default_prepare, null_test,
       default_finished, null_check },
@@ -560,6 +588,8 @@ static struct test tests[] = {
 	    default_finished, npt_us_check },
     { "npt_rsvd", npt_supported, npt_rsvd_prepare, null_test,
 	    default_finished, npt_rsvd_check },
+    { "npt_rw", npt_supported, npt_rw_prepare, npt_rw_test,
+	    default_finished, npt_rw_check },
 };
 
 int main(int ac, char **av)
-- 
1.7.0.4


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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