mbox series

[v5,00/17] i386: KVM: expand Hyper-V features early and provide simple 'hv-default=on' option

Message ID 20210301135103.306003-1-vkuznets@redhat.com (mailing list archive)
Headers show
Series i386: KVM: expand Hyper-V features early and provide simple 'hv-default=on' option | expand

Message

Vitaly Kuznetsov March 1, 2021, 1:50 p.m. UTC
Changes since v4:
- Temporary drop 'hv-evmcs' from the 'hv-default' set as handling it
 properly requires custom options parsers (we need to e.g distinguish
 between 'hv-default,-vmx' and 'hv-default,hv-evmcs,-vmx') but custom
 parsers are called evil. I'm not giving up on the idea, I just want
 to get things moving here. I'll be sending patches to add 'hv-evmcs'
 back separately.
- Patch to support 'hv-passthrough,hv-feature=off' is also dropped
 for now, we'll get back to it later (with either custom option
 parsers or 'scratch CPUs' depending on 'hv-evmcs' discussion 
 outcome).
- Null-terminate hv-vendor string in 'hv-passthrough' mode (bug in
  PATCH1).

Original description:

Upper layer tools like libvirt want to figure out which Hyper-V features are
supported by the underlying stack (QEMU/KVM) but currently they are unable to
do so. We have a nice 'hv_passthrough' CPU flag supported by QEMU but it has
no effect on e.g. QMP's 

query-cpu-model-expansion type=full model={"name":"host","props":{"hv-passthrough":true}}

command as we parse Hyper-V features after creating KVM vCPUs and not at
feature expansion time. To support the use-case we first need to make 
KVM_GET_SUPPORTED_HV_CPUID ioctl a system-wide ioctl as the existing
vCPU version can't be used that early. This is what KVM part does. With
that done, we can make early Hyper-V feature expansion (this series).

In addition, provide a simple 'hv-default' option which enables (and
requires from KVM) all currently supported Hyper-V enlightenments except
for 'hv-evmcs' (for now). Unlike 'hv-passthrough' mode, this is going to be
migratable.

Vitaly Kuznetsov (17):
  i386: keep hyperv_vendor string up-to-date
  i386: invert hyperv_spinlock_attempts setting logic with
    hv_passthrough
  i386: always fill Hyper-V CPUID feature leaves from X86CPU data
  i386: stop using env->features[] for filling Hyper-V CPUIDs
  i386: introduce hyperv_feature_supported()
  i386: introduce hv_cpuid_get_host()
  i386: drop FEAT_HYPERV feature leaves
  i386: introduce hv_cpuid_cache
  i386: split hyperv_handle_properties() into
    hyperv_expand_features()/hyperv_fill_cpuids()
  i386: move eVMCS enablement to hyperv_init_vcpu()
  i386: switch hyperv_expand_features() to using error_setg()
  i386: adjust the expected KVM_GET_SUPPORTED_HV_CPUID array size
  i386: prefer system KVM_GET_SUPPORTED_HV_CPUID ioctl over vCPU's one
  i386: use global kvm_state in hyperv_enabled() check
  i386: expand Hyper-V features during CPU feature expansion time
  i386: provide simple 'hv-default=on' option
  qtest/hyperv: Introduce a simple hyper-v test

 MAINTAINERS                |   1 +
 docs/hyperv.txt            |  18 +-
 target/i386/cpu.c          | 163 +++++-------
 target/i386/cpu.h          |   9 +-
 target/i386/kvm/kvm-stub.c |   5 +
 target/i386/kvm/kvm.c      | 517 ++++++++++++++++++++-----------------
 target/i386/kvm/kvm_i386.h |   1 +
 tests/qtest/hyperv-test.c  | 270 +++++++++++++++++++
 tests/qtest/meson.build    |   3 +-
 9 files changed, 645 insertions(+), 342 deletions(-)
 create mode 100644 tests/qtest/hyperv-test.c