samples: remove mpu_stack_guard_test
This old "test" has been superseded by test cases in tests/kernel/mem_protect. Fixes: #14870 Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
710adac50d
commit
9a8f7451fe
6 changed files with 0 additions and 201 deletions
|
@ -1,7 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.13.1)
|
||||
|
||||
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
|
||||
project(mpu_stack_guard_test)
|
||||
|
||||
FILE(GLOB app_sources src/*.c)
|
||||
target_sources(app PRIVATE ${app_sources})
|
|
@ -1,76 +0,0 @@
|
|||
.. _mpu_stack_guard_test:
|
||||
|
||||
MPU Stack Guard Test
|
||||
####################
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
This is a simple application that demonstrates basic thread stack guarding on
|
||||
the supported platforms.
|
||||
A thread spawned by the main task recursively calls a function that fills the
|
||||
thread stack up to where it overwrites a preposed canary.
|
||||
If the MPU is enabled and the Stack Guard feature is present the test succeeds
|
||||
because an MEM Faults exception prevents the canary from being overwritten.
|
||||
If the MPU is disabled the test fails because the canary is overwritten.
|
||||
|
||||
Building and Running
|
||||
********************
|
||||
|
||||
This project outputs to the console.
|
||||
To build the test with the MPU disabled:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/mpu/mpu_stack_guard_test
|
||||
:board: frdm_k64f
|
||||
:goals: build flash
|
||||
:compact:
|
||||
|
||||
To build the test with the MPU enabled and the stack guard feature present:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/mpu/mpu_stack_guard_test
|
||||
:board: frdm_k64f
|
||||
:conf: prj_stack_guard.conf
|
||||
:goals: build flash
|
||||
:compact:
|
||||
|
||||
Sample Output
|
||||
=============
|
||||
|
||||
With the MPU enabled but the stack guard feature disabled:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
***** Booting Zephyr OS v1.13.0-rc1-14-gd47fada *****
|
||||
STACK_ALIGN 0x8
|
||||
MPU STACK GUARD Test
|
||||
Canary Initial Value = 0xf0cacc1a threads 0x20000ff8
|
||||
Canary = 0x20000128 Test not passed.
|
||||
***** BUS FAULT *****
|
||||
Instruction bus error
|
||||
NXP MPU error, port 3
|
||||
Mode: Supervisor, Instruction Address: 0x20001030
|
||||
Type: Read, Master: 0, Regions: 0x8800
|
||||
***** Hardware exception *****
|
||||
Current thread ID = 0x20000ff8
|
||||
Faulting instruction address = 0x20001030
|
||||
Fatal fault in essential thread! Spinning...
|
||||
|
||||
With the MPU enabled and the stack guard feature enabled:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
***** Booting Zephyr OS v1.13.0-rc1-14-gd47fada *****
|
||||
STACK_ALIGN 0x20
|
||||
MPU STACK GUARD Test
|
||||
Canary Initial Value = 0xf0cacc1a threads 0x20001100
|
||||
***** BUS FAULT *****
|
||||
Stacking error
|
||||
NXP MPU error, port 3
|
||||
Mode: Supervisor, Data Address: 0x200011b0
|
||||
Type: Write, Master: 0, Regions: 0x8400
|
||||
***** Hardware exception *****
|
||||
Current thread ID = 0x20001100
|
||||
Faulting instruction address = 0x0
|
||||
Fatal fault in thread 0x20001100! Aborting.
|
|
@ -1 +0,0 @@
|
|||
CONFIG_STDOUT_CONSOLE=y
|
|
@ -1,3 +0,0 @@
|
|||
CONFIG_STDOUT_CONSOLE=y
|
||||
CONFIG_HW_STACK_PROTECTION=y
|
||||
CONFIG_LOG=y
|
|
@ -1,29 +0,0 @@
|
|||
sample:
|
||||
name: MPU Stack Guard
|
||||
tests:
|
||||
sample.mpu:
|
||||
tags: mpu stackguard
|
||||
harness: console
|
||||
# We do not handle segfaults here
|
||||
arch_whitelist: arm
|
||||
platform_exclude: qemu_cortex_m3
|
||||
harness_config:
|
||||
type: multi_line
|
||||
ordered: false
|
||||
regex:
|
||||
- "Fatal fault in .*thread"
|
||||
- "STACK_ALIGN.*"
|
||||
- "Canary Initial Value = 0x[0-9a-f]+ threads 0x[0-9a-f]+"
|
||||
sample.mpu.stack_guard:
|
||||
arch_whitelist: arm
|
||||
extra_args: CONF_FILE=prj_stack_guard.conf
|
||||
filter: CONFIG_MPU_STACK_GUARD
|
||||
tags: mpu stackguard
|
||||
harness: console
|
||||
harness_config:
|
||||
type: multi_line
|
||||
ordered: false
|
||||
regex:
|
||||
- "Fatal fault in thread 0x[0-9a-f]+! Aborting."
|
||||
- "STACK_ALIGN.*"
|
||||
- "Canary Initial Value = 0x[0-9a-f]+ threads 0x[0-9a-f]+"
|
|
@ -1,85 +0,0 @@
|
|||
/* main.c - Hello World demo */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2014 Wind River Systems, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <misc/printk.h>
|
||||
|
||||
/* size of stack area used by each thread */
|
||||
#define STACKSIZE 512
|
||||
|
||||
/* scheduling priority used by each thread */
|
||||
#define PRIORITY 7
|
||||
|
||||
/* delay between greetings (in ms) */
|
||||
#define SLEEPTIME 500
|
||||
|
||||
/* delay between greetings (in ms) */
|
||||
#define SCHEDTIME 30
|
||||
|
||||
/* Focaccia tastes better than DEEDBEEF ;-) */
|
||||
#define STACK_GUARD_CANARY 0xF0CACC1A
|
||||
|
||||
struct stack_guard_buffer {
|
||||
/* Make sure canary is not optimized by the compiler */
|
||||
struct k_thread thread;
|
||||
volatile u32_t canary;
|
||||
K_THREAD_STACK_MEMBER(stack, STACKSIZE);
|
||||
};
|
||||
|
||||
#define LAST_THREAD_NUM 6
|
||||
struct stack_guard_buffer buf[LAST_THREAD_NUM+1];
|
||||
|
||||
u32_t recursive_loop(u32_t counter, int num, void *dummy)
|
||||
{
|
||||
|
||||
if (buf[num].canary != STACK_GUARD_CANARY) {
|
||||
printk("Canary = 0x%08x\tTest not passed.\n", buf[num].canary);
|
||||
|
||||
while (1) {
|
||||
k_sleep(SLEEPTIME);
|
||||
}
|
||||
}
|
||||
counter++;
|
||||
if (dummy == 0)
|
||||
return counter;
|
||||
return recursive_loop(counter, num, dummy)
|
||||
+recursive_loop(counter, num, dummy);
|
||||
}
|
||||
|
||||
|
||||
/* stack_guard_thread is a dynamic thread */
|
||||
void stack_guard_thread(void *dummy1, void *dummy2, void *dummy3)
|
||||
{
|
||||
ARG_UNUSED(dummy1);
|
||||
recursive_loop(0, (int)dummy1, dummy2);
|
||||
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
int i;
|
||||
bool failed;
|
||||
|
||||
printk("STACK_ALIGN 0x%x\n", STACK_ALIGN);
|
||||
for (i = 0; i <= LAST_THREAD_NUM; i++) {
|
||||
buf[i].canary = STACK_GUARD_CANARY;
|
||||
failed = (i == LAST_THREAD_NUM) ? true : false;
|
||||
if (failed) {
|
||||
printk("MPU STACK GUARD Test\n");
|
||||
printk("Canary Initial Value = 0x%x threads %p\n",
|
||||
buf[i].canary, &buf[i].thread);
|
||||
}
|
||||
|
||||
/* create stack_guard_thread */
|
||||
k_thread_create(&buf[i].thread, buf[i].stack,
|
||||
K_THREAD_STACK_SIZEOF(buf[i].stack),
|
||||
stack_guard_thread, (void *)i,
|
||||
(void *)failed, NULL, PRIORITY, 0, K_NO_WAIT);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue