From: Andrew Cooper Date: Wed, 3 Aug 2016 11:33:52 +0000 (+0100) Subject: Introduce test_needs_fep to help uniform handling of fep being unavailable X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=37163d21c0e83b5b3d647d9e0c9bdd3911b98fc5;p=people%2Fliuw%2Fxtf.git Introduce test_needs_fep to help uniform handling of fep being unavailable Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/setup.c b/arch/x86/setup.c index 8560001..b074814 100644 --- a/arch/x86/setup.c +++ b/arch/x86/setup.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -197,6 +198,18 @@ void arch_setup(void) */ bool xtf_has_fep = false; +/* + * Default weak settings. + * + * test_wants_* indicates default settings for the framework, which may be + * overridden by individual tests by providing non-weak variables. + * + * test_needs_* indicates options required by the test, without which the test + * isn't worth running. + */ +bool __weak test_wants_user_mappings = false; +bool __weak test_needs_fep = false; + void test_setup(void) { /* @@ -204,21 +217,15 @@ void test_setup(void) * 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:" _ASM_XEN_FEP - "mov $1, %0;" + asm volatile ("1:" _ASM_XEN_FEP "mov $1, %[fep];" "2:" _ASM_EXTABLE(1b, 2b) - : "=q" (xtf_has_fep)); -} + : [fep] "=q" (xtf_has_fep) + : "0" (false)); -/* - * 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; + if ( test_needs_fep && !xtf_has_fep ) + return xtf_skip("FEP unavailable, but needed by test\n"); +} /* * Local variables: diff --git a/common/report.c b/common/report.c index 685542c..8a6ddfa 100644 --- a/common/report.c +++ b/common/report.c @@ -116,6 +116,11 @@ void xtf_report_status(void) " with warnings" : ""); } +bool xtf_status_reported(void) +{ + return status != STATUS_RUNNING; +} + /* * Local variables: * mode: C diff --git a/common/setup.c b/common/setup.c index 16d4b7f..3c2f848 100644 --- a/common/setup.c +++ b/common/setup.c @@ -26,7 +26,10 @@ void __noreturn xtf_main(void) test_setup(); - test_main(); + if ( !xtf_status_reported() ) + { + test_main(); + } xtf_report_status(); diff --git a/include/xtf/report.h b/include/xtf/report.h index 6ec5047..3d08fb0 100644 --- a/include/xtf/report.h +++ b/include/xtf/report.h @@ -67,6 +67,11 @@ void xtf_failure(const char *fmt, ...) __printf(1, 2); */ void xtf_report_status(void); +/** + * Query whether a status has already been reported. + */ +bool xtf_status_reported(void); + #endif /* XTF_REPORT_H */ /* diff --git a/include/xtf/test.h b/include/xtf/test.h index e763998..778090c 100644 --- a/include/xtf/test.h +++ b/include/xtf/test.h @@ -33,6 +33,12 @@ extern bool xtf_has_fep; */ extern bool test_wants_user_mappings; +/** + * Boolean indicating whether the test is entirely predicated on the available + * of the Force Emulation Prefix. + */ +extern bool test_needs_fep; + #endif /* XTF_TEST_H */ /* diff --git a/tests/xsa-123/main.c b/tests/xsa-123/main.c index 92c80f2..7ed3876 100644 --- a/tests/xsa-123/main.c +++ b/tests/xsa-123/main.c @@ -29,15 +29,14 @@ */ #include +bool test_needs_fep = true; + void test_main(void) { unsigned long src = 0x1234, dest = 0; printk("XSA-123 PoC\n"); - if ( !xtf_has_fep ) - return xtf_error("Error: FEP not available\n"); - asm volatile(_ASM_XEN_FEP /* Explicit %cs segment override. */ ".byte 0x2e;"