[PATCH v2 1/4] x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h

2018-11-26 Thread Vitaly Kuznetsov
We implement Hyper-V SynIC and synthetic timers in KVM too so there's some room for code sharing. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/hyperv-tlfs.h | 69 ++ drivers/hv/hv.c| 2 +- drivers/hv/hyperv_vmbus.h | 68

[PATCH v2 1/4] x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h

2018-11-26 Thread Vitaly Kuznetsov
We implement Hyper-V SynIC and synthetic timers in KVM too so there's some room for code sharing. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/hyperv-tlfs.h | 69 ++ drivers/hv/hv.c| 2 +- drivers/hv/hyperv_vmbus.h | 68

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

2018-11-26 Thread Vitaly Kuznetsov
stimer_send_msg() takes not less than 1500 cpu cycles and stimer_notify_direct() can usually be done in 300-400. WS2016 without Hyper-V, however, always sticks to non-direct version. Signed-off-by: Vitaly Kuznetsov --- - Changes since v1: avoid open-coding stimer_mark_pending

[PATCH v2 4/4] x86/kvm/hyper-v: avoid open-coding stimer_mark_pending() in kvm_hv_notify_acked_sint()

2018-11-26 Thread Vitaly Kuznetsov
-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 9533133be566..e6a2a085644a 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -206,7 +206,7 @@ static void

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

2018-11-26 Thread Vitaly Kuznetsov
stimer_send_msg() takes not less than 1500 cpu cycles and stimer_notify_direct() can usually be done in 300-400. WS2016 without Hyper-V, however, always sticks to non-direct version. Signed-off-by: Vitaly Kuznetsov --- - Changes since v1: avoid open-coding stimer_mark_pending

[PATCH v2 4/4] x86/kvm/hyper-v: avoid open-coding stimer_mark_pending() in kvm_hv_notify_acked_sint()

2018-11-26 Thread Vitaly Kuznetsov
-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 9533133be566..e6a2a085644a 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -206,7 +206,7 @@ static void

[PATCH v2 0/4] x86/kvm/hyper-v: Implement Direct Mode for synthetic timers

2018-11-26 Thread Vitaly Kuznetsov
instead of sending a SynIC message. Qemu and kvm-unit-test patches for testing this series can be found in v1 submission: https://lkml.org/lkml/2018/11/13/972 Vitaly Kuznetsov (4): x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h x86/kvm/hyper-v: use stimer config

[PATCH v2 2/4] x86/kvm/hyper-v: use stimer config definition from hyperv-tlfs.h

2018-11-26 Thread Vitaly Kuznetsov
As a preparation to implementing Direct Mode for Hyper-V synthetic timers switch to using stimer config definition from hyperv-tlfs.h. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/hyperv-tlfs.h | 6 -- arch/x86/include/asm/kvm_host.h| 2 +- arch/x86/kvm/hyperv.c

[PATCH v2 0/4] x86/kvm/hyper-v: Implement Direct Mode for synthetic timers

2018-11-26 Thread Vitaly Kuznetsov
instead of sending a SynIC message. Qemu and kvm-unit-test patches for testing this series can be found in v1 submission: https://lkml.org/lkml/2018/11/13/972 Vitaly Kuznetsov (4): x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h x86/kvm/hyper-v: use stimer config

[PATCH v2 2/4] x86/kvm/hyper-v: use stimer config definition from hyperv-tlfs.h

2018-11-26 Thread Vitaly Kuznetsov
As a preparation to implementing Direct Mode for Hyper-V synthetic timers switch to using stimer config definition from hyperv-tlfs.h. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/hyperv-tlfs.h | 6 -- arch/x86/include/asm/kvm_host.h| 2 +- arch/x86/kvm/hyperv.c

Re: KVM selftests are failing

2018-11-16 Thread Vitaly Kuznetsov
Ahmed Soliman writes: > Hello once again, > > I noticed that there is still more problems with kvmself test (at > least on my machine) > > Any test that would successfully reach the guest's code immediately > VMexit by a shutdown. > > $ ./vmx_tsc_adjust_test > Test Assertion Failure >

Re: KVM selftests are failing

2018-11-16 Thread Vitaly Kuznetsov
Ahmed Soliman writes: > Hello once again, > > I noticed that there is still more problems with kvmself test (at > least on my machine) > > Any test that would successfully reach the guest's code immediately > VMexit by a shutdown. > > $ ./vmx_tsc_adjust_test > Test Assertion Failure >

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

