Notes about Memory Type in SDM。
建议读者先看下CPU CacheCPU Cache一致性问题

1. MESI

2. Caching Terminology

3. Methods of Caching Available



3.1 Buffering of Write Combining Memory Locations

3.2 Choosing a Memory Type


4. Cache Control Registers and Bits





5. MTRR(Memory Type Range Register)

6. PAT(Page Attribute Table)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ mount -t debugfs debugfs /sys/kernel/debug
$ cat /sys/kernel/debug/x86/pat_memtype_list
PAT memtype list:
uncached-minus @ 0x7fadf000-0x7fae0000
uncached-minus @ 0x7fb19000-0x7fb1a000
uncached-minus @ 0x7fb1a000-0x7fb1b000
uncached-minus @ 0x7fb1b000-0x7fb1c000
uncached-minus @ 0x7fb1c000-0x7fb1d000
uncached-minus @ 0x7fb1d000-0x7fb1e000
uncached-minus @ 0x7fb1e000-0x7fb25000
uncached-minus @ 0x7fb25000-0x7fb26000
uncached-minus @ 0x7fb26000-0x7fb27000
uncached-minus @ 0x7fb27000-0x7fb28000
uncached-minus @ 0x7fb28000-0x7fb2e000
uncached-minus @ 0x7fb2e000-0x7fb2f000
uncached-minus @ 0x7fb2f000-0x7fb30000
uncached-minus @ 0x7fb31000-0x7fb32000
uncached-minus @ 0x80000000-0x90000000

https://www.kernel.org/doc/Documentation/x86/pat.txt

7. Precedence of Cache Controls

考虑如下情况,一个物理页面,被MTRR和PAT同时设置了不同的Memory Type,那么,最终有效的Memory Type(Effective Memory Type)是什么呢?其实就是按照一套优先级规则,推导出Effective Memory Type。规则如下:

7.1 Effective Memory Type

按照优先级规则推导出的结果如下:

8. Corner case

Mark下SDM中的Corner case吧。

8.1 case1

8.2 case2


参考资料:

  1. Getting a handle on caching
  2. Write combining
  3. PAT (Page Attribute Table)
  4. osdev MTRR