<!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>KVM CPUID bits — 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="Known limitations of CPU virtualization" href="errata.html" />
<link rel="prev" title="Secure Encrypted Virtualization (SEV)" href="amd-memory-encryption.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 class="current">
<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 current"><a class="reference internal" href="../../../subsystem-apis.html">Subsystems</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../../subsystem-apis.html#core-subsystems">Core subsystems</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../subsystem-apis.html#human-interfaces">Human interfaces</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../subsystem-apis.html#networking-interfaces">Networking interfaces</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../subsystem-apis.html#storage-interfaces">Storage interfaces</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../../../subsystem-apis.html#other-subsystems">Other subsystems</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../../../accounting/index.html">Accounting</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../cpu-freq/index.html">CPUFreq - CPU frequency and voltage scaling code in the Linux(TM) kernel</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../edac/index.html">EDAC Subsystem</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../fpga/index.html">FPGA</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../i2c/index.html">I2C/SMBus Subsystem</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../iio/index.html">Industrial I/O</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../pcmcia/index.html">PCMCIA</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../spi/index.html">Serial Peripheral Interface (SPI)</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../w1/index.html">1-Wire Subsystem</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../watchdog/index.html">Watchdog Support</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="../../index.html">Virtualization Support</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../hwmon/index.html">Hardware Monitoring</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../accel/index.html">Compute Accelerators</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../security/index.html">Security Documentation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../crypto/index.html">Crypto API</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../bpf/index.html">BPF Documentation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../usb/index.html">USB support</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../PCI/index.html">PCI Bus Subsystem</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../misc-devices/index.html">Assorted Miscellaneous Devices Documentation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../peci/index.html">PECI Subsystem</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../wmi/index.html">WMI Subsystem</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../tee/index.html">TEE Subsystem</a></li>
</ul>
</li>
</ul>
</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>
<li class="toctree-l1"><a class="reference internal" href="../../../arch/index.html">CPU architectures</a></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/virt/kvm/x86/cpuid.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="kvm-cpuid-bits">
<h1>KVM CPUID bits<a class="headerlink" href="#kvm-cpuid-bits" title="Link to this heading">¶</a></h1>
<dl class="field-list simple">
<dt class="field-odd">Author<span class="colon">:</span></dt>
<dd class="field-odd"><p>Glauber Costa <<a class="reference external" href="mailto:glommer%40gmail.com">glommer<span>@</span>gmail<span>.</span>com</a>></p>
</dd>
</dl>
<p>A guest running on a kvm host, can check some of its features using
cpuid. This is not always guaranteed to work, since userspace can
mask-out some, or even all KVM-related cpuid features before launching
a guest.</p>
<p>KVM cpuid functions are:</p>
<p>function: KVM_CPUID_SIGNATURE (0x40000000)</p>
<p>returns:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>eax = 0x40000001
ebx = 0x4b4d564b
ecx = 0x564b4d56
edx = 0x4d
</pre></div>
</div>
<p>Note that this value in ebx, ecx and edx corresponds to the string “KVMKVMKVM”.
The value in eax corresponds to the maximum cpuid function present in this leaf,
and will be updated if more functions are added in the future.
Note also that old hosts set eax value to 0x0. This should
be interpreted as if the value was 0x40000001.
This function queries the presence of KVM cpuid leafs.</p>
<p>function: define KVM_CPUID_FEATURES (0x40000001)</p>
<p>returns:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>ebx, ecx
eax = an OR'ed group of (1 << flag)
</pre></div>
</div>
<p>where <code class="docutils literal notranslate"><span class="pre">flag</span></code> is defined as below:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>flag</p></th>
<th class="head"><p>value</p></th>
<th class="head"><p>meaning</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>KVM_FEATURE_CLOCKSOURCE</p></td>
<td><p>0</p></td>
<td><p>kvmclock available at msrs
0x11 and 0x12</p></td>
</tr>
<tr class="row-odd"><td><p>KVM_FEATURE_NOP_IO_DELAY</p></td>
<td><p>1</p></td>
<td><p>not necessary to perform delays
on PIO operations</p></td>
</tr>
<tr class="row-even"><td><p>KVM_FEATURE_MMU_OP</p></td>
<td><p>2</p></td>
<td><p>deprecated</p></td>
</tr>
<tr class="row-odd"><td><p>KVM_FEATURE_CLOCKSOURCE2</p></td>
<td><p>3</p></td>
<td><p>kvmclock available at msrs
0x4b564d00 and 0x4b564d01</p></td>
</tr>
<tr class="row-even"><td><p>KVM_FEATURE_ASYNC_PF</p></td>
<td><p>4</p></td>
<td><p>async pf can be enabled by
writing to msr 0x4b564d02</p></td>
</tr>
<tr class="row-odd"><td><p>KVM_FEATURE_STEAL_TIME</p></td>
<td><p>5</p></td>
<td><p>steal time can be enabled by
writing to msr 0x4b564d03</p></td>
</tr>
<tr class="row-even"><td><p>KVM_FEATURE_PV_EOI</p></td>
<td><p>6</p></td>
<td><p>paravirtualized end of interrupt
handler can be enabled by
writing to msr 0x4b564d04</p></td>
</tr>
<tr class="row-odd"><td><p>KVM_FEATURE_PV_UNHALT</p></td>
<td><p>7</p></td>
<td><p>guest checks this feature bit
before enabling paravirtualized
spinlock support</p></td>
</tr>
<tr class="row-even"><td><p>KVM_FEATURE_PV_TLB_FLUSH</p></td>
<td><p>9</p></td>
<td><p>guest checks this feature bit
before enabling paravirtualized
tlb flush</p></td>
</tr>
<tr class="row-odd"><td><p>KVM_FEATURE_ASYNC_PF_VMEXIT</p></td>
<td><p>10</p></td>
<td><p>paravirtualized async PF VM EXIT
can be enabled by setting bit 2
when writing to msr 0x4b564d02</p></td>
</tr>
<tr class="row-even"><td><p>KVM_FEATURE_PV_SEND_IPI</p></td>
<td><p>11</p></td>
<td><p>guest checks this feature bit
before enabling paravirtualized
send IPIs</p></td>
</tr>
<tr class="row-odd"><td><p>KVM_FEATURE_POLL_CONTROL</p></td>
<td><p>12</p></td>
<td><p>host-side polling on HLT can
be disabled by writing
to msr 0x4b564d05.</p></td>
</tr>
<tr class="row-even"><td><p>KVM_FEATURE_PV_SCHED_YIELD</p></td>
<td><p>13</p></td>
<td><p>guest checks this feature bit
before using paravirtualized
sched yield.</p></td>
</tr>
<tr class="row-odd"><td><p>KVM_FEATURE_ASYNC_PF_INT</p></td>
<td><p>14</p></td>
<td><p>guest checks this feature bit
before using the second async
pf control msr 0x4b564d06 and
async pf acknowledgment msr
0x4b564d07.</p></td>
</tr>
<tr class="row-even"><td><p>KVM_FEATURE_MSI_EXT_DEST_ID</p></td>
<td><p>15</p></td>
<td><p>guest checks this feature bit
before using extended destination
ID bits in MSI address bits 11-5.</p></td>
</tr>
<tr class="row-odd"><td><p>KVM_FEATURE_HC_MAP_GPA_RANGE</p></td>
<td><p>16</p></td>
<td><p>guest checks this feature bit before
using the map gpa range hypercall
to notify the page state change</p></td>
</tr>
<tr class="row-even"><td><p>KVM_FEATURE_MIGRATION_CONTROL</p></td>
<td><p>17</p></td>
<td><p>guest checks this feature bit before
using MSR_KVM_MIGRATION_CONTROL</p></td>
</tr>
<tr class="row-odd"><td><p>KVM_FEATURE_CLOCKSOURCE_STABLE_BIT</p></td>
<td><p>24</p></td>
<td><p>host will warn if no guest-side
per-cpu warps are expected in
kvmclock</p></td>
</tr>
</tbody>
</table>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>edx = an OR'ed group of (1 << flag)
</pre></div>
</div>
<p>Where <code class="docutils literal notranslate"><span class="pre">flag</span></code> here is defined as below:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>flag</p></th>
<th class="head"><p>value</p></th>
<th class="head"><p>meaning</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>KVM_HINTS_REALTIME</p></td>
<td><p>0</p></td>
<td><p>guest checks this feature bit to
determine that vCPUs are never
preempted for an unlimited time
allowing optimizations</p></td>
</tr>
</tbody>
</table>
</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/virt/kvm/x86/cpuid.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>