From e55fd562ec562f1493b1bb5efe65266419f62f7d Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Wed, 5 Jul 2017 14:32:32 -0700 Subject: [PATCH] tests: protection: don't do exec tests on x86 The IA32 MMU has no concept of a "no execute" flag, this is unfortunately only implemented in x86_64. Signed-off-by: Andrew Boie --- tests/kernel/protection/src/main.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/kernel/protection/src/main.c b/tests/kernel/protection/src/main.c index 258e0b0246c..7176c717c64 100644 --- a/tests/kernel/protection/src/main.c +++ b/tests/kernel/protection/src/main.c @@ -48,11 +48,20 @@ void _SysFatalErrorHandler(unsigned int reason, const NANO_ESF *pEsf) #define DO_BARRIERS() do { } while (0) #endif +#if defined(CONFIG_ARM) +#define NO_EXECUTE_SUPPORT 1 +#elif defined(CONFIG_X86) +/* i386 MMU doesn't control execute capabilities, only on x86_64 */ +#else +#error "Architecture not supported" +#endif + static int __attribute__((noinline)) add_one(int i) { return (i + 1); } +#ifdef NO_EXECUTE_SUPPORT static void execute_from_buffer(u8_t *dst) { void *src = FUNC_TO_PTR(add_one); @@ -79,6 +88,7 @@ static void execute_from_buffer(u8_t *dst) INFO("Did not get expected return value!\n"); } } +#endif static void write_ro(void) { @@ -130,6 +140,7 @@ static void write_text(void) zassert_unreachable("Write to text did not fault"); } +#ifdef NO_EXECUTE_SUPPORT static void exec_data(void) { execute_from_buffer(data_buf); @@ -154,17 +165,20 @@ static void exec_heap(void) zassert_unreachable("Execute from heap did not fault"); } #endif +#endif /* NO_EXECUTE_SUPPORT */ void test_main(void *unused1, void *unused2, void *unused3) { ztest_test_suite(test_protection, - ztest_unit_test(write_ro), - ztest_unit_test(write_text), +#ifdef NO_EXECUTE_SUPPORT ztest_unit_test(exec_data), - ztest_unit_test(exec_stack) + ztest_unit_test(exec_stack), #if (CONFIG_HEAP_MEM_POOL_SIZE > 0) - , ztest_unit_test(exec_heap) + ztest_unit_test(exec_heap), #endif +#endif /* NO_EXECUTE_SUPPORT */ + ztest_unit_test(write_ro), + ztest_unit_test(write_text) ); ztest_run_test_suite(test_protection); }