Re: About the performance of hyper-v

2021-05-19 Thread Vitaly Kuznetsov
Liang Li writes: > [resend for missing cc] > > Hi Vitaly, > > I found a case that the virtualization overhead was almost doubled > when turning on Hper-v related features compared to that without any > no hyper-v feature. It happens when running a 3D game in windows > guest in qemu kvm

Re: [PATCH v6 01/19] i386: keep hyperv_vendor string up-to-date

2021-06-02 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Thu, Apr 22, 2021 at 06:11:12PM +0200, Vitaly Kuznetsov wrote: >> When cpu->hyperv_vendor is not set manually we default to "Microsoft Hv" >> and in 'hv_passthrough' mode we get the information from the host. This >> information

Re: About the performance of hyper-v

2021-05-24 Thread Vitaly Kuznetsov
Liang Li writes: >> >> > Analyze events for all VMs, all VCPUs: >> >> > VM-EXITSamples Samples% Time%Min TimeMax >> >> > Time Avg time >> >> > EXTERNAL_INTERRUPT 47183159.89%68.58% 0.64us >> >> > 65.42us 2.34us ( +- 0.11% ) >> >> >

Re: [PATCH v7 3/9] i386: hardcode supported eVMCS version to '1'

2021-06-07 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Fri, Jun 04, 2021 at 09:28:15AM +0200, Vitaly Kuznetsov wrote: >> Eduardo Habkost writes: >> >> > On Thu, Jun 03, 2021 at 01:48:29PM +0200, Vitaly Kuznetsov wrote: >> >> Currently, the only eVMCS version, supported by KVM (and d

Re: [PATCH 1/2] i386: reorder call to cpu_exec_realizefn in x86_cpu_realizefn

2021-06-03 Thread Vitaly Kuznetsov
Eduardo Habkost writes: >> >> diff --git a/target/i386/cpu.c b/target/i386/cpu.c >> index 9e211ac2ce..6bcb7dbc2c 100644 >> --- a/target/i386/cpu.c >> +++ b/target/i386/cpu.c >> @@ -6133,34 +6133,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error >> **errp) >> Error *local_err =

[PATCH v7 3/9] i386: hardcode supported eVMCS version to '1'

2021-06-03 Thread Vitaly Kuznetsov
-evmcs=2'). Signed-off-by: Vitaly Kuznetsov --- docs/hyperv.txt | 2 +- target/i386/kvm/kvm.c | 16 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index a51953daa833..000638a2fd38 100644 --- a/docs/hyperv.txt +++ b/docs

[PATCH v7 9/9] qtest/hyperv: Introduce a simple hyper-v test

2021-06-03 Thread Vitaly Kuznetsov
For the beginning, just test 'hv-passthrough' and a couple of custom Hyper-V enlightenments configurations through QMP. Later, it would be great to complement this by checking CPUID values from within the guest. Signed-off-by: Vitaly Kuznetsov --- MAINTAINERS | 1 + tests/qtest

[PATCH v7 6/9] i386: kill off hv_cpuid_check_and_set()

2021-06-03 Thread Vitaly Kuznetsov
lso, in 'passthrough' mode we don't really need to check dependencies because KVM is supposed to provide a consistent set anyway. Reviewed-by: Eduardo Habkost Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 104 +++--- 1 file changed, 36 insertions(+),

[PATCH v7 8/9] i386: Hyper-V SynIC requires POST_MESSAGES/SIGNAL_EVENTS priviliges

2021-06-03 Thread Vitaly Kuznetsov
When Hyper-V SynIC is enabled, we may need to allow Windows guests to make hypercalls (POST_MESSAGES/SIGNAL_EVENTS). No issue is currently observed because KVM is very permissive, allowing these hypercalls regarding of guest visible CPUid bits. Signed-off-by: Vitaly Kuznetsov --- target/i386

[PATCH v7 7/9] i386: HV_HYPERCALL_AVAILABLE privilege bit is always needed

2021-06-03 Thread Vitaly Kuznetsov
is observed. We may, however, want to tighten the checks eventually. Conforming to the spec is probably also a good idea. Enable HV_HYPERCALL_AVAILABLE bit unconditionally. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff

[PATCH v7 2/9] i386: clarify 'hv-passthrough' behavior

2021-06-03 Thread Vitaly Kuznetsov
Clarify the fact that 'hv-passthrough' only enables features which are already known to QEMU and that it overrides all other 'hv-*' settings. Signed-off-by: Vitaly Kuznetsov --- docs/hyperv.txt | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/hyperv.txt b/docs

[PATCH v7 1/9] i386: avoid hardcoding '12' as 'hyperv_vendor_id' length

2021-06-03 Thread Vitaly Kuznetsov
While this is very unlikely to change, let's avoid hardcoding '12' as 'hyperv_vendor_id' length. No functional change intended. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/target/i386/cpu.c b/target/i386

