diff mbox

[kvm-unit-tests,31/32] x86: force ept 2m test

Message ID 20170421005004.137260-32-dmatlack@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Matlack April 21, 2017, 12:50 a.m. UTC
From: Peter Feiner <pfeiner@google.com>

EPT tests don't exercise 2m support unless it's advertised properly.
This test asserts that we actually advertise it and that some basic 2m
stuff works.

Signed-off-by: Peter Feiner <pfeiner@google.com>
Signed-off-by: David Matlack <dmatlack@google.com>
---
 x86/unittests.cfg |  6 ++++++
 x86/vmx_tests.c   | 13 +++++++++++++
 2 files changed, 19 insertions(+)
diff mbox

Patch

diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index bc245651ce80..09b2252ac2af 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -482,6 +482,12 @@  extra_params = -cpu host,+vmx -m 2048 -append ept_access_test_paddr_not_present_
 arch = x86_64
 groups = vmx
 
+[vmx_ept_access_test_force_2m_page]
+file = vmx.flat
+extra_params = -cpu host,+vmx -m 2048 -append ept_access_test_force_2m_page
+arch = x86_64
+groups = vmx
+
 [debug]
 file = debug.flat
 arch = x86_64
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index c4cd3f96001d..d59ca0baf48a 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -2807,6 +2807,18 @@  static void ept_access_test_paddr_not_present_page_fault(void)
 	 */
 }
 
+static void ept_access_test_force_2m_page(void)
+{
+	ept_access_test_setup();
+
+	TEST_ASSERT_EQ(ept_2m_supported(), true);
+	ept_allowed_at_level_mkhuge(true, 2, 0, 0, OP_READ);
+	ept_violation_at_level_mkhuge(true, 2, EPT_PRESENT, EPT_RA, OP_WRITE,
+				      EPT_VLT_WR | EPT_VLT_PERM_RD |
+				      EPT_VLT_LADDR_VLD | EPT_VLT_PADDR);
+	ept_misconfig_at_level_mkhuge(true, 2, EPT_PRESENT, EPT_WA);
+}
+
 #define TEST(name) { #name, .v2 = name }
 
 /* name/init/guest_main/exit_handler/syscall_handler/guest_regs */
@@ -2866,5 +2878,6 @@  struct vmx_test vmx_tests[] = {
 	TEST(ept_access_test_paddr_read_execute_ad_disabled),
 	TEST(ept_access_test_paddr_read_execute_ad_enabled),
 	TEST(ept_access_test_paddr_not_present_page_fault),
+	TEST(ept_access_test_force_2m_page),
 	{ NULL, NULL, NULL, NULL, NULL, {0} },
 };