blob: c93ff5f4c0ddc0e979daa1ad0e950c8c1c6e31c1 [file] [log] [blame]
venkatesh.pallipadi@intel.comd27554d2008-03-18 17:00:13 -07001
2PAT (Page Attribute Table)
3
4x86 Page Attribute Table (PAT) allows for setting the memory attribute at the
5page level granularity. PAT is complementary to the MTRR settings which allows
6for setting of memory types over physical address ranges. However, PAT is
7more flexible than MTRR due to its capability to set attributes at page level
8and also due to the fact that there are no hardware limitations on number of
9such attribute settings allowed. Added flexibility comes with guidelines for
10not having memory type aliasing for the same physical memory with multiple
11virtual addresses.
12
13PAT allows for different types of memory attributes. The most commonly used
14ones that will be supported at this time are Write-back, Uncached,
15Write-combined and Uncached Minus.
16
venkatesh.pallipadi@intel.com59dfc3f2008-08-20 16:45:54 -070017
18PAT APIs
19--------
20
venkatesh.pallipadi@intel.comd27554d2008-03-18 17:00:13 -070021There are many different APIs in the kernel that allows setting of memory
22attributes at the page level. In order to avoid aliasing, these interfaces
23should be used thoughtfully. Below is a table of interfaces available,
24their intended usage and their memory attribute relationships. Internally,
25these APIs use a reserve_memtype()/free_memtype() interface on the physical
26address range to avoid any aliasing.
27
28
29-------------------------------------------------------------------
30API | RAM | ACPI,... | Reserved/Holes |
31-----------------------|----------|------------|------------------|
32 | | | |
venkatesh.pallipadi@intel.com59dfc3f2008-08-20 16:45:54 -070033ioremap | -- | UC- | UC- |
venkatesh.pallipadi@intel.comd27554d2008-03-18 17:00:13 -070034 | | | |
35ioremap_cache | -- | WB | WB |
36 | | | |
venkatesh.pallipadi@intel.com59dfc3f2008-08-20 16:45:54 -070037ioremap_nocache | -- | UC- | UC- |
venkatesh.pallipadi@intel.comd27554d2008-03-18 17:00:13 -070038 | | | |
39ioremap_wc | -- | -- | WC |
40 | | | |
venkatesh.pallipadi@intel.com59dfc3f2008-08-20 16:45:54 -070041set_memory_uc | UC- | -- | -- |
venkatesh.pallipadi@intel.comd27554d2008-03-18 17:00:13 -070042 set_memory_wb | | | |
43 | | | |
44set_memory_wc | WC | -- | -- |
45 set_memory_wb | | | |
46 | | | |
venkatesh.pallipadi@intel.com59dfc3f2008-08-20 16:45:54 -070047pci sysfs resource | -- | -- | UC- |
venkatesh.pallipadi@intel.comd27554d2008-03-18 17:00:13 -070048 | | | |
49pci sysfs resource_wc | -- | -- | WC |
50 is IORESOURCE_PREFETCH| | | |
51 | | | |
venkatesh.pallipadi@intel.com59dfc3f2008-08-20 16:45:54 -070052pci proc | -- | -- | UC- |
venkatesh.pallipadi@intel.comd27554d2008-03-18 17:00:13 -070053 !PCIIOC_WRITE_COMBINE | | | |
54 | | | |
55pci proc | -- | -- | WC |
56 PCIIOC_WRITE_COMBINE | | | |
57 | | | |
venkatesh.pallipadi@intel.com59dfc3f2008-08-20 16:45:54 -070058/dev/mem | -- | WB/WC/UC- | WB/WC/UC- |
venkatesh.pallipadi@intel.comd27554d2008-03-18 17:00:13 -070059 read-write | | | |
60 | | | |
venkatesh.pallipadi@intel.com59dfc3f2008-08-20 16:45:54 -070061/dev/mem | -- | UC- | UC- |
venkatesh.pallipadi@intel.comd27554d2008-03-18 17:00:13 -070062 mmap SYNC flag | | | |
63 | | | |
venkatesh.pallipadi@intel.com59dfc3f2008-08-20 16:45:54 -070064/dev/mem | -- | WB/WC/UC- | WB/WC/UC- |
venkatesh.pallipadi@intel.comd27554d2008-03-18 17:00:13 -070065 mmap !SYNC flag | |(from exist-| (from exist- |
66 and | | ing alias)| ing alias) |
67 any alias to this area| | | |
68 | | | |
69/dev/mem | -- | WB | WB |
70 mmap !SYNC flag | | | |
71 no alias to this area | | | |
72 and | | | |
73 MTRR says WB | | | |
74 | | | |
venkatesh.pallipadi@intel.com59dfc3f2008-08-20 16:45:54 -070075/dev/mem | -- | -- | UC- |
venkatesh.pallipadi@intel.comd27554d2008-03-18 17:00:13 -070076 mmap !SYNC flag | | | |
77 no alias to this area | | | |
78 and | | | |
79 MTRR says !WB | | | |
80 | | | |
81-------------------------------------------------------------------
82
83Notes:
84
85-- in the above table mean "Not suggested usage for the API". Some of the --'s
86are strictly enforced by the kernel. Some others are not really enforced
87today, but may be enforced in future.
88
89For ioremap and pci access through /sys or /proc - The actual type returned
90can be more restrictive, in case of any existing aliasing for that address.
91For example: If there is an existing uncached mapping, a new ioremap_wc can
92return uncached mapping in place of write-combine requested.
93
94set_memory_[uc|wc] and set_memory_wb should be used in pairs, where driver will
95first make a region uc or wc and switch it back to wb after use.
96
97Over time writes to /proc/mtrr will be deprecated in favor of using PAT based
98interfaces. Users writing to /proc/mtrr are suggested to use above interfaces.
99
100Drivers should use ioremap_[uc|wc] to access PCI BARs with [uc|wc] access
101types.
102
103Drivers should use set_memory_[uc|wc] to set access type for RAM ranges.
104
venkatesh.pallipadi@intel.com59dfc3f2008-08-20 16:45:54 -0700105
106PAT debugging
107-------------
108
109With CONFIG_DEBUG_FS enabled, PAT memtype list can be examined by
110
111# mount -t debugfs debugfs /sys/kernel/debug
112# cat /sys/kernel/debug/x86/pat_memtype_list
113PAT memtype list:
114uncached-minus @ 0x7fadf000-0x7fae0000
115uncached-minus @ 0x7fb19000-0x7fb1a000
116uncached-minus @ 0x7fb1a000-0x7fb1b000
117uncached-minus @ 0x7fb1b000-0x7fb1c000
118uncached-minus @ 0x7fb1c000-0x7fb1d000
119uncached-minus @ 0x7fb1d000-0x7fb1e000
120uncached-minus @ 0x7fb1e000-0x7fb25000
121uncached-minus @ 0x7fb25000-0x7fb26000
122uncached-minus @ 0x7fb26000-0x7fb27000
123uncached-minus @ 0x7fb27000-0x7fb28000
124uncached-minus @ 0x7fb28000-0x7fb2e000
125uncached-minus @ 0x7fb2e000-0x7fb2f000
126uncached-minus @ 0x7fb2f000-0x7fb30000
127uncached-minus @ 0x7fb31000-0x7fb32000
128uncached-minus @ 0x80000000-0x90000000
129
130This list shows physical address ranges and various PAT settings used to
131access those physical address ranges.
132
133Another, more verbose way of getting PAT related debug messages is with
134"debugpat" boot parameter. With this parameter, various debug messages are
135printed to dmesg log.
136