From: Andrew Cooper Date: Tue, 22 Dec 2015 20:20:23 +0000 (+0000) Subject: Introduce test_setup() to detect runtime support relevant for tests X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=2f25600af8cbf72b568e3fa4b0a522e49a377957;p=people%2Froyger%2Fxen-test-framework.git Introduce test_setup() to detect runtime support relevant for tests Currently it just identifies whether the Forced Emulation Prefix is available. Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/setup.c b/arch/x86/setup.c index 3cd40c6..0bfff1e 100644 --- a/arch/x86/setup.c +++ b/arch/x86/setup.c @@ -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 diff --git a/common/setup.c b/common/setup.c index c0ef369..16d4b7f 100644 --- a/common/setup.c +++ b/common/setup.c @@ -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(); diff --git a/include/xtf/framework.h b/include/xtf/framework.h index afac050..7829898 100644 --- a/include/xtf/framework.h +++ b/include/xtf/framework.h @@ -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; diff --git a/include/xtf/test.h b/include/xtf/test.h index 5fa84ee..f7ef95e 100644 --- a/include/xtf/test.h +++ b/include/xtf/test.h @@ -6,11 +6,19 @@ #ifndef XTF_TEST_H #define XTF_TEST_H +#include + /** * 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 */ /*