]> xenbits.xensource.com Git - xtf.git/commitdiff
Introduce a per-test opt-in for using user mappings
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 19 Jul 2016 13:51:04 +0000 (14:51 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 19 Jul 2016 15:08:20 +0000 (16:08 +0100)
The choice of user or supervisor mappings is currently chosen for the
test, and is inflexible for a test needing to run in situations where
Xen leaks SMEP/SMAP into the guest, or where the test specifically wants
to use SMEP/SMAP itself.

As it turns out, fewer tests require user mappings than not.  For the
tests which don't require user mappings, allowing them to run on
supervisor mappings is quicker to set up, and allows the test to run
even if Xen leaks paging state.

Introduce test_wants_user_mappings and default it to false.  Tests which
want user mappings can opt-in by overriding the weak reference to true.
Explicit set the opt-in for the three tests which currently require
them.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Doxyfile
arch/x86/setup.c
include/xtf/compiler.h
include/xtf/test.h
tests/pv-iopl/main.c
tests/selftest/main.c
tests/swint-emulation/main.c

index c669a6e7e56e4f2a34ef5f56ea07608899f4627c..51db23bd16213e8fc0932adc5dfc285567338293 100644 (file)
--- a/Doxyfile
+++ b/Doxyfile
@@ -2032,6 +2032,7 @@ PREDEFINED             = __aligned(x)= \
                          __noinline \
                          __noreturn \
                          __used \
+                         __weak \
 
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
index 433148a84befc6bbcd2701d4e342910628a1e48e..7f4b68fe2b964d40251b142137ce3fe611b6b021 100644 (file)
@@ -213,6 +213,14 @@ void test_setup(void)
                   : "=q" (xtf_has_fep));
 }
 
+/*
+ * Default weak settings.
+ *
+ * test_wants_* indicates default settings for the framework, which may be
+ * overridden by individual tests by providing non-weak variables.
+ */
+bool __weak test_wants_user_mappings = false;
+
 /*
  * Local variables:
  * mode: C
index 74dec31b70fef331ab4c0427e25ae3216fb2c99d..1ab7fb91d20ccfb0f750b4d95806da295a94ab26 100644 (file)
@@ -13,6 +13,8 @@
 #define __always_inline       __attribute__((__always_inline__))
 #endif
 
+#define __weak                __attribute__((weak))
+
 #define __noreturn            __attribute__((__noreturn__))
 #define unreachable()         __builtin_unreachable()
 
index d28aac9a542bcb2e7b82e784d98e498dbcbedffb..e7639984c5f3456c7dec2326edde70a1c3157bd5 100644 (file)
@@ -19,6 +19,20 @@ void test_main(void);
  */
 extern bool xtf_has_fep;
 
+/**
+ * Boolean indicating whether the test wants user mappings or not.
+ *
+ * Some tests want an easy transition between supervisor and user modes.  For
+ * such tests, this requires running on _PAGE_USER mappings, and they must
+ * opt-in.
+ *
+ * @see @ref errata
+ *
+ * The framework variable is a weak reference, and may be overridden by a test
+ * wishing to change the default.
+ */
+extern bool test_wants_user_mappings;
+
 #endif /* XTF_TEST_H */
 
 /*
index b966635d7b32dbf52bb19214a34f59b07c000474..f3a57f064e49a328b25c37af0364b1a90f427d72 100644 (file)
@@ -42,6 +42,8 @@
 
 #include <arch/x86/processor.h>
 
+bool test_wants_user_mappings = true;
+
 /**
  * Execute @p fn at user privilege on the current stack, folding @p iopl into
  * the iret frame.
index c68eadb5100c31b95e7cee1a63cbe98261cf524a..72b4045ed5fa4f5890accc981121da2c25a1374e 100644 (file)
@@ -14,6 +14,8 @@
 #include <arch/x86/processor.h>
 #include <arch/x86/segment.h>
 
+bool test_wants_user_mappings = true;
+
 static void test_int3_breakpoint(void)
 {
     printk("Test: int3 breakpoint\n");
index 2394e0a729d2b5b98dd7f0dcf42d8c63be875eaf..5807f771a81132dc2dcb61bf1c1c96dd5cfcc2fb 100644 (file)
@@ -51,6 +51,8 @@
 
 #include "lowlevel.h"
 
+bool test_wants_user_mappings = true;
+
 /** Single stub's worth of information. */
 struct single
 {