[PATCH] Strict thread-stack isolation

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Jul 14 07:43:32 UTC 2020


Hello Utkarsh,

if you look a the stuff you added to the score and compare it with 
something existing in the score, do you notice differences in the naming 
conventions and the code format? Have you looked at

https://docs.rtems.org/branches/master/eng/coding.html

?

On 13/07/2020 18:33, Utkarsh Rai wrote:
> - This is the complete set of changes for strict isolation of thread stacks.
> - There needs to be a confiuration operation,(#if defined(USE_THREAD_STACK_PROTECTION) for simple configuration can be used)
> - The stack attributes are allocated through malloc, this needs to be done through score unlimited objects.
> ---
>   bsps/arm/headers.am                           |   1 +
>   .../include/bsp/arm-cp15-set-ttb-entries.h    |   7 +
>   .../shared/cp15/arm-cp15-set-ttb-entries.c    |   3 +
>   bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c   |  72 +++++++++
>   bsps/shared/start/stackalloc.c                |  20 ++-
>   c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am  |   5 +-
>   cpukit/Makefile.am                            |   1 +
>   cpukit/headers.am                             |   2 +
>   cpukit/include/rtems/score/memorymanagement.h |  22 +++
>   cpukit/include/rtems/score/stackmanagement.h  |  49 ++++++
>   cpukit/score/cpu/arm/cpu.c                    |   3 +
>   cpukit/score/cpu/arm/cpu_asm.S                |  22 ++-
>   .../score/cpu/arm/include/rtems/score/cpu.h   |  20 +++
>   cpukit/score/src/stackmanagement.c            | 143 ++++++++++++++++++
>   14 files changed, 365 insertions(+), 5 deletions(-)
>   create mode 100644 bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
>   create mode 100644 bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
>   create mode 100644 cpukit/include/rtems/score/memorymanagement.h
>   create mode 100644 cpukit/include/rtems/score/stackmanagement.h
>   create mode 100644 cpukit/score/src/stackmanagement.c
>
> diff --git a/bsps/arm/headers.am b/bsps/arm/headers.am
> index 3d2b09effa..b1e86f3385 100644
> --- a/bsps/arm/headers.am
> +++ b/bsps/arm/headers.am
> @@ -15,6 +15,7 @@ include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-a9mpcore-clock.h
>   include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-a9mpcore-irq.h
>   include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-a9mpcore-regs.h
>   include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-a9mpcore-start.h
> +include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
>   include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-cp15-start.h
>   include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-errata.h
>   include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-gic-irq.h
> diff --git a/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h b/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> new file mode 100644
> index 0000000000..39170927da
> --- /dev/null
> +++ b/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> @@ -0,0 +1,7 @@
> +#include<bsp/arm-cp15-start.h>
> +
> +uint32_t arm_cp15_set_translation_table_entries(
> +  const void *begin,
> +  const void *end,
> +  uint32_t section_flags
> +);
> \ No newline at end of file
Why did you add this header file?
> diff --git a/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c b/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> index 507277dca1..f5d0494167 100644
> --- a/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> +++ b/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> @@ -14,6 +14,7 @@
>   
>   #include <rtems.h>
>   #include <libcpu/arm-cp15.h>
> +#include <bsp/arm-cp15-set-ttb-entries.h>
>   #include <bspopts.h>
>   
>   /*
> @@ -30,6 +31,8 @@
>    * ARM DDI 0406C.b (ID072512)
>    */
>   
> +#define ARM_MMU_USE_SMALL_PAGES
> +

This is the wrong place to define this define. This is supposed to be a 
BSP option.

>   static uint32_t set_translation_table_entries(
>     const void *begin,
>     const void *end,
> diff --git a/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c b/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
> new file mode 100644
> index 0000000000..978e35b86c
> --- /dev/null
> +++ b/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
> @@ -0,0 +1,72 @@
> +#include <bsp/arm-cp15-start.h>
> +#include <bsp/arm-cp15-set-ttb-entries.h>
> +#include <rtems/score/memorymanagement.h>
> +#include <libcpu/arm-cp15.h>
> +#include <rtems.h>
> +
> +#ifdef USE_THREAD_STACK_PROTECTION

Who defines USE_THREAD_STACK_PROTECTION?

[...]



More information about the devel mailing list