简体   繁体   中英

What should be Memory Protection Strategy for ARM Cortex CPU?

I need to implement a multitasking system with MPU for ARM Cortex M3/M4 processors.

In that system, there will be a Kernel which manages resource in Privileged mode and user applications in Unprivilege mode. And I want to seperate User Application from rest of it and system resources.

Therefore, when I switch to a new task, I am releasing Stack and Global Memory area of user application. It can be done easily using ARM Cortex MPU registers.

But problem is that, when a context switching is occurred, I need to use also some global variables of Kernel.

For example, I am calling a function to get next TCB in PendSV Handler during context switching but task pool is out of user app area and it is protected from user application.

So, it seems there should be balance, right? What are the secure and efficient strategies for memory protection?

Privilieged mode can be raised before context switching when Yield function is called but it does not seem a good solution.

What are the general strategies on that issue?

Perhaps you might take a look at an existing open source implementation and see what design decisions were made there. FreeRTOS for example has Cortex-M MPU support here ; it may not answer your exact question directly and you may have to inspect the source code to get complete details.

Possibly divide the data memory into three regions - user, kernel and shared.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM