__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<!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>27. Bus lock detection and handling — 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="28. USB Legacy support" href="usb-legacy-support.html" />
<link rel="prev" title="26. TSX Async Abort (TAA) mitigation" href="tsx_async_abort.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"><a class="reference internal" href="pat.html">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 current"><a class="current reference internal" href="#">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/buslock.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="bus-lock-detection-and-handling">
<h1><span class="section-number">27. </span>Bus lock detection and handling<a class="headerlink" href="#bus-lock-detection-and-handling" title="Link to this heading">¶</a></h1>
<dl class="field-list simple">
<dt class="field-odd">Copyright<span class="colon">:</span></dt>
<dd class="field-odd"><p>© 2021 Intel Corporation</p>
</dd>
<dt class="field-even">Authors<span class="colon">:</span></dt>
<dd class="field-even"><ul class="simple">
<li><p>Fenghua Yu <<a class="reference external" href="mailto:fenghua.yu%40intel.com">fenghua<span>.</span>yu<span>@</span>intel<span>.</span>com</a>></p></li>
<li><p>Tony Luck <<a class="reference external" href="mailto:tony.luck%40intel.com">tony<span>.</span>luck<span>@</span>intel<span>.</span>com</a>></p></li>
</ul>
</dd>
</dl>
<section id="problem">
<h2><span class="section-number">27.1. </span>Problem<a class="headerlink" href="#problem" title="Link to this heading">¶</a></h2>
<p>A split lock is any atomic operation whose operand crosses two cache lines.
Since the operand spans two cache lines and the operation must be atomic,
the system locks the bus while the CPU accesses the two cache lines.</p>
<p>A bus lock is acquired through either split locked access to writeback (WB)
memory or any locked access to non-WB memory. This is typically thousands of
cycles slower than an atomic operation within a cache line. It also disrupts
performance on other cores and brings the whole system to its knees.</p>
</section>
<section id="detection">
<h2><span class="section-number">27.2. </span>Detection<a class="headerlink" href="#detection" title="Link to this heading">¶</a></h2>
<p>Intel processors may support either or both of the following hardware
mechanisms to detect split locks and bus locks. Some AMD processors also
support bus lock detect.</p>
<section id="ac-exception-for-split-lock-detection">
<h3><span class="section-number">27.2.1. </span>#AC exception for split lock detection<a class="headerlink" href="#ac-exception-for-split-lock-detection" title="Link to this heading">¶</a></h3>
<p>Beginning with the Tremont Atom CPU split lock operations may raise an
Alignment Check (#AC) exception when a split lock operation is attempted.</p>
</section>
<section id="db-exception-for-bus-lock-detection">
<h3><span class="section-number">27.2.2. </span>#DB exception for bus lock detection<a class="headerlink" href="#db-exception-for-bus-lock-detection" title="Link to this heading">¶</a></h3>
<p>Some CPUs have the ability to notify the kernel by an #DB trap after a user
instruction acquires a bus lock and is executed. This allows the kernel to
terminate the application or to enforce throttling.</p>
</section>
</section>
<section id="software-handling">
<h2><span class="section-number">27.3. </span>Software handling<a class="headerlink" href="#software-handling" title="Link to this heading">¶</a></h2>
<p>The kernel #AC and #DB handlers handle bus lock based on the kernel
parameter “split_lock_detect”. Here is a summary of different options:</p>
<table class="docutils align-default">
<tbody>
<tr class="row-odd"><td><p>split_lock_detect=</p></td>
<td><p>#AC for split lock</p></td>
<td><p>#DB for bus lock</p></td>
</tr>
<tr class="row-even"><td><p>off</p></td>
<td><p>Do nothing</p></td>
<td><p>Do nothing</p></td>
</tr>
<tr class="row-odd"><td><p>warn
(default)</p></td>
<td><p>Kernel OOPs
Warn once per task, add a
delay, add synchronization
to prevent more than one
core from executing a
split lock in parallel.
sysctl split_lock_mitigate
can be used to avoid the
delay and synchronization
When both features are
supported, warn in #AC</p></td>
<td><p>Warn once per task and
and continues to run.</p></td>
</tr>
<tr class="row-even"><td><p>fatal</p></td>
<td><p>Kernel OOPs
Send SIGBUS to user
When both features are
supported, fatal in #AC</p></td>
<td><p>Send SIGBUS to user.</p></td>
</tr>
<tr class="row-odd"><td><p>ratelimit:N
(0 < N <= 1000)</p></td>
<td><p>Do nothing</p></td>
<td><p>Limit bus lock rate to
N bus locks per second
system wide and warn on
bus locks.</p></td>
</tr>
</tbody>
</table>
</section>
<section id="usages">
<h2><span class="section-number">27.4. </span>Usages<a class="headerlink" href="#usages" title="Link to this heading">¶</a></h2>
<p>Detecting and handling bus lock may find usages in various areas:</p>
<p>It is critical for real time system designers who build consolidated real
time systems. These systems run hard real time code on some cores and run
“untrusted” user processes on other cores. The hard real time cannot afford
to have any bus lock from the untrusted processes to hurt real time
performance. To date the designers have been unable to deploy these
solutions as they have no way to prevent the “untrusted” user code from
generating split lock and bus lock to block the hard real time code to
access memory during bus locking.</p>
<p>It’s also useful for general computing to prevent guests or user
applications from slowing down the overall system by executing instructions
with bus lock.</p>
</section>
<section id="guidance">
<h2><span class="section-number">27.5. </span>Guidance<a class="headerlink" href="#guidance" title="Link to this heading">¶</a></h2>
<section id="off">
<h3><span class="section-number">27.5.1. </span>off<a class="headerlink" href="#off" title="Link to this heading">¶</a></h3>
<p>Disable checking for split lock and bus lock. This option can be useful if
there are legacy applications that trigger these events at a low rate so
that mitigation is not needed.</p>
</section>
<section id="warn">
<h3><span class="section-number">27.5.2. </span>warn<a class="headerlink" href="#warn" title="Link to this heading">¶</a></h3>
<p>A warning is emitted when a bus lock is detected which allows to identify
the offending application. This is the default behavior.</p>
</section>
<section id="fatal">
<h3><span class="section-number">27.5.3. </span>fatal<a class="headerlink" href="#fatal" title="Link to this heading">¶</a></h3>
<p>In this case, the bus lock is not tolerated and the process is killed.</p>
</section>
<section id="ratelimit">
<h3><span class="section-number">27.5.4. </span>ratelimit<a class="headerlink" href="#ratelimit" title="Link to this heading">¶</a></h3>
<p>A system wide bus lock rate limit N is specified where 0 < N <= 1000. This
allows a bus lock rate up to N bus locks per second. When the bus lock rate
is exceeded then any task which is caught via the buslock #DB exception is
throttled by enforced sleeps until the rate goes under the limit again.</p>
<p>This is an effective mitigation in cases where a minimal impact can be
tolerated, but an eventual Denial of Service attack has to be prevented. It
allows to identify the offending processes and analyze whether they are
malicious or just badly written.</p>
<p>Selecting a rate limit of 1000 allows the bus to be locked for up to about
seven million cycles each second (assuming 7000 cycles for each bus
lock). On a 2 GHz processor that would be about 0.35% system slowdown.</p>
</section>
</section>
</section>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©The kernel development community.
|
Powered by <a href="https://www.sphinx-doc.org/">Sphinx 8.1.3</a>
& <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>
|
<a href="../../_sources/arch/x86/buslock.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>| 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 |
|