[PATCH v7 4/9] i386: make hyperv_expand_features() return bool

2021-06-03 Thread Vitaly Kuznetsov
Return 'false' when hyperv_expand_features() sets an error. No functional change intended. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 40 +--- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target

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

2021-06-03 Thread Vitaly Kuznetsov
y 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

[PATCH v7 5/9] i386: expand Hyper-V features during CPU feature expansion time

2021-06-03 Thread Vitaly Kuznetsov
can't use kvm_arch_get_supported_cpuid() as Hyper-V specific CPUID leaves intersect with KVM's. Note, early expansion will only happen when KVM supports system wide KVM_GET_SUPPORTED_HV_CPUID ioctl (KVM_CAP_SYS_HYPERV_CPUID). Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 4

Re: [PATCH v7 3/9] i386: hardcode supported eVMCS version to '1'

2021-06-04 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Thu, Jun 03, 2021 at 01:48:29PM +0200, Vitaly Kuznetsov wrote: >> Currently, the only eVMCS version, supported by KVM (and described in TLFS) >> is '1'. When Enlightened VMCS feature is enabled, QEMU takes the supported >> eVMC

Re: [PATCH v7 8/9] i386: Hyper-V SynIC requires POST_MESSAGES/SIGNAL_EVENTS priviliges

2021-06-04 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Thu, Jun 03, 2021 at 01:48:34PM +0200, Vitaly Kuznetsov wrote: >> When Hyper-V SynIC is enabled, we may need to allow Windows guests to make >> hypercalls (POST_MESSAGES/SIGNAL_EVENTS). No issue is currently observed >> because KVM is very

Re: [PATCH v7 5/9] i386: expand Hyper-V features during CPU feature expansion time

2021-06-04 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Thu, Jun 03, 2021 at 01:48:31PM +0200, Vitaly Kuznetsov wrote: >> To make Hyper-V features appear in e.g. QMP query-cpu-model-expansion we >> need to expand and set the corresponding CPUID leaves early. Modify >> x86_cpu_get_supported_feature

Re: [PATCH v7 9/9] qtest/hyperv: Introduce a simple hyper-v test

2021-06-04 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Thu, Jun 03, 2021 at 01:48:35PM +0200, Vitaly Kuznetsov wrote: >> For the beginning, just test 'hv-passthrough' and a couple of custom >> Hyper-V enlightenments configurations through QMP. Later, it would >> be great to complement this by check

Re: [PATCH v6 17/19] i386: HV_HYPERCALL_AVAILABLE privilege bit is always needed

2021-05-27 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Mon, May 24, 2021 at 02:22:47PM +0200, Vitaly Kuznetsov wrote: >> Eduardo Habkost writes: >> >> > On Thu, Apr 22, 2021 at 06:11:28PM +0200, Vitaly Kuznetsov wrote: >> >> According to TLFS, Hyper-V guest is supposed to check &g

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

2021-05-27 Thread Vitaly Kuznetsov
Eduardo Habkost 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:

Re: [PATCH v6 10/19] i386: move eVMCS enablement to hyperv_init_vcpu()

