0. 狀態(tài)
執(zhí)行態(tài): AARCH64, AARCH32
最高異常等級只能工作在Aarch64, 其他EL可以工作在Aarch64或者Aarch32. SCR_EL3.RW, HCR_EL2.RW和PSTATE控制執(zhí)行狀態(tài)。
Security態(tài): Security 和 non-Security
SCR_EL3.NS 控制security狀態(tài)
1. 寄存器
共31個64bit GPR寄存器X0~X30 ,X29做為FP, X30作為LR。
另外還有PC,SPs(SPEL0~SPEL3), ELRs(exception link register)。
32個128bit 浮點(diǎn)寄存器V0~V31
PSTATE:處理器狀態(tài),pstate不是一個寄存器,由幾個寄存器組成(條件寄存器:NZCV, 異常mask寄存器:DAIF, SP選擇寄存器:SPSEL. 異常等級寄存器: CurrentEL)
SPSRs:當(dāng)異常發(fā)生時,PSTATE在SPSRs里面保存。
M[3:2] Encodes the Exception level, 0-3. M[1] Reserved
M[0] Selects the SP:
0 SP_EL0
1 SP_ELx
2. 指令集
A64指令集, 寄存器位寬 w-32位, x-64位
尋址:寄存器索引尋址,PC相對尋址,Load/Store尋址
3. 異常模型
異常分為同步異常和異步異常。
同步異常有如下特點(diǎn):
a.由直接執(zhí)行或者試圖執(zhí)行一條指令產(chǎn)品
b.精確的 (能保證給出正確的pc)
異步異常也就是中斷,包括SError,IRQ,F(xiàn)IQ。
ARMv8異常模型,Exception Level 從EL0到EL3. EL3權(quán)限最大
EL0 Applications.
EL1 OS kernel and associated functionsthat are typically described as privileged.
EL2 Hypervisor.
EL3 Secure monitor.
異?;芳拇嫫鳎篤BAR_ELx, 要求1k字節(jié)對齊。
Exception Entry:
PSTATE -> SPSR_ELx
PC -> ELR_ELx
PSTATE(D,A,I,F) -> 0b1111
更新ESR_ELx 如果是同步異?;蛘逽Error
選擇SP_ELx
跳轉(zhuǎn)到異常向量定義的地址
Exception return:
執(zhí)行ERET指令從異常返回
ELR_ELx ----> PC
SPSR_ELx ----> PSTATE
異常返回同時執(zhí)行:
設(shè)置Event Register
清local exclusive monitor,實(shí)現(xiàn)定義是否清global exclusive monitor
異常優(yōu)先級(由高到低):
1). Software Step exceptions
2). Misaligned PC exceptions
3). Instruction Abort exceptions
4). Hardware Breakpoint exceptions or Address Matching Vector Catch exception
5). Illegal Execution State exceptions
6). Exceptions taken from EL1 toEL2 because of one of the following configuration settings:
· For exceptions taken from AArch64 state:
— HSTR_EL2.Tn.
— HCR_EL2.TIDCP.
· For exceptions taken from AArch32 state:
— HSTR.Tn.
— HCR.TIDCP.
7). Undefined Instruction exception
......19). Trapped floating-point exceptions
20). Stack Pointer Alignment faults
21). Data Abort exceptions other than a Data Abort exception generated by a Synchronous external abort that was
not generated by a translation table walk
22). Watchpoint exceptions.
23). Data Abort exception generated by a Synchronous external abort that was not generated by a translation table
walk
如果中斷進(jìn)入pending態(tài)先于以下情況,cpu會先響應(yīng)中斷處理(當(dāng)然在中斷沒有關(guān)閉的情況):
An ISB instruction.
Exception entry.
Exception return.
Exit from Debug state.
4. MMU
內(nèi)存屬性:和armv7相比,去掉了strong order。只有nomal和device了。
None-security: EL1&0 VA --Stage 1----> IPA ---Stage 2---> PA
VA: 地址寬度48 bit。分為兩個虛擬地址空間,0x0~2^48 和 2^64-2^48 ~ 2^64。
PA: 地址最大寬度為48 bit,可以從ID_AA64MMFR0_EL1讀取實(shí)際支持多少bit。
EL1模式下的控制MMU的主要寄存器:
TTBR0_EL1/EEBR1_EL1 轉(zhuǎn)換表的基地址寄存器。VA[55]為0使用TTBR0,為1使用TTBR1。
SCTLR_EL1 (EE, M)控制轉(zhuǎn)換表的大小端和MMU使能
TCR_EL1轉(zhuǎn)換表控制寄存器,可以設(shè)置ASID寬度,頁的大小,虛擬地址范圍。設(shè)置頁表的內(nèi)存屬性等等。
MAIR_EL1內(nèi)存屬性間接寄存器,提供內(nèi)存屬性編碼,為頁或塊的內(nèi)存屬性attribIdx提供索引。
轉(zhuǎn)換表格式: 最多四級地址轉(zhuǎn)換,Input Address/Output Address 48bit.
頁粒度:4k/16k/64k。
塊粒度:
4k頁:level1的塊支持1G,level2的塊支持2M。 level0不支持塊。 level0是必須的如果地址寬度大于等于40bit。最多四級轉(zhuǎn)換,頁目錄9bit(47-39:38-30:29-21:20-12)
16k頁:level2的塊支持32M。 level0和level1不支持塊。最多四級轉(zhuǎn)換,頁目錄11bit(47:46-36:35-25:24-14)
64k頁:level2的塊支持512M。 level1不支持塊。無level0, 最多三級轉(zhuǎn)換,頁目錄13bit(47-42:41-29:28-16)
5. Cache
指令cache
支持PIPT(physical index physical tag),VIPT,VIVT。
數(shù)據(jù)cache
Non-cacheable
Write-Through cacheable
Write-Back cacheable
cache分配策略:
Read-Allocate, Transient Read-Allocate, or No Read-Allocate
Write-Allocate, Transient Write-Allocate, or No Write-Allocate
non-cacheable 不等于cacheable with both no read-allocate and no write-allocate. non-cacheable的內(nèi)存能和除cacheable with both no read-allocate and no write-allocate以外的內(nèi)存保證一致性。
cache的使能:
SCTLR_EL1的I bit控制指令cache的使能. C bit控制數(shù)據(jù)cache和unified cache的使能。
PoU(Point of Unification):PoU is the point in the memory system where the data, instruction and table walk (MMU) interfaces of this core see the same copy of a location
PoC(Point of Coherency):PoC is where this core and an other master (e.g. a DMA) see the same copy
6. AAPCS64 (Procedure Call Standard for the ARM 64-bit Architecture)
ARM64的棧要求16字節(jié)對齊