armv8 mmu 内存页表属性

armv8中的页表项

D5.3 VMSAv8-64 translation table format descriptors

In general, a descriptor is one of: 页表项的4种类型

• An invalid or fault entry. 有效的或者无效的页表项

• A table entry, that points to the next-level translation table. 指向下一级的页表项

• A block entry, that defines the memory properties for the access. 块页表项

• A reserved format. 保留的页表项

Bit[1] of the descriptor indicates the descriptor type, and bit[0] indicates whether the descriptor is valid. bit1表示页表项的类型,bit0表示这个页表项有效还是无效

介绍L0/L1/L2页表项的格式

D5.3.1 VMSAv8-64 translation table level 0, level 1, and level 2 descriptor formats

上图展示了L0/L1/L2页表的三种类型。

Descriptor encodings, Armv8 level 0, level 1, and level 2 formats

Descriptor bit[0] identifies whether the descriptor is valid, and is 1 for a valid descriptor. If a lookup returns an

invalid descriptor, the associated input address is unmapped, and any attempt to access it generates a Translation fault.

Descriptor bit[1] identifies the descriptor type, and is encoded as:

0, Block

The descriptor gives the base address of a block of memory, and the attributes for that memory

region.

1, Table

The descriptor gives the address of the next level of translation table, and for a stage 1 translation,

some attributes for that translation.

The other fields in the valid descriptors are:

Block descriptor

Gives the base address and attributes of a block of memory, as follows:

4KB translation granule

• For a level 1 Block descriptor, bits[47:30] are bits[47:30] of the output address.

This output address specifies a 1GB block of memory.

• For a level 2 descriptor, bits[47:21] are bits[47:21] of the output address.This

output address specifies a 2MB block of memory.

16KB translation granule

For a level 2 Block descriptor, bits[47:25] are bits[47:25] of the output address.This

output address specifies a 32MB block of memory.

64KB translation granule

For a level 1 Block descriptor:

• If ARMv8.2-LPA is implemented, bits[15:12] are bits[51:48] of the output

address and bits[47:42] are bits [47:42] of the output address. This output address

specifies a 4TB block of memory.

• If ARMv8.2-LPA is not implemented, there is no level 1 Block descriptor.

For a level 2 Block descriptor:

• If ARMv8.2-LPA is implemented, bits[15:12] are bits[51:48] of the output

address, and bits[47:29] are bits [47:29] of the output address.This output address

specifies a 512MB block of memory.

• If ARMv8.2-LPA is not implemented, bits[47:29] are bits[47:29] of the output

address.This output address specifies a 512MB block of memory.

In Armv8.0, bits[63:52, 11:2] provide attributes for the target memory block. When

ARMv8.1-TTHM is implemented, bits[63:51, 11:2] provide the attributes for the target memory

block. For more information, see Memory attribute fields in the VMSAv8-64 translation table format

descriptors on page D5-2599.

Note

• In Armv8.0, the position and contents of bits[63:52, 11:2] are identical to bits[63:52, 11:2] in

the Page descriptors.

• When ARMv8.1-TTHM is implemented, the position and contents of bits[63:51, 11:2] are

identical to bits[63:51, 11:2] in the Page descriptors

上诉描述了block类型的页表,在不同粒度下一个block 的位宽以及能覆盖的内存大小

Table descriptor

Gives the translation table address for the next-level lookup, as follows:

4KB translation granule

  • Bits[47:12] are bits[47:12] of the address of the required next-level table, which is:

For a level 0 Table descriptor, the address of a level 1 table.

For a level 1 Table descriptor, the address of a level 2 table.

For a level 2 Table descriptor, the address of a level 3 table.

  • Bits[11:0] of the table address are zero.

16KB translation granule

  • Bits[47:14] are bits[47:14] of the address of the required next-level table, which is:

For a level 0 Table descriptor, the address of a level 1 table.

For a level 1 Table descriptor, the address of a level 2 table.

For a level 2 Table descriptor, the address of a level 3 table.

• Bits[13:0] of the table address are zero.

64KB translation granule

  •  Bits[47:16] are bits[47:16] of the address of the required next-level table, which is:

For a level 1 Table descriptor, the address of a level 2 table.

For a level 2 Table descriptor, the address of a level 3 table.

When ARMv8.2-LPA is implemented, bits[15:12] are bits[51:48] of the required

next-level table.

  • Bits[15:0] of the table address are zero.

