[PATCH v3 3/3] KVM: X86: Don't use PV TLB flush with dedicated vCPUs and steal time disabled

2018-02-10 Thread Wanpeng Li
From: Wanpeng Li vCPUs are very unlikely to get preempted when they are the only task running on a CPU. PV TLB flush is slower that the native flush in that case. In addition, avoid traversing all the cpus for pv tlb flush when steal time is disabled since pv tlb flush depends on the field

[PATCH v3 2/3] KVM: X86: Choose qspinlock when dedicated vCPUs available

2018-02-10 Thread Wanpeng Li
From: Wanpeng Li Waiman Long mentioned that: Generally speaking, unfair lock performs well for VMs with a small number of vCPUs. Native qspinlock may perform better than pvqspinlock if there is vCPU pinning and there is no vCPU over-commitment. This patch uses a KVM_HINTS_DEDICATED

[PATCH v3 0/3] KVM: Introduce dedicated vCPUs hint KVM_HINTS_DEDICATED

2018-02-10 Thread Wanpeng Li
v1 -> v2: * update to KVM_HINTS_DEDICATED Wanpeng Li (3): KVM: Introduce dedicated vCPUs hint KVM_HINTS_DEDICATED KVM: X86: Choose qspinlock when dedicated vCPUs available KVM: X86: Don't use PV TLB flush with dedicated vCPUs and steal time disabled Documentation/virtual/kvm/cpuid.txt

[PATCH v3 0/3] KVM: Introduce dedicated vCPUs hint KVM_HINTS_DEDICATED

2018-02-10 Thread Wanpeng Li
v1 -> v2: * update to KVM_HINTS_DEDICATED Wanpeng Li (3): KVM: Introduce dedicated vCPUs hint KVM_HINTS_DEDICATED KVM: X86: Choose qspinlock when dedicated vCPUs available KVM: X86: Don't use PV TLB flush with dedicated vCPUs and steal time disabled Documentation/virtual/kvm/cpuid.txt

[PATCH v2 2/2] KVM: X86: Don't use PV TLB flush with dedicated vCPUs and steal time disabled

2018-02-09 Thread Wanpeng Li
From: Wanpeng Li <wanpen...@tencent.com> vCPUs are very unlikely to get preempted when they are the only task running on a CPU. PV TLB flush is slower that the native flush in that case. In addition, avoid traversing all the cpus for pv tlb flush when steal time is disabled since pv tlb

[PATCH v2 2/2] KVM: X86: Don't use PV TLB flush with dedicated vCPUs and steal time disabled

2018-02-09 Thread Wanpeng Li
From: Wanpeng Li vCPUs are very unlikely to get preempted when they are the only task running on a CPU. PV TLB flush is slower that the native flush in that case. In addition, avoid traversing all the cpus for pv tlb flush when steal time is disabled since pv tlb flush depends on the field

[PATCH v2 1/2] KVM: x86: Add dedicated vCPU hint KVM_HINTS_DEDICATED

2018-02-09 Thread Wanpeng Li
From: Wanpeng Li <wanpen...@tencent.com> Waiman Long mentioned that: Generally speaking, unfair lock performs well for VMs with a small number of vCPUs. Native qspinlock may perform better than pvqspinlock if there is vCPU pinning and there is no vCPU over-commitment. This patc

[PATCH v2 1/2] KVM: x86: Add dedicated vCPU hint KVM_HINTS_DEDICATED

2018-02-09 Thread Wanpeng Li
From: Wanpeng Li Waiman Long mentioned that: Generally speaking, unfair lock performs well for VMs with a small number of vCPUs. Native qspinlock may perform better than pvqspinlock if there is vCPU pinning and there is no vCPU over-commitment. This patch adds a performance hint to allow

[PATCH v2] target-i386: add KVM_HINTS_DEDICATED performance hint

2018-02-09 Thread Wanpeng Li
From: Wanpeng Li <wanpen...@tencent.com> Add KVM_HINTS_DEDICATED performance hint, guest checks this feature bit to determine if they run on dedicated vCPUs, allowing optimizations such as usage of qspinlocks. Cc: Paolo Bonzini <pbonz...@redhat.com> Cc: Radim Krčmář <rkrc...

[PATCH v2] target-i386: add KVM_HINTS_DEDICATED performance hint

2018-02-09 Thread Wanpeng Li
From: Wanpeng Li Add KVM_HINTS_DEDICATED performance hint, guest checks this feature bit to determine if they run on dedicated vCPUs, allowing optimizations such as usage of qspinlocks. Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Eduardo Habkost Signed-off-by: Wanpeng Li --- v1 -> v2: *