2021-05-27 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Mon, May 24, 2021 at 02:00:37PM +0200, Vitaly Kuznetsov wrote: > [...] >> >> @@ -1455,6 +1454,21 @@ static int hyperv_init_vcpu(X86CPU *cpu) >> >> } >> >> } >> >> >> >> +if (hype

Re: [PATCH v6 15/19] i386: expand Hyper-V features during CPU feature expansion time

2021-05-27 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Mon, May 24, 2021 at 02:13:09PM +0200, Vitaly Kuznetsov wrote: > [...] >> >> diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c >> >> index a42263b24fca..d5551c4ab5cf 100644 >> >> --- a/target/i386/kvm/kvm.c >>

Re: [PATCH v6 10/19] i386: move eVMCS enablement to hyperv_init_vcpu()

2021-05-24 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Thu, Apr 22, 2021 at 06:11:21PM +0200, Vitaly Kuznetsov wrote: >> hyperv_expand_features() will be called before we create vCPU so >> evmcs enablement should go away. hyperv_init_vcpu() looks like the >> right place. >> >>

Re: [PATCH v6 15/19] i386: expand Hyper-V features during CPU feature expansion time

2021-05-24 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Thu, Apr 22, 2021 at 06:11:26PM +0200, Vitaly Kuznetsov wrote: >> To make Hyper-V features appear in e.g. QMP query-cpu-model-expansion we >> need to expand and set the corresponding CPUID leaves early. Modify >> x86_cpu_get_supported_feature

Re: [PATCH v6 17/19] i386: HV_HYPERCALL_AVAILABLE privilege bit is always needed

2021-05-24 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Thu, Apr 22, 2021 at 06:11:28PM +0200, Vitaly Kuznetsov wrote: >> According to TLFS, Hyper-V guest is supposed to check >> HV_HYPERCALL_AVAILABLE privilege bit before accessing >> HV_X64_MSR_GUEST_OS_ID/HV_X64_MSR_HYPERCALL MSRs but at least som

Re: [PATCH v6 13/19] i386: prefer system KVM_GET_SUPPORTED_HV_CPUID ioctl over vCPU's one

2021-05-24 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Thu, Apr 22, 2021 at 06:11:24PM +0200, Vitaly Kuznetsov wrote: >> KVM_GET_SUPPORTED_HV_CPUID was made a system wide ioctl which can be called >> prior to creating vCPUs and we are going to use that to expand Hyper-V cpu >> features early. Use it

Re: [PATCH v6 16/19] i386: kill off hv_cpuid_check_and_set()

2021-05-24 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Thu, Apr 22, 2021 at 06:11:27PM +0200, Vitaly Kuznetsov wrote: >> hv_cpuid_check_and_set() does too much: >> - Checks if the feature is supported by KVM; >> - Checks if all dependencies are enabled; >> - Sets the feature bit in cpu->hy

Re: [PATCH v6 11/19] i386: switch hyperv_expand_features() to using error_setg()

2021-05-24 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Thu, Apr 22, 2021 at 06:11:22PM +0200, Vitaly Kuznetsov wrote: >> Use standard error_setg() mechanism in hyperv_expand_features(). >> >> Signed-off-by: Vitaly Kuznetsov > > No objections, but only suggestions below: > >>

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

2021-04-22 Thread Vitaly Kuznetsov
d 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 feat

[PATCH v6 04/19] i386: stop using env->features[] for filling Hyper-V CPUIDs

2021-04-22 Thread Vitaly Kuznetsov
As a preparatory patch to dropping Hyper-V CPUID leaves from feature_word_info[] stop using env->features[] as a temporary storage of Hyper-V CPUIDs, just build Hyper-V CPUID leaves directly from kvm_hyperv_properties[] data. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.h |

[PATCH v6 03/19] i386: always fill Hyper-V CPUID feature leaves from X86CPU data

2021-04-22 Thread Vitaly Kuznetsov
but arguably this is a good change. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 9 - 1 file changed, 9 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index afd173514da1..7c751185491f 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c

[PATCH v6 07/19] i386: drop FEAT_HYPERV feature leaves

2021-04-22 Thread Vitaly Kuznetsov
PUID func/reg pairs for features, this allows us to get rid of hv_cpuid_get_fw() conversion. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 90 +-- target/i386/cpu.h | 5 -- target/i386/kvm/kvm.c | 108 ++

[PATCH v6 08/19] i386: introduce hv_cpuid_cache

2021-04-22 Thread Vitaly Kuznetsov
ote, hv_cpuid_get_fw() is converted to using hv_cpuid_get_host() just to be removed later with Hyper-V specific feature words. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 109 ++ 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/target/i386/

[PATCH v6 13/19] i386: prefer system KVM_GET_SUPPORTED_HV_CPUID ioctl over vCPU's one

2021-04-22 Thread Vitaly Kuznetsov
KVM_GET_SUPPORTED_HV_CPUID was made a system wide ioctl which can be called prior to creating vCPUs and we are going to use that to expand Hyper-V cpu features early. Use it when it is supported by KVM. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 17 + 1 file

[PATCH v6 06/19] i386: introduce hv_cpuid_get_host()

2021-04-22 Thread Vitaly Kuznetsov
As a preparation to implementing hv_cpuid_cache intro introduce hv_cpuid_get_host(). No functional change intended. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 102 +++--- 1 file changed, 57 insertions(+), 45 deletions(-) diff --git a/target

[PATCH v6 02/19] i386: invert hyperv_spinlock_attempts setting logic with hv_passthrough

2021-04-22 Thread Vitaly Kuznetsov
There is no need to have this special case: like all other Hyper-V enlightenments we can just use kernel's supplied value in hv_passthrough mode. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/target/i386/kvm

[PATCH v6 16/19] i386: kill off hv_cpuid_check_and_set()

2021-04-22 Thread Vitaly Kuznetsov
lso, in 'passthrough' mode we don't really need to check dependencies because KVM is supposed to provide a consistent set anyway. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 105 +++--- 1 file changed, 36 insertions(+), 69 deletions(-) diff --git a/tar

[PATCH v6 10/19] i386: move eVMCS enablement to hyperv_init_vcpu()

2021-04-22 Thread Vitaly Kuznetsov
hyperv_expand_features() will be called before we create vCPU so evmcs enablement should go away. hyperv_init_vcpu() looks like the right place. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 60 ++- 1 file changed, 37 insertions(+), 23

[PATCH v6 18/19] i386: Hyper-V SynIC requires POST_MESSAGES/SIGNAL_EVENTS priviliges

2021-04-22 Thread Vitaly Kuznetsov
-by: Vitaly Kuznetsov --- target/i386/kvm/hyperv-proto.h | 6 ++ target/i386/kvm/kvm.c | 5 + 2 files changed, 11 insertions(+) diff --git a/target/i386/kvm/hyperv-proto.h b/target/i386/kvm/hyperv-proto.h index e30d64b4ade4..5fbb385cc136 100644 --- a/target/i386/kvm/hyperv

[PATCH v6 19/19] qtest/hyperv: Introduce a simple hyper-v test

2021-04-22 Thread Vitaly Kuznetsov
For the beginning, just test 'hv-passthrough' and a couple of custom Hyper-V enlightenments configurations through QMP. Later, it would be great to complement this by checking CPUID values from within the guest. Signed-off-by: Vitaly Kuznetsov --- MAINTAINERS | 1 + tests/qtest

[PATCH v6 01/19] i386: keep hyperv_vendor string up-to-date

2021-04-22 Thread Vitaly Kuznetsov
el-expansion output is incorrect. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 19 +-- target/i386/kvm/kvm.c | 5 + 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ad99cad0e7ce..2d05df232329 100644 ---

[PATCH v6 05/19] i386: introduce hyperv_feature_supported()

2021-04-22 Thread Vitaly Kuznetsov
Clean up hv_cpuid_check_and_set() by separating hyperv_feature_supported() off it. No functional change intended. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 49 ++- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/target

[PATCH v6 11/19] i386: switch hyperv_expand_features() to using error_setg()

2021-04-22 Thread Vitaly Kuznetsov
Use standard error_setg() mechanism in hyperv_expand_features(). Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 101 +- 1 file changed, 61 insertions(+), 40 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index

[PATCH v6 09/19] i386: split hyperv_handle_properties() into hyperv_expand_features()/hyperv_fill_cpuids()

2021-04-22 Thread Vitaly Kuznetsov
The intention is to call hyperv_expand_features() early, before vCPUs are created and use the acquired data later when we set guest visible CPUID data. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 34 -- 1 file changed, 24 insertions(+), 10

[PATCH v6 17/19] i386: HV_HYPERCALL_AVAILABLE privilege bit is always needed

2021-04-22 Thread Vitaly Kuznetsov
is observed. We may, however, want to tighten the checks eventually. Conforming to the spec is probably also a good idea. Add HV_HYPERCALL_AVAILABLE to all 'leaf' features with no dependencies. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 15 +-- 1 file changed, 9 insertions

[PATCH v6 12/19] i386: adjust the expected KVM_GET_SUPPORTED_HV_CPUID array size

2021-04-22 Thread Vitaly Kuznetsov
SYNDBG leaves were recently (Linux-5.8) added to KVM but we haven't updated the expected size of KVM_GET_SUPPORTED_HV_CPUID output in KVM so we now make serveral tries before succeeding. Update the default. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 3 ++- 1 file changed, 2

[PATCH v6 15/19] i386: expand Hyper-V features during CPU feature expansion time

2021-04-22 Thread Vitaly Kuznetsov
can't use kvm_arch_get_supported_cpuid() as Hyper-V specific CPUID leaves intersect with KVM's. Note, early expansion will only happen when KVM supports system wide KVM_GET_SUPPORTED_HV_CPUID ioctl (KVM_CAP_SYS_HYPERV_CPUID). Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 4

[PATCH v6 14/19] i386: use global kvm_state in hyperv_enabled() check

2021-04-22 Thread Vitaly Kuznetsov
There is no need to use vCPU-specific kvm state in hyperv_enabled() check and we need to do that when feature expansion happens early, before vCPU specific KVM state is created. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions

[PATCH v4 07/21] i386: drop FEAT_HYPERV feature leaves

2021-02-10 Thread Vitaly Kuznetsov
PUID func/reg pairs for features, this allows us to get rid of hv_cpuid_get_fw() conversion. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 90 +-- target/i386/cpu.h | 5 -- target/i386/kvm/kvm.c | 108 ++

[PATCH v4 02/21] i386: invert hyperv_spinlock_attempts setting logic with hv_passthrough

2021-02-10 Thread Vitaly Kuznetsov
There is no need to have this special case: like all other Hyper-V enlightenments we can just use kernel's supplied value in hv_passthrough mode. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/target/i386/kvm

[PATCH v4 00/19] i386: KVM: expand Hyper-V features early and provide simple 'hv-default=on' option

2021-02-10 Thread Vitaly Kuznetsov
a simple 'hv-default' option which enables (and requires from KVM) all currently supported Hyper-V enlightenments. Unlike 'hv-passthrough' mode, this is going to be migratable. Vitaly Kuznetsov (21): i386: keep hyperv_vendor string up-to-date i386: invert hyperv_spinlock_attempts setting logic wi

[PATCH v4 04/21] i386: stop using env->features[] for filling Hyper-V CPUIDs

2021-02-10 Thread Vitaly Kuznetsov
As a preparatory patch to dropping Hyper-V CPUID leaves from feature_word_info[] stop using env->features[] as a temporary storage of Hyper-V CPUIDs, just build Hyper-V CPUID leaves directly from kvm_hyperv_properties[] data. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.h |

[PATCH v4 10/21] i386: move eVMCS enablement to hyperv_init_vcpu()

2021-02-10 Thread Vitaly Kuznetsov
hyperv_expand_features() will be called before we create vCPU so evmcs enablement should go away. hyperv_init_vcpu() looks like the right place. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 60 ++- 1 file changed, 37 insertions(+), 23

[PATCH v4 03/21] i386: always fill Hyper-V CPUID feature leaves from X86CPU data

2021-02-10 Thread Vitaly Kuznetsov
but arguably this is a good change. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 9 - 1 file changed, 9 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 211efbd13b49..ba285a364792 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c

[PATCH v4 08/21] i386: introduce hv_cpuid_cache

2021-02-10 Thread Vitaly Kuznetsov
ote, hv_cpuid_get_fw() is converted to using hv_cpuid_get_host() just to be removed later with Hyper-V specific feature words. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 109 ++ 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/target/i386/

[PATCH v4 05/21] i386: introduce hyperv_feature_supported()

2021-02-10 Thread Vitaly Kuznetsov
Clean up hv_cpuid_check_and_set() by separating hyperv_feature_supported() off it. No functional change intended. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 49 ++- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/target

[PATCH v4 01/21] i386: keep hyperv_vendor string up-to-date

2021-02-10 Thread Vitaly Kuznetsov
el-expansion output is incorrect. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 19 +-- target/i386/kvm/kvm.c | 4 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 9c3d2d60b7e5..d03c1588ba0e 100644 ---

[PATCH v4 16/21] i386: track explicit 'hv-*' features enablement/disablement

2021-02-10 Thread Vitaly Kuznetsov
n an older kernel without KVM_CAP_SYS_HYPERV_CPUID support. To get the list of the supported Hyper-V features we need to actually create KVM VCPU and this happens much later. No functional change intended. Signed-off-by: Vitaly Kuznetsov --- target/i386/c

[PATCH v4 06/21] i386: introduce hv_cpuid_get_host()

2021-02-10 Thread Vitaly Kuznetsov
As a preparation to implementing hv_cpuid_cache intro introduce hv_cpuid_get_host(). No functional change intended. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 100 +++--- 1 file changed, 56 insertions(+), 44 deletions(-) diff --git a/target

[PATCH v4 13/21] i386: prefer system KVM_GET_SUPPORTED_HV_CPUID ioctl over vCPU's one

2021-02-10 Thread Vitaly Kuznetsov
KVM_GET_SUPPORTED_HV_CPUID was made a system wide ioctl which can be called prior to creating vCPUs and we are going to use that to expand Hyper-V cpu features early. Use it when it is supported by KVM. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 17 + 1 file

[PATCH v4 15/21] i386: expand Hyper-V features during CPU feature expansion time

2021-02-10 Thread Vitaly Kuznetsov
can't use kvm_arch_get_supported_cpuid() as Hyper-V specific CPUID leaves intersect with KVM's. Note, early expansion will only happen when KVM supports system wide KVM_GET_SUPPORTED_HV_CPUID ioctl (KVM_CAP_SYS_HYPERV_CPUID). Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 4

[PATCH v4 09/21] i386: split hyperv_handle_properties() into hyperv_expand_features()/hyperv_fill_cpuids()

2021-02-10 Thread Vitaly Kuznetsov
The intention is to call hyperv_expand_features() early, before vCPUs are created and use the acquired data later when we set guest visible CPUID data. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 34 -- 1 file changed, 24 insertions(+), 10

[PATCH v4 12/21] i386: adjust the expected KVM_GET_SUPPORTED_HV_CPUID array size

2021-02-10 Thread Vitaly Kuznetsov
SYNDBG leaves were recently (Linux-5.8) added to KVM but we haven't updated the expected size of KVM_GET_SUPPORTED_HV_CPUID output in KVM so we now make serveral tries before succeeding. Update the default. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 3 ++- 1 file changed, 2

[PATCH v4 21/21] qtest/hyperv: Introduce a simple hyper-v test

2021-02-10 Thread Vitaly Kuznetsov
For the beginning, just test 'hv-default', 'hv-passthrough' and a couple of custom Hyper-V enlightenments configurations through QMP. Later, it would be great to complement this by checking CPUID values from within the guest. Signed-off-by: Vitaly Kuznetsov --- MAINTAINERS | 1

[PATCH v4 11/21] i386: switch hyperv_expand_features() to using error_setg()

2021-02-10 Thread Vitaly Kuznetsov
Use standard error_setg() mechanism in hyperv_expand_features(). Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 101 +- 1 file changed, 61 insertions(+), 40 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index

[PATCH v4 18/21] i386: be more picky about implicit 'hv-evmcs' enablement

2021-02-10 Thread Vitaly Kuznetsov
possible scenario is 'hv-passthrough' which will enable 'hv-evmcs' when the host supports it, regardless of guest VMX exposure. The upcoming 'hv-default' should also avoid enabling 'hv-evmcs' without VMX. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 13 +++-- 1 file changed, 11

[PATCH v4 20/21] i386: provide simple 'hv-default=on' option

2021-02-10 Thread Vitaly Kuznetsov
e a simple 'hv-default=on' CPU flag enabling all currently supported Hyper-V enlightenments. Later, when new enlightenments get implemented, compat_props mechanism will be used to disable them for legacy machine types, this will keep 'hv-default=on' configurations migratable. Signed-off-by: Vitaly

[PATCH v4 14/21] i386: use global kvm_state in hyperv_enabled() check

2021-02-10 Thread Vitaly Kuznetsov
There is no need to use vCPU-specific kvm state in hyperv_enabled() check and we need to do that when feature expansion happens early, before vCPU specific KVM state is created. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions

[PATCH v4 17/21] i386: support 'hv-passthrough, hv-feature=off' on the command line

2021-02-10 Thread Vitaly Kuznetsov
make 'hv-passthrough' parse semantics in-line with other options in qemu: when specified, it overrides what was previously set with what's supported by the host. This can later be modified with 'hv-feature=on'/ 'hv-feature=off'. Signed-off-by: Vitaly Kuznetsov --- target

[PATCH v4 19/21] i386: introduce kvm_hv_evmcs_available()

2021-02-10 Thread Vitaly Kuznetsov
Enlightened VMCS feature is hardware specific, it is only supported on Intel CPUs. Introduce a simple kvm_hv_evmcs_available() helper, it will be used to filter out 'hv_evmcs' when 'hyperv=on' option is added to X86MachineClass. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm-stub.c | 5

Re: [PATCH v4 00/19] i386: KVM: expand Hyper-V features early and provide simple 'hv-default=on' option

2021-02-11 Thread Vitaly Kuznetsov
Eduardo Habkost writes: > On Wed, Feb 10, 2021 at 04:56:06PM +, Daniel P. Berrangé wrote: >> On Wed, Feb 10, 2021 at 05:40:12PM +0100, Vitaly Kuznetsov wrote: >> > Changes since v3: >> > - Make 'hv-default' override 'hv-*' options which were already set >

Re: [PATCH v4 00/19] i386: KVM: expand Hyper-V features early and provide simple 'hv-default=on' option

2021-02-11 Thread Vitaly Kuznetsov
Daniel P. Berrangé writes: > On Thu, Feb 11, 2021 at 09:30:53AM +0100, Vitaly Kuznetsov wrote: >> Eduardo Habkost writes: >> >> > On Wed, Feb 10, 2021 at 04:56:06PM +, Daniel P. Berrangé wrote: >> >> On Wed, Feb 10, 2021 at 05:40:12PM +0100, Vitaly Kuzne

[PATCH] i386: Make 'hv-reenlightenment' require explicit 'tsc-frequency' setting

2021-03-30 Thread Vitaly Kuznetsov
fail late and this may come as an unpleasant surprise. To make things more explicit, require 'tsc-frequency=' on the command line when 'hv-reenlightenment' was enabled. Make the change affect 6.0+ machine types only to preserve previously-valid configurations valid. Signed-off-by: Vitaly Kuznetsov

Re: [PATCH v2] i386: Make migration fail when Hyper-V reenlightenment was enabled but 'user_tsc_khz' is unset

2021-03-30 Thread Vitaly Kuznetsov
"Dr. David Alan Gilbert" writes: > * Vitaly Kuznetsov (vkuzn...@redhat.com) wrote: >> "Dr. David Alan Gilbert" writes: >> >> > * Vitaly Kuznetsov (vkuzn...@redhat.com) wrote: >> >> KVM doesn't fully support Hyper-V reenlightenment not

Re: [PATCH v2] i386: Make migration fail when Hyper-V reenlightenment was enabled but 'user_tsc_khz' is unset

2021-03-29 Thread Vitaly Kuznetsov
"Dr. David Alan Gilbert" writes: > * Vitaly Kuznetsov (vkuzn...@redhat.com) wrote: >> KVM doesn't fully support Hyper-V reenlightenment notifications on >> migration. In particular, it doesn't support emulating TSC frequency >> of the source host by trapping

[PATCH 1/2] i386: Add 'kvm-asyncpf-int' to kvm_default_props array

2021-04-01 Thread Vitaly Kuznetsov
Just like all other KVM PV features, 'kvm-asyncpf-int' needs to be added to all CPU models when KVM is enabled or the feature will always remain 'off' unless specified explicitly on the command line. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 1 + 1 file changed, 1 insertion

[PATCH 0/2] i386: Fix interrupt based Async PF enablement

2021-04-01 Thread Vitaly Kuznetsov
migration. This went unnoticed because of 1) I believe. Vitaly Kuznetsov (2): i386: Add 'kvm-asyncpf-int' to kvm_default_props array i386: Disable 'kvm-asyncpf-int' feature for machine types <= 5.1 hw/i386/pc.c | 1 + target/i386/cpu.c | 1 + 2 files changed, 2 insertions(+) -- 2.30.2

