hyperv: Support hv-emsr-bitmap enlightenment

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>
This commit is contained in:
Tim Wiederhake 2024-08-13 18:51:46 +02:00
parent d543c4e753
commit 0313a500a9
33 changed files with 48 additions and 1 deletions

View 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

View 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;

View 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;

View File

@ -7967,6 +7967,11 @@
<ref name="featurestate"/>
</element>
</optional>
<optional>
<element name="emsr_bitmap">
<ref name="featurestate"/>
</element>
</optional>
</interleave>
</group>
</choice>

View 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;

View 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"

View 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;
}

View 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));

View File

@ -285,6 +285,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -287,6 +287,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -285,6 +285,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -288,6 +288,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -289,6 +289,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -288,6 +288,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -290,6 +290,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -289,6 +289,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -290,6 +290,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -290,6 +290,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -291,6 +291,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -290,6 +290,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -294,6 +294,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -290,6 +290,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -294,6 +294,7 @@
<value>tlbflush</value>
<value>ipi</value>
<value>avic</value>
<value>emsr_bitmap</value>
</enum>
</hyperv>
<launchSecurity supported='no'/>

View File

@ -3456,5 +3456,6 @@
<cap name='tlbflush'/>
<cap name='ipi'/>
<cap name='avic'/>
<cap name='emsr_bitmap'/>
</hypervCapabilities>
</qemuCaps>

View File

@ -3785,5 +3785,6 @@
<cap name='tlbflush'/>
<cap name='ipi'/>
<cap name='avic'/>
<cap name='emsr_bitmap'/>
</hypervCapabilities>
</qemuCaps>

View File

@ -3759,5 +3759,6 @@
<cap name='tlbflush'/>
<cap name='ipi'/>
<cap name='avic'/>
<cap name='emsr_bitmap'/>
</hypervCapabilities>
</qemuCaps>

View File

@ -3694,5 +3694,6 @@
<cap name='tlbflush'/>
<cap name='ipi'/>
<cap name='avic'/>
<cap name='emsr_bitmap'/>
</hypervCapabilities>
</qemuCaps>

View File

@ -3950,5 +3950,6 @@
<cap name='tlbflush'/>
<cap name='ipi'/>
<cap name='avic'/>
<cap name='emsr_bitmap'/>
</hypervCapabilities>
</qemuCaps>

View 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'>

View File

@ -25,6 +25,7 @@
<tlbflush state='off'/>
<ipi state='off'/>
<evmcs state='off'/>
<emsr_bitmap state='off'/>
</hyperv>
</features>
<clock offset='utc'/>

View 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 \

View 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'>

View File

@ -26,6 +26,7 @@
<ipi state='on'/>
<evmcs state='on'/>
<avic state='on'/>
<emsr_bitmap state='on'/>
</hyperv>
</features>
<clock offset='utc'/>