^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ==========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) PAT (Page Attribute Table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) ==========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) x86 Page Attribute Table (PAT) allows for setting the memory attribute at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) page level granularity. PAT is complementary to the MTRR settings which allows
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) for setting of memory types over physical address ranges. However, PAT is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) more flexible than MTRR due to its capability to set attributes at page level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) and also due to the fact that there are no hardware limitations on number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) such attribute settings allowed. Added flexibility comes with guidelines for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) not having memory type aliasing for the same physical memory with multiple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) virtual addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) PAT allows for different types of memory attributes. The most commonly used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) ones that will be supported at this time are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) === ==============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) WB Write-back
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) UC Uncached
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) WC Write-combined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) WT Write-through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) UC- Uncached Minus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) === ==============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) PAT APIs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) There are many different APIs in the kernel that allows setting of memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) attributes at the page level. In order to avoid aliasing, these interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) should be used thoughtfully. Below is a table of interfaces available,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) their intended usage and their memory attribute relationships. Internally,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) these APIs use a reserve_memtype()/free_memtype() interface on the physical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) address range to avoid any aliasing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) | API | RAM | ACPI,... | Reserved/Holes |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) | ioremap | -- | UC- | UC- |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) | ioremap_cache | -- | WB | WB |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) | ioremap_uc | -- | UC | UC |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) | ioremap_wc | -- | -- | WC |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) | ioremap_wt | -- | -- | WT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) | set_memory_uc, | UC- | -- | -- |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) | set_memory_wb | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) | set_memory_wc, | WC | -- | -- |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) | set_memory_wb | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) | set_memory_wt, | WT | -- | -- |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) | set_memory_wb | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) | pci sysfs resource | -- | -- | UC- |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) | pci sysfs resource_wc | -- | -- | WC |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) | is IORESOURCE_PREFETCH | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) | pci proc | -- | -- | UC- |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) | !PCIIOC_WRITE_COMBINE | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) | pci proc | -- | -- | WC |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) | PCIIOC_WRITE_COMBINE | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) | /dev/mem | -- | WB/WC/UC- | WB/WC/UC- |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) | read-write | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) | /dev/mem | -- | UC- | UC- |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) | mmap SYNC flag | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) | /dev/mem | -- | WB/WC/UC- | WB/WC/UC- |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) | mmap !SYNC flag | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) | and | |(from existing| (from existing |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) | any alias to this area | |alias) | alias) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) | /dev/mem | -- | WB | WB |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) | mmap !SYNC flag | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) | no alias to this area | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) | and | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) | MTRR says WB | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) | /dev/mem | -- | -- | UC- |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) | mmap !SYNC flag | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) | no alias to this area | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) | and | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) | MTRR says !WB | | | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) +------------------------+----------+--------------+------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) Advanced APIs for drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) =========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) A. Exporting pages to users with remap_pfn_range, io_remap_pfn_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) vmf_insert_pfn.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) Drivers wanting to export some pages to userspace do it by using mmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) interface and a combination of:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 1) pgprot_noncached()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 2) io_remap_pfn_range() or remap_pfn_range() or vmf_insert_pfn()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) With PAT support, a new API pgprot_writecombine is being added. So, drivers can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) continue to use the above sequence, with either pgprot_noncached() or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) pgprot_writecombine() in step 1, followed by step 2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) In addition, step 2 internally tracks the region as UC or WC in memtype
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) list in order to ensure no conflicting mapping.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) Note that this set of APIs only works with IO (non RAM) regions. If driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) wants to export a RAM region, it has to do set_memory_uc() or set_memory_wc()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) as step 0 above and also track the usage of those pages and use set_memory_wb()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) before the page is freed to free pool.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) MTRR effects on PAT / non-PAT systems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) =====================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) The following table provides the effects of using write-combining MTRRs when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) using ioremap*() calls on x86 for both non-PAT and PAT systems. Ideally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) mtrr_add() usage will be phased out in favor of arch_phys_wc_add() which will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) be a no-op on PAT enabled systems. The region over which a arch_phys_wc_add()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) is made, should already have been ioremapped with WC attributes or PAT entries,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) this can be done by using ioremap_wc() / set_memory_wc(). Devices which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) combine areas of IO memory desired to remain uncacheable with areas where
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) write-combining is desirable should consider use of ioremap_uc() followed by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) set_memory_wc() to white-list effective write-combined areas. Such use is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) nevertheless discouraged as the effective memory type is considered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) implementation defined, yet this strategy can be used as last resort on devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) with size-constrained regions where otherwise MTRR write-combining would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) otherwise not be effective.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) ==== ======= === ========================= =====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) MTRR Non-PAT PAT Linux ioremap value Effective memory type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) ==== ======= === ========================= =====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) PAT Non-PAT | PAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) |PCD |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) ||PWT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) ||| |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) WC 000 WB _PAGE_CACHE_MODE_WB WC | WC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) WC 001 WC _PAGE_CACHE_MODE_WC WC* | WC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) WC 010 UC- _PAGE_CACHE_MODE_UC_MINUS WC* | UC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) WC 011 UC _PAGE_CACHE_MODE_UC UC | UC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) ==== ======= === ========================= =====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) (*) denotes implementation defined and is discouraged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) .. note:: -- in the above table mean "Not suggested usage for the API". Some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) of the --'s are strictly enforced by the kernel. Some others are not really
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) enforced today, but may be enforced in future.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) For ioremap and pci access through /sys or /proc - The actual type returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) can be more restrictive, in case of any existing aliasing for that address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) For example: If there is an existing uncached mapping, a new ioremap_wc can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) return uncached mapping in place of write-combine requested.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) set_memory_[uc|wc|wt] and set_memory_wb should be used in pairs, where driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) will first make a region uc, wc or wt and switch it back to wb after use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) Over time writes to /proc/mtrr will be deprecated in favor of using PAT based
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) interfaces. Users writing to /proc/mtrr are suggested to use above interfaces.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) Drivers should use ioremap_[uc|wc] to access PCI BARs with [uc|wc] access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) Drivers should use set_memory_[uc|wc|wt] to set access type for RAM ranges.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) PAT debugging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) =============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) With CONFIG_DEBUG_FS enabled, PAT memtype list can be examined by::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) # mount -t debugfs debugfs /sys/kernel/debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) # cat /sys/kernel/debug/x86/pat_memtype_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) PAT memtype list:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) uncached-minus @ 0x7fadf000-0x7fae0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) uncached-minus @ 0x7fb19000-0x7fb1a000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) uncached-minus @ 0x7fb1a000-0x7fb1b000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) uncached-minus @ 0x7fb1b000-0x7fb1c000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) uncached-minus @ 0x7fb1c000-0x7fb1d000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) uncached-minus @ 0x7fb1d000-0x7fb1e000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) uncached-minus @ 0x7fb1e000-0x7fb25000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) uncached-minus @ 0x7fb25000-0x7fb26000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) uncached-minus @ 0x7fb26000-0x7fb27000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) uncached-minus @ 0x7fb27000-0x7fb28000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) uncached-minus @ 0x7fb28000-0x7fb2e000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) uncached-minus @ 0x7fb2e000-0x7fb2f000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) uncached-minus @ 0x7fb2f000-0x7fb30000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) uncached-minus @ 0x7fb31000-0x7fb32000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) uncached-minus @ 0x80000000-0x90000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) This list shows physical address ranges and various PAT settings used to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) access those physical address ranges.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) Another, more verbose way of getting PAT related debug messages is with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) "debugpat" boot parameter. With this parameter, various debug messages are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) printed to dmesg log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) PAT Initialization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) The following table describes how PAT is initialized under various
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) configurations. The PAT MSR must be updated by Linux in order to support WC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) and WT attributes. Otherwise, the PAT MSR has the value programmed in it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) by the firmware. Note, Xen enables WC attribute in the PAT MSR for guests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) ==== ===== ========================== ========= =======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) MTRR PAT Call Sequence PAT State PAT MSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) ==== ===== ========================== ========= =======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) E E MTRR -> PAT init Enabled OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) E D MTRR -> PAT init Disabled -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) D E MTRR -> PAT disable Disabled BIOS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) D D MTRR -> PAT disable Disabled -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) - np/E PAT -> PAT disable Disabled BIOS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) - np/D PAT -> PAT disable Disabled -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) E !P/E MTRR -> PAT init Disabled BIOS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) D !P/E MTRR -> PAT disable Disabled BIOS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) !M !P/E MTRR stub -> PAT disable Disabled BIOS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) ==== ===== ========================== ========= =======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) Legend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) ========= =======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) E Feature enabled in CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) D Feature disabled/unsupported in CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) np "nopat" boot option specified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) !P CONFIG_X86_PAT option unset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) !M CONFIG_MTRR option unset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) Enabled PAT state set to enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) Disabled PAT state set to disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) OS PAT initializes PAT MSR with OS setting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) BIOS PAT keeps PAT MSR with BIOS setting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) ========= =======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)