[PATCH 2/2] i386: Disable 'kvm-asyncpf-int' feature for machine types <= 5.1

2021-04-01 Thread Vitaly Kuznetsov
enabled. Fixes: db5daafab2 ("target/i386: support KVM_FEATURE_ASYNC_PF_INT") Signed-off-by: Vitaly Kuznetsov --- hw/i386/pc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 8a84b25a031e..04d5f76bf133 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c

[PATCH v2] i386: Make 'hv-reenlightenment' require explicit 'tsc-frequency' setting

2021-03-31 Thread Vitaly Kuznetsov
fails late and this may come as an unpleasant surprise. To make things more explicit, require 'tsc-frequency=' on the command line when 'hv-reenlightenment' was enabled. Make the change affect 6.0+ machine types only to preserve previously-valid configurations. Signed-off-by: Vitaly Kuznetsov Ac

Re: [PATCH 0/2] i386: Fix interrupt based Async PF enablement

2021-04-06 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 01/04/21 17:19, Vitaly Kuznetsov wrote: >> I noticed two issues with 'kvm-asyncpf-int' enablement: >> 1) We forgot to add to to kvm_default_props[] so it doesn't get enabled >> automatically (unless '-cpu host' is used or the feature is

Re: [PATCH 1/5] i386: move hyperv_vendor_id initialization to x86_cpu_realizefn()

