]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/commitdiff
Introduce test_setup() to detect runtime support relevant for tests
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 22 Dec 2015 20:20:23 +0000 (20:20 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 22 Dec 2015 20:59:26 +0000 (20:59 +0000)
Currently it just identifies whether the Forced Emulation Prefix is available.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/setup.c
common/setup.c
include/xtf/framework.h
include/xtf/test.h

index 3cd40c6823f092f1a63b7b04f9f2ff3d048cac31..0bfff1e0b88b2eae09c736b4aaa6c32a449ecf70 100644 (file)
@@ -127,6 +127,29 @@ void arch_setup(void)
     setup_pv_console();
 }
 
+/*
+ * Common test setup:
+ *
+ * xtf_has_* indicates the availabiliy of options which require runtime
+ * detection.
+ */
+bool xtf_has_fep = false;
+
+void test_setup(void)
+{
+    /*
+     * Attempt to use the forced emulation prefix to set the value of
+     * xtf_has_fep to the value of 1.  Use the exception table to compensate
+     * for the #UD exception if FEP is not available.
+     */
+    asm volatile ("xor %0, %0;"
+                  "1: ud2a; .ascii \"xen\";"
+                  "mov $1, %0;"
+                  "2:"
+                  _ASM_EXTABLE(1b, 2b)
+                  : "=q" (xtf_has_fep));
+}
+
 /*
  * Local variables:
  * mode: C
index c0ef3698d4f783bbe18a4468ac9003fce5b4631c..16d4b7f243cae851ff9e6989574cdb9627c83ea0 100644 (file)
@@ -24,6 +24,8 @@ void __noreturn xtf_main(void)
     printk("--- Xen Test Framework ---\n");
     printk("Environment: %s\n", environment_description);
 
+    test_setup();
+
     test_main();
 
     xtf_report_status();
index afac05082a759674a205b101f0e831a66019cd5c..78298980ff54e7cc9e283a997730cd3ada177914 100644 (file)
@@ -3,6 +3,7 @@
 
 /* To be implemented by each arch */
 void arch_setup(void);
+void test_setup(void);
 
 /* Single line summary of execution environment. */
 extern const char *environment_description;
index 5fa84ee2186b465b96c83dded3247735ae380161..f7ef95e17831bd245e3eb14bc6bd75c4447da1d4 100644 (file)
@@ -6,11 +6,19 @@
 #ifndef XTF_TEST_H
 #define XTF_TEST_H
 
+#include <xtf/types.h>
+
 /**
  * To be implemented by each test, as its entry point.
  */
 void test_main(void);
 
+/**
+ * Boolean indicating whether generic Force Emulation Prefix support is
+ * available for the test to use.
+ */
+extern const bool xtf_has_fep;
+
 #endif /* XTF_TEST_H */
 
 /*