简体   繁体   English

什么是ARM Cortex CPU的内存保护策略?

[英]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. 我需要用MPU为ARM Cortex M3 / M4处理器实现多任务系统。

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. 我想将User Application与其他应用程序和系统资源分开。

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. 使用ARM Cortex MPU寄存器可以轻松完成此操作。

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. 例如,我正在调用一个函数来在上下文切换期间在PendSV Handler中获取下一个TCB,但是任务池超出了用户应用程序区域,并且受到了用户应用程序的保护。

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. 当调用Yield函数时,可以在上下文切换之前提升特权模式,但这似乎不是一个好的解决方案。

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 ; 例如,FreeRTOS 在这里具有Cortex-M MPU支持。 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. 可能将数据存储器分为三个区域-用户,内核和共享。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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