2021-03-10 Thread Vitaly Kuznetsov
Claudio Fontana writes: > On 11/19/20 11:32 AM, Vitaly Kuznetsov wrote: >> As a preparation to expanding Hyper-V CPU features early, move >> hyperv_vendor_id initialization to x86_cpu_realizefn(). Introduce >> x86_cpu_hyperv_realize() to not not pollute x86_cpu_

[PATCH 3/3] i386: Make sure kvm_arch_set_tsc_khz() succeeds on migration when 'hv-reenlightenment' was exposed

2021-03-18 Thread Vitaly Kuznetsov
env.tsc_khz packed in 'cpu/tsc_khz' but we don't want to be dependent on the section order. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/hyperv.h | 1 + target/i386/kvm/kvm.c| 11 +++ target/i386/machine.c| 37 + 3 files changed, 49 insertions

[PATCH 0/3] i386: Make sure TSC frequency is preserved across migration when Hyper-V reenlightenment is in use

2021-03-18 Thread Vitaly Kuznetsov
with migration. Vitaly Kuznetsov (3): i386: Make Hyper-V related sections KVM only i386: Fix 'hypercall_hypercall' typo i386: Make sure kvm_arch_set_tsc_khz() succeeds on migration when 'hv-reenlightenment' was exposed target/i386/kvm/hyperv.h | 1 + target/i386/kvm/kvm.c| 11