For a stage 1 translation only, bits[63:59] provide attributes for the next-level lookup, see Memory

attribute fields in the VMSAv8-64 translation table format descriptors on page D5-2599.

If the translation table defines either the Secure or Non-secure EL1&0, when EL2 is enabled, stage 1 translations,

then the output address in the descriptor is the IPA of the target block or table. Otherwise, it is the PA of the target

block or table.

table类型的页表,在不同粒度下一个table类型指向下一级页表的地址位宽。

L3的页表格式

level 3就是linux内核中的PTE(page table entry)页表

D5.3.2 Armv8 translation table level 3 descriptor formats

 

从上图可以看出armv8架构支持5种 L3页表格式

Descriptor bit[0] identifies whether the descriptor is valid, and is 1 for a valid descriptor. If a lookup returns an

invalid descriptor, the associated input address is unmapped, and any attempt to access it generates a Translation

fault.

Descriptor bit[1] identifies the descriptor type, and is encoded as:

  • 0, Reserved, invalid

    • Behaves identically to encodings with bit[0] set to 0.

    • This encoding must not be used in level 3 translation tables.

  • 1, Page          Gives the address and attributes of a 4KB, 16KB, or 64KB page of memory.

At this level, the only valid format is the Page descriptor. The other fields in the Page descriptor are:.....

内存属性

D5.3.3 Memory attribute fields in the VMSAv8-64 translation table format descriptors

下一级页表的属性

Next-level attributes in stage 1 VMSAv8-64 Table descriptors

In a Table descriptor for a stage 1 translation, bits[63:59] of the descriptor define the attributes for the next-level

translation table access, and bits[58:51] are IGNORED:

These attributes are:(2599页)

name

describe

描述

NSTable, bit[63]

For memory accesses from Secure state, specifies the Security state for subsequent levels of lookup,

see Hierarchical control of Secure or Non-secure memory accesses on page D5-2605.

For memory accesses from Non-secure state, including all accesses in the EL2 or EL2&0 translation

regime, this bit is RES0 and is ignored by the PE.

APTable, bits[62:61]

Access permissions limit for subsequent levels of lookup, see Hierarchical control of data access

permissions on page D5-2611.

APTable[0] is RES0:

• In the EL2 translation regime.

• In the EL3 translation regime.

From Armv8.1, when ARMv8.1-HPD is implemented, this field can be disabled. When the value

of TCR_ELx.HPD{0} or TCR_ELx.HPD1 is 1:

• The value of the corresponding APTable field is IGNORED by hardware, allowing the field to

be used by software.

The behavior of the system is as if the value of the corresponding APTable field is 0.

UXNTable or XNTable, bit[60]

XN limit for subsequent levels of lookup, see Hierarchical control of instruction fetching on

page D5-2616.

The naming of this field depends on whether stage 1 of the translation regime can support two VA

ranges:

Stage 1 can support two VA ranges

This field is UXNTable, and determines whether execution at EL0 of instructions

fetched from the region identified at a lower level of lookup permitted.

Note

PXNTable is the equivalent control of execution at a higher Exception level.

Stage 1 supports only one VA range

This field is XNTable.

From Armv8.1, when ARMv8.1-HPD is implemented, this field can be disabled. When the value

of TCR_ELx.HPD{0} or TCR_ELx.HPD1 is 1:

• The value of the corresponding UXNTable field is IGNORED by hardware, allowing the field

to be used by software.

• The behavior of the system is as if the value of the corresponding UXNTable field is 0.

Note

From Armv8.3, if EL2 is enabled in the current Security state, in the EL1 translation regime, when

the value of HCR_EL2.{NV, NV1} == {1, 1}, bit[60] holds PXNTable, see Additional behaviors

when HCR_EL2.NV == 1 and HCR_EL2.NV1 == 1 on page D5-2645.

PXNTable, bit[59]

PXN limit for subsequent levels of lookup, see Hierarchical control of instruction fetching on

page D5-2616.

This field is valid only for a stage 1 translation that can support two VA ranges. It is RES0 for stage 1

translations that can support only one VA range.

From Armv8.1, when ARMv8.1-HPD is implemented, this field can be disabled. When the value

of TCR_ELx.HPD{0} or TCR_EL1.HPD1 is 1:

• The value of the corresponding PXNTable field is IGNORED by hardware, allowing the field

to be used by software.

• The behavior of the system is as if the value of the corresponding PXNTable field is 0.