Re: [PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-07 Thread Wanpeng Li
2018-02-07 22:16 GMT+08:00 Paolo Bonzini <pbonz...@redhat.com>: > On 07/02/2018 07:25, Wanpeng Li wrote: >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index 786cd00..445e702 100644 >> --- a/arch/x86/kvm/x86.c >> +++ b/arch/x86/kvm/x8

Re: [PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-07 Thread Wanpeng Li
2018-02-07 22:16 GMT+08:00 Paolo Bonzini : > On 07/02/2018 07:25, Wanpeng Li wrote: >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index 786cd00..445e702 100644 >> --- a/arch/x86/kvm/x86.c >> +++ b/arch/x86/kvm/x86.c >> @@ -7458,6 +7458,11 @@ int kvm_ar

[PATCH v2] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-07 Thread Wanpeng Li
From: Wanpeng Li <wanpen...@tencent.com> Reported by syzkaller: WARNING: CPU: 6 PID: 2434 at arch/x86/kvm/vmx.c:6660 handle_ept_misconfig+0x54/0x1e0 [kvm_intel] CPU: 6 PID: 2434 Comm: repro_test Not tainted 4.15.0+ #4 RIP: 0010:handle_ept_misconfig+0x54/0x1e0 [kvm_intel] Call

[PATCH v2] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-07 Thread Wanpeng Li
From: Wanpeng Li Reported by syzkaller: WARNING: CPU: 6 PID: 2434 at arch/x86/kvm/vmx.c:6660 handle_ept_misconfig+0x54/0x1e0 [kvm_intel] CPU: 6 PID: 2434 Comm: repro_test Not tainted 4.15.0+ #4 RIP: 0010:handle_ept_misconfig+0x54/0x1e0 [kvm_intel] Call Trace: vmx_handle_exit

Re: [PATCH] KVM: nVMX: Fix CR4 after VMLAUNCH/VMRESUME failure

2018-02-07 Thread Wanpeng Li
ven if vmcs shadow is enabled since host_cr[34] is not shadowed in the bitmap, why it is not up-to-date when L1 is running? Regards, Wanpeng Li > they are legal (because we checked them), but that's about it. If the > VMLAUNCH/VMRESUME of vmcs12 fails for "invalid control field," t

Re: [PATCH] KVM: nVMX: Fix CR4 after VMLAUNCH/VMRESUME failure

2018-02-07 Thread Wanpeng Li
e host_cr[34] is not shadowed in the bitmap, why it is not up-to-date when L1 is running? Regards, Wanpeng Li > they are legal (because we checked them), but that's about it. If the > VMLAUNCH/VMRESUME of vmcs12 fails for "invalid control field," there > is no VM-exit

Re: [PATCH] KVM: nVMX: Fix CR4 after VMLAUNCH/VMRESUME failure

2018-02-07 Thread Wanpeng Li
2018-02-07 0:58 GMT+08:00 Jim Mattson <jmatt...@google.com>: > On Mon, Feb 5, 2018 at 4:57 PM, Wanpeng Li <kernel...@gmail.com> wrote: > >> This is effective one, what I restore in this patch is >> achitectural/guest visible. > > This patch doesn't "re

Re: [PATCH] KVM: nVMX: Fix CR4 after VMLAUNCH/VMRESUME failure

2018-02-07 Thread Wanpeng Li
2018-02-07 0:58 GMT+08:00 Jim Mattson : > On Mon, Feb 5, 2018 at 4:57 PM, Wanpeng Li wrote: > >> This is effective one, what I restore in this patch is >> achitectural/guest visible. > > This patch doesn't "restore" the guest visible CR4 to its value at the >

[PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-06 Thread Wanpeng Li
From: Wanpeng Li <wanpen...@tencent.com> Reported by syzkaller: WARNING: CPU: 6 PID: 2434 at arch/x86/kvm/vmx.c:6660 handle_ept_misconfig+0x54/0x1e0 [kvm_intel] CPU: 6 PID: 2434 Comm: repro_test Not tainted 4.15.0+ #4 RIP: 0010:handle_ept_misconfig+0x54/0x1e0 [kvm_intel] Call

[PATCH] KVM: X86: Fix SMRAM accessing even if VM is shutdown

2018-02-06 Thread Wanpeng Li
From: Wanpeng Li Reported by syzkaller: WARNING: CPU: 6 PID: 2434 at arch/x86/kvm/vmx.c:6660 handle_ept_misconfig+0x54/0x1e0 [kvm_intel] CPU: 6 PID: 2434 Comm: repro_test Not tainted 4.15.0+ #4 RIP: 0010:handle_ept_misconfig+0x54/0x1e0 [kvm_intel] Call Trace: vmx_handle_exit

Re: WARNING in handle_ept_misconfig

2018-02-06 Thread Wanpeng Li
gt; handle_ept_misconfig+0x140/0x520 arch/x86/kvm/vmx.c:6771 > Kernel panic - not syncing: panic_on_warn set ... I can reproduce, will have a look. Regards, Wanpeng Li > > CPU: 0 PID: 4187 Comm: syzkaller225100 Not tainted 4.15.0+ #298 > Hardware name: Google Google Com

Re: WARNING in handle_ept_misconfig

2018-02-06 Thread Wanpeng Li
nic - not syncing: panic_on_warn set ... I can reproduce, will have a look. Regards, Wanpeng Li > > CPU: 0 PID: 4187 Comm: syzkaller225100 Not tainted 4.15.0+ #298 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS > Google 01/01/2011 > Call Trace: > __dump_st

Re: [PATCH 2/5] KVM: x86: add support for UMIP

2018-02-05 Thread Wanpeng Li
return 1; There is a scenario here, UMIP CPUID is not exposed to the guest since it depends on SECONDARY_EXEC_DESC is set, however, SECONDARY_EXEC_DESC depends on guest sets the X86_CR4_UMIP bit, the function kvm_set_cr4() will inject a #GP and fails to set X86_CR4_UMIP bit since UMIP CPUID is not exposed to the guest. This scenario can be observed when running kvm-unit-tests/umip.flat in the L1. Regards, Wanpeng Li

Re: [PATCH 2/5] KVM: x86: add support for UMIP

2018-02-05 Thread Wanpeng Li
PUID is not exposed to the guest since it depends on SECONDARY_EXEC_DESC is set, however, SECONDARY_EXEC_DESC depends on guest sets the X86_CR4_UMIP bit, the function kvm_set_cr4() will inject a #GP and fails to set X86_CR4_UMIP bit since UMIP CPUID is not exposed to the guest. This scenario can be observed when running kvm-unit-tests/umip.flat in the L1. Regards, Wanpeng Li

Re: [PATCH] KVM: nVMX: Fix CR4 after VMLAUNCH/VMRESUME failure

2018-02-05 Thread Wanpeng Li
ware. > >> CR4 should be unchanged from the time of the VMLAUNCH/VMRESUME. There is This is effective one, what I restore in this patch is achitectural/guest visible. Regards, Wanpeng Li >> no guarantee that vmcs12->host_cr4 holds the correct value. > > >> On Mon,

Re: [PATCH] KVM: nVMX: Fix CR4 after VMLAUNCH/VMRESUME failure

2018-02-05 Thread Wanpeng Li
he VMLAUNCH/VMRESUME. There is This is effective one, what I restore in this patch is achitectural/guest visible. Regards, Wanpeng Li >> no guarantee that vmcs12->host_cr4 holds the correct value. > > >> On Mon, Feb 5, 2018 at 3:05 AM Wanpeng Li wrote: > >>> F

[PATCH] KVM: nVMX: Fix CR4 after VMLAUNCH/VMRESUME failure

2018-02-05 Thread Wanpeng Li
From: Wanpeng Li <wanpen...@tencent.com> In L0, Haswell client host: nested_vmx_exit_reflected failed vm entry 7 WARNING: CPU: 6 PID: 6797 at kvm/arch/x86/kvm//vmx.c:6206 handle_desc+0x2d/0x40 [kvm_intel] CPU: 6 PID: 6797 Comm: qemu-system-x86 Tainted: GW OE4.15.0+ #4 RIP

[PATCH] KVM: nVMX: Fix CR4 after VMLAUNCH/VMRESUME failure

2018-02-05 Thread Wanpeng Li
From: Wanpeng Li In L0, Haswell client host: nested_vmx_exit_reflected failed vm entry 7 WARNING: CPU: 6 PID: 6797 at kvm/arch/x86/kvm//vmx.c:6206 handle_desc+0x2d/0x40 [kvm_intel] CPU: 6 PID: 6797 Comm: qemu-system-x86 Tainted: GW OE4.15.0+ #4 RIP: 0010:handle_desc+0x2d/0x40

Re: [PATCH 2/2] KVM: X86: Add per-VM no-HLT-exiting capability

2018-02-04 Thread Wanpeng Li
2018-02-03 3:02 GMT+08:00 Radim Krčmář <rkrc...@redhat.com>: > 2018-02-01 23:11-0800, Wanpeng Li: >> From: Wanpeng Li <wanpen...@tencent.com> >> >> If host CPUs are dedicated to a VM, we can avoid VM exits on HLT. >> This patch adds the per-VM non-HLT-exit

Re: [PATCH 2/2] KVM: X86: Add per-VM no-HLT-exiting capability

2018-02-04 Thread Wanpeng Li
2018-02-03 3:02 GMT+08:00 Radim Krčmář : > 2018-02-01 23:11-0800, Wanpeng Li: >> From: Wanpeng Li >> >> If host CPUs are dedicated to a VM, we can avoid VM exits on HLT. >> This patch adds the per-VM non-HLT-exiting capability. >> >> Cc: Paolo Bonz

[PATCH v2 1/2] KVM: X86: Add per-VM no-HLT-exiting capability

2018-02-04 Thread Wanpeng Li
From: Wanpeng Li <wanpen...@tencent.com> If host CPUs are dedicated to a VM, we can avoid VM exits on HLT. This patch adds the per-VM non-HLT-exiting capability. Cc: Paolo Bonzini <pbonz...@redhat.com> Cc: Radim Krčmář <rkrc...@redhat.com> Signed-off-by: Wanpeng Li <wanpen..

[PATCH v2 1/2] KVM: X86: Add per-VM no-HLT-exiting capability

2018-02-04 Thread Wanpeng Li
From: Wanpeng Li If host CPUs are dedicated to a VM, we can avoid VM exits on HLT. This patch adds the per-VM non-HLT-exiting capability. Cc: Paolo Bonzini Cc: Radim Krčmář Signed-off-by: Wanpeng Li --- v1 -> v2: * vmx_clear_hlt() around INIT handling * vmx_clear_hlt() upon

[PATCH v2 2/2] KVM: X86: Avoid traversing all the cpus for pv tlb flush when steal time is disabled

2018-02-04 Thread Wanpeng Li
From: Wanpeng Li <wanpen...@tencent.com> Avoid traversing all the cpus for pv tlb flush when steal time is disabled since pv tlb flush depends on the field in steal time for shared data. Cc: Paolo Bonzini <pbonz...@redhat.com> Cc: Radim Krčmář <rkrc...@redhat.com> Signed-

[PATCH v2 2/2] KVM: X86: Avoid traversing all the cpus for pv tlb flush when steal time is disabled

2018-02-04 Thread Wanpeng Li
From: Wanpeng Li Avoid traversing all the cpus for pv tlb flush when steal time is disabled since pv tlb flush depends on the field in steal time for shared data. Cc: Paolo Bonzini Cc: Radim Krčmář Signed-off-by: Wanpeng Li --- arch/x86/kernel/kvm.c | 6 -- 1 file changed, 4

[PATCH 2/2] KVM: X86: Add per-VM no-HLT-exiting capability

2018-02-01 Thread Wanpeng Li
From: Wanpeng Li <wanpen...@tencent.com> If host CPUs are dedicated to a VM, we can avoid VM exits on HLT. This patch adds the per-VM non-HLT-exiting capability. Cc: Paolo Bonzini <pbonz...@redhat.com> Cc: Radim Krčmář <rkrc...@redhat.com> Signed-off-by: Wanpeng Li <

[PATCH 2/2] KVM: X86: Add per-VM no-HLT-exiting capability

2018-02-01 Thread Wanpeng Li
From: Wanpeng Li If host CPUs are dedicated to a VM, we can avoid VM exits on HLT. This patch adds the per-VM non-HLT-exiting capability. Cc: Paolo Bonzini Cc: Radim Krčmář Signed-off-by: Wanpeng Li --- Documentation/virtual/kvm/api.txt | 11 +++ arch/x86/include/asm/kvm_host.h

[PATCH 1/2] KVM: X86: Add dedicated pCPU hint PV_DEDICATED

2018-02-01 Thread Wanpeng Li
From: Wanpeng Li <wanpen...@tencent.com> Waiman Long mentioned that: Generally speaking, unfair lock performs well for VMs with a small number of vCPUs. Native qspinlock may perform better than pvqspinlock if there is vCPU pinning and there is no vCPU over-commitment. This patc

[PATCH 1/2] KVM: X86: Add dedicated pCPU hint PV_DEDICATED

2018-02-01 Thread Wanpeng Li
From: Wanpeng Li Waiman Long mentioned that: Generally speaking, unfair lock performs well for VMs with a small number of vCPUs. Native qspinlock may perform better than pvqspinlock if there is vCPU pinning and there is no vCPU over-commitment. This patch adds a performance hint to allow

[PATCH 0/2] KVM: X86: Add dedicated pCPU hint and per-VM non-HLT-exiting capability

2018-02-01 Thread Wanpeng Li
performance under the dedicated pCPU scenarios. Wanpeng Li (2): KVM: X86: Add dedicated pCPU hint PV_DEDICATED KVM: X86: Add per-VM no-HLT-exiting capability Documentation/virtual/kvm/api.txt| 11 +++ Documentation/virtual/kvm/cpuid.txt | 6 ++ arch/x86/include/asm/kvm_host.h

[PATCH 0/2] KVM: X86: Add dedicated pCPU hint and per-VM non-HLT-exiting capability

2018-02-01 Thread Wanpeng Li
performance under the dedicated pCPU scenarios. Wanpeng Li (2): KVM: X86: Add dedicated pCPU hint PV_DEDICATED KVM: X86: Add per-VM no-HLT-exiting capability Documentation/virtual/kvm/api.txt| 11 +++ Documentation/virtual/kvm/cpuid.txt | 6 ++ arch/x86/include/asm/kvm_host.h

Re: [PATCH v2] KVM: x86: fix backward migration with async_PF

2018-02-01 Thread Wanpeng Li
g different cases, we are checking for CPUID feature bit > before enabling the feature and nothing else. > > Fixes: 52a5c155cf79 ("KVM: async_pf: Let guest support delivery of async_pf > from guest mode") > Cc: <sta...@vger.kernel.org> > Signed-off-by: Radim Krčmá

Re: [PATCH v2] KVM: x86: fix backward migration with async_PF

2018-02-01 Thread Wanpeng Li
cking for CPUID feature bit > before enabling the feature and nothing else. > > Fixes: 52a5c155cf79 ("KVM: async_pf: Let guest support delivery of async_pf > from guest mode") > Cc: > Signed-off-by: Radim Krčmář Reviewed-by: Wanpeng Li > --- > v2: > * ad

Re: [PATCH] x86/kvm: disable fast MMIO when running nested

2018-01-24 Thread Wanpeng Li
fast mmio when running nested. > > Signed-off-by: Vitaly Kuznetsov <vkuzn...@redhat.com> Reviewed-by: Wanpeng Li <wanpeng...@hotmail.com> > --- > arch/x86/kvm/vmx.c | 9 - > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/vmx.c

Re: [PATCH] x86/kvm: disable fast MMIO when running nested

2018-01-24 Thread Wanpeng Li
ted. > > Signed-off-by: Vitaly Kuznetsov Reviewed-by: Wanpeng Li > --- > arch/x86/kvm/vmx.c | 9 - > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index c829d89e2e63..54afb446f38e 100644 > --- a/arc

Re: unixbench context switch perfomance & cpu topology

2018-01-24 Thread Wanpeng Li
2018-01-23 21:49 GMT+08:00 Mike Galbraith <efa...@gmx.de>: > On Tue, 2018-01-23 at 18:36 +0800, Wanpeng Li wrote: >> >> Thanks for having a try, Mike. :) Actually the two context1 tasks >> don't stack up on one logical cpu at the most of time which is >> observe

Re: unixbench context switch perfomance & cpu topology

2018-01-24 Thread Wanpeng Li
2018-01-23 21:49 GMT+08:00 Mike Galbraith : > On Tue, 2018-01-23 at 18:36 +0800, Wanpeng Li wrote: >> >> Thanks for having a try, Mike. :) Actually the two context1 tasks >> don't stack up on one logical cpu at the most of time which is >> observed by kernelshar

Re: unixbench context switch perfomance & cpu topology

2018-01-23 Thread Wanpeng Li
2018-01-22 21:37 GMT+08:00 Mike Galbraith <efa...@gmx.de>: > On Mon, 2018-01-22 at 20:27 +0800, Wanpeng Li wrote: >> 2018-01-22 20:08 GMT+08:00 Mike Galbraith <efa...@gmx.de>: >> > On Mon, 2018-01-22 at 19:47 +0800, Wanpeng Li wrote: >> >> Hi all, &g

Re: unixbench context switch perfomance & cpu topology

2018-01-23 Thread Wanpeng Li
2018-01-22 21:37 GMT+08:00 Mike Galbraith : > On Mon, 2018-01-22 at 20:27 +0800, Wanpeng Li wrote: >> 2018-01-22 20:08 GMT+08:00 Mike Galbraith : >> > On Mon, 2018-01-22 at 19:47 +0800, Wanpeng Li wrote: >> >> Hi all, >> >> >> >> We can o

Re: unixbench context switch perfomance & cpu topology

2018-01-23 Thread Wanpeng Li
2018-01-22 20:53 GMT+08:00 Peter Zijlstra <pet...@infradead.org>: > On Mon, Jan 22, 2018 at 07:47:45PM +0800, Wanpeng Li wrote: >> Hi all, >> >> We can observe unixbench context switch performance is heavily >> influenced by cpu topology which is exposed to the gu

Re: unixbench context switch perfomance & cpu topology

2018-01-23 Thread Wanpeng Li
2018-01-22 20:53 GMT+08:00 Peter Zijlstra : > On Mon, Jan 22, 2018 at 07:47:45PM +0800, Wanpeng Li wrote: >> Hi all, >> >> We can observe unixbench context switch performance is heavily >> influenced by cpu topology which is exposed to the guest. the score is >&g

Re: unixbench context switch perfomance & cpu topology

2018-01-22 Thread Wanpeng Li
2018-01-22 20:08 GMT+08:00 Mike Galbraith <efa...@gmx.de>: > On Mon, 2018-01-22 at 19:47 +0800, Wanpeng Li wrote: >> Hi all, >> >> We can observe unixbench context switch performance is heavily >> influenced by cpu topology which is exposed to the guest. the

Re: unixbench context switch perfomance & cpu topology

2018-01-22 Thread Wanpeng Li
2018-01-22 20:08 GMT+08:00 Mike Galbraith : > On Mon, 2018-01-22 at 19:47 +0800, Wanpeng Li wrote: >> Hi all, >> >> We can observe unixbench context switch performance is heavily >> influenced by cpu topology which is exposed to the guest. the score is >> pos

unixbench context switch perfomance & cpu topology

2018-01-22 Thread Wanpeng Li
, Wanpeng Li

unixbench context switch perfomance & cpu topology

2018-01-22 Thread Wanpeng Li
, Wanpeng Li

Re: [PATCH] KVM: prevent overlap between user and private memslots

2018-01-19 Thread Wanpeng Li
2018-01-19 17:01 GMT+08:00 Wanpeng Li <kernel...@gmail.com>: > 2018-01-19 16:18 GMT+08:00 Eric Biggers <ebigge...@gmail.com>: >> From: Eric Biggers <ebigg...@google.com> >> >> Memslots must not overlap in guest physical memory, since otherwise some >> g

Re: [PATCH] KVM: prevent overlap between user and private memslots

2018-01-19 Thread Wanpeng Li
2018-01-19 17:01 GMT+08:00 Wanpeng Li : > 2018-01-19 16:18 GMT+08:00 Eric Biggers : >> From: Eric Biggers >> >> Memslots must not overlap in guest physical memory, since otherwise some >> guest physical addresses will not uniquely map to a memslot.

Re: [PATCH] KVM: prevent overlap between user and private memslots

2018-01-19 Thread Wanpeng Li
VM_SET_TSS_ADDR, 0); > ioctl(cpu, KVM_RUN, 0); > ioctl(vm, KVM_SET_USER_MEMORY_REGION, ); > } > > Reported-by: syzbot <syzkal...@googlegroups.com> > Fixes: e0d62c7f4860 ("KVM: Add kernel-internal memory slots") > Cc: <sta...@vger.kernel

