]> xenbits.xensource.com Git - libvirt.git/commitdiff
hyperv: Support hv-emsr-bitmap enlightenment
authorTim Wiederhake <twiederh@redhat.com>
Tue, 13 Aug 2024 16:51:46 +0000 (18:51 +0200)
committerTim Wiederhake <twiederh@redhat.com>
Mon, 26 Aug 2024 09:48:15 +0000 (11:48 +0200)
qemu supports this enlightenment since version 7.10.

From the qemu commit:
    The newly introduced enlightenment allow L0 (KVM) and L1 (Hyper-V)
    hypervisors to collaborate to avoid unnecessary updates to L2
    MSR-Bitmap upon vmexits.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
33 files changed:
docs/formatdomain.rst
src/conf/domain_conf.c
src/conf/domain_conf.h
src/conf/schemas/domaincommon.rng
src/cpu/cpu_x86.c
src/cpu/cpu_x86_data.h
src/qemu/qemu_command.c
src/qemu/qemu_process.c
tests/domaincapsdata/qemu_8.0.0-q35.x86_64.xml
tests/domaincapsdata/qemu_8.0.0-tcg.x86_64.xml
tests/domaincapsdata/qemu_8.0.0.x86_64.xml
tests/domaincapsdata/qemu_8.1.0-q35.x86_64.xml
tests/domaincapsdata/qemu_8.1.0-tcg.x86_64.xml
tests/domaincapsdata/qemu_8.1.0.x86_64.xml
tests/domaincapsdata/qemu_8.2.0-q35.x86_64.xml
tests/domaincapsdata/qemu_8.2.0-tcg.x86_64.xml
tests/domaincapsdata/qemu_8.2.0.x86_64.xml
tests/domaincapsdata/qemu_9.0.0-q35.x86_64.xml
tests/domaincapsdata/qemu_9.0.0-tcg.x86_64.xml
tests/domaincapsdata/qemu_9.0.0.x86_64.xml
tests/domaincapsdata/qemu_9.1.0-q35.x86_64.xml
tests/domaincapsdata/qemu_9.1.0-tcg.x86_64.xml
tests/domaincapsdata/qemu_9.1.0.x86_64.xml
tests/qemucapabilitiesdata/caps_8.0.0_x86_64.xml
tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml
tests/qemucapabilitiesdata/caps_8.2.0_x86_64.xml
tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml
tests/qemucapabilitiesdata/caps_9.1.0_x86_64.xml
tests/qemuxmlconfdata/hyperv-off.x86_64-latest.xml
tests/qemuxmlconfdata/hyperv-off.xml
tests/qemuxmlconfdata/hyperv.x86_64-latest.args
tests/qemuxmlconfdata/hyperv.x86_64-latest.xml
tests/qemuxmlconfdata/hyperv.xml

index 741405ec1207447bd4c02364fe62c1a51c3e901c..f34688e1cad2a2efdca726e2b60bbf2e251a682c 100644 (file)
@@ -1989,6 +1989,7 @@ Hypervisors may allow certain CPU / machine features to be toggled on/off.
        <tlbflush state='on'/>
        <ipi state='on'/>
        <evmcs state='on'/>
+       <emsr_bitmap state='on'/>
      </hyperv>
      <kvm>
        <hidden state='on'/>
@@ -2077,6 +2078,7 @@ are:
    ipi             Enable PV IPI support                                                  on, off                                      :since:`4.10.0 (QEMU 3.1)`
    evmcs           Enable Enlightened VMCS                                                on, off                                      :since:`4.10.0 (QEMU 3.1)`
    avic            Enable use Hyper-V SynIC with hardware APICv/AVIC                      on, off                                      :since:`8.10.0 (QEMU 6.2)`
+   emsr_bitmap     Avoid unnecessary updates to L2 MSR Bitmap upon vmexits.               on, off                                      :since:`10.7.0 (QEMU 7.1)`
    =============== ====================================================================== ============================================ =======================================================
 
    :since:`Since 8.0.0`, the hypervisor can be configured further by setting