[PATCH 2/3] i386: Fix 'hypercall_hypercall' typo

2021-03-18 Thread Vitaly Kuznetsov
Even the name of this section is 'cpu/msr_hyperv_hypercall', 'hypercall_hypercall' is clearly a typo. Signed-off-by: Vitaly Kuznetsov --- target/i386/machine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/machine.c b/target/i386/machine.c index

Re: [PATCH 3/3] i386: Make sure kvm_arch_set_tsc_khz() succeeds on migration when 'hv-reenlightenment' was exposed

2021-03-18 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 18/03/21 17:02, Vitaly Kuznetsov wrote: >> KVM doesn't fully support Hyper-V reenlightenment notifications on >> migration. In particular, it doesn't support emulating TSC frequency >> of the source host by trapping all TSC accesses

[PATCH 1/3] i386: Make Hyper-V related sections KVM only

2021-03-18 Thread Vitaly Kuznetsov
Currently, Hyper-V enlightenments are only implemented by KVM so there's no need to have corresponding vmstate_x86_cpu sections when !CONFIG_KVM. Signed-off-by: Vitaly Kuznetsov --- target/i386/machine.c | 4 1 file changed, 4 insertions(+) diff --git a/target/i386/machine.c b/target/i386

Re: [PATCH 1/5] i386: move hyperv_vendor_id initialization to x86_cpu_realizefn()