Re: [PATCH] KVM: prevent overlap between user and private memslots

2018-01-19 Thread Wanpeng Li
N, 0); > ioctl(vm, KVM_SET_USER_MEMORY_REGION, ); > } > > Reported-by: syzbot > Fixes: e0d62c7f4860 ("KVM: Add kernel-internal memory slots") > Cc: # v2.6.25+ > Signed-off-by: Eric Biggers Please refer to this one. https://patchwork.kernel.org/patch/96

Re: [RFC 0/6] Enlightened VMCS support for KVM on Hyper-V

2018-01-15 Thread Wanpeng Li
ad of > doing VMWRITE/VMREAD instructions. Tests show that this speeds up > tight CPUID loop almost 3 times: > > Before: > ./cpuid_tight > 20459 > > After: > ./cpuid_tight > 7698 Maybe you can apply a similar idea to kvm nested on kvm. Regards, Wanpeng Li > > ch

Re: [RFC 0/6] Enlightened VMCS support for KVM on Hyper-V

2018-01-15 Thread Wanpeng Li
MREAD instructions. Tests show that this speeds up > tight CPUID loop almost 3 times: > > Before: > ./cpuid_tight > 20459 > > After: > ./cpuid_tight > 7698 Maybe you can apply a similar idea to kvm nested on kvm. Regards, Wanpeng Li > > checkpatch.pl errors/warnin

