mbox series

[v6,00/19] i386: KVM: expand Hyper-V features early

Message ID 20210422161130.652779-1-vkuznets@redhat.com (mailing list archive)
Headers show
Series i386: KVM: expand Hyper-V features early | expand

Message

Vitaly Kuznetsov April 22, 2021, 4:11 p.m. UTC
Changes since v5:
- Temporary drop 'hv-default' feature as it is causing some controversy.
 The rest of the patchset is valuable on its own.
- Add 3 additiona fixes:
 i386: kill off hv_cpuid_check_and_set() [Igor's suggestion]
 i386: HV_HYPERCALL_AVAILABLE privilege bit is always needed
 i386: Hyper-V SynIC requires POST_MESSAGES/SIGNAL_EVENTS priviliges

The last two patches are inspired by 'Fine-grained access check to Hyper-V
hypercalls and MSRs' work for KVM:
https://lore.kernel.org/kvm/20210419160127.192712-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 (19):
  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: 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 +
 target/i386/cpu.c              | 113 +-------
 target/i386/cpu.h              |   6 +-
 target/i386/kvm/hyperv-proto.h |   6 +
 target/i386/kvm/kvm-stub.c     |   5 +
 target/i386/kvm/kvm.c          | 514 +++++++++++++++++----------------
 target/i386/kvm/kvm_i386.h     |   1 +
 tests/qtest/hyperv-test.c      | 225 +++++++++++++++
 tests/qtest/meson.build        |   3 +-
 9 files changed, 526 insertions(+), 348 deletions(-)
 create mode 100644 tests/qtest/hyperv-test.c

Comments

Eduardo Habkost May 26, 2021, 8:20 p.m. UTC | #1
On Thu, Apr 22, 2021 at 06:11:11PM +0200, Vitaly Kuznetsov wrote:
> Vitaly Kuznetsov (19):
>   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

I'm queueing patches 1-14 (the ones above) on my x86-next branch.
Thanks!

>   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
Vitaly Kuznetsov May 27, 2021, 7:39 a.m. UTC | #2
Eduardo Habkost <ehabkost@redhat.com> writes:

> On Thu, Apr 22, 2021 at 06:11:11PM +0200, Vitaly Kuznetsov wrote:
>> Vitaly Kuznetsov (19):
>>   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
>
> I'm queueing patches 1-14 (the ones above) on my x86-next branch.

Thank you! Is it published somewhere so I can base next version[s] on it?
Eduardo Habkost May 27, 2021, 7:35 p.m. UTC | #3
On Thu, May 27, 2021 at 09:39:02AM +0200, Vitaly Kuznetsov wrote:
> Eduardo Habkost <ehabkost@redhat.com> writes:
> 
> > On Thu, Apr 22, 2021 at 06:11:11PM +0200, Vitaly Kuznetsov wrote:
> >> Vitaly Kuznetsov (19):
> >>   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
> >
> > I'm queueing patches 1-14 (the ones above) on my x86-next branch.
> 
> Thank you! Is it published somewhere so I can base next version[s] on it? 

Yes: http://gitlab.com/ehabkost/qemu x86-next