]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
KFX harness xen-kfx github/xen-kfx
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 22 Dec 2020 21:19:40 +0000 (21:19 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 23 Dec 2020 00:59:17 +0000 (00:59 +0000)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>
docs/all-tests.dox
tests/kfx/Makefile [new file with mode: 0644]
tests/kfx/main.c [new file with mode: 0644]

index 902fc44d298f70035c26adc4dd413417756a7a64..155e680841d3f5ca0068c6ef3e96e83d28d40b6a 100644 (file)
@@ -179,3 +179,5 @@ states.
 
 @subpage test-nested-vmx - Nested VT-x tests.
 */
+# Placeholder: Merge into the appropriate location above
+@subpage test-kfx - @todo title
diff --git a/tests/kfx/Makefile b/tests/kfx/Makefile
new file mode 100644 (file)
index 0000000..2ebcacd
--- /dev/null
@@ -0,0 +1,9 @@
+include $(ROOT)/build/common.mk
+
+NAME      := kfx
+CATEGORY  := utility
+TEST-ENVS := pv32pae pv64
+
+obj-perenv += main.o
+
+include $(ROOT)/build/gen.mk
diff --git a/tests/kfx/main.c b/tests/kfx/main.c
new file mode 100644 (file)
index 0000000..73969d7
--- /dev/null
@@ -0,0 +1,77 @@
+/**
+ * @file tests/kfx/main.c
+ * @ref test-kfx
+ *
+ * @page test-kfx kfx
+ *
+ * @todo Docs for test-kfx
+ *
+ * @see tests/kfx/main.c
+ */
+#include <xtf.h>
+
+const char test_title[] = "Test kfx";
+
+static struct xen_domctl op;
+
+static void kfx_fuzz_setup(void *_p, size_t s)
+{
+    intptr_t p = (intptr_t)_p;
+    unsigned int tmp;
+
+    asm volatile ("cpuid"
+                  : "=a" (tmp), "=c" (tmp)
+                  : "a" (0x13371337), "c" (s)
+                  : "bx", "dx");
+
+    asm volatile ("cpuid"
+                  : "=a" (tmp), "=c" (tmp)
+#ifdef __x86_64__
+                  : "a" (p >> 32),
+#else
+                  : "a" (0),
+#endif
+                    "c" (p)
+                  : "bx", "dx");
+}
+
+static void kfx_fuzz_stop(void)
+{
+    cpuid_eax(0x13371337);
+}
+
+void test_main(void)
+{
+    int interface_version = xtf_probe_domctl_interface_version();
+    if ( interface_version < 0 )
+        return xtf_error("Failed to get domctl version\n");
+
+    printk("Domctl version: %#x. Struct @ %p size %zu\n",
+           interface_version, &op, sizeof(op));
+
+    kfx_fuzz_setup(&op, sizeof(op));
+
+    op.cmd = XEN_DOMCTL_createdomain,
+    op.interface_version = interface_version;
+
+    int rc = hypercall_domctl(&op);
+    if ( rc == 0 )
+    {
+        op.cmd = XEN_DOMCTL_destroydomain;
+        hypercall_domctl(&op);
+    }
+
+    kfx_fuzz_stop();
+
+    xtf_success("Fuzzing done\n");
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */