首页 > 其他分享 >OS-Memory Protection

OS-Memory Protection

时间:2024-11-14 16:15:37浏览次数:3  
标签:Area area Read Data Memory Protection memory protected OS

OS uses memory protection facilities of a processor to achieve freedom from interference between OS applications and cores. For this purpose it may use the memory protection units (MPU) which are responsible for monitoring all memory accesses made by CPU and/or peripheral devices and triggering an exception upon detection of an illegal memory access.

Illegal memory access by non-trusted OSAP is called a memory protection violation. When a memory protection violation is detected, the ProtectionHook is called with status code E_OS_PROTECTION_MEMORY. [SWS_Os_00044]

Note: Freedom from Interference (FFI) is one of the critical criteria to support coexistence of elements with different criticality in a mixed-criticality system (MCS). The principle of FFI is to ensure an element with lower criticality cannot influence an element with higher criticality.

Memory Protection Unit (MPU)

 A Memory Protection Unit (MPU) enables memory partitioning with individual protection attributes. This is distinct from a Memory Management Unit (MMU) that provides a mapping between virtual addresses and physical memory locations at runtime. Note that some devices may realize the functionality of an MPU in an MMU.

Overview of protection for memory areas

The memory area to be accessed is first divided into sections in the object file by the compiler. This is the pre-link section. By defining the MPS to which the section before each link is to be placed in the configuration and inputting it to the OS generator, the OS generator generates an information file (linker script, etc.) used as the input of the linker. Then, the linker arranges each section that should be protected in the same way as a memory protection section based on the information in the linker script. Each memory protection section contains one or more post-link sections. The memory protection function uses the information in this memory protection section for control.

 

Classification of memory area

No.Memory AreaOsAppMpsRefWriteableReadableExecutableShortData
aPrivate Code AreaVALIDFALSEPRIVATETRUEFALSE
eShared Code Area-FALSESHAREDTRUEFALSE
bPrivate Read-only Data AreaVALIDFALSEPRIVATEFALSEFALSE
hPrivate Read-only Short Data AreaVALIDFALSEPRIVATEFALSETRUE
fShared Read-only Data Area-FALSESHAREDFALSEFALSE
kShared Read-only Short Data Area-FALSESHAREDFALSETRUE
cPrivate Read/Write Data AreaVALIDTRUEPRIVATEFALSEFALSE
iPrivate Read/Write Short Data AreaVALIDTRUEPRIVATEFALSETRUE
gShared Read/Write Data Area-TRUESHAREDFALSEFALSE
lShared Read/Write Short Data Area-TRUESHAREDFALSETRUE
dShared Read Private Write Data AreaVALIDTRUESHAREDFALSEFALSE
jShared Read Private Write Short Data AreaVALIDTRUESHAREDFALSETRUE
mLink Only Section-FALSENO_READFALSE-
Link Only Section

As a special memory protection section, it is a post-link section that is placed in the memory by the linker and is not protected by the OS (not set in the protected area of the MPU). It is supposed to be used to link startup routines and exception vector tables.

Addressing section

 A memory protection section with a specific name used to specify the base address of a short data area. Only OsMemoryProtectSectionStartAddress can be specified.

Memory area type

The memory area to be accessed is explained by dividing it into the following two.
1) OSAP memory area and shared memory area
2) OS memory area

OSAP memory area and shared memory area
Memory area to be accessedWRX
Memory area belonging to
the same non-trusted OSAP
Stack of the same task×
Stack of different tasks×××
Private Code Area×
Private Read-only (Short) Data Area×
Private Read/Write (Short) Data Area×
Shared Read Private Write (Short) Data Area×
Memory area belonging to
a different non-trusted OSAP
Stack×××
Private Code Area×××
Private Read-only (Short) Data Area×××
Private Read/Write (Short) Data Area×××
Shared Read Private Write (Short) Data Area××
Shared memory areaShared Code Area×
Shared Read-only (Short) Data Area×
Shared Read/Write (Short) Data Area×

                                                                        ✔: Access allowed,  ×: Access prohibited,  ※: Target dependent