Re: [PATCH 4/8] kvm: vmx: Set IBPB when running a different VCPU

2018-01-11 Thread Wanpeng Li
R_IA32_PRED_CMD, PRED_CMD_IBPB); > } Intel guys told us the recycle is about the address of vmcs, not the content. Could you explain more why it matters? Regards, Wanpeng Li

Re: [PATCH 4/8] kvm: vmx: Set IBPB when running a different VCPU

2018-01-11 Thread Wanpeng Li
BPB); > } Intel guys told us the recycle is about the address of vmcs, not the content. Could you explain more why it matters? Regards, Wanpeng Li

Re: [PATCH 6/8] kvm: svm: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to guest

2018-01-11 Thread Wanpeng Li
48. They expose only 0x49. >> >> That is only the IPBP is needed on AMD? (I haven't actually seen any official >> docs from AMD). > > AMD is not exposing 0x48 yet, but they plan to based on my information > from a few weeks ago. Haha, interesting, they announce officially there is no issue for variant 2. http://www.amd.com/en/corporate/speculative-execution Regards, Wanpeng Li

Re: [PATCH 6/8] kvm: svm: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to guest

2018-01-11 Thread Wanpeng Li
nly 0x49. >> >> That is only the IPBP is needed on AMD? (I haven't actually seen any official >> docs from AMD). > > AMD is not exposing 0x48 yet, but they plan to based on my information > from a few weeks ago. Haha, interesting, they announce officially there is no issue for variant 2. http://www.amd.com/en/corporate/speculative-execution Regards, Wanpeng Li

Re: [PATCH 0/4] KVM: nVMX: prepare_vmcs02 optimizations

2018-01-01 Thread Wanpeng Li
2018-01-02 7:01 GMT+08:00 Paolo Bonzini <pbonz...@redhat.com>: > On 01/01/2018 10:36, Paolo Bonzini wrote: >> On 28/12/2017 09:39, Wanpeng Li wrote: >>> 2017-12-27 22:28 GMT+08:00 Paolo Bonzini <pbonz...@redhat.com>: >>>> On 25/12/2017 11:08, Wanpeng Li w

Re: [PATCH 0/4] KVM: nVMX: prepare_vmcs02 optimizations

2018-01-01 Thread Wanpeng Li
2018-01-02 7:01 GMT+08:00 Paolo Bonzini : > On 01/01/2018 10:36, Paolo Bonzini wrote: >> On 28/12/2017 09:39, Wanpeng Li wrote: >>> 2017-12-27 22:28 GMT+08:00 Paolo Bonzini : >>>> On 25/12/2017 11:08, Wanpeng Li wrote: >>>>>> I observe L1

Re: [PATCH 2/4] KVM: nVMX: track dirty state of non-shadowed VMCS fields

2017-12-31 Thread Wanpeng Li
2017-12-31 16:08 GMT+08:00 Paolo Bonzini <pbonz...@redhat.com>: > On 25/12/2017 04:03, Wanpeng Li wrote: >> 2017-12-21 20:43 GMT+08:00 Paolo Bonzini <pbonz...@redhat.com>: >>> VMCS12 fields that are not handled through shadow VMCS are rarely >>> written,

Re: [PATCH 2/4] KVM: nVMX: track dirty state of non-shadowed VMCS fields

2017-12-31 Thread Wanpeng Li
2017-12-31 16:08 GMT+08:00 Paolo Bonzini : > On 25/12/2017 04:03, Wanpeng Li wrote: >> 2017-12-21 20:43 GMT+08:00 Paolo Bonzini : >>> VMCS12 fields that are not handled through shadow VMCS are rarely >>> written, and thus they are also almost constant in the vmcs02

Re: [PATCH 0/4] KVM: nVMX: prepare_vmcs02 optimizations

2017-12-28 Thread Wanpeng Li
2017-12-27 22:28 GMT+08:00 Paolo Bonzini <pbonz...@redhat.com>: > On 25/12/2017 11:08, Wanpeng Li wrote: >>> I observe L1(latest kvm/queue) panic and L0(latest kvm/queue) >>> calltrace, I'm not sure whether it is caused by this patchset. >> It can be reproduced s

Re: [PATCH 0/4] KVM: nVMX: prepare_vmcs02 optimizations

2017-12-28 Thread Wanpeng Li
2017-12-27 22:28 GMT+08:00 Paolo Bonzini : > On 25/12/2017 11:08, Wanpeng Li wrote: >>> I observe L1(latest kvm/queue) panic and L0(latest kvm/queue) >>> calltrace, I'm not sure whether it is caused by this patchset. >> It can be reproduced steadily by running kvm-uni

Re: [PATCH 4/4] KVM: nVMX: initialize more non-shadowed fields in prepare_vmcs02_full

2017-12-27 Thread Wanpeng Li
2017-12-27 17:54 GMT+08:00 Paolo Bonzini <pbonz...@redhat.com>: > On 25/12/2017 04:09, Wanpeng Li wrote: >> 2017-12-21 20:43 GMT+08:00 Paolo Bonzini <pbonz...@redhat.com>: >>> These fields are also simple copies of the data in the vmcs12 struct. >>> For so

Re: [PATCH 4/4] KVM: nVMX: initialize more non-shadowed fields in prepare_vmcs02_full

2017-12-27 Thread Wanpeng Li
2017-12-27 17:54 GMT+08:00 Paolo Bonzini : > On 25/12/2017 04:09, Wanpeng Li wrote: >> 2017-12-21 20:43 GMT+08:00 Paolo Bonzini : >>> These fields are also simple copies of the data in the vmcs12 struct. >>> For some of them, prepare_vmcs02 was skipping the copy wh

Re: WARNING in do_debug

2017-12-25 Thread Wanpeng Li
scm/virt/kvm/kvm.git/commit/?h=queue=ed3b37ac63a060bdc184d126c0655c1af8b6de62 There is a fix in kvm/queue. Regards, Wanpeng Li > > WARNING: CPU: 0 PID: 3356 at arch/x86/kernel/traps.c:801 > cond_local_irq_disable arch/x86/kernel/traps.c:86 [inline] > WARNING: CPU: 0 PID: 3356 at arch/x86/kernel/tr

Re: WARNING in do_debug

2017-12-25 Thread Wanpeng Li
Raw console output is attached. > C reproducer is attached > syzkaller reproducer is attached. See https://goo.gl/kgGztJ > for information about syzkaller reproducers > https://git.kernel.org/pub/scm/virt/kvm/kvm.git/commit/?h=queue=ed3b37ac63a060bdc184d126c0655c1af8b6de62 There is a fix in k

Re: [PATCH 0/4] KVM: nVMX: prepare_vmcs02 optimizations

2017-12-25 Thread Wanpeng Li
2017-12-25 18:07 GMT+08:00 Wanpeng Li <kernel...@gmail.com>: > 2017-12-21 20:43 GMT+08:00 Paolo Bonzini <pbonz...@redhat.com>: >> That's about 800-1000 clock cycles more that can be easily peeled, by >> saving about 60 VMWRITEs on every exit. >> >>

Re: [PATCH 0/4] KVM: nVMX: prepare_vmcs02 optimizations

2017-12-25 Thread Wanpeng Li
2017-12-25 18:07 GMT+08:00 Wanpeng Li : > 2017-12-21 20:43 GMT+08:00 Paolo Bonzini : >> That's about 800-1000 clock cycles more that can be easily peeled, by >> saving about 60 VMWRITEs on every exit. >> >> My numbers so far have been collected on a Haswell system vs

Re: [PATCH 0/4] KVM: nVMX: prepare_vmcs02 optimizations

2017-12-25 Thread Wanpeng Li
5 74 1b 45 31 c0 31 c9 31 f6 ba 10 00 00 00 e8 2d 0e f8 ff 85 c0 0f 94 c0 0f b6 c0 5d c3 <0f> ff eb e1 0f 1f 44 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f [ 149.014080] ---[ end trace 53c0bffb9d8f6939 ]--- Regards, Wanpeng Li

Re: [PATCH 0/4] KVM: nVMX: prepare_vmcs02 optimizations

2017-12-25 Thread Wanpeng Li
31 f6 ba 10 00 00 00 e8 2d 0e f8 ff 85 c0 0f 94 c0 0f b6 c0 5d c3 <0f> ff eb e1 0f 1f 44 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f [ 149.014080] ---[ end trace 53c0bffb9d8f6939 ]--- Regards, Wanpeng Li

Re: [PATCH] KVM: x86: ioapic: Clear IRR for rtc bit when rtc EOI gotten

2017-12-24 Thread Wanpeng Li
t;irr) || > (!edge && entry.fields.remote_irr)) { > ret = 0; > goto out; > } > > According to RTC spec, after RTC injects a High level irq, OS will read CMOS's I think it is falling edge and active low. Regards,

