1.. _mpu_userspace: 2 3MPU Backed Userspace 4#################### 5 6The MPU backed userspace implementation requires the creation of a secondary 7set of stacks. These stacks exist in a 1:1 relationship with each thread stack 8defined in the system. The privileged stacks are created as a part of the 9build process. 10 11A post-build script :ref:`gen_kobject_list.py` scans the generated 12ELF file and finds all of the thread stack objects. A set of privileged 13stacks, a lookup table, and a set of helper functions are created and added 14to the image. 15 16During the process of dropping a thread to user mode, the privileged stack 17information is filled in and later used by the swap and system call 18infrastructure to configure the MPU regions properly for the thread stack and 19guard (if applicable). 20 21During system calls, the user mode thread's access to the system call and the 22passed-in parameters are all validated. The user mode thread is then elevated 23to privileged mode, the stack is switched to use the privileged stack, and the 24call is made to the specified kernel API. On return from the kernel API, the 25thread is set back to user mode and the stack is restored to the user stack. 26