OS memory area

The Operating System module shall prevent write access to its own data sections and its own stack from non-trusted OS-Applications. [SWS_Os_00198]
The OS shall offer the possibility to restrict write access of trusted OS-Applications in the same way as it is done for non-trusted OS-Applications. [SWS_Os_00795]

The OS prohibits non-trusted OSAPs read, write, and execute access to the OS memory area.

Standard ROM/RAM region 

In the configuration, the memory region used as the standard ROM area is called the standard ROM region, and the memory region used as the standard RAM area is called the standard RAM region, and each is specified at the time of configuration.

Standard ROM region 

The standard ROM region is specified by OsStandardRomRegionRef. It is used for the following purposes.

  • Place the initial value area (when neither OsInitialDataMemoryRegionRef nor OsInitialDataStartAddress is set).
  • Place a section (.secinfo) containing information for memory initialization [GHS].
Standard RAM region

The standard RAM region is specified by OsStandardRamRegionRef. It is used for the following purposes.

  • When allocating the user stack area for non-trusted tasks with the OS generator, allocate it in the standard RAM region.

Maximum number of protected areas

Since the number of protected areas of the MPU has an upper limit, as a result of configuring MPS and MPA, if the number of protected areas required to operate one non-trusted OSAP or the number of protected areas shared by all OSAPs exceeds the upper limit of the target, the OS generator detects an error.

The upper limit of the protected area in ARMv8-R is as follows.

  • Cortex-R52_FVP: 16

Optimization of the number of protected areas

When using short data, as an optimization to reduce the number of protected areas of the MPU used, memory protection sections that should be protected in the same way are continuously arranged across the boundary between the short data area and the non-short data area. Specifically, by arranging the "Shared Read-only Data Area" and the "Shared Read-only Short Data Area", and the "Shared Read/Write Data Area" and the "Shared Read/Write Short Data Area" in succession, each is set as one in the protected area of MPU. In addition, the SRPW area of other OSAPs is a data area that can only be read, and is protected in the same way as the shared read-only (short) data area. For this reason, by arranging the SRPW area for each OSAP, and the "Shared Read-only Data Area" and the "Shared Read-only Short Data Area" consecutively, the read-only data area is set to 1 to 3 as the protected area of the MPU. The number of protected areas to be combined depends on whether the microcomputer can overlap the protected areas of the MPU and whether it supports short data.

MPU that can overlap protected areas

If short data is not supported, the entire SRPW area can be combined into one and set as the protected area of the MPU. In this case, when switching OSAP, it is not necessary to switch the setting of the protected area of MPU related to read access, so high-speed processing can be performed. In addition, one MPU protected area is used for write access to its own SRPW area.

 

When short data is supported, another MPU protection area is required because the SRPW area supports the short data of the own OSAP.

MPU that cannot overlap protected areas

 If short data is not supported, the read-only data area can be combined into two and set as the protected area of the MPU. In addition, one MPU protection area is used for the SRPW area of the own OSAP.

 

When supporting short data, a total of five MPU protection areas are required, three for the read-only data area and two for the SRPW data area and the SRPW short data area of the own OSAP.

ARMv8-R does not support short data and cannot overlap protected areas.

Access right check for memory area

API / MACRODescription
CheckISRMemoryAccessThis service checks if a memory region is write/read/execute accessible and also returns information if the memory region is part of the stack space.
CheckTaskMemoryAccessThis service checks if a memory region is write/read/execute accessible and also returns information if the memory region is part of the stack space.
OSMEMORY_IS_READABLEThese macros return a value not equal to zero if the memory is readable / writable / executable or stack space.
The argument of the macros must be of type AccessType.
Typically the return value of the service CheckTaskMemoryAccess (or CheckISRMemoryAccess) is used as argument for these macros.
OSMEMORY_IS_WRITEABLE
OSMEMORY_IS_EXECUTABLE
OSMEMORY_IS_STACKSPACE

标签:Area,area,Read,Data,Memory,Protection,memory,protected,OS
From: https://blog.csdn.net/erroror/article/details/143773448