2018-11-15 Thread Vitaly Kuznetsov
Srinivasan Acked-by: Jiri Kosina Signed-off-by: Vitaly Kuznetsov --- - It seems the patch slipped through the cracks, resending. --- drivers/hid/hid-hyperv.c | 2 +- drivers/input/serio/hyperv-keyboard.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drive

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

2018-11-15 Thread Vitaly Kuznetsov
Srinivasan Acked-by: Jiri Kosina Signed-off-by: Vitaly Kuznetsov --- - It seems the patch slipped through the cracks, resending. --- drivers/hid/hid-hyperv.c | 2 +- drivers/input/serio/hyperv-keyboard.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drive

Re: KVM selftests are failing

2018-11-15 Thread Vitaly Kuznetsov
Ahmed Soliman writes: > Hello, > On Thu, Nov 15, 2018 at 4:50 PM Andrew Jones wrote: >> >> On Thu, Nov 15, 2018 at 03:36:44PM +0200, Ahmed Soliman wrote: >> > mmap(NULL, 6291456, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, >> > -1, 0) = 0x7f46ea2a1000 >> > madvise(0x7f46ea2a1000, 6291456,

Re: KVM selftests are failing

2018-11-15 Thread Vitaly Kuznetsov
Ahmed Soliman writes: > Hello, > On Thu, Nov 15, 2018 at 4:50 PM Andrew Jones wrote: >> >> On Thu, Nov 15, 2018 at 03:36:44PM +0200, Ahmed Soliman wrote: >> > mmap(NULL, 6291456, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, >> > -1, 0) = 0x7f46ea2a1000 >> > madvise(0x7f46ea2a1000, 6291456,

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

2018-11-13 Thread Vitaly Kuznetsov
stimer_send_msg() takes not less than 1500 cpu cycles and stimer_notify_direct() can usually be done in 300-400. WS2016 without Hyper-V, however, always sticks to non-direct version. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c| 71 +++- arch/x86/kvm

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

2018-11-13 Thread Vitaly Kuznetsov
stimer_send_msg() takes not less than 1500 cpu cycles and stimer_notify_direct() can usually be done in 300-400. WS2016 without Hyper-V, however, always sticks to non-direct version. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c| 71 +++- arch/x86/kvm

[kvm-unit-tests PATCH] x86/hyper-v: stimer_direct test

2018-11-13 Thread Vitaly Kuznetsov
Signed-off-by: Vitaly Kuznetsov --- x86/Makefile.common| 3 + x86/hyperv.h | 7 ++ x86/hyperv_stimer_direct.c | 250 + x86/unittests.cfg | 6 + 4 files changed, 266 insertions(+) create mode 100644 x86

[QEMU PATCH] i386/kvm: add support for Direct Mode for Hyper-V synthetic timers

2018-11-13 Thread Vitaly Kuznetsov
Signed-off-by: Vitaly Kuznetsov --- linux-headers/linux/kvm.h | 1 + target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/hyperv-proto.h | 1 + target/i386/kvm.c | 11 +++ 5 files changed, 15 insertions(+) diff --git a/linux-headers/linux/kvm.h b

[kvm-unit-tests PATCH] x86/hyper-v: stimer_direct test

2018-11-13 Thread Vitaly Kuznetsov
Signed-off-by: Vitaly Kuznetsov --- x86/Makefile.common| 3 + x86/hyperv.h | 7 ++ x86/hyperv_stimer_direct.c | 250 + x86/unittests.cfg | 6 + 4 files changed, 266 insertions(+) create mode 100644 x86

[QEMU PATCH] i386/kvm: add support for Direct Mode for Hyper-V synthetic timers

2018-11-13 Thread Vitaly Kuznetsov
Signed-off-by: Vitaly Kuznetsov --- linux-headers/linux/kvm.h | 1 + target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/hyperv-proto.h | 1 + target/i386/kvm.c | 11 +++ 5 files changed, 15 insertions(+) diff --git a/linux-headers/linux/kvm.h b

[PATCH 2/3] x86/kvm/hyper-v: use stimer config definition from hyperv-tlfs.h

2018-11-13 Thread Vitaly Kuznetsov
As a preparation to implementing Direct Mode for Hyper-V synthetic timers switch to using stimer config definition from hyperv-tlfs.h. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/hyperv-tlfs.h | 6 -- arch/x86/include/asm/kvm_host.h| 2 +- arch/x86/kvm/hyperv.c

[PATCH 2/3] x86/kvm/hyper-v: use stimer config definition from hyperv-tlfs.h

2018-11-13 Thread Vitaly Kuznetsov
As a preparation to implementing Direct Mode for Hyper-V synthetic timers switch to using stimer config definition from hyperv-tlfs.h. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/hyperv-tlfs.h | 6 -- arch/x86/include/asm/kvm_host.h| 2 +- arch/x86/kvm/hyperv.c

[PATCH 0/3] x86/kvm/hyper-v: Implement Direct Mode for synthetic timers

2018-11-13 Thread Vitaly Kuznetsov
patches for testing purposes. Vitaly Kuznetsov (3): x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h x86/kvm/hyper-v: use stimer config definition from hyperv-tlfs.h x86/kvm/hyper-v: direct mode for synthetic timers arch/x86/include/asm/hyperv-tlfs.h | 73

[PATCH 1/3] x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h

2018-11-13 Thread Vitaly Kuznetsov
We implement Hyper-V SynIC and synthetic timers in KVM too so there's some room for code sharing. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/hyperv-tlfs.h | 69 ++ drivers/hv/hv.c| 2 +- drivers/hv/hyperv_vmbus.h | 68

[PATCH 0/3] x86/kvm/hyper-v: Implement Direct Mode for synthetic timers

2018-11-13 Thread Vitaly Kuznetsov
patches for testing purposes. Vitaly Kuznetsov (3): x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h x86/kvm/hyper-v: use stimer config definition from hyperv-tlfs.h x86/kvm/hyper-v: direct mode for synthetic timers arch/x86/include/asm/hyperv-tlfs.h | 73

[PATCH 1/3] x86/hyper-v: move synic/stimer control structures definitions to hyperv-tlfs.h

2018-11-13 Thread Vitaly Kuznetsov
We implement Hyper-V SynIC and synthetic timers in KVM too so there's some room for code sharing. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/hyperv-tlfs.h | 69 ++ drivers/hv/hv.c| 2 +- drivers/hv/hyperv_vmbus.h | 68

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

2018-11-12 Thread Vitaly Kuznetsov
Jim Mattson writes: > I'm not convinced that the "one size fits all" and "context-free" > approaches to VMCS shadowing are terribly effective. > > For example, we never shadow VMX_INSTRUCTION_INFO, but if we just > reflected an exit to L1 for which that field is defined, there's > probably a

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

2018-11-12 Thread Vitaly Kuznetsov
Jim Mattson writes: > I'm not convinced that the "one size fits all" and "context-free" > approaches to VMCS shadowing are terribly effective. > > For example, we never shadow VMX_INSTRUCTION_INFO, but if we just > reflected an exit to L1 for which that field is defined, there's > probably a

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 c

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 c

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

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

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

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

2018-10-19 Thread Vitaly Kuznetsov
-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..641a65b30685 100644

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

2018-10-19 Thread Vitaly Kuznetsov
-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..641a65b30685 100644

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

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

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

[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

[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

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

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

[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 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 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 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 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 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 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 08/13] x86/kvm/lapic: preserve gfn_to_hva_cache len on cache reinit

2018-10-16 Thread Vitaly Kuznetsov
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,22 @@

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

2018-10-16 Thread Vitaly Kuznetsov
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,22 @@

[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
(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/kvm/vmx.c

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

[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
(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/kvm/vmx.c

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

[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 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 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 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 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 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 00/13] KVM: nVMX: Enlightened VMCS for Hyper-V on KVM

2018-10-16 Thread Vitaly Kuznetsov
cpuid 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 00/13] KVM: nVMX: Enlightened VMCS for Hyper-V on KVM

2018-10-16 Thread Vitaly Kuznetsov
cpuid 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

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-

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-

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

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

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 callbac

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 callbac

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

2018-10-11 Thread Vitaly Kuznetsov
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: Vitaly Kuznetso

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

2018-10-11 Thread Vitaly Kuznetsov
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: Vitaly Kuznetso

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

[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 changed, 6

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

[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 changed, 6

[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 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 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 '!!' instead

[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 '!!' instead

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

2018-10-08 Thread Vitaly Kuznetsov
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: make vcpu->mmu a pointer to the cu

[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 4/9] x86/kvm/mmu: introduce guest_mmu

2018-10-08 Thread Vitaly Kuznetsov
; 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: Sean Christop

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

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

2018-10-08 Thread Vitaly Kuznetsov
; 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: Sean Christop

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

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

2018-10-08 Thread Vitaly Kuznetsov
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: make vcpu->mmu a pointer to the cu

<    5   6   7   8   9   10   11   12   13   14   >