arch: arc: add user space support for arc

* add the implementation of syscall
  * based on 'trap_s' intruction, id = 3
* add the privilege stack
  * the privilege stack is allocted with thread stack
  * for the kernel thread, the privilege stack is also a
    part of thread stack, the start of stack can be configured
    as stack guard
  * for the user thread, no stack guard, when the user stack is
    overflow, it will fall into kernel memory area which requires
    kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
  saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
  interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
  specific
* the above codes have been tested through tests/kernel/mem_protect/
  userspace for MPU version 2

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
This commit is contained in:
Wayne Ren 2018-01-23 17:13:09 +08:00 committed by ruuddw
commit f81dee0b2b
28 changed files with 655 additions and 107 deletions

View file

@ -37,6 +37,16 @@
#endif
#endif
#ifdef CONFIG_ARC_MPU_ENABLE
#if CONFIG_ARC_MPU_VER == 2
#define MPU_ADDR_ALIGN . = ALIGN(2048);
#elif CONFIG_ARC_MPU_VER == 3
#define MPU_ADDR_ALIGN . = ALIGN(32);
#endif
#else
#define MPU_ADDR_ALIGN
#endif
#if defined(CONFIG_XIP)
#define _DATA_IN_ROM __data_rom_start
#else
@ -108,7 +118,9 @@ SECTIONS {
} GROUP_LINK_IN(ROMABLE_REGION)
_image_rodata_end = .;
MPU_ADDR_ALIGN
_image_rom_end = .;
_image_rom_size = _image_rom_end - _image_rom_start;
GROUP_END(ROMABLE_REGION)
@ -117,6 +129,7 @@ SECTIONS {
#ifdef CONFIG_APPLICATION_MEMORY
SECTION_DATA_PROLOGUE(_APP_DATA_SECTION_NAME, (OPTIONAL),)
{
MPU_ADDR_ALIGN
__app_ram_start = .;
__app_data_ram_start = .;
_image_ram_start = .;
@ -142,12 +155,19 @@ SECTIONS {
{
APP_INPUT_SECTION(.noinit)
APP_INPUT_SECTION(".noinit.*")
/*
* for MPU v2,the application memory section must be aligned to the size of
* section
*/
MPU_ADDR_ALIGN
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
__app_ram_end = .;
__app_ram_size = __app_ram_end - __app_ram_start;
#endif /* CONFIG_APPLICATION_MEMORY */
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),) {
MPU_ADDR_ALIGN
/*
* For performance, BSS section is assumed to be 4 byte aligned and
* a multiple of 4 bytes
@ -204,6 +224,8 @@ SECTIONS {
__data_ram_end = .;
MPU_ADDR_ALIGN
/* Define linker symbols */
_image_ram_end = .;
_end = .; /* end of image */