Re: [PATCH] KVM: x86: ioapic: Clear IRR for rtc bit when rtc EOI gotten

2017-12-24 Thread Wanpeng Li
amp;& entry.fields.remote_irr)) { > ret = 0; > goto out; > } > > According to RTC spec, after RTC injects a High level irq, OS will read CMOS's I think it is falling edge and active low. Regards, Wanpeng Li > register C

Re: [PATCH 4/4] KVM: nVMX: initialize more non-shadowed fields in prepare_vmcs02_full

2017-12-24 Thread Wanpeng Li
> field exists on the host, because the corresponding execution control > might be one of the shadowed fields. Why we don't need to copy them always before the patchset? Regards, Wanpeng Li

Re: [PATCH 4/4] KVM: nVMX: initialize more non-shadowed fields in prepare_vmcs02_full

2017-12-24 Thread Wanpeng Li
ost, because the corresponding execution control > might be one of the shadowed fields. Why we don't need to copy them always before the patchset? Regards, Wanpeng Li

Re: [PATCH 2/4] KVM: nVMX: track dirty state of non-shadowed VMCS fields

2017-12-24 Thread Wanpeng Li
> return kvm_skip_emulated_instruction(vcpu); > } > > + switch (field) { > +#define SHADOW_FIELD_RW(x) case x: > +#include "vmx_shadow_fields.h" What's will happen here if enable_shadow_vmcs == false? Regards, Wanpeng Li > +

Re: [PATCH 2/4] KVM: nVMX: track dirty state of non-shadowed VMCS fields

2017-12-24 Thread Wanpeng Li
emulated_instruction(vcpu); > } > > + switch (field) { > +#define SHADOW_FIELD_RW(x) case x: > +#include "vmx_shadow_fields.h" What's will happen here if enable_shadow_vmcs == false? Regards, Wanpeng Li > + /* > +

Re: general protection fault in native_write_cr4

2017-12-19 Thread Wanpeng Li
> compiler: gcc (GCC) 7.1.1 20170620 > .config is attached > Raw console output is attached. > C reproducer is attached > syzkaller reproducer is attached. See https://goo.gl/kgGztJ > for information about syzkaller reproducers > > I will have a look again, you continue to run

Re: general protection fault in native_write_cr4

2017-12-19 Thread Wanpeng Li
nsole output is attached. > C reproducer is attached > syzkaller reproducer is attached. See https://goo.gl/kgGztJ > for information about syzkaller reproducers > > I will have a look again, you continue to run it in kvm guest, right? Regards, Wanpeng Li > kvm: KVM_SET_TSS_ADDR need

Re: [PATCH v2] IPI performance benchmark

2017-12-19 Thread Wanpeng Li
ock results omitted. Smaller - better. Could you test on a x86 box? I see a lot of calltraces on my haswell client host, there is no calltrace in the guest, however, I can still observe "Invalid parameters" warning when insmod this module. In addition, the x86 box fails to boot when ipi_benchmark is buildin. Regards, Wanpeng Li

Re: [PATCH v2] IPI performance benchmark

2017-12-19 Thread Wanpeng Li
etter. Could you test on a x86 box? I see a lot of calltraces on my haswell client host, there is no calltrace in the guest, however, I can still observe "Invalid parameters" warning when insmod this module. In addition, the x86 box fails to boot when ipi_benchmark is buildin. Regards, Wanpeng Li

Re: [PATCH v4] KVM: Fix stack-out-of-bounds read in write_mmio

2017-12-18 Thread Wanpeng Li
= gpa; > __entry->val = 0; > if (val) > - memcpy(&__entry->val, val, min(8, len)); > + memcpy(&__entry->val, val, > + min_t(u32, sizeof(__entry->val), len)); > ), > > TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx", Thanks Paolo. :) Regards, Wanpeng Li

