Qemu-3.0 supports Hyper-V-style PV TLB flush, Windows guests can benefit from this feature as KVM knows which vCPUs are not currently scheduled (and thus don't require any immediate action). Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> --- docs/formatdomain.html.in | 7 +++++++ docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 6 +++++- src/conf/domain_conf.h | 1 + src/cpu/cpu_x86.c | 3 +++ src/cpu/cpu_x86_data.h | 1 + src/qemu/qemu_command.c | 1 + src/qemu/qemu_parse_command.c | 1 + src/qemu/qemu_process.c | 1 + tests/qemuxml2argvdata/hyperv-off.xml | 1 + tests/qemuxml2argvdata/hyperv.args | 2 +- tests/qemuxml2argvdata/hyperv.xml | 1 + tests/qemuxml2xmloutdata/hyperv-off.xml | 1 + tests/qemuxml2xmloutdata/hyperv.xml | 1 + 14 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index de0993696e..c37a4389dc 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1939,6 +1939,7 @@ <vendor_id state='on' value='KVM Hv'/> <frequencies state='on'/> <reenlightenment state='on'/> + <tlbflush state='on'/> </hyperv> <kvm> <hidden state='on'/> @@ -2073,6 +2074,12 @@ <td> on, off</td> <td><span class="since">4.7.0 (QEMU 3.0)</span></td> </tr> + <tr> + <td>tlbflush</td> + <td>Enable PV TLB flush support</td> + <td> on, off</td> + <td><span class="since">4.7.0 (QEMU 3.0)</span></td> + </tr> </table> </dd> <dt><code>pvspinlock</code></dt> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index b2a1ebfa3f..eab2618e51 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5726,6 +5726,11 @@ <ref name="featurestate"/> </element> </optional> + <optional> + <element name="tlbflush"> + <ref name="featurestate"/> + </element> + </optional> </interleave> </element> </define> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e2154b5bf7..f32bbd760c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -171,7 +171,8 @@ VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST, "reset", "vendor_id", "frequencies", - "reenlightenment") + "reenlightenment", + "tlbflush") VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST, "hidden") @@ -20021,6 +20022,7 @@ virDomainDefParseXML(xmlDocPtr xml, case VIR_DOMAIN_HYPERV_RESET: case VIR_DOMAIN_HYPERV_FREQUENCIES: case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: + case VIR_DOMAIN_HYPERV_TLBFLUSH: break; case VIR_DOMAIN_HYPERV_SPINLOCKS: @@ -22207,6 +22209,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src, case VIR_DOMAIN_HYPERV_RESET: case VIR_DOMAIN_HYPERV_FREQUENCIES: case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: + case VIR_DOMAIN_HYPERV_TLBFLUSH: if (src->hyperv_features[i] != dst->hyperv_features[i]) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("State of HyperV enlightenment " @@ -27859,6 +27862,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, case VIR_DOMAIN_HYPERV_RESET: case VIR_DOMAIN_HYPERV_FREQUENCIES: case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: + case VIR_DOMAIN_HYPERV_TLBFLUSH: break; case VIR_DOMAIN_HYPERV_SPINLOCKS: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8fa5002985..1287e862fc 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1793,6 +1793,7 @@ typedef enum { VIR_DOMAIN_HYPERV_VENDOR_ID, VIR_DOMAIN_HYPERV_FREQUENCIES, VIR_DOMAIN_HYPERV_REENLIGHTENMENT, + VIR_DOMAIN_HYPERV_TLBFLUSH, VIR_DOMAIN_HYPERV_LAST } virDomainHyperv; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 7a48b78eb9..7fa84f6014 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -113,6 +113,8 @@ KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_FREQUENCIES, 0x40000003, 0x00000800); KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_REENLIGHTENMENT, 0x40000003, 0x00002000); +KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_TLBFLUSH, + 0x40000004, 0x00000004); static virCPUx86Feature x86_kvm_features[] = { @@ -135,6 +137,7 @@ static virCPUx86Feature x86_kvm_features[] = KVM_FEATURE(VIR_CPU_x86_KVM_HV_RESET), KVM_FEATURE(VIR_CPU_x86_KVM_HV_FREQUENCIES), KVM_FEATURE(VIR_CPU_x86_KVM_HV_REENLIGHTENMENT), + KVM_FEATURE(VIR_CPU_x86_KVM_HV_TLBFLUSH), }; typedef struct _virCPUx86Model virCPUx86Model; diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h index a810c64fc9..090a21156f 100644 --- a/src/cpu/cpu_x86_data.h +++ b/src/cpu/cpu_x86_data.h @@ -65,6 +65,7 @@ struct _virCPUx86CPUID { # define VIR_CPU_x86_KVM_HV_RESET "__kvm_hv_reset" # define VIR_CPU_x86_KVM_HV_FREQUENCIES "__kvm_hv_frequencies" # define VIR_CPU_x86_KVM_HV_REENLIGHTENMENT "__kvm_hv_reenlightenment" +# define VIR_CPU_x86_KVM_HV_TLBFLUSH "__kvm_hv_tlbflush" # define VIR_CPU_X86_DATA_INIT { 0 } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 17d4c0a359..f0b2553c5e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6922,6 +6922,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, case VIR_DOMAIN_HYPERV_RESET: case VIR_DOMAIN_HYPERV_FREQUENCIES: case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: + case VIR_DOMAIN_HYPERV_TLBFLUSH: if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON) virBufferAsprintf(&buf, ",hv_%s", virDomainHypervTypeToString(i)); diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index 1e67a5a8c8..fdc1d34068 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -1538,6 +1538,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom, case VIR_DOMAIN_HYPERV_RESET: case VIR_DOMAIN_HYPERV_FREQUENCIES: case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: + case VIR_DOMAIN_HYPERV_TLBFLUSH: if (value) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("HyperV feature '%s' should not " diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e97628dd4a..19a7405d99 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3914,6 +3914,7 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def, case VIR_DOMAIN_HYPERV_RESET: case VIR_DOMAIN_HYPERV_FREQUENCIES: case VIR_DOMAIN_HYPERV_REENLIGHTENMENT: + case VIR_DOMAIN_HYPERV_TLBFLUSH: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("host doesn't support hyperv '%s' feature"), virDomainHypervTypeToString(i)); diff --git a/tests/qemuxml2argvdata/hyperv-off.xml b/tests/qemuxml2argvdata/hyperv-off.xml index b2e3612df9..dc5777355f 100644 --- a/tests/qemuxml2argvdata/hyperv-off.xml +++ b/tests/qemuxml2argvdata/hyperv-off.xml @@ -22,6 +22,7 @@ <vendor_id state='off'/> <frequencies state='off'/> <reenlightenment state='off'/> + <tlbflush state='off'/> </hyperv> </features> <clock offset='utc'/> diff --git a/tests/qemuxml2argvdata/hyperv.args b/tests/qemuxml2argvdata/hyperv.args index 4feafad8e2..6ee6198fb0 100644 --- a/tests/qemuxml2argvdata/hyperv.args +++ b/tests/qemuxml2argvdata/hyperv.args @@ -10,7 +10,7 @@ QEMU_AUDIO_DRV=none \ -machine pc,accel=tcg,usb=off,dump-guest-core=off \ -cpu 'qemu32,hv_relaxed,hv_vapic,hv_spinlocks=0x2fff,hv_vpindex,hv_runtime,\ hv_synic,hv_stimer,hv_reset,hv_vendor_id=KVM Hv,hv_frequencies,\ -hv_reenlightenment' \ +hv_reenlightenment,hv_tlbflush' \ -m 214 \ -smp 6,sockets=6,cores=1,threads=1 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ diff --git a/tests/qemuxml2argvdata/hyperv.xml b/tests/qemuxml2argvdata/hyperv.xml index 20fcdba59e..816adf6907 100644 --- a/tests/qemuxml2argvdata/hyperv.xml +++ b/tests/qemuxml2argvdata/hyperv.xml @@ -22,6 +22,7 @@ <vendor_id state='on' value='KVM Hv'/> <frequencies state='on'/> <reenlightenment state='on'/> + <tlbflush state='on'/> </hyperv> </features> <clock offset='utc'/> diff --git a/tests/qemuxml2xmloutdata/hyperv-off.xml b/tests/qemuxml2xmloutdata/hyperv-off.xml index 4a41e0c37e..77a8dac810 100644 --- a/tests/qemuxml2xmloutdata/hyperv-off.xml +++ b/tests/qemuxml2xmloutdata/hyperv-off.xml @@ -22,6 +22,7 @@ <vendor_id state='off'/> <frequencies state='off'/> <reenlightenment state='off'/> + <tlbflush state='off'/> </hyperv> </features> <clock offset='utc'/> diff --git a/tests/qemuxml2xmloutdata/hyperv.xml b/tests/qemuxml2xmloutdata/hyperv.xml index 183b45980b..fc8c59a557 100644 --- a/tests/qemuxml2xmloutdata/hyperv.xml +++ b/tests/qemuxml2xmloutdata/hyperv.xml @@ -22,6 +22,7 @@ <vendor_id state='on' value='KVM Hv'/> <frequencies state='on'/> <reenlightenment state='on'/> + <tlbflush state='on'/> </hyperv> </features> <clock offset='utc'/> -- 2.14.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list