diff mbox

[XTF,09/16] vvmx: test vmxon with unaligned VMXON region address

Message ID 20161216134348.16236-10-haozhong.zhang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Haozhong Zhang Dec. 16, 2016, 1:43 p.m. UTC
VMfailInvalid is expected in this case.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
---
 tests/vvmx/vmxon.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff mbox

Patch

diff --git a/tests/vvmx/vmxon.c b/tests/vvmx/vmxon.c
index 8147679..f230fdf 100644
--- a/tests/vvmx/vmxon.c
+++ b/tests/vvmx/vmxon.c
@@ -87,6 +87,21 @@  static bool test_vmxon_invalid_paddr_width(void)
                               VMXERR_VMFAIL_INVALID, 0, 0);
 }
 
+/**
+ * vmxon with VMXON region address not aligned to 4096
+ *
+ * Expect: VMfailInvalid
+ */
+static bool test_vmxon_unaligned_addr(void)
+{
+    uint64_t unaligned_addr = (uint64_t)vmxon_region | 0xff;
+    exinfo_t fault;
+    uint8_t ret = vmxon(unaligned_addr, &fault);
+
+    return handle_vmxinsn_err(__func__, ret, fault,
+                              VMXERR_VMFAIL_INVALID, 0, 0);
+}
+
 bool test_vmxon(void)
 {
     if ( !test_vmxon_novmxe() )
@@ -101,6 +116,9 @@  bool test_vmxon(void)
     if ( !test_vmxon_invalid_paddr_width() )
         return false;
 
+    if ( !test_vmxon_unaligned_addr() )
+        return false;
+
     return true;
 }