Re: [PATCH v4] KVM: Fix stack-out-of-bounds read in write_mmio

2017-12-18 Thread Wanpeng Li
l) > - memcpy(&__entry->val, val, min(8, len)); > + memcpy(&__entry->val, val, > + min_t(u32, sizeof(__entry->val), len)); > ), > > TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx", Thanks Paolo. :) Regards, Wanpeng Li

Re: BUG: unable to handle kernel NULL pointer dereference in irq_bypass_register_consumer

2017-12-17 Thread Wanpeng Li
> compiler: gcc (GCC) 7.1.1 20170620 > .config is attached > Raw console output is attached. > > syzkaller reproducer is attached. See https://goo.gl/kgGztJ > for information about syzkaller reproducers > > I will have a look. Regards, Wanpeng Li > BUG:

Re: BUG: unable to handle kernel NULL pointer dereference in irq_bypass_register_consumer

2017-12-17 Thread Wanpeng Li
nsole output is attached. > > syzkaller reproducer is attached. See https://goo.gl/kgGztJ > for information about syzkaller reproducers > > I will have a look. Regards, Wanpeng Li > BUG: unable to handle kernel NULL pointer dereference at 0010 > IP: irq_bypass_regi

Re: [PATCH v4] KVM: Fix stack-out-of-bounds read in write_mmio

