armv8 mmu Memory access control

内存访问控制

D5.4 Memory access control

The access control fields in the translation table descriptors determine whether the PE, in its current state, is permitted to perform the required access to the output address given in the translation table descriptor. If a translation stage does not permit the access then an MMU fault is generated for that translation stage, and no memory access is performed. 页表项中的内存访问权限,如果一个内存访问权限不对,会触发一个MMU fault

In addition to an output address, a translation table entry that refers to a page or region of memory includes fields that define properties of the target memory region. These fields can be classified as address map control, access control, and region attribute fields. Control of Secure or Non-secure memory access on page D5-2605 describes the address map control, and Memory region attributes on page D5-2628 describes the other fields.

地址映射control,访问控制和内存区域属性

D5.4.1 About access permissions

The translation table descriptors include fields that define access permissions for data accesses and for instruction fetches. This section introduces those fields. In addition:

• System register controls can prevent execution from writable locations, see Preventing execution from writable locations on page D5-2617.

For the effect of disabling a stage of address translation on the access permissions see The effects of disabling a stage of address translation on page D5-2586. 关闭MMU后对权限的影响

• From Armv8.1, the PSTATE.PAN bit can affect the access permissions for privileged data accesses, see About PSTATE.PAN on page D5-2607.

• From Armv8.2, the PSTATE.UAO bit can affect the access permissions for unprivileged instructions, see About PSTATE.UAO on page D5-2608.

The access permission bits control access to the corresponding memory region. The VMSAv8-64 translation table

format:

• In stage 1 translations, uses AP[2:1] to define the data access permissions, see The AP[2:1] data access permissions, for stage 1 translations on page D5-2610.  对于stage1,AP[2:1]来表示访问权限

• In stage 2 translations, uses S2AP[1:0] to define the data access permissions, see The S2AP data access permissions, Secure or Non-secure EL1&0, when EL2 is enabled, translation regime on page D5-2611. 对于stage2,S2AP[2:1]来表示访问权限

• Uses the UXN, XN and PXN fields to define access controls for instruction fetches, see Access permissions for instruction execution on page D5-2612. 使用UXN,XN和PXN来控制指令的预取

An attempt to perform a memory access that the translation table access permission bits do not permit generates a Permission fault, for the corresponding stage of translation 访问了没有正确权限的内存,触发访问权限fault

D5.4.2 About PSTATE.PAN

When the value of PSTATE.PAN is 1, any privileged data access from EL1, or EL2 when HCR_EL2.E2H is 1, to a virtual memory address that is accessible at EL0, generates a Permission fault. 当PSTATE.PAN = 1时,在特权模式下访问用户模式下的地址会触发一个Permission fault

当异常发生时,SPSR_ELx.PAN保存到PSTATE.PAN中

On an exception return from AArch64 state:

• SPSR_ELx.PAN is copied to PSTATE.PAN, when the target Exception level is in AArch64 state.

• SPSR_ELx.PAN is copied to CPSR.PAN, when the target Exception level is in AArch32 state.

D5.4.3 About PSTATE.UAO

When the value of PSTATE.UAO is 1, a Load/Store unprivileged instruction executed at EL1, or executed at EL2

when the Effective value of HCR_EL2.{E2H, TGE} is {1, 1} is subject to the memory access permissions that apply to the Exception level at which it is executed, rather than being subject to the EL0 access permissions. This means the Load/Store unprivileged instruction is subject to the same access permissions as the corresponding Load/Store register instruction. See Load/Store unprivileged on page C3-213 and Load/Store register on page C3-209.

如果UAO=1,在EL1中执行非特权模式下的ldr/str指令,这时候的内存访问权限会根据正在执行的EL权限来分,而不是EL0的访问权限。即权限会被提升到EL1或者EL2

D5.4.5 Data access permission controls

主要讲述AP的访问权限的使用

The AP[2:1] data access permissions, for stage 1 translations

In VMSAv8-64, for a translation regime that applies to both EL0 and a higher Exception level, the AP[2:1] bits

control the stage 1 data access permissions, and:

AP[2]

Selects between read-only and read/write access.

AP[1]

Selects between Application level (EL0) control and the higher Exception level control.

Selects between Application level (EL0) control and the higher Exception level control.

AP2: 只读或者可读可写?

AP1: 只能在用户空间执行?还是用户空间和内核空间都执行?

查看下图便知道:

APtable是"指向下一级页表"的页表项里的属性,如下图:

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

byd yes

你的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值