2021-03-10 Thread Vitaly Kuznetsov
Claudio Fontana writes: > On 3/10/21 12:43 PM, Vitaly Kuznetsov wrote: >> Claudio Fontana writes: >> >>> On 11/19/20 11:32 AM, Vitaly Kuznetsov wrote: >>>> As a preparation to expanding Hyper-V CPU features early, move >>>> hyperv_vendor_id

[PATCH v2] i386: Make migration fail when Hyper-V reenlightenment was enabled but 'user_tsc_khz' is unset

2021-03-19 Thread Vitaly Kuznetsov
as we have to guarantee that TSC frequency stays constant. Require 'tsc-frequency=' command line option to be specified for successful migration when re-enlightenment was enabled by the guest. Signed-off-by: Vitaly Kuznetsov --- This patch is a successor of "[PATCH 3/3] i386: Make

Re: [PATCH 3/3] i386: Make sure kvm_arch_set_tsc_khz() succeeds on migration when 'hv-reenlightenment' was exposed

2021-03-19 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 18/03/21 17:38, Vitaly Kuznetsov wrote: >>> Could we instead fail to load the reenlightenment section if >>> user_tsc_khz was not set? This seems to be user (well, management) >>> error really, since reenlightenment has to be en

Re: [PATCH 3/3] i386: Make sure kvm_arch_set_tsc_khz() succeeds on migration when 'hv-reenlightenment' was exposed

