[PATCH v2 1/2] x86/hyper-v: Stop caring about EOI for direct stimers

2018-12-12 Thread Vitaly Kuznetsov
()). Remove the redundant part. Suggested-by: Roman Kagan Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 36 +++- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index e6a2a085644a..0a16a77e6ac3

Re: [PATCH v3] x86/hyper-v: Mark TLFS structures packed

2018-12-12 Thread Vitaly Kuznetsov
Vitaly Kuznetsov writes: > /* Define virtual processor assist page structure. */ > struct hv_vp_assist_page { > @@ -519,7 +519,7 @@ struct hv_vp_assist_page { > __u64 nested_enlightenments_control[2]; > __u32 enlighten_vmentry; > __u64 current_nested_vmcs; &

[PATCH v4] x86/hyper-v: Mark TLFS structures packed

2018-12-12 Thread Vitaly Kuznetsov
this. 'struct hv_vp_assist_page' and 'struct hv_enlightened_vmcs' need to be properly padded to support the change. Suggested-by: Nadav Amit Signed-off-by: Vitaly Kuznetsov Acked-by: Thomas Gleixner Acked-by: Nadav Amit Reviewed-by: Michael Kelley --- - Changes since

Re: [PATCH v6 05/13] KVM: nVMX: implement enlightened VMPTRLD and VMCLEAR

2018-12-13 Thread Vitaly Kuznetsov
Jim Mattson writes: > On Tue, Oct 16, 2018 at 9:50 AM Vitaly Kuznetsov wrote: >> >> + >> + vmx->nested.hv_evmcs = kmap(vmx->nested.hv_evmcs_page); > > Are you sure that directly mapping guest memory isn't going to lead to > time-of-check

Re: [PATCH v2 0/7] x86/kvm/hyper-v: Implement KVM_GET_SUPPORTED_HV_CPUID

2018-12-18 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 17/12/18 11:30, Vitaly Kuznetsov wrote: >>> Queued, thanks. I moved this above the direct EOI series so that >>> KVM_CAP_HYPERV_STIMER_DIRECT need not exist at any point of the history. >>> >> Thanks! Just to make sure (and t

[PATCH] KVM: x86: svm: report MSR_IA32_MCG_EXT_CTL as unsupported

2018-12-19 Thread Vitaly Kuznetsov
d-off-by: Vitaly Kuznetsov --- arch/x86/kvm/svm.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 2acb42b74a51..dfdf7d0b7f88 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -5845,6 +5845,13 @@ static bool svm_cpu_has_accelerate

[PATCH] selftests: kvm: report failed stage when exit reason is unexpected

2018-12-19 Thread Vitaly Kuznetsov
xit reason: 8 (SHUTDOWN), it is not obvious which particular stage failed. Add the info. Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/x86_64/evmcs_test.c | 4 ++-- tools/testing/selftests/kvm/x86_64/state_test.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --

[PATCH] KVM: x86: nSVM: fix switch to guest mmu

2018-12-19 Thread Vitaly Kuznetsov
reconfiguration is needed") Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/svm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index b78c691adea2..38821b0b78da 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -2923

Re: [PATCH v2 0/7] x86/kvm/hyper-v: Implement KVM_GET_SUPPORTED_HV_CPUID

2018-12-17 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > > Queued, thanks. I moved this above the direct EOI series so that > KVM_CAP_HYPERV_STIMER_DIRECT need not exist at any point of the history. > Thanks! Just to make sure (and to conclude our discussion with Roman): with your Qemu maintainer hat on, do you agree with the

Re: [PATCH v2 3/4] x86/kvm/hyper-v: direct mode for synthetic timers

2018-12-10 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Mon, Nov 26, 2018 at 04:47:31PM +0100, Vitaly Kuznetsov wrote: >> Turns out Hyper-V on KVM (as of 2016) will only use synthetic timers >> if direct mode is available. With direct mode we notify the guest by >> asserting APIC irq instead of se

Re: [PATCH v2 3/4] x86/kvm/hyper-v: direct mode for synthetic timers

2018-12-10 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Mon, Dec 10, 2018 at 01:54:18PM +0100, Vitaly Kuznetsov wrote: >> Roman Kagan writes: >> > Just noticed that the patch seems to assume that "direct" timers are >> > allowed to use any vectors including 0-15. I guess this is incorrec

[PATCH v2 0/7] x86/kvm/hyper-v: Implement KVM_GET_SUPPORTED_HV_CPUID

2018-12-10 Thread Vitaly Kuznetsov
nd removes recently added KVM_CAP_HYPERV_STIMER_DIRECT before it's too late. Vitaly Kuznetsov (7): x86/hyper-v: Do some housekeeping in hyperv-tlfs.h x86/hyper-v: Drop HV_X64_CONFIGURE_PROFILER definition x86/kvm/hyper-v: Introduce nested_get_evmcs_version() helper x86/kvm/hyper-v: Introduce KVM_GET_SUPPOR

[PATCH v2 3/7] x86/kvm/hyper-v: Introduce nested_get_evmcs_version() helper

2018-12-10 Thread Vitaly Kuznetsov
The upcoming KVM_GET_SUPPORTED_HV_CPUID ioctl will need to return Enlightened VMCS version in HYPERV_CPUID_NESTED_FEATURES.EAX when it was enabled. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm.c | 7 +++ arch/x86/kvm/vmx.c

[PATCH v2 1/7] x86/hyper-v: Do some housekeeping in hyperv-tlfs.h

2018-12-10 Thread Vitaly Kuznetsov
Signed-off-by: Vitaly Kuznetsov Reviewed-by: Michael Kelley --- arch/x86/include/asm/hyperv-tlfs.h | 186 ++--- arch/x86/kvm/hyperv.c | 4 +- 2 files changed, 93 insertions(+), 97 deletions(-) diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/

[PATCH v2 7/7] KVM: selftests: Add hyperv_cpuid test

2018-12-10 Thread Vitaly Kuznetsov
Add a simple (and stupid) hyperv_cpuid test: check that we got the expected number of entries with and without Enlightened VMCS enabled and that all currently reserved fields are zeroed. Signed-off-by: Vitaly Kuznetsov --- Changes since v1: - Check for -E2BIG --- tools/testing/selftests/kvm

[PATCH v2 4/7] x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID

2018-12-10 Thread Vitaly Kuznetsov
sect with KVM's (e.g. 0x4000, 0x4001) and we would probably confuse userspace in case we decide to return these twice. KVM_CAP_HYPERV_CPUID's number is interim: we're intended to drop KVM_CAP_HYPERV_STIMER_DIRECT and use its number instead. Suggested-by: Paolo Bonzini Signed-of

[PATCH v2 6/7] KVM: selftests: implement an unchecked version of vcpu_ioctl()

2018-12-10 Thread Vitaly Kuznetsov
In case we want to test failing ioctls we need an option to not fail. Following _vcpu_run() precedent implement _vcpu_ioctl(). Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/include/kvm_util.h | 2 ++ tools/testing/selftests/kvm/lib/kvm_util.c | 14 -- 2 files

[PATCH v2 2/7] x86/hyper-v: Drop HV_X64_CONFIGURE_PROFILER definition

2018-12-10 Thread Vitaly Kuznetsov
BIT(13) in HYPERV_CPUID_FEATURES.EBX is described as "ConfigureProfiler" in TLFS v4.0 but starting 5.0 it is replaced with 'Reserved'. As we don't currently us it in kernel it can just be dropped. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Michael Kelley --- ar

[PATCH v2 5/7] x86/kvm/hyper-v: Drop KVM_CAP_HYPERV_STIMER_DIRECT

2018-12-10 Thread Vitaly Kuznetsov
The newly introduced KVM_GET_SUPPORTED_HV_CPUID covers Direct Mode stimers feature so we can drop KVM_CAP_HYPERV_STIMER_DIRECT and reuse its number. Signed-off-by: Vitaly Kuznetsov --- - This patch only makes sense befor 4.21 merge window, disregard if it doesn't make it in time. --- arc

Re: [PATCH 1/4] arm64: hyperv: Add core Hyper-V include files

2018-12-10 Thread Vitaly Kuznetsov
k...@linuxonhyperv.com writes: > + > +static inline u64 hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page > *tsc_pg, > +u64 *cur_tsc) > +{ > + u64 scale, offset; > + u32 sequence; > + > + /* > + * The protocol for reading Hyper-V TSC

Re: [PATCH v2 4/7] x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID

2018-12-11 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Mon, Dec 10, 2018 at 06:21:56PM +0100, Vitaly Kuznetsov wrote: >> + >> +Currently, the following list of CPUID leaves are returned: >> + HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS >> + HYPERV_CPUID_INTERFACE >> + HYPERV_CPUID_V

Re: [PATCH v2 4/7] x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID

2018-12-11 Thread Vitaly Kuznetsov
Roman Kagan writes: > On Tue, Dec 11, 2018 at 02:28:14PM +0100, Vitaly Kuznetsov wrote: >> Roman Kagan writes: >> >> > On Mon, Dec 10, 2018 at 06:21:56PM +0100, Vitaly Kuznetsov wrote: >> >> >> + >> >> +Curr

[PATCH] x86/intel_rdt: use rdmsr_safe() to workaround AWS host issue

2018-12-20 Thread Vitaly Kuznetsov
cess error: RDMSR from 0xc90 at rIP: 0x88c5bba3 (native_read_msr+0x3/0x30) The issue should definitely get fixed on AWS side. We can, however, simply workaround this in Linux and live happily after. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kernel/cpu/intel_rdt.c | 3 ++- 1 file

Re: [PATCH] x86/intel_rdt: use rdmsr_safe() to workaround AWS host issue

2018-12-20 Thread Vitaly Kuznetsov
Borislav Petkov writes: > On Thu, Dec 20, 2018 at 02:40:46PM +0100, Vitaly Kuznetsov wrote: >> It was found that AWS x1 instances (Xen-based) lack xen.git commit >> 1f1d183d4900 (x86/HVM: don't give the wrong impression of WRMSR succeeding) >> and because of that

Re: [PATCH] KVM: x86: svm: report MSR_IA32_MCG_EXT_CTL as unsupported

2018-12-21 Thread Vitaly Kuznetsov
Radim Krčmář writes: > 2018-12-19 12:06+0100, Vitaly Kuznetsov: >> AMD doesn't seem to implement MSR_IA32_MCG_EXT_CTL and svm code in kvm >> knows nothing about it, however, this MSR is among emulated_msrs and >> thus returned with KVM_GET_MSR_INDEX_LIST. The cons

Re: [PATCH] hv_balloon: avoid touching uninitialized struct page during tail onlining

2019-01-07 Thread Vitaly Kuznetsov
David Hildenbrand writes: > On 04.01.19 15:19, Vitaly Kuznetsov wrote: >> Hyper-V memory hotplug protocol has 2M granularity and in Linux x86 we use >> 128M. To deal with it we implement partial section onlining by registering >> custom page onlining callback (hv_online_page

Re: [PATCH] hv_balloon: avoid touching uninitialized struct page during tail onlining

2019-01-07 Thread Vitaly Kuznetsov
Sasha Levin writes: > On Mon, Jan 07, 2019 at 02:44:30PM +0100, Vitaly Kuznetsov wrote: >>P.S. I still think about bringing mem_hotplug_begin()/done() to >>hv_balloon but that's going to be a separate discussion, here I want to >>have a small fix backportable to stable

[PATCH] KVM: nSVM: clear events pending from svm_complete_interrupts() when exiting to L1

2019-01-07 Thread Vitaly Kuznetsov
ending and we do NMI injection upon entry so it got delivered to L1 instead of L2. It seems that VMX code solves the same issue in prepare_vmcs12(), this was introduced with code refactoring in commit 5f3d5799974b ("KVM: nVMX: Rework event injection and recovery"). Signed-off-by: Vital

Re: [PATCH] hv_balloon: avoid touching uninitialized struct page during tail onlining

2019-01-08 Thread Vitaly Kuznetsov
David Hildenbrand writes: > On 07.01.19 14:44, Vitaly Kuznetsov wrote: >> David Hildenbrand writes: >> ... >>> On 04.01.19 15:19, Vitaly Kuznetsov wrote: >>>>if (start_pfn > has->start_pfn && >>>>

[PATCH] hv_balloon: avoid touching uninitialized struct page during tail onlining

2019-01-04 Thread Vitaly Kuznetsov
ds inspecting struct pages and checks sections instead. But in Hyper-V balloon driver we do PageReserved(pfn_to_page()) check and this is now wrong. Switch to checking online_section_nr() instead. Signed-off-by: Vitaly Kuznetsov --- drivers/hv/hv_balloon.c | 10 ++ 1 file changed

[PATCH v4 4/9] x86/kvm/mmu: introduce guest_mmu

2018-10-08 Thread Vitaly Kuznetsov
oot caches; the improved hit rate is not very important for single vCPU performance, but it avoids contention on the mmu_lock for many vCPUs. On the nested CPUID benchmark, with 16 vCPUs, an L2->L1->L2 vmexit goes from 42k to 26k cycles. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Sea

[PATCH v4 2/9] x86/kvm/mmu.c: set get_pdptr hook in kvm_init_shadow_ept_mmu()

2018-10-08 Thread Vitaly Kuznetsov
kvm_init_shadow_ept_mmu() doesn't set get_pdptr() hook and is this not a problem just because MMU context is already initialized and this hook points to kvm_pdptr_read(). As we're intended to use a dedicated MMU for shadow EPT MMU set this hook explicitly. Signed-off-by: Vitaly Kuznets

[PATCH v4 0/9] x86/kvm/nVMX: optimize MMU switch between L1 and L2

2018-10-08 Thread Vitaly Kuznetsov
really needed. This spares us about 1000 cpu cycles on nested vmexit. Brief look at SVM makes me think it can be optimized the exact same way, I'll do this in a separate series. Paolo Bonzini (1): x86/kvm/mmu: get rid of redundant kvm_mmu_setup() Vitaly Kuznetsov (8): x86/kvm/mmu: ma

[PATCH v4 3/9] x86/kvm/mmu.c: add kvm_mmu parameter to kvm_mmu_free_roots()

2018-10-08 Thread Vitaly Kuznetsov
Add an option to specify which MMU root we want to free. This will be used when nested and non-nested MMUs for L1 are split. Signed-off-by: Vitaly Kuznetsov Signed-off-by: Paolo Bonzini Reviewed-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/mmu.c

[PATCH v4 1/9] x86/kvm/mmu: make vcpu->mmu a pointer to the current MMU

2018-10-08 Thread Vitaly Kuznetsov
As a preparation to full MMU split between L1 and L2 make vcpu->arch.mmu a pointer to the currently used mmu. For now, this is always vcpu->arch.root_mmu. No functional change. Signed-off-by: Vitaly Kuznetsov Signed-off-by: Paolo Bonzini Reviewed-by: Sean Christopherson --- arch/x86/i

[PATCH v4 7/9] x86/kvm/nVMX: introduce source data cache for kvm_init_shadow_ept_mmu()

2018-10-08 Thread Vitaly Kuznetsov
MMU re-initialization is expensive, in particular, update_permission_bitmask() and update_pkru_bitmask() are. Cache the data used to setup shadow EPT MMU and avoid full re-init when it is unchanged. Signed-off-by: Vitaly Kuznetsov Sean Christopherson --- Changes since v3: - Use '!!'

[PATCH v4 6/9] x86/kvm/mmu: make space for source data caching in struct kvm_mmu

2018-10-08 Thread Vitaly Kuznetsov
In preparation to MMU reconfiguration avoidance we need a space to cache source data. As this partially intersects with kvm_mmu_page_role, create 64bit sized union kvm_mmu_role holding both base and extended data. No functional change. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Sean

[PATCH v4 8/9] x86/kvm/mmu: check if tdp/shadow MMU reconfiguration is needed

2018-10-08 Thread Vitaly Kuznetsov
MMU reconfiguration in init_kvm_tdp_mmu()/kvm_init_shadow_mmu() can be avoided if the source data used to configure it didn't change; enhance MMU extended role with the required fields and consolidate common code in kvm_calc_mmu_role_common(). Signed-off-by: Vitaly Kuznetsov Reviewed-by:

[PATCH v4 5/9] x86/kvm/mmu: get rid of redundant kvm_mmu_setup()

2018-10-08 Thread Vitaly Kuznetsov
From: Paolo Bonzini Just inline the contents into the sole caller, kvm_init_mmu is now public. Suggested-by: Vitaly Kuznetsov Signed-off-by: Paolo Bonzini Reviewed-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/mmu.c | 12 arch/x86

[PATCH v4 9/9] x86/kvm/mmu: check if MMU reconfiguration is needed in init_kvm_nested_mmu()

2018-10-08 Thread Vitaly Kuznetsov
We don't use root page role for nested_mmu, however, optimizing out re-initialization in case nothing changed is still valuable as this is done for every nested vmentry. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Sean Christopherson --- arch/x86/kvm/mmu.c | 6 ++ 1 file chang

Re: [PATCH v5 09/12] x86/kvm/nVMX: allow bare VMXON state migration

2018-10-16 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 13/09/2018 19:05, Vitaly Kuznetsov wrote: >> It is perfectly valid for a guest to do VMXON and not do VMPTRLD. This >> state needs to be preserved on migration. >> >> Signed-off-by: Vitaly Kuznetsov > > Please cover this in state-tes

[PATCH v6 00/13] KVM: nVMX: Enlightened VMCS for Hyper-V on KVM

2018-10-16 Thread Vitaly Kuznetsov
id loop in WS2016 with Hyper-V role on KVM: 15200 cycles -> 13700 cycles). Ladi Prosek (1): KVM: hyperv: define VP assist page helpers Vitaly Kuznetsov (12): KVM: VMX: refactor evmcs_sanitize_exec_ctrls() KVM: nVMX: add KVM_CAP_HYPERV_ENLIGHTENED_VMCS capability KVM: nVMX: add enlighten

[PATCH v6 01/13] KVM: hyperv: define VP assist page helpers

2018-10-16 Thread Vitaly Kuznetsov
From: Ladi Prosek The state related to the VP assist page is still managed by the LAPIC code in the pv_eoi field. Signed-off-by: Ladi Prosek Signed-off-by: Vitaly Kuznetsov Reviewed-by: Liran Alon --- arch/x86/kvm/hyperv.c | 23 +-- arch/x86/kvm/hyperv.h | 4 arch

[PATCH v6 02/13] KVM: VMX: refactor evmcs_sanitize_exec_ctrls()

2018-10-16 Thread Vitaly Kuznetsov
Split off EVMCS1_UNSUPPORTED_* macros so we can re-use them when enabling Enlightened VMCS for Hyper-V on KVM. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/vmx.c | 108 - 1 file changed, 47 insertions(+), 61 deletions(-) diff --git a/arch/x86/kvm

[PATCH v6 03/13] KVM: nVMX: add KVM_CAP_HYPERV_ENLIGHTENED_VMCS capability

2018-10-16 Thread Vitaly Kuznetsov
KVM_CAP_HYPERV_ENLIGHTENED_VMCS. The version is to be advertised to the nested hypervisor, currently done via a cpuid leaf for Hyper-V. Suggested-by: Ladi Prosek Signed-off-by: Vitaly Kuznetsov Reviewed-by: Liran Alon --- arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/svm.c | 9 arch/x86

[PATCH v6 04/13] KVM: nVMX: add enlightened VMCS state

2018-10-16 Thread Vitaly Kuznetsov
Adds hv_evmcs pointer and implement copy_enlightened_to_vmcs12() and copy_enlightened_to_vmcs12(). prepare_vmcs02()/prepare_vmcs02_full() separation is not valid for Enlightened VMCS, do full sync for now. Suggested-by: Ladi Prosek Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/vmx.c | 440

[PATCH v6 05/13] KVM: nVMX: implement enlightened VMPTRLD and VMCLEAR

2018-10-16 Thread Vitaly Kuznetsov
tened VMCS structure for the current L2 guest permanently mapped from struct nested_vmx instead of mapping it every time. Suggested-by: Ladi Prosek Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/vmx.c | 115 ++--- 1 file changed, 108 insertions(+), 7 deletion

[PATCH v6 06/13] KVM: nVMX: optimize prepare_vmcs02{,_full} for Enlightened VMCS case

2018-10-16 Thread Vitaly Kuznetsov
-dependent (and a bit ugly). Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/vmx.c | 118 + 1 file changed, 65 insertions(+), 53 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index cfb44acd4291..0b665c74fadc 100644 --- a/arch/x86

[PATCH v6 08/13] x86/kvm/lapic: preserve gfn_to_hva_cache len on cache reinit

2018-10-16 Thread Vitaly Kuznetsov
d-off-by: Vitaly Kuznetsov --- arch/x86/kvm/lapic.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 79358fd6a71c..3cd227ff807f 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -2647,14 +2647,2

[PATCH v6 07/13] x86/kvm/hyperv: don't clear VP assist pages on init

2018-10-16 Thread Vitaly Kuznetsov
VP assist pages may hold valuable data which needs to be preserved across migration. Clean PV EOI portion of the data on init, the guest is responsible for making sure there's no garbage in the rest. This will be used for nVMX migration, eVMCS address needs to be preserved. Signed-off-by: V

[PATCH v6 09/13] x86/kvm/nVMX: allow bare VMXON state migration

2018-10-16 Thread Vitaly Kuznetsov
It is perfectly valid for a guest to do VMXON and not do VMPTRLD. This state needs to be preserved on migration. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/vmx.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c

[PATCH v6 10/13] KVM: selftests: state_test: test bare VMXON migration

2018-10-16 Thread Vitaly Kuznetsov
Split prepare_for_vmx_operation() into prepare_for_vmx_operation() and load_vmcs() so we can inject GUEST_SYNC() in between. Signed-off-by: Vitaly Kuznetsov --- .../selftests/kvm/include/x86_64/vmx.h| 1 + tools/testing/selftests/kvm/lib/x86_64/vmx.c | 5 + .../testing/selftests

[PATCH v6 11/13] x86/kvm/nVMX: nested state migration for Enlightened VMCS

2018-10-16 Thread Vitaly Kuznetsov
Add support for get/set of nested state when Enlightened VMCS is in use. A new KVM_STATE_NESTED_EVMCS flag to indicate eVMCS on the vCPU was enabled is added. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/uapi/asm/kvm.h | 1 + arch/x86/kvm/vmx.c | 78

[PATCH v6 12/13] tools/headers: update kvm.h

2018-10-16 Thread Vitaly Kuznetsov
Pick up the latest kvm.h definitions. Signed-off-by: Vitaly Kuznetsov --- tools/include/uapi/linux/kvm.h | 5 + 1 file changed, 5 insertions(+) diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h index 07548de5c988..a67ea86edb0b 100644 --- a/tools/include/uapi

[PATCH v6 13/13] KVM: selftests: add Enlightened VMCS test

2018-10-16 Thread Vitaly Kuznetsov
Modify test library and add eVMCS test. This includes nVMX save/restore testing. Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/Makefile |1 + tools/testing/selftests/kvm/include/evmcs.h | 1098 + .../selftests/kvm/include/x86_64/vmx.h

[PATCH v3] kernel/hung_task.c: disable on suspend

2018-10-16 Thread Vitaly Kuznetsov
Call Trace: ? __schedule+0x1fe/0x7e0 schedule+0x28/0x80 suspend_devices_and_enter+0x4ac/0x750 pm_suspend+0x2c0/0x310 Register a PM notifier to disable the detector on suspend and re-enable back on wakeup. Signed-off-by: Vitaly Kuznetsov --- Changes since v2: - Resurrect 'v1' as ze

[PATCH v4] kernel/hung_task.c: disable on suspend

2018-10-17 Thread Vitaly Kuznetsov
Call Trace: ? __schedule+0x1fe/0x7e0 schedule+0x28/0x80 suspend_devices_and_enter+0x4ac/0x750 pm_suspend+0x2c0/0x310 Register a PM notifier to disable the detector on suspend and re-enable back on wakeup. Signed-off-by: Vitaly Kuznetsov --- Changes since v3: - Handle PM_RESTORE_PREPARE/PM_

Re: [PATCH v6 06/13] KVM: nVMX: optimize prepare_vmcs02{,_full} for Enlightened VMCS case

2018-10-17 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 16/10/2018 18:50, Vitaly Kuznetsov wrote: >> +if (!hv_evmcs || !(hv_evmcs->hv_clean_fields & >> + HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2)) { >> +vmcs_write16(GUEST_CS_SELECTO

Re: [PATCH] KVM/VMX: Check ept_pointer before flushing ept tlb

2018-11-06 Thread Vitaly Kuznetsov
ltyker...@gmail.com writes: > From: Lan Tianyu > > This patch is to initialize ept_pointer to INVALID_PAGE and check it > before flushing ept tlb. If ept_pointer is invalidated, bypass the flush > request. > > Signed-off-by: Lan Tianyu > --- > arch/x86/kvm/vmx.c | 16 +--- > 1 file

Re: [PATCH] hyper-v: Fix wakeup from suspend-to-idle

2018-11-06 Thread Vitaly Kuznetsov
"Rafael J. Wysocki" writes: > On Mon, Sep 24, 2018 at 11:24 AM Jiri Kosina wrote: >> >> On Wed, 12 Sep 2018, Vitaly Kuznetsov wrote: >> >> > It makes little sense but still possible to put Hyper-V guests into >> > suspend-to-idle state. To wake t

Re: [PATCH] KVM/VMX: Check ept_pointer before flushing ept tlb

2018-11-07 Thread Vitaly Kuznetsov
Tianyu Lan writes: > Hi Vitaly: > Thanks for your review. > > On 11/6/2018 11:50 PM, Vitaly Kuznetsov wrote: >> ltyker...@gmail.com writes: >> >>> From: Lan Tianyu >>> >>> This patch is to initialize ept_pointer to INVALID_PAGE and chec

[PATCH] KVM: vmx: hyper-v: don't pass EPT configuration info to vmx_hv_remote_flush_tlb()

2018-10-11 Thread Vitaly Kuznetsov
ot; So apparently, Hyper-V doesn't expect us to pass naked EPTP, only PML4 pointer should be used. Strip off EPT configuration information before calling into vmx_hv_remote_flush_tlb(). Fixes: 877ad952be3d ("KVM: vmx: Add tlb_remote_flush callback support") Signed-off-by: Vital

Re: [PATCH] KVM: vmx: hyper-v: don't pass EPT configuration info to vmx_hv_remote_flush_tlb()

2018-10-11 Thread Vitaly Kuznetsov
Tianyu Lan writes: > On Thu, Oct 11, 2018 at 6:32 PM Vitaly Kuznetsov wrote: >> >> I'm observing random crashes in multi-vCPU L2 guests running on KVM on >> Hyper-V. I bisected the issue to the commit 877ad952be3d ("KVM: vmx: Add >> tlb_remote_flush ca

Re: [PATCH] KVM: vmx: hyper-v: don't pass EPT configuration info to vmx_hv_remote_flush_tlb()

2018-10-11 Thread Vitaly Kuznetsov
Tianyu Lan writes: > On Thu, Oct 11, 2018 at 8:18 PM Vitaly Kuznetsov wrote: >> >> Tianyu Lan writes: >> >> > On Thu, Oct 11, 2018 at 6:32 PM Vitaly Kuznetsov >> > wrote: >> >> >> >> I'm observing random crashes in multi-vCP

Re: [LKP] [x86/kvm/lapic] d176620277: kvm-unit-tests.vmx_EPT_AD_disabled.fail

2018-10-08 Thread Vitaly Kuznetsov
kernel test robot writes: > [31mFAIL[0m vmx_EPT_AD_disabled (19 tests, 1 unexpected failures) It seems the test is buggy: MMIO access is tested by reading ACPI version from 0xfee00030 without putting APIC to xAPIC mode first. I'll double check and send a patch to kvm-unit-test in case my guess i

Re: [PATCH v6 06/13] KVM: nVMX: optimize prepare_vmcs02{,_full} for Enlightened VMCS case

2018-10-18 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 17/10/2018 19:08, Jim Mattson wrote: >> I believe that ESXi reads GUEST_CS_AR_BYTES on every VM-exit to >> determine code size. > > Which makes me wonder, maybe we should add GUEST_SS_AR_BYTES which is > where the CPL lives. But then your tests from last year didn't fi

[PATCH] x86/kvm/nVMX: tweak shadow fields

2018-10-19 Thread Vitaly Kuznetsov
ten. Suggested-by: Paolo Bonzini Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/vmx.c | 10 +- arch/x86/kvm/vmx_shadow_fields.h | 5 + 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index abeeb45d1c33..641a65b306

Re: [PATCH v4 RESEND 3/5] KVM: x86: hyperv: use get_vcpu_by_vpidx() in kvm_hv_flush_tlb()

2018-09-17 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 22/08/2018 12:18, Vitaly Kuznetsov wrote: >> VP_INDEX almost always matches VCPU id and get_vcpu_by_vpidx() is fast, >> use it instead of traversing full vCPU list every time. > > ... but if it doesn't, the algorithm is now quadratic, isn

[PATCH v1 RESEND 7/9] x86/kvm/nVMX: introduce scache for kvm_init_shadow_ept_mmu

2018-09-18 Thread Vitaly Kuznetsov
MMU re-initialization is expensive, in particular, update_permission_bitmask() and update_pkru_bitmask() are. Cache the data used to setup shadow EPT MMU and avoid full re-init when it is unchanged. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/kvm_host.h | 14 +++ arch/x86

[PATCH v1 RESEND 0/9] x86/kvm/nVMX: optimize MMU switch between L1 and L2

2018-09-18 Thread Vitaly Kuznetsov
and checking if MMU reset is really needed. This spares us about 1000 cpu cycles on nested vmexit. Brief look at SVM makes me think it can be optimized the exact same way. I'll do this in a separate series if nobody objects. Paolo Bonzini (1): x86/kvm/mmu: get rid of redundant kvm_mmu_setu

[PATCH v1 RESEND 4/9] x86/kvm/mmu: introduce guest_mmu

2018-09-18 Thread Vitaly Kuznetsov
oot caches; the improved hit rate is not very important for single vCPU performance, but it avoids contention on the mmu_lock for many vCPUs. On the nested CPUID benchmark, with 16 vCPUs, an L2->L1->L2 vmexit goes from 42k to 26k cycles. Signed-off-by: Vitaly Kuznetsov Signed-off-b

[PATCH v1 RESEND 2/9] x86/kvm/mmu.c: set get_pdptr hook in kvm_init_shadow_ept_mmu()

2018-09-18 Thread Vitaly Kuznetsov
kvm_init_shadow_ept_mmu() doesn't set get_pdptr() hook and is this not a problem just because MMU context is already initialized and this hook points to kvm_pdptr_read(). As we're intended to use a dedicated MMU for shadow EPT MMU set this hook explicitly. Signed-off-by: Vitaly Kuznets

[PATCH v1 RESEND 6/9] x86/kvm/mmu: make space for source data caching in struct kvm_mmu

2018-09-18 Thread Vitaly Kuznetsov
In preparation to MMU reconfiguration avoidance we need a space to cache source data. As this partially intersects with kvm_mmu_page_role, create 64bit sized union kvm_mmu_role holding both base_role and extended data. No functional change. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include

[PATCH v1 RESEND 1/9] x86/kvm/mmu: make vcpu->mmu a pointer to the current MMU

2018-09-18 Thread Vitaly Kuznetsov
As a preparation to full MMU split between L1 and L2 make vcpu->arch.mmu a pointer to the currently used mmu. For now, this is always vcpu->arch.root_mmu. No functional change. Signed-off-by: Vitaly Kuznetsov Signed-off-by: Paolo Bonzini --- arch/x86/include/asm/kvm_host.h | 5 +- ar

[PATCH v1 RESEND 8/9] x86/kvm/mmu: check if tdp/shadow MMU reconfiguration is needed

2018-09-18 Thread Vitaly Kuznetsov
MMU reconfiguration in init_kvm_tdp_mmu()/kvm_init_shadow_mmu() can be avoided if the source data used to configure it didn't change; enhance kvm_mmu_scache with the required fields and consolidate common code in kvm_calc_mmu_role_common(). Signed-off-by: Vitaly Kuznetsov --- arch/x86/in

[PATCH v1 RESEND 9/9] x86/kvm/mmu: check if MMU reconfiguration is needed in init_kvm_nested_mmu()

2018-09-18 Thread Vitaly Kuznetsov
We don't use root page role for nested_mmu, however, optimizing out re-initialization in case nothing changed is still valuable as this is done for every nested vmentry. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/mmu.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/x8

[PATCH v1 RESEND 5/9] x86/kvm/mmu: get rid of redundant kvm_mmu_setup()

2018-09-18 Thread Vitaly Kuznetsov
From: Paolo Bonzini Just inline the contents into the sole caller, kvm_init_mmu is now public. Suggested-by: Vitaly Kuznetsov Signed-off-by: Paolo Bonzini --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/mmu.c | 7 --- arch/x86/kvm/x86.c | 2 +- 3 files

[PATCH v1 RESEND 3/9] x86/kvm/mmu.c: add kvm_mmu parameter to kvm_mmu_free_roots()

2018-09-18 Thread Vitaly Kuznetsov
Add an option to specify which MMU root we want to free. This will be used when nested and non-nested MMUs for L1 are split. Signed-off-by: Vitaly Kuznetsov Signed-off-by: Paolo Bonzini --- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/mmu.c | 9 + arch/x86/kvm

Re: [PATCH] net: appletalk: remove cops support

2023-09-27 Thread Vitaly Kuznetsov
e can add it back later once the > license is cleared up. > > Reported-by: Prarit Bhargava > Cc: Christoph Hellwig > Cc: Vitaly Kuznetsov FWIW, Reviewed-by: Vitaly Kuznetsov > Cc: jsch...@samba.org > Signed-off-by: Greg Kroah-Hartman > --- > .../device_dr

Re: [PATCH 5/5] KVM: VMX: Always honor guest PAT on CPUs that support self-snoop

2024-09-02 Thread Vitaly Kuznetsov
Yan Zhao writes: > On Fri, Aug 30, 2024 at 03:47:11PM +0200, Vitaly Kuznetsov wrote: >> Gerd Hoffmann writes: >> >> >> Necroposting! >> >> >> >> Turns out that this change broke "bochs-display" driver in QEMU even >> >

Re: [PATCH 5/5] KVM: VMX: Always honor guest PAT on CPUs that support self-snoop

2024-09-03 Thread Vitaly Kuznetsov
Sean Christopherson writes: > On Mon, Sep 02, 2024, Vitaly Kuznetsov wrote: >> FWIW, I use QEMU-9.0 from the same C10S (qemu-kvm-9.0.0-7.el10.x86_64) >> but I don't think it matters in this case. My CPU is "Intel(R) Xeon(R) >> Silver 4410Y". > > Has

Re: [PATCH 5/5] KVM: VMX: Always honor guest PAT on CPUs that support self-snoop

2024-09-04 Thread Vitaly Kuznetsov
Vitaly Kuznetsov writes: > Sean Christopherson writes: > >> On Mon, Sep 02, 2024, Vitaly Kuznetsov wrote: >>> FWIW, I use QEMU-9.0 from the same C10S (qemu-kvm-9.0.0-7.el10.x86_64) >>> but I don't think it matters in this case. My CPU is "Intel(R) Xeon(R

Re: [PATCH v2 3/7] KVM: x86: hyper-v: Move the remote TLB flush logic out of vmx

2021-04-20 Thread Vitaly Kuznetsov
Vineeth Pillai writes: > On 4/16/2021 4:36 AM, Vitaly Kuznetsov wrote: >> >>> struct kvm_vm_stat { >>> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c >>> index 58fa8c029867..614b4448a028 100644 >>> --- a/arch/x86/kvm/hyperv.c >>

Re: [PATCH] x86/hyperv: Restrict get_vtl to only VTL platforms

2023-09-14 Thread Vitaly Kuznetsov
Saurabh Sengar writes: > For non VTL platforms vtl is always 0, and there is no need of > get_vtl function. For VTL platforms get_vtl should always succeed > and should return the correct VTL. > > Signed-off-by: Saurabh Sengar > --- > arch/x86/hyperv/hv_init.c | 8 +--- > 1 file changed, 5

Re: linux-next: Fixes tag needs some work in the pm tree

2021-04-08 Thread Vitaly Kuznetsov
Stephen Rothwell writes: > Hi all, > > In commit > > fa26d0c778b4 ("ACPI: processor: Fix build when CONFIG_ACPI_PROCESSOR=m") > > Fixes tag > > Fixes: 8c182bd7 ("CPI: processor: Fix CPU0 wakeup in > acpi_idle_play_dead()") "A" in "ACPI" seems to be missing > > has these problem(s): > >

Re: [PATCH 1/7] hyperv: Detect Nested virtualization support for SVM

2021-04-08 Thread Vitaly Kuznetsov
Vineeth Pillai writes: > Detect nested features exposed by Hyper-V if SVM is enabled. > > Signed-off-by: Vineeth Pillai > --- > arch/x86/kernel/cpu/mshyperv.c | 10 +- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/

Re: [PATCH 3/7] KVM: x86: hyper-v: Move the remote TLB flush logic out of vmx

2021-04-08 Thread Vitaly Kuznetsov
Vineeth Pillai writes: > Currently the remote TLB flush logic is specific to VMX. > Move it to a common place so that SVM can use it as well. > > Signed-off-by: Vineeth Pillai > --- > arch/x86/include/asm/kvm_host.h | 15 + > arch/x86/kvm/hyperv.c | 89

Re: [PATCH 5/7] KVM: SVM: hyper-v: Remote TLB flush for SVM

2021-04-08 Thread Vitaly Kuznetsov
Vineeth Pillai writes: > Enable remote TLB flush for SVM. > > Signed-off-by: Vineeth Pillai > --- > arch/x86/kvm/svm/svm.c | 35 +++ > 1 file changed, 35 insertions(+) > > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index baee91c1e936..6287cab6

Re: [PATCH 6/7] KVM: SVM: hyper-v: Enlightened MSR-Bitmap support

2021-04-08 Thread Vitaly Kuznetsov
Vineeth Pillai writes: > Enlightened MSR-Bitmap as per TLFS: > > "The L1 hypervisor may collaborate with the L0 hypervisor to make MSR > accesses more efficient. It can enable enlightened MSR bitmaps by setting > the corresponding field in the enlightened VMCS to 1. When enabled, L0 > hype

Re: [PATCH 7/7] KVM: SVM: hyper-v: Direct Virtual Flush support

2021-04-08 Thread Vitaly Kuznetsov
Vineeth Pillai writes: > From Hyper-V TLFS: > "The hypervisor exposes hypercalls (HvFlushVirtualAddressSpace, > HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressList, and > HvFlushVirtualAddressListEx) that allow operating systems to more > efficiently manage the virtual TLB. The L1 hype

Re: [PATCH 3/4] KVM: x86: kvm_hv_flush_tlb use inputs from XMM registers

2021-04-08 Thread Vitaly Kuznetsov
Siddharth Chandrasekaran writes: > Hyper-V supports the use of XMM registers to perform fast hypercalls. > This allows guests to take advantage of the improved performance of the > fast hypercall interface even though a hypercall may require more than > (the current maximum of) two input register

Re: [PATCH 4/4] KVM: hyper-v: Advertise support for fast XMM hypercalls

2021-04-08 Thread Vitaly Kuznetsov
Siddharth Chandrasekaran writes: > Now that all extant hypercalls that can use XMM registers (based on > spec) for input/outputs are patched to support them, we can start > advertising this feature to guests. > > Cc: Alexander Graf > Cc: Evgeny Iakovlev > Signed-off-by: Siddharth Chandrasekaran

Re: [PATCH 3/4] KVM: x86: kvm_hv_flush_tlb use inputs from XMM registers

2021-04-08 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 08/04/21 14:01, Vitaly Kuznetsov wrote: >> >> Also, we can probably defer kvm_hv_hypercall_read_xmm() until we know >> how many regs we actually need to not read them all (we will always >> need xmm[0] I guess so we can as well read it her

Re: [PATCH 4/4] KVM: hyper-v: Advertise support for fast XMM hypercalls

2021-04-08 Thread Vitaly Kuznetsov
Siddharth Chandrasekaran writes: > On Thu, Apr 08, 2021 at 02:05:53PM +0200, Vitaly Kuznetsov wrote: >> Siddharth Chandrasekaran writes: >> >> > Now that all extant hypercalls that can use XMM registers (based on >> > spec) for input/outputs are patc

Re: [PATCH 4/4] KVM: hyper-v: Advertise support for fast XMM hypercalls

2021-04-09 Thread Vitaly Kuznetsov
Siddharth Chandrasekaran writes: > On Thu, Apr 08, 2021 at 04:44:23PM +0200, Vitaly Kuznetsov wrote: >> CAUTION: This email originated from outside of the organization. Do not >> click links or open attachments unless you can confirm the sender and know >>

Re: [PATCH 0/4] Add support for XMM fast hypercalls

2021-04-09 Thread Vitaly Kuznetsov
Siddharth Chandrasekaran writes: > On Thu, Apr 08, 2021 at 04:30:18PM +, Wei Liu wrote: >> On Thu, Apr 08, 2021 at 05:54:43PM +0200, Siddharth Chandrasekaran wrote: >> > On Thu, Apr 08, 2021 at 05:48:19PM +0200, Paolo Bonzini wrote: >> > > On 08/04/21 17:40, Siddharth Chandrasekaran wrote: >>

Re: [PATCH] tools: hv: kvp_daemon: make IPv6-only-injection work

2014-12-09 Thread Vitaly Kuznetsov
Dexuan Cui writes: > Currently IPv6-only-injection doesn't work because the daemon doesn't parse > any IPv6 information at all once it finds the dhcp_enabled flag is true. > > But according to the Hyper-v host team, the flag is only for IPv4. > In the case the host only injects 1 IPv6 address, th

[PATCH v2] xen/blkfront: remove redundant flush_op

2014-12-09 Thread Vitaly Kuznetsov
flush_op is unambiguously defined by feature_flush: REQ_FUA | REQ_FLUSH -> BLKIF_OP_WRITE_BARRIER REQ_FLUSH -> BLKIF_OP_FLUSH_DISKCACHE 0 -> 0 and thus can be removed. This is just a cleanup. The patch was suggested by Boris Ostrovsky. Signed-off-by: Vitaly Kuznetsov --

[PATCH 0/5] Tools: hv: fix compiler warnings and do minor cleanup

2014-12-09 Thread Vitaly Kuznetsov
' in hv_start_fcopy()" Vitaly Kuznetsov (5): Tools: hv: add mising fcopyd to the Makefile Tools: hv: remove unused bytes_written from kvp_update_file() Tools: hv: address compiler warnings for hv_kvp_daemon.c Tools: hv: address compiler warnings for hv_fcopy_daemon.c Tools: h

[PATCH 2/5] Tools: hv: remove unused bytes_written from kvp_update_file()

2014-12-09 Thread Vitaly Kuznetsov
’ set but not used [-Wunused-but-set-variable] Remove bytes_written completely. Signed-off-by: Vitaly Kuznetsov --- tools/hv/hv_kvp_daemon.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index 6a6432a..5a274ca 100644

<    1   2   3   4   5   6   7   8   9   10   >