2017-12-16 Thread Wanpeng Li
2017-12-15 19:06 GMT+08:00 Marc Zyngier <marc.zyng...@arm.com>: > On 15/12/17 01:40, Wanpeng Li wrote: >> From: Wanpeng Li <wanpeng...@hotmail.com> >> >> Reported by syzkaller: >> >> BUG: KASAN: stack-out-of-bounds in write_mmio+0x11e/0x270 [kvm]

Re: [PATCH v4] KVM: Fix stack-out-of-bounds read in write_mmio

2017-12-16 Thread Wanpeng Li
2017-12-15 19:06 GMT+08:00 Marc Zyngier : > On 15/12/17 01:40, Wanpeng Li wrote: >> From: Wanpeng Li >> >> Reported by syzkaller: >> >> BUG: KASAN: stack-out-of-bounds in write_mmio+0x11e/0x270 [kvm] >> Read of size 8 at addr 8803259df7f8 by tas

Re: BUG: unable to handle kernel paging request in __switch_to

2017-12-15 Thread Wanpeng Li
gt; +kvm maintainers, you can see full thread here: >> https://groups.google.com/forum/#!topic/syzkaller-bugs/_oveOKGm3jw I didn't see any issue after running the test. Regards, Wanpeng Li

Re: BUG: unable to handle kernel paging request in __switch_to

