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

2021-04-22 Thread Vitaly Kuznetsov
converted to using raw CPUID 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 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
guest 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

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

2021-04-22 Thread Vitaly Kuznetsov
7;s query-cpu-model-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..2d05

[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 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 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/i38

[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 16/19] i386: kill off hv_cpuid_check_and_set()

2021-04-22 Thread Vitaly Kuznetsov
it. Also, 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 delet

[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
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

[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
Signed-off-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/

[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 + t

[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 chang

[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

[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

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

2021-02-22 Thread Vitaly Kuznetsov
Vitaly Kuznetsov writes: > Igor Mammedov writes: > >>> >>> We need to distinguish because that would be sane. >>> >>> Enlightened VMCS is an extension to VMX, it can't be used without >>> it. Genuine Hyper-V doesn't have a knob

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

2021-02-23 Thread Vitaly Kuznetsov
Igor Mammedov writes: > On Mon, 22 Feb 2021 11:20:34 +0100 > Vitaly Kuznetsov wrote: > >> Vitaly Kuznetsov writes: >> >> > Igor Mammedov writes: >> > >> >>> >> >>> We need to distinguish because that would be sane. >

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

2021-02-23 Thread Vitaly Kuznetsov
Igor Mammedov writes: > On Tue, 23 Feb 2021 16:46:50 +0100 > Vitaly Kuznetsov wrote: > >> Igor Mammedov writes: >> >> > On Mon, 22 Feb 2021 11:20:34 +0100 >> > Vitaly Kuznetsov wrote: >> > >> >> Vita

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 00/17] i386: KVM: expand Hyper-V features early and provide simple 'hv-default=on' option

2021-03-01 Thread Vitaly Kuznetsov
ne, 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, thi

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

2021-03-01 Thread Vitaly Kuznetsov
guest 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

[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 01/17] i386: keep hyperv_vendor string up-to-date

2021-03-01 Thread Vitaly Kuznetsov
7;s query-cpu-model-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 6a53446e6a56..ee09

[PATCH v5 09/17] i386: split hyperv_handle_properties() into hyperv_expand_features()/hyperv_fill_cpuids()

2021-03-01 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 v5 06/17] i386: introduce hv_cpuid_get_host()

2021-03-01 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 v5 07/17] i386: drop FEAT_HYPERV feature leaves

2021-03-01 Thread Vitaly Kuznetsov
converted to using raw CPUID 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 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/i38

[PATCH v5 10/17] i386: move eVMCS enablement to hyperv_init_vcpu()

2021-03-01 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 v5 12/17] i386: adjust the expected KVM_GET_SUPPORTED_HV_CPUID array size

2021-03-01 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 chang

[PATCH v5 08/17] i386: introduce hv_cpuid_cache

2021-03-01 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 v5 13/17] i386: prefer system KVM_GET_SUPPORTED_HV_CPUID ioctl over vCPU's one

2021-03-01 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 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 16/17] i386: provide simple 'hv-default=on' option

2021-03-01 Thread Vitaly Kuznetsov
tion. Introduce 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

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

2021-03-01 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

[PATCH v5 17/17] qtest/hyperv: Introduce a simple hyper-v test

2021-03-01 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

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

2021-03-01 Thread Vitaly Kuznetsov
Igor Mammedov writes: > On Wed, 24 Feb 2021 18:00:43 +0100 > Vitaly Kuznetsov wrote: > >> Igor Mammedov writes: >> >> > On Tue, 23 Feb 2021 19:08:42 +0100 >> > Vitaly Kuznetsov wrote: >> > >> >> Igor Mammedov writes: >&g

[PATCH RFC v3 01/23] WIP: update linux/headers

2020-10-09 Thread Vitaly Kuznetsov
KVM_CAP_SYS_HYPERV_CPUID definition is needed for this series. Signed-off-by: Vitaly Kuznetsov --- linux-headers/asm-x86/kvm.h | 20 linux-headers/linux/kvm.h | 27 --- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/linux-headers

[PATCH RFC v3 03/23] i386: drop x86_cpu_get_supported_feature_word() forward declaration

2020-10-09 Thread Vitaly Kuznetsov
We only use x86_cpu_get_supported_feature_word() after its implementation, no forward declaration needed. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index f37eb7b675f4..bbfdfb8a3f88 100644

[PATCH RFC v3 02/23] i386: fill in FEAT_HYPERV_EDX from edx instead of eax

2020-10-09 Thread Vitaly Kuznetsov
There was a typo which went unnoticed. Fixes: e48ddcc6ce13 ("i386/kvm: implement 'hv-passthrough' mode") Signed-off-by: Vitaly Kuznetsov --- - Similar fix h

[PATCH RFC v3 05/23] i386: move hyperv_interface_id initialization to x86_cpu_realizefn()

2020-10-09 Thread Vitaly Kuznetsov
As a preparation to expanding Hyper-V CPU features early, move hyperv_interface_id initialization to x86_cpu_realizefn(). Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 6 ++ target/i386/cpu.h | 1 + target/i386/kvm.c | 18 -- 3 files changed, 19 insertions(+), 6

[PATCH RFC v3 04/23] i386: move hyperv_vendor_id initialization to x86_cpu_realizefn()

2020-10-09 Thread Vitaly Kuznetsov
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_realizefn() itself. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 23 ++- target

[PATCH RFC v3 10/23] i386: always fill Hyper-V CPUID feature leaves from X86CPU data

2020-10-09 Thread Vitaly Kuznetsov
guest but arguably this is a good change. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm.c | 9 - 1 file changed, 9 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 5350cd867759..56bfc8da85d0 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1206,9 +1206,6

[PATCH RFC v3 06/23] i386: move hyperv_version_id initialization to x86_cpu_realizefn()

2020-10-09 Thread Vitaly Kuznetsov
As a preparation to expanding Hyper-V CPU features early, move hyperv_version_id initialization to x86_cpu_realizefn(). Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 4 target/i386/cpu.h | 1 + target/i386/kvm.c | 14 -- 3 files changed, 17 insertions(+), 2

[PATCH RFC v3 00/23] i386: KVM: expand Hyper-V features early

2020-10-09 Thread Vitaly Kuznetsov
Hyper-V feature expansion (this series). In addition, add a simple 'hyperv=on' option to x86 machine types which enables (and requires from KVM) all currently supported Hyper-V enlightenments. Unlike 'hv_passthrough' mode, this is going to be migratable. Vitaly Ku

[PATCH RFC v3 07/23] i386: move hyperv_limits initialization to x86_cpu_realizefn()

2020-10-09 Thread Vitaly Kuznetsov
As a preparation to expanding Hyper-V CPU features early, move hyperv_limits initialization to x86_cpu_realizefn(). Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 5 + target/i386/cpu.h | 1 + target/i386/kvm.c | 13 - 3 files changed, 18 insertions(+), 1 deletion

[PATCH RFC v3 12/23] i386: introduce hyperv_feature_supported()

2020-10-09 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.c | 49 +-- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/target

[PATCH RFC v3 13/23] i386: introduce hv_cpuid_get_host()

2020-10-09 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.c | 100 ++ 1 file changed, 56 insertions(+), 44 deletions(-) diff --git a/target

[PATCH RFC v3 08/23] i386: keep hyperv_vendor string up-to-date

2020-10-09 Thread Vitaly Kuznetsov
7;s query-cpu-model-expansion output is incorrect. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 20 ++-- target/i386/kvm.c | 4 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 45644f063947..c12d539389

[PATCH RFC v3 11/23] i386: stop using env->features[] for filling Hyper-V CPUIDs

2020-10-09 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 | 1 + tar

[PATCH RFC v3 15/23] i386: introduce hv_cpuid_cache

2020-10-09 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.c | 109 -- 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/target/i

[PATCH RFC v3 09/23] i386: invert hyperv_spinlock_attempts setting logic with hv_passthrough

2020-10-09 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.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/target/i386/kv

[PATCH RFC v3 19/23] i386: adjust the expected KVM_GET_SUPPORTED_HV_CPUID array size

2020-10-09 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.c | 3 ++- 1 file chang

[PATCH RFC v3 21/23] i386: use global kvm_state in hyperv_enabled() check

2020-10-09 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.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff

[PATCH RFC v3 14/23] i386: drop FEAT_HYPERV feature leaves

2020-10-09 Thread Vitaly Kuznetsov
converted to using raw CPUID 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.c | 108 -

[PATCH RFC v3 17/23] i386: move eVMCS enablement to hyperv_init_vcpu()

2020-10-09 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.c | 60 +-- 1 file changed, 37 insertions(+), 23

[PATCH RFC v3 22/23] i386: expand Hyper-V features during CPU feature expansion time

2020-10-09 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

[PATCH RFC v3 16/23] i386: split hyperv_handle_properties() into hyperv_expand_features()/hyperv_fill_cpuids()

2020-10-09 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.c | 34 -- 1 file changed, 24 insertions(+), 10 deletions

[PATCH RFC v3 18/23] i386: switch hyperv_expand_features() to using error_setg()

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

[PATCH RFC v3 20/23] i386: prefer system KVM_GET_SUPPORTED_HV_CPUID ioctl over vCPU's one

2020-10-09 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.c | 17 + 1 file changed

[PATCH RFC v3 23/23] i386: provide simple 'hyperv=on' option to x86 machine types

2020-10-09 Thread Vitaly Kuznetsov
tion. Introduce a simple 'hyperv=on' option for all x86 machine types enabling all currently supported Hyper-V enlightenments. Later, when new enlightenments get implemented, we will be adding them to newer machine types only (by disabling them for legacy machine types) thus preservin

Re: [PATCH v3 18/19] i386: provide simple 'hv-default=on' option

2021-01-21 Thread Vitaly Kuznetsov
Igor Mammedov writes: > On Thu, 21 Jan 2021 09:45:33 +0100 > Vitaly Kuznetsov wrote: > >> > >> > So far I read snippet above as a problem: >> > 1: >> > host supports evmcs: >> > and exposes HYPERV_FEAT_EVMCS in CPUID >> >&g

[PATCH RFC] memory: pause all vCPUs for the duration of memory transactions

2020-10-26 Thread Vitaly Kuznetsov
ansaction in one shot but as a band-aid we can just pause all vCPUs to make memory transations atomic. Reported-by: Dr. David Alan Gilbert Signed-off-by: Vitaly Kuznetsov --- RFC: Generally, memap updates happen only a few times during guest boot but I'm not sure there are no scena

Re: [PATCH RFC] memory: pause all vCPUs for the duration of memory transactions

2020-10-27 Thread Vitaly Kuznetsov
David Hildenbrand writes: > On 26.10.20 11:43, David Hildenbrand wrote: >> On 26.10.20 09:49, Vitaly Kuznetsov wrote: >>> Currently, KVM doesn't provide an API to make atomic updates to memmap when >>> the change touches more than one memory slot, e.g. in case we&

Re: [PATCH RFC] memory: pause all vCPUs for the duration of memory transactions

2020-10-27 Thread Vitaly Kuznetsov
David Hildenbrand writes: > On 27.10.20 14:02, Vitaly Kuznetsov wrote: >> >> Sorry for not being clear: your patch looks good to me, what I tried to >> say is that with the current KVM API the only way to guarantee atomicity >> of the update is to make vCPUs stop (o

Re: [PATCH RFC] memory: pause all vCPUs for the duration of memory transactions

2020-10-27 Thread Vitaly Kuznetsov
David Hildenbrand writes: > On 27.10.20 13:36, Vitaly Kuznetsov wrote: >> David Hildenbrand writes: >> >>> On 26.10.20 11:43, David Hildenbrand wrote: >>>> On 26.10.20 09:49, Vitaly Kuznetsov wrote: >>>>> Currently, KVM doesn't pro

Re: [PATCH RFC] memory: pause all vCPUs for the duration of memory transactions

2020-10-27 Thread Vitaly Kuznetsov
David Hildenbrand writes: >>> Same applies to all other kinds of operations (splitting, punching out, >>> ...) as you also mentioned. >> >> One question from a QEMU newbie though: why do you put >> kvm_ioctl_inhibit_begin()/kvm_ioctl_inhibit_end() to kvm_region_resize() >> only and not taking it

[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/i38

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

2021-02-10 Thread Vitaly Kuznetsov
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. Unlike 'hv-passthrough' mode, this is going to

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

2021-02-10 Thread Vitaly Kuznetsov
converted to using raw CPUID 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 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
guest 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

[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
7;s query-cpu-model-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..d03c

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

2021-02-10 Thread Vitaly Kuznetsov
ation time when 'hv-passthrough' is specified and we're running on 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

[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

[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 chang

[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

[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
ently, the only 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 --- targe

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

2021-02-10 Thread Vitaly Kuznetsov
tion. Introduce 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

[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
ure". While on it, 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-feat

[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/i38

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 w

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

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

2021-02-12 Thread Vitaly Kuznetsov
Igor Mammedov writes: > On Wed, 10 Feb 2021 17:40:28 +0100 > Vitaly Kuznetsov wrote: > >> Sometimes we'd like to know which features were explicitly enabled and which >> were explicitly disabled on the command line. E.g. it seems logical to handle >> 'hv_p

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

2021-02-12 Thread Vitaly Kuznetsov
Igor Mammedov writes: > On Wed, 10 Feb 2021 17:40:29 +0100 > Vitaly Kuznetsov wrote: > >> Currently, we support 'hv-passthrough,hv-feature=on' enablement, this >> is supposed to mean "hv-feature is mandatory, don't start without it". Add >>

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

2021-02-12 Thread Vitaly Kuznetsov
Igor Mammedov writes: > On Wed, 10 Feb 2021 17:40:32 +0100 > Vitaly Kuznetsov wrote: > >> Enabling Hyper-V emulation for a Windows VM is a tiring experience as it >> requires listing all currently supported enlightenments ("hv-*" CPU >> features) explici

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

2021-02-12 Thread Vitaly Kuznetsov
Igor Mammedov writes: > On Fri, 12 Feb 2021 09:45:52 +0100 > Vitaly Kuznetsov wrote: > >> Igor Mammedov writes: >> >> > On Wed, 10 Feb 2021 17:40:28 +0100 >> > Vitaly Kuznetsov wrote: >> > >> >> Sometimes we'd like to know w

<    1   2   3   4   5   6   >