相关文章

  • note centos初始化
    网卡编辑/etc/sysconfig/network-scripts/目录下BOOTPROTO="static"#也就是将dhcp改为staticONBOOT=“yes”#将网卡设置为开机启用IPADDR=192.168.12.230#静态IPGATEWAY=192.168.12.1#默认网关NETMASK=255.255.255.0#子网掩码DNS1=192.168.12.1#DNS配置......
  • windows 设置nacos开机自启 并后台运行
    windows安装目录D:\nacos路径根据实际情况调整下面脚本路径在当前目录下创建nacos.bat@echooffechoStartingNacosat%DATE%%TIME%>>D:\nacos\nacos_startup.logD:CDD:\nacos\binstart""/bcmd/c"startup.cmd>D:\nacos\nacos_output.log2>&......
  • .NET 8 强大功能 IHostedService 与 BackgroundService 实战
    前言在.NET8中,IHostedService和BackgroundService两个核心接口的引入,增强了项目开发中处理定时任务的能力。这两个接口不仅简化了定时任务、后台处理作业以及定期维护任务的实现过程,还提升了在ASP.NETCore或任何基于.NET的宿主应用程序中的集成与管理效率。IHostedService......
  • Grafana:监控PostgreSQL数据运维新利器
    在数据驱动的业务环境中,数据库的性能监控是确保数据流畅和系统稳定的关键。PostgreSQL,作为强大的开源关系型数据库,其性能监控尤为重要。Grafana,一个开源的数据可视化和监控平台,提供了一个直观的界面来监控和分析数据。本文将带您了解如何利用Grafana来监控PostgreSQL,让您的数据库......
  • 爬虫开发工具与环境搭建——使用Postman和浏览器开发者工具
    第三节:使用Postman和浏览器开发者工具在网络爬虫开发过程中,我们经常需要对HTTP请求进行测试、分析和调试。Postman和浏览器开发者工具(特别是Network面板和Console面板)是两种最常用的工具,能够帮助开发者有效地捕获、分析和调试HTTP请求与响应,从而使爬虫的开发过程更加顺利。1.......
  • Greenlight - Choosing a router
    We’regoingtousethepopularthird-partypackagehttprouterastherouterfor ourapplication,insteadofusinghttp.ServeMuxfromthestandard-library.Therearetworeasonsforthis:WewantourAPItoconsistentlysendJSONresponseswhereverpossib......
  • hostapd移植到RK356X
    1.简介开发环境:Ubuntu20.04目标平台:RK356X,内核版本:4.19.234hostapd版本:2.10,依赖特定版本的openssl和libnlopsnssl版本:3.0.15libnl版本:3.2.32.openssl移植hostapd依赖openssl,需要先移植openssl获取openssl源码,选择使用3.0.15版本,链接如下http......
  • 三步解决error: Microsoft Visual C++ 14.0 or greater is required. Get it with “M
    文章目录前言一、问题描述二、报错信息三、解决步骤1.下载并安装MicrosoftVisualC++BuildTools2.配置系统环境变量3.重新运行安装指令四、安装成功总结前言本文记录了在使用AnacondaPrompt安装Python程序包时遇到的报错问题,并详细描述了如何通过安装Micros......
  • HarmonyOS NEXT开发实战教程-记账app
    今天分享的实战教程是一款记账app,最近分享的项目都是纯页面,没有服务端,没有数据接口,因为鸿蒙开发主要就是写页面,都是前端嘛。如果有友友想要完整的项目可以找幽蓝君定制,想学服务端开发的话幽蓝君也可以写。话不多说,看一下记账app的效果图: 下面为大家分享本项目的开发教程,其实......
  • 占用资源极低!这款轻量级 Nacos 性能炸裂!
    大家好,我是Java陈序员。在开发中,Nacos作为一款非常流行的微服务配置中心、注册中心,在构建微服务项目时往往会使用到它。但是对于个人开发者而言,云服务器资源有限,往往无法撑起Nacos服务的高内存使用!今天,给大家介绍一款轻量级的Nacos服务,功能平替,占用资源极低!关注微信公......