index a897b0b7271e4be0c785a88d31daee128e081de8..8614a044c991aab75a1f10c0f234185e2408538c 100644 (file)
@@ -212,6 +212,7 @@ VIR_ENUM_IMPL(virDomainHyperv,
               "ipi",
               "evmcs",
               "avic",
+              "emsr_bitmap",
 );
 
 VIR_ENUM_IMPL(virDomainKVM,
@@ -16575,6 +16576,7 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def,
         case VIR_DOMAIN_HYPERV_IPI:
         case VIR_DOMAIN_HYPERV_EVMCS:
         case VIR_DOMAIN_HYPERV_AVIC:
+        case VIR_DOMAIN_HYPERV_EMSR_BITMAP:
             break;
 
         case VIR_DOMAIN_HYPERV_STIMER:
@@ -21023,6 +21025,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDef *src,
             case VIR_DOMAIN_HYPERV_IPI:
             case VIR_DOMAIN_HYPERV_EVMCS:
             case VIR_DOMAIN_HYPERV_AVIC:
+            case VIR_DOMAIN_HYPERV_EMSR_BITMAP:
                 if (src->hyperv_features[i] != dst->hyperv_features[i]) {
                     virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                    _("State of HyperV enlightenment feature '%1$s' differs: source: '%2$s', destination: '%3$s'"),
@@ -27765,6 +27768,7 @@ virDomainDefFormatFeatures(virBuffer *buf,
                 case VIR_DOMAIN_HYPERV_IPI:
                 case VIR_DOMAIN_HYPERV_EVMCS:
                 case VIR_DOMAIN_HYPERV_AVIC:
+                case VIR_DOMAIN_HYPERV_EMSR_BITMAP:
                     virBufferAddLit(&childBuf, "/>\n");
                     break;
 
index f65cdd87b603f6e1717d5d120c8b380bc361fd79..89675311edb4f61d827257f1c5c84b1cb740dc2c 100644 (file)
@@ -2204,6 +2204,7 @@ typedef enum {
     VIR_DOMAIN_HYPERV_IPI,
     VIR_DOMAIN_HYPERV_EVMCS,
     VIR_DOMAIN_HYPERV_AVIC,
+    VIR_DOMAIN_HYPERV_EMSR_BITMAP,
 
     VIR_DOMAIN_HYPERV_LAST
 } virDomainHyperv;
index a71f1d97b913f8576663529b97e93ae58f15ca97..ff83cf8980646c658be5cee8be55307fe2018d57 100644 (file)
                 <ref name="featurestate"/>
               </element>
             </optional>
+            <optional>
+              <element name="emsr_bitmap">
+                <ref name="featurestate"/>
+              </element>
+            </optional>
           </interleave>
         </group>
       </choice>
index fcbce0ec467d103648a0476924a994ca2fb63a10..139ac48234202ff9bda6df35d2c4d023ffb64898 100644 (file)
@@ -107,6 +107,9 @@ KVM_FEATURE_DEF(VIR_CPU_x86_HV_IPI,
 KVM_FEATURE_DEF(VIR_CPU_x86_HV_EVMCS,
                 0x40000004, 0x00004000, 0x0);
 
+KVM_FEATURE_DEF(VIR_CPU_x86_HV_EMSR_BITMAP,
+                0x4000000A, 0x00080000, 0x0);
+
 static virCPUx86Feature x86_kvm_features[] =
 {
     KVM_FEATURE(VIR_CPU_x86_KVM_PV_UNHALT),
@@ -124,6 +127,7 @@ static virCPUx86Feature x86_kvm_features[] =
     KVM_FEATURE(VIR_CPU_x86_HV_IPI),
     KVM_FEATURE(VIR_CPU_x86_HV_EVMCS),
     KVM_FEATURE(VIR_CPU_x86_HV_STIMER_DIRECT),
+    KVM_FEATURE(VIR_CPU_x86_HV_EMSR_BITMAP),
 };
 
 typedef struct _virCPUx86Signature virCPUx86Signature;
index d1ca63db6db00c6441b7e09ba0aa321368092d77..414643fe8d8058d17d0409662912a7077ae68d7c 100644 (file)
@@ -62,6 +62,7 @@ struct _virCPUx86MSR {
 #define VIR_CPU_x86_HV_IPI       "hv-ipi"
 #define VIR_CPU_x86_HV_EVMCS     "hv-evmcs"
 #define VIR_CPU_x86_HV_AVIC      "hv-avic"
+#define VIR_CPU_x86_HV_EMSR_BITMAP "hv-emsr_bitmap"
 
 /* Hyper-V Synthetic Timer option */
 #define VIR_CPU_x86_HV_STIMER_DIRECT "hv-stimer-direct"
index bb6fee4bfdfdcd941a9ebb69d8a9bfffab40914e..7610a6f043e2381c19010f20c4db918ff5b2fe7e 100644 (file)
@@ -6523,6 +6523,11 @@ qemuBuildCpuCommandLine(virCommand *cmd,
                                       def->hyperv_vendor_id);
                 break;
 
+            case VIR_DOMAIN_HYPERV_EMSR_BITMAP:
+                if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON)
+                    virBufferAsprintf(&buf, ",%s=on", "hv-emsr-bitmap");
+                break;
+
             case VIR_DOMAIN_HYPERV_LAST:
                 break;
             }
index c2977a552ab99448d6fc0a28ad874ba1514d2c66..e2e55797c362f0dc9b88ea9d3c0aa647a2f4663d 100644 (file)
@@ -4304,6 +4304,7 @@ qemuProcessVerifyHypervFeatures(virDomainDef *def,
         case VIR_DOMAIN_HYPERV_IPI:
         case VIR_DOMAIN_HYPERV_EVMCS:
         case VIR_DOMAIN_HYPERV_AVIC:
+        case VIR_DOMAIN_HYPERV_EMSR_BITMAP:
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("host doesn't support hyperv '%1$s' feature"),
                            virDomainHypervTypeToString(i));
index 8eda04948f99f0ee87a5b3028dac4f392b035e9a..1dfbf98248e5b434f92a76a209b76f2a0fce010e 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index c2d537b520a0ee908a479247a8e0eef78a1fa277..516eade95b54d9cfb6e305d9cfcd99d07ddce680 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index 71674064538a88e28335fd4d8fa0ac706042ff56..96cfc5776e7259b60ca9e581aa75c78d8fb4e99d 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index bac0b066836140a941bbf86ba66342d9cbd89c71..5bb1299fb1710de90199783de18018cfcf1dd227 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index 6c455f7ab92fcb91c7edc79a5e9f4c861f055386..743a6e728be555aef3d2e102713297b94041d6dd 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index f103da3010efdcb98ca4ae36d422ae35e8de7384..fa635fd12b44336542a5a3ef18f14d138c190dda 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index 784c44219caa1d6b2b8a822971e415c385a51d1c..6c394ba3c4384606fbec9f2695621b54706af5e1 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index 4be710044d858ff56ea3237b369b7dde3efcbde6..7ebd3ced3a8d33eb3b561cd05fb47db5983b5780 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index 2cdf5169644254a68ea766e5eea99d5cb7842343..1db706ef7e5dd9ec16c7e51498bb58d4cd698a80 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index 670314ba3e320a3ee065efec34fcc43d4f0b91cc..4fb0ebc45f84479223992e77ed9cdd0c8c3d3b14 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index 13afe99cdba63a35e0fc400840e8f89d68361f20..43ff5c3d9f8e24bc4ceea9b7641c4de04074751d 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index 71c05e0e9773b9c1763b41b5d914d9e5ef4082e8..86edbec0dd2acd80952fecad484254817dc9bd01 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index 5ca6d0fdacdae737f108d35f15f03bd9bbd7a62f..c9bf0139b517a07767f91d84727ff831307339a7 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index 133ee4d7239580af3c9fa8d2ef02d97453e8cc74..288047b38b952cfe803d94c0fdb91785b00a1a63 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index f378000c2b385628c303c2bc52b4cd145ba29559..4cae2f73ccd3cd3e775829b9a139976e7b23a901 100644 (file)
         <value>tlbflush</value>
         <value>ipi</value>
         <value>avic</value>
+        <value>emsr_bitmap</value>
       </enum>
     </hyperv>
     <launchSecurity supported='no'/>
index 91a4ca7f4a10f6d05f93f7571cf9c32dbb9d0ce8..a2e5c1cb95fdd5ecb9cad3e5fcdfa0159295a680 100644 (file)
     <cap name='tlbflush'/>
     <cap name='ipi'/>
     <cap name='avic'/>
+    <cap name='emsr_bitmap'/>
   </hypervCapabilities>
 </qemuCaps>
index a792c0e365bb7a48ada56d127b702f1d541b8b3b..3813434206d145da17bc282bad1e62b685148679 100644 (file)
     <cap name='tlbflush'/>
     <cap name='ipi'/>
     <cap name='avic'/>
+    <cap name='emsr_bitmap'/>
   </hypervCapabilities>
 </qemuCaps>
index c049500cbc0ceeceaacfbd3f3a145e607cf87fa9..8e601db07fced9cae195f7202b48c7b11eb1b25e 100644 (file)
     <cap name='tlbflush'/>
     <cap name='ipi'/>
     <cap name='avic'/>
+    <cap name='emsr_bitmap'/>
   </hypervCapabilities>
 </qemuCaps>
index ea0ff8d44422a7e1e7e65edceb275094f6df06b3..0dc762ac7e381ee0c1b2c09b8792ccbd39698af6 100644 (file)
     <cap name='tlbflush'/>
     <cap name='ipi'/>
     <cap name='avic'/>
+    <cap name='emsr_bitmap'/>
   </hypervCapabilities>
 </qemuCaps>
index 612a68e468cba866b275dd54f5c009e1fbe07dea..3d4d225ed54bde0e2080280a0e30bdf09a8415c6 100644 (file)
     <cap name='tlbflush'/>
     <cap name='ipi'/>
     <cap name='avic'/>
+    <cap name='emsr_bitmap'/>
   </hypervCapabilities>
 </qemuCaps>
index 5805fea7b78e6ce9849662a7fff2e27b68a6a2f4..2b5f3537a8f9a11c546ab6185717eab747ef46c9 100644 (file)
@@ -25,6 +25,7 @@
       <tlbflush state='off'/>
       <ipi state='off'/>
       <evmcs state='off'/>
+      <emsr_bitmap state='off'/>
     </hyperv>
   </features>
   <cpu mode='custom' match='exact' check='none'>
index 1e7e632b1ceebfaa20d6f9ed0866cd29eaf8a2cb..f760a9676ba14b8f3c5c825c5b84e1661d8a435d 100644 (file)
@@ -25,6 +25,7 @@
       <tlbflush state='off'/>
       <ipi state='off'/>
       <evmcs state='off'/>
+      <emsr_bitmap state='off'/>
     </hyperv>
   </features>
   <clock offset='utc'/>
index 8f0a02230c9c761902d2e210cf299c22020292e7..5046ec6ea068e4155f8c81cc123311d0e86e4a41 100644 (file)
@@ -12,7 +12,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
 -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \
 -machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=on \
 -accel tcg \
--cpu 'qemu64,hv-relaxed=on,hv-vapic=on,hv-spinlocks=0x2fff,hv-vpindex=on,hv-runtime=on,hv-synic=on,hv-stimer=on,hv-reset=on,hv-vendor-id=KVM Hv,hv-frequencies=on,hv-reenlightenment=on,hv-tlbflush=on,hv-ipi=on,hv-evmcs=on,hv-avic=on' \
+-cpu 'qemu64,hv-relaxed=on,hv-vapic=on,hv-spinlocks=0x2fff,hv-vpindex=on,hv-runtime=on,hv-synic=on,hv-stimer=on,hv-reset=on,hv-vendor-id=KVM Hv,hv-frequencies=on,hv-reenlightenment=on,hv-tlbflush=on,hv-ipi=on,hv-evmcs=on,hv-avic=on,hv-emsr-bitmap=on' \
 -m size=219136k \
 -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
 -overcommit mem-lock=off \
index 48281772631c47a6044babfcefc150afd550d03c..d5cb27bf1d81098fadc0d9ecf4e19e6b0902c73b 100644 (file)
@@ -26,6 +26,7 @@
       <ipi state='on'/>
       <evmcs state='on'/>
       <avic state='on'/>
+      <emsr_bitmap state='on'/>
     </hyperv>
   </features>
   <cpu mode='custom' match='exact' check='none'>
index dde091aa9a2a37a926175bf6fd933619c834c4cc..db520e207403218a322a774b6f7cf5640ca90914 100644 (file)
@@ -26,6 +26,7 @@
       <ipi state='on'/>
       <evmcs state='on'/>
       <avic state='on'/>
+      <emsr_bitmap state='on'/>
     </hyperv>
   </features>
   <clock offset='utc'/>