參考:
參考:Arm Architecture Reference Manual for A-profile architecture
Chapter D5 The AArch64 Virtual Memory System Architecture
內存屬性存放位置
MAIR_EL1, Memory Attribute Indirection Register
這個寄存器里面,可以放 8 個內存屬性。
內存屬性使用
然后 頁表描述符 的 AttrIndx[2:0], bits[4:2] 來 做 index, 索引 使用 MAIR_EL1 中配置的內存屬性。
內存屬性 - 即描述一塊內存的屬性。
設備IO內存還是普通內存?
設備IO內存 屬性
device類型的內存還有三種屬性:
(1) G, Gather, Determines whether multiple accesses can be merged into a single bus transaction。多個memory access merge為 合並成一個bus-transaction
(2) R, reorder, Determines whether accesses to the same device can be reordered。device memory的access 是否可以重新排序。
(3) E, Early Write Ack,Indicates to the memory system whether a buffer can send acknowledgements。 write不寫入device,通過中間buffer之后就 return ack。
在 MAIR_EL1 寄存器中,以 0b0000dd00 是形式出現。0bdd 不同,標識不同屬性。如下:
普通內存屬性
share 共享 屬性
Non-shareable - 不共享。 core 0 的和 Core 1 的緩存都不共享。
Inner-shareable - 只在一個 cluster 內共享。
outer-shareable - 可以在不同的cluster 之間共享。
引用 https://blog.csdn.net/weixin_42135087/article/details/121117593 的圖
cache 屬性
(1)Non-cacheable or cachable 不緩存 緩存
(2)write through or write back 寫穿緩存 回寫緩存
Write Back:Cache Line中的數據被CPU核修改時並不立刻寫回內存,Cache Line和內存中的數據會暫時不一致,在Cache Line中有一個Dirty位標記這一情況。當一條Cache Line要被其它VA的數據替換時,如果不是Dirty的就直接替換掉,如果是Dirty的就先寫回內存再替換。 Write Through:每當CPU核修改Cache Line中的數據時就立刻寫回內存,Cache Line和內存中的數據總是一致的。如果有多個CPU或設備同時訪問內存,例如采用雙口RAM,那么Cache中的數據和內存保持一致就非常重要了,這時相關的內存頁面通常配置為Write Through模式 |
(3)Read allocate or write allocate 讀分配緩存 寫分配緩存
Cache知識整理-Read-Allocate/Write-Allocate https://blog.csdn.net/weixin_43936338/article/details/119774287 CPU read hit – read from cache miss: a – read through – 直接從內存讀取 b – read allocate – 先把數據讀取到cache, 再從cache 里面讀取。
cpu write hit a – write through 把數據同時寫道cache 和內存 b – write back – 把數據寫到cache,再通過flush 方式寫入內存 miss a – write allocate – 寫cache ,然后再flush 方式寫到內存 b – no write allocate – 直接寫到內存中。
write allocate 和 write back 一起使用 no write allocate 和 write through 一起使用。 |
(4)transient or non-transient cache 瞬逝緩存 非瞬時緩存
在 MAIR_EL1 寄存器中,以0booooiiii 格式定義 。