[PATCH v7 0/9] i386: KVM: expand Hyper-V features early

Vitaly Kuznetsov posted 9 patches 2 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/next-importer-push tags/patchew/20210603114835.847451-1-vkuznets@redhat.com
Maintainers: Laurent Vivier <lvivier@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Thomas Huth <thuth@redhat.com>
There is a newer version of this series
MAINTAINERS                    |   1 +
docs/hyperv.txt                |   9 +-
target/i386/cpu.c              |  13 +-
target/i386/kvm/hyperv-proto.h |   6 +
target/i386/kvm/kvm-stub.c     |   5 +
target/i386/kvm/kvm.c          | 166 ++++++++++++------------
target/i386/kvm/kvm_i386.h     |   1 +
tests/qtest/hyperv-test.c      | 225 +++++++++++++++++++++++++++++++++
tests/qtest/meson.build        |   3 +-
9 files changed, 337 insertions(+), 92 deletions(-)
create mode 100644 tests/qtest/hyperv-test.c
[PATCH v7 0/9] i386: KVM: expand Hyper-V features early
Posted by Vitaly Kuznetsov 2 years, 10 months ago
Changes since v6 [Eduardo]:
- First 14 patches of v6 made it upstream!
- New patches addressing feedback on the already merged patches added:
  i386: make hyperv_expand_features() return bool
  i386: hardcode supported eVMCS version to '1'
  i386: clarify 'hv-passthrough' behavior
  i386: avoid hardcoding '12' as 'hyperv_vendor_id' length
- Some comments expanded.
- HV_HYPERCALL_AVAILABLE setting moved to hyperv_fill_cpuids()

Note: Windows guest on QEMU are currently completely broken, see Claudio's
https://lore.kernel.org/kvm/20210529091313.16708-1-cfontana@suse.de/

The last two functional patches are inspired by 'Fine-grained access check
to Hyper-V hypercalls and MSRs' work for KVM:
https://lore.kernel.org/kvm/20210521095204.2161214-1-vkuznets@redhat.com/

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).

Vitaly Kuznetsov (9):
  i386: avoid hardcoding '12' as 'hyperv_vendor_id' length
  i386: clarify 'hv-passthrough' behavior
  i386: hardcode supported eVMCS version to '1'
  i386: make hyperv_expand_features() return bool
  i386: expand Hyper-V features during CPU feature expansion time
  i386: kill off hv_cpuid_check_and_set()
  i386: HV_HYPERCALL_AVAILABLE privilege bit is always needed
  i386: Hyper-V SynIC requires POST_MESSAGES/SIGNAL_EVENTS priviliges
  qtest/hyperv: Introduce a simple hyper-v test

 MAINTAINERS                    |   1 +
 docs/hyperv.txt                |   9 +-
 target/i386/cpu.c              |  13 +-
 target/i386/kvm/hyperv-proto.h |   6 +
 target/i386/kvm/kvm-stub.c     |   5 +
 target/i386/kvm/kvm.c          | 166 ++++++++++++------------
 target/i386/kvm/kvm_i386.h     |   1 +
 tests/qtest/hyperv-test.c      | 225 +++++++++++++++++++++++++++++++++
 tests/qtest/meson.build        |   3 +-
 9 files changed, 337 insertions(+), 92 deletions(-)
 create mode 100644 tests/qtest/hyperv-test.c

-- 
2.31.1


Re: [PATCH v7 0/9] i386: KVM: expand Hyper-V features early
Posted by Eduardo Habkost 2 years, 9 months ago
On Thu, Jun 03, 2021 at 01:48:26PM +0200, Vitaly Kuznetsov wrote:
> Changes since v6 [Eduardo]:
> - First 14 patches of v6 made it upstream!
> - New patches addressing feedback on the already merged patches added:
>   i386: make hyperv_expand_features() return bool
>   i386: hardcode supported eVMCS version to '1'
>   i386: clarify 'hv-passthrough' behavior
>   i386: avoid hardcoding '12' as 'hyperv_vendor_id' length
> - Some comments expanded.
> - HV_HYPERCALL_AVAILABLE setting moved to hyperv_fill_cpuids()
> 
> Note: Windows guest on QEMU are currently completely broken, see Claudio's
> https://lore.kernel.org/kvm/20210529091313.16708-1-cfontana@suse.de/
> 
> The last two functional patches are inspired by 'Fine-grained access check
> to Hyper-V hypercalls and MSRs' work for KVM:
> https://lore.kernel.org/kvm/20210521095204.2161214-1-vkuznets@redhat.com/
> 
> 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).

I'm finally queueing this.  Thanks, and sorry for the delay!

-- 
Eduardo