2021-03-19 Thread Vitaly Kuznetsov
Marcelo Tosatti writes: > On Thu, Mar 18, 2021 at 05:38:00PM +0100, Vitaly Kuznetsov wrote: >> Paolo Bonzini writes: >> >> > On 18/03/21 17:02, Vitaly Kuznetsov wrote: >> >> KVM doesn't fully support Hyper-V reenlightenment notifications on >> >&

Re: [PATCH 3/3] i386: Make sure kvm_arch_set_tsc_khz() succeeds on migration when 'hv-reenlightenment' was exposed

2021-03-19 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 19/03/21 10:41, Vitaly Kuznetsov wrote: >>> What I want to achieve is to forbid migration of VMs with >>> reenlightenment, if they don't also specify tsc-khz to the frequency of >>> the TSC on the source host. We can't check it at

Re: [PATCH v4 16/21] i386: track explicit 'hv-*' features enablement/disablement

2021-02-24 Thread Vitaly Kuznetsov
Igor Mammedov writes: > On Tue, 23 Feb 2021 19:08:42 +0100 > Vitaly Kuznetsov wrote: > >> Igor Mammedov writes: >> >> > On Tue, 23 Feb 2021 16:46:50 +0100 >> > Vitaly Kuznetsov wrote: >> > >> >> Igor Mammedov writes: >&g

[PATCH v5 02/17] i386: invert hyperv_spinlock_attempts setting logic with hv_passthrough

2021-03-01 Thread Vitaly Kuznetsov
There is no need to have this special case: like all other Hyper-V enlightenments we can just use kernel's supplied value in hv_passthrough mode. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/target/i386/kvm

[PATCH v5 11/17] i386: switch hyperv_expand_features() to using error_setg()

2021-03-01 Thread Vitaly Kuznetsov
Use standard error_setg() mechanism in hyperv_expand_features(). Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 101 +- 1 file changed, 61 insertions(+), 40 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index

[PATCH v5 14/17] i386: use global kvm_state in hyperv_enabled() check

2021-03-01 Thread Vitaly Kuznetsov
There is no need to use vCPU-specific kvm state in hyperv_enabled() check and we need to do that when feature expansion happens early, before vCPU specific KVM state is created. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions

[PATCH v5 03/17] i386: always fill Hyper-V CPUID feature leaves from X86CPU data

2021-03-01 Thread Vitaly Kuznetsov
but arguably this is a good change. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 9 - 1 file changed, 9 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 3c1202333d9d..1b1934362a89 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c

[PATCH v5 04/17] i386: stop using env->features[] for filling Hyper-V CPUIDs

2021-03-01 Thread Vitaly Kuznetsov
As a preparatory patch to dropping Hyper-V CPUID leaves from feature_word_info[] stop using env->features[] as a temporary storage of Hyper-V CPUIDs, just build Hyper-V CPUID leaves directly from kvm_hyperv_properties[] data. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.h |

[PATCH v5 05/17] i386: introduce hyperv_feature_supported()

2021-03-01 Thread Vitaly Kuznetsov
Clean up hv_cpuid_check_and_set() by separating hyperv_feature_supported() off it. No functional change intended. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm/kvm.c | 49 ++- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/target

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

2021-03-01 Thread Vitaly Kuznetsov
es (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 wit

<    1   2   3   4   5   6   >