2017-12-15 Thread Wanpeng Li
e full thread here: >> https://groups.google.com/forum/#!topic/syzkaller-bugs/_oveOKGm3jw I didn't see any issue after running the test. Regards, Wanpeng Li

Re: BUG: unable to handle kernel paging request in __switch_to

2017-12-15 Thread Wanpeng Li
ted=1 >> kvm-intel.unrestricted_guest=1 kvm-intel.ept=1 >> kvm-intel.flexpriority=1 kvm-intel.vpid=1 >> kvm-intel.emulate_invalid_guest_state=1 kvm-intel.eptad=1 >> kvm-intel.enable_shadow_vmcs=1 kvm-intel.pml=1 >> kvm-intel.enable_apicv=1 console=ttyS0 root=/dev/sda >> earlyprintk=serial slub_debug=UZ vsyscall=native rodata=n oops=panic >> panic_on_warn=1 panic=86400 >> [0.00] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating >> point registers' >> [0.00] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers' >> [0.00] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers' >> [0.00] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256 >> [0.00] x86/fpu: Enabled xstate features 0x7, context size is >> 832 bytes, using 'standard' format. >> [0.00] e820: BIOS-provided physical RAM map: >> ... > > > Well, the crash was minimized down to: > > // autogenerated by syzkaller (http://github.com/google/syzkaller) > #define _GNU_SOURCE > #include > #include > #include > #include > #include > #include > #include > #include > > int main() > { > int fd = open("/dev/kvm", 0x80102ul); > int vm = ioctl(fd, KVM_CREATE_VM, 0); > int cpu = ioctl(vm, KVM_CREATE_VCPU, 4); > ioctl(cpu, KVM_RUN, 0); > return 0; > } > > And, yes, this in fact triggers instant reboot of kernel (running in qemu). > Am I missing something here? > > +kvm maintainers, you can see full thread here: > https://groups.google.com/forum/#!topic/syzkaller-bugs/_oveOKGm3jw I will have a try. Regards, Wanpeng Li

Re: BUG: unable to handle kernel paging request in __switch_to

2017-12-15 Thread Wanpeng Li
nable_shadow_vmcs=1 kvm-intel.pml=1 >> kvm-intel.enable_apicv=1 console=ttyS0 root=/dev/sda >> earlyprintk=serial slub_debug=UZ vsyscall=native rodata=n oops=panic >> panic_on_warn=1 panic=86400 >> [0.00] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating >> point registers' >> [0.00] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers' >> [0.00] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers' >> [0.00] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256 >> [0.00] x86/fpu: Enabled xstate features 0x7, context size is >> 832 bytes, using 'standard' format. >> [0.00] e820: BIOS-provided physical RAM map: >> ... > > > Well, the crash was minimized down to: > > // autogenerated by syzkaller (http://github.com/google/syzkaller) > #define _GNU_SOURCE > #include > #include > #include > #include > #include > #include > #include > #include > > int main() > { > int fd = open("/dev/kvm", 0x80102ul); > int vm = ioctl(fd, KVM_CREATE_VM, 0); > int cpu = ioctl(vm, KVM_CREATE_VCPU, 4); > ioctl(cpu, KVM_RUN, 0); > return 0; > } > > And, yes, this in fact triggers instant reboot of kernel (running in qemu). > Am I missing something here? > > +kvm maintainers, you can see full thread here: > https://groups.google.com/forum/#!topic/syzkaller-bugs/_oveOKGm3jw I will have a try. Regards, Wanpeng Li

Re: [PATCH v3] KVM: X86: Fix stack-out-of-bounds read in write_mmio

2017-12-14 Thread Wanpeng Li
(though I've not confirmed). Yeah, fix it in v4, https://lkml.org/lkml/2017/12/14/954 however, I don't have an ARM environment to compile it though the change is very simple. Regards, Wanpeng Li

Re: [PATCH v3] KVM: X86: Fix stack-out-of-bounds read in write_mmio

2017-12-14 Thread Wanpeng Li
Yeah, fix it in v4, https://lkml.org/lkml/2017/12/14/954 however, I don't have an ARM environment to compile it though the change is very simple. Regards, Wanpeng Li

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