Note

From Armv8.3, if EL2 is enabled in the current Security state, in the EL1&0 translation regime,

when the value of HCR_EL2.{NV, NV1} == {1, 1}, bit[59] is RES0, see Additional behaviors when

HCR_EL2.NV == 1 and HCR_EL2.NV1 == 1 on page D5-2645.

block或page的页表项的属性

分成高位和低位属性

Attribute fields in stage 1 VMSAv8-64 Block and Page descriptors

In Block and Page descriptors, the memory attributes are split into an upper block and a lower block, as shown for a stage 1 translation:

Attribute fields for VMSAv8-64 stage 1 Block and Page descriptors

名称

比特位

描述

AttrIndx[2:0]

Bit[4:2]

MAIR_ELn寄存器用来表示内存的属性,比如设备内存(Device Memory)、普通内存等。软件可以设置8个不同内存属性。常见的内存属性有:

  • 0:DEVICE_nGnRnE

  • 1:DEVICE_nGnRE

  • 2:DEVICE_GRE

  • 3:NORMAL_NC

  • 4:NORMAL

  • 5:NORMAL_WT

AttrIndex用来索引不同的内存属性

NS

Bit[5]

非安全比特位(Non-secure)。当处于安全模式时用来指定访问的内存地址是安全映射的还是非安全映射的

AP[2:1]

Bit[7:6]

数据访问权限比特位。

AP[1]:表示该内存允许用户权限(EL0)还是更高权限的特权异常等级(EL1)来访问。在Linux内核中使用PTE_USER宏来表示可以在用户态访问该页面。

  • 1:表示可以被EL0以及更高特权的异常等级访问

  • 0:表示不能被EL0访问,但是可以被EL1访问。

AP[2]: 只读权限还是可读可写权限。在Linux内核中使用PTE_RDONLY宏来表示该比特位。

  • 1:表示只读

  • 0:表示可读可写

SH

Bit[9:8]

内存缓存共享属性。在Linux内核中使用PTE_SHARED宏来表示该比特位。

  • 00:没有共享

  • 01:保留

  • 10:Outer Shareable

  • 11:Inner Shareable

AF

Bit[10]

访问比特位(access flag)。Linux内核使用PTE_AF宏来表示该比特位。

当第一次访问页面时硬件会自动设置这个访问比特位。

nG

Bit[11]

非全局比特位(the not global bit)。Linux内核使用PTE_NG宏来表示该比特位。

这个比特位用于TLB管理。TLB的表项分成全局的和进程持有的。当设置该比特位时表示这个页面对应的TLB表项是进程持有的。

nT

Bit[16]

块类型(Block)的页表项(block translation entry)

DBM

Bit[51]

脏比特位(Dirty Bit Modifier)。Linux内核使用PTE_DBM宏来表示该比特位

Contiguous

Bit[52]

表示当前页表项处在一个连续物理页面集合中,可以使用一个单一的TLB表项进行优化。

Linux内核使用PTE_CONT宏来表示该比特位。

PXN

Bit[53]

The Privileged execute-never field,表示该页面在特权模式下不能执行。

Linux内核使用PTE_PXN宏来表示该比特位。

XN/UXN

Bit[54]

The Execute-never or Unprivileged execute-never field. XN表示该页面在任何模式下都不能执行。UXN表示该页面在用户模式下不能执行。linux内核使用PTE_UXN宏来表示

PBHA

Bit[62:59]

Page-based Hardware Attributes bits页面相关的硬件属性。

  • 4
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
# 学习对象在全民造车、造芯的大时代,在努力去解决卡脖子的时代,ASIC硬件、SOC底层软件、Linux Kernel等操作系统软件(内核/驱动)、软硬件方面的系统架构师等的岗位需求也越来越明显,社会一直都是非常缺人的,缺的是核心的那一小撮、领头的那一小撮,社会所缺的更是能够软硬件融合的那一小撮人……总之,要想在这个时代,站稳自己的脚跟,能够在大公司或行业上拥有一席之地,就必需深入学习底层技术原理,核心技术才是您的看家本领。本课程设计之初,主要针对SOC底层软件开发的者、系统开发者,或者励志成为这样的人。既适合资深/高级工程师来查缺补漏,又适合初级工程师入门。(理论上该课程和ASIC硬件电路设计无关,该课程偏软件,但事实购买该课程的做ASIC的同学已然超过了15%)适用人群1、芯片开发者(包括底层软件、或做ASIC硬件的)。不限行业,例如车、云、物联网、移动端等领域;2、汽车行业开发者(主机厂、tier1、SOC厂家、各级供应商);3、嵌入式开发者、kernel开发者、驱动、软件工程师;4、学生。既适合学生从入门到精通,也适合资深工程师查缺补漏;您的收益:1、全体系的掌握ARMv8/ARMv9的核心知识点(ARM基础、异常中断GIC、MMU/Cache、architecture...);2、掌握ARM架构、掌握SOC架构、掌握常规IP(gic、smmu、timer、AXI/ACE/CHI、TZC400...);3、快速熟悉常规系统软件(bootrom、spl、ATF、TEE、bootloader、kernel...), Secureboot安全启动...4、技术水平提升N个level, 掌握快速的学习方法;# 学习什么在ARM蓬勃发展的年代,不仅仅涉及到物联网IOT、移动领域(如手机)、汽车电子领域,现在还涉及到PC、服务器的,简直就是各行各业。ARMv8出来已经有10年了,ARMv9也2年时间了。在技术不断更新迭代的背景下,此时再去学习十五年前的ARMv7、二十年前的ARMv5/v6显然不是明智的选择。本课程主要基于当前最新的架构,ARMv8的aarch64和ARMv9,如涉及具体的ARM Core IP主要还是以最新的ARM Core IP为主,软件架构也是以当前最主流的/未来所趋势的架构来讲解。以下也给大家列举初了一个ARM产品的timeline的总结(在本课程中有着大量的这种总结),从这张图中,您是可以清晰的看到本课程拥有独具一格的风格、拥有全网最新(且唯一)的资料总结或学习路线。# 本课程大纲和规划(课程持续更新中,课程总量统计:2022/10/02  当前是 61节课, 22小时)第一章:主要是快速学习: ARM简介、指令集、寄存器总结等。第二章:本系列视频的一大亮点,系统全面地讲解了arm异常中断gic等相关的软硬件知识,本人一直在倡导“学arm安全其实就是学arm架构,学arm架构其实就是学习arm的异常和中断”,异常中断是领着你进入架构的入门,是让你变成系统软硬件架构师的必走之路。第三章:安全专题,这也是本视频最核心的东西。因为你无论买书还是看博客等,你都很难找到讲解安全的教程,这里就是有和无的区别。本人系统的整理的安全的知识,带领你快速入门。第四章:mmu专题,透过事务看本质的讲解,白话式的演讲。在所有模块中,mmu也算是相对较简单模块。相信人人听得懂,人人学得会。第五章:cache专题,一切追求实事求是,不人云亦云,一切知识点都有迹可循,推翻了网络的很多观念。在众多模块中,cache算是一个比较难的模块。了解了cache后,才能算真正了解系统的软硬件架构。第六章:虚拟化,本人不擅长,会啥就随便讲点啥。(以后学会了再来补)第七章:architecture,就是零散和零碎的系统架构知识,如exclusive、arch timer、reset、系统启动、SOC设计、AMBA/AXI/ACE、DSU、WFE/WFI这样的。第八章: 新增的ARMv9 CCA/RME安全架构专题第九章:主要放置一些直播课。# 课程收益1、知道我学习什么,我要怎么去学习,从此之后有了一个明确的学习路线。2、认识一些共同目标的人,相互讨论问题,共同进步。勤学、共学、助学。3、ARM不再神秘,SOC不在神秘,让您短期内就能cover住全局4、熟悉ARM Architecture架构知识5、熟悉SOC架构知识6、熟悉主流的系统软件框架7、熟悉各项硬件原理和机制,如异常中断、MMU、cache、TLB、VMSA、Trustzone6、深入了解当前的系统架构、软硬件架构,能够看懂这些大家,将来也能够自己设计。7、熟悉系统的启动流程、Secureboot等8、熟悉各类标准和规范9、能够进入芯片厂商干活、能够在非芯片产生成为技术担当。10、学习资料的获取方法,会看11500多页的ARM手册,会看数以百计的ARM各项参考手册。 本课程会持续更新。也希望通过本课程的学习,能够让大家的ARMv8/ARMv9开发技术能有质的飞越,能找到自己心仪的工作。在购买之前,也建议大家看一看第一章第一节的课程介绍。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

byd yes

你的鼓励是我最大的动力

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

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

打赏作者

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

抵扣说明:

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

余额充值