认识ASID

注:以下讨论的前提是针对于 ARM V7 中 Cache 属性为 PIPT 的情况。 ASID 是 ARM 提供的 Context ID register 寄存器的低 8 位。它的全称是 Address Space Identifier 也叫 Application Space Identifier. 这两个名称在 ARM Reference 中都提到了。 为什么要引入 ASID 呢? To reduce the software overhead of TLB maintenance, the VMSA distinguishes between Global pages and Process specific pages. The Address Space Identifier (ASID) identifies pages associated with a specific process and provides a mechanism for changing process specific tables without having to perform maintenance on the TLB structures. [1] 在 Kernel 中,对 ASID 的注释写的言简意赅: The ASID is used to tag entries in the CPU caches and TLBs. [2] 所以:由于每一个进程对应一个 ASID ,并且 TLB 的每一个 Entry 使用 ASID 来进行 tag ,那么就不必在每一次在做进程切换的时候,都需要刷新 TLB 。 不过,这只是一个粗浅的理解。对于 ASID 的理解,需要和 Pagetable 中的 nG 位放在一起讨论。下图是 ARM V7 的 mapping entry format 的 first-level descriptor formats [3] 和 second-level descriptor formats [4] 。 红色标注的地方是 nG 位。 nG 位的作用: nG == 0 The translation is globa...