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 <andrew.p.boie@intel.com>
This commit is contained in:
parent
ed1962a65c
commit
e55fd562ec
1 changed files with 18 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue