Re: [RFC PATCH] kvm,x86: Exit to user space in case of page fault error

2020-06-26 Thread Vitaly Kuznetsov
Vivek Goyal writes: > Page fault error handling behavior in kvm seems little inconsistent when > page fault reports error. If we are doing fault synchronously > then we capture error (-EFAULT) returned by __gfn_to_pfn_memslot() and > exit to user space and qemu reports error, "error: kvm run

Re: [PATCH 0/4] KVM: SVM: Code move follow-up

2020-06-25 Thread Vitaly Kuznetsov
ed.c | 8 +-- > arch/x86/kvm/svm/sev.c| 2 +- > arch/x86/kvm/svm/svm.c| 138 +++--- > arch/x86/kvm/svm/svm.h| 20 +++--- > 5 files changed, 85 insertions(+), 85 deletions(-) Series: Reviewed-by: Vitaly Kuznetsov -- Vitaly

[PATCH] KVM: x86/mmu: Avoid mixing gpa_t with gfn_t in walk_addr_generic()

2020-06-22 Thread Vitaly Kuznetsov
ant's cage, do not trust your eyes', but let's fix it for good. No functional change intended. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/mmu/paging_tmpl.h | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/pag

Re: selftests: kvm: Test results on x86_64

2020-06-22 Thread Vitaly Kuznetsov
Naresh Kamboju writes: > FYI, > Linaro test farm selftests kvm test cases results. > * kvm_mmio_warning_test — SKIP > * kvm_svm_vmcall_test — SKIP > * kvm_clear_dirty_log_test — PASS > * kvm_cr4_cpuid_sync_test — PASS > * kvm_debug_regs — PASS > * kvm_demand_paging_test — PASS > *

Re: [PATCH RFC] Revert "KVM: VMX: Micro-optimize vmexit time when not exposing PMU"

2020-06-19 Thread Vitaly Kuznetsov
"Xu, Like" writes: > On 2020/6/19 17:40, Vitaly Kuznetsov wrote: >> Guest crashes are observed on a Cascade Lake system when 'perf top' is >> launched on the host, e.g. > Interesting, is it specific to Cascade Lake? > Actually no, just reproduced this on a Haswe

[PATCH RFC] Revert "KVM: VMX: Micro-optimize vmexit time when not exposing PMU"

2020-06-19 Thread Vitaly Kuznetsov
74b81f4ef9. Reported-by: Maxime Coquelin Signed-off-by: Vitaly Kuznetsov --- - Perf/KVM interractions are a mystery to me, thus RFC. --- arch/x86/kvm/vmx/vmx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 36

Re: [PATCH v2] KVM: SVM: emulate MSR_IA32_PERF_CAPABILITIES

2020-06-18 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 18/06/20 13:13, Vitaly Kuznetsov wrote: >> state_test/smm_test selftests are failing on AMD with: >> "Unexpected result from KVM_GET_MSRS, r: 51 (failed MSR was 0x345)" >> >> MSR_IA32_PERF_CAPABILITIES is an emulated MSR on Int

[PATCH v2] KVM: SVM: emulate MSR_IA32_PERF_CAPABILITIES

2020-06-18 Thread Vitaly Kuznetsov
. This way the code is better prepared to the eventual appearance of the feature in AMD hardware. Fixes: 27461da31089 ("KVM: x86/pmu: Support full width counting") Suggested-by: Jim Mattson Suggested-by: Paolo Bonzini Signed-off-by: Vitaly Kuznetsov --- arch/x8

Re: [PATCH] KVM: SVM: drop MSR_IA32_PERF_CAPABILITIES from emulated MSRs

2020-06-18 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 17/06/20 13:38, Vitaly Kuznetsov wrote: >> >> For KVM_GET_MSR_INDEX_LIST, the promise is "guest msrs that are >> supported" and I'm not exactly sure what this means. Personally, I see >> no point in returning MSRs which can't be re

Re: [PATCH 2/3] kvm: Add capability to be able to report async pf error to guest

2020-06-17 Thread Vitaly Kuznetsov
Vivek Goyal writes: > As of now asynchronous page fault mecahanism assumes host will always be > successful in resolving page fault. So there are only two states, that > is page is not present and page is ready. > > If a page is backed by a file and that file has been truncated (as > can be the

Re: [PATCH 1/3] kvm,x86: Force sync fault if previous attempts failed

2020-06-17 Thread Vitaly Kuznetsov
Vivek Goyal writes: > Page fault error handling behavior in kvm seems little inconsistent when > page fault reports error. If we are doing fault synchronously > then we capture error (-EFAULT) returned by __gfn_to_pfn_memslot() and > exit to user space and qemu reports error, "error: kvm run

Re: [PATCH v2 2/3] KVM:SVM: Add extended intercept support

2020-06-17 Thread Vitaly Kuznetsov
Babu Moger writes: > The new intercept bits have been added in vmcb control > area to support the interception of INVPCID instruction. > > The following bit is added to the VMCB layout control area > to control intercept of INVPCID: > > Byte Offset Bit(s) Function > 14h

Re: [PATCH v2 1/3] KVM: X86: Move handling of INVPCID types to x86

2020-06-17 Thread Vitaly Kuznetsov
Babu Moger writes: > INVPCID instruction handling is mostly same across both VMX and > SVM. So, move the code to common x86.c. > > Signed-off-by: Babu Moger > --- > arch/x86/kvm/vmx/vmx.c | 68 + > arch/x86/kvm/x86.c | 79 >

Re: [PATCH] KVM: SVM: drop MSR_IA32_PERF_CAPABILITIES from emulated MSRs

2020-06-17 Thread Vitaly Kuznetsov
Jim Mattson writes: > On Tue, Jun 16, 2020 at 9:45 AM Vitaly Kuznetsov wrote: >> >> Jim Mattson writes: >> >> > On Tue, Jun 16, 2020 at 9:14 AM Vitaly Kuznetsov >> > wrote: >> >> >> >> state_test/smm_test selftests are failing

Re: [PATCH] KVM: VMX: Remove vcpu_vmx's defunct copy of host_pkru

2020-06-17 Thread Vitaly Kuznetsov
an just dropping it and trying to compile the whole thing? Leaving #define-s, configs,... aside ...) Reviewed-by: Vitaly Kuznetsov -- Vitaly

Re: [PATCH] KVM: SVM: drop MSR_IA32_PERF_CAPABILITIES from emulated MSRs

2020-06-16 Thread Vitaly Kuznetsov
Jim Mattson writes: > On Tue, Jun 16, 2020 at 9:14 AM Vitaly Kuznetsov wrote: >> >> state_test/smm_test selftests are failing on AMD with: >> "Unexpected result from KVM_GET_MSRS, r: 51 (failed MSR was 0x345)" >> >> MSR_IA32_PERF_CAPABILITIES is an emu

[PATCH] KVM: SVM: drop MSR_IA32_PERF_CAPABILITIES from emulated MSRs

2020-06-16 Thread Vitaly Kuznetsov
ST. Fixes: 27461da31089 ("KVM: x86/pmu: Support full width counting") Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/svm/svm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 8ccfa4197d9c..2c423d64fb8f 100644 --- a/arch/x86/kvm/svm/svm.

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Vitaly Kuznetsov
d your patch with Hyper-V, it works, so: Tested-by: Vitaly Kuznetsov > Plus this whole series to kill of vmalloc_exec entirely: > > http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/vmalloc_exec-fixes > FWIW, the vmalloc_exec() doing W+X allocation is misleading indeed, thus

RE: hv_hypercall_pg page permissios

2020-06-16 Thread Vitaly Kuznetsov
Dexuan Cui writes: >> From: linux-hyperv-ow...@vger.kernel.org >> On Behalf Of Dexuan Cui >> Sent: Monday, June 15, 2020 10:42 AM >> > > >> > > Hi hch, >> > > The patch is merged into the mainine recently, but unluckily we noticed >> > > a warning with CONFIG_DEBUG_WX=y >> > > >> > > Should we

[PATCH] KVM: async_pf: change kvm_setup_async_pf()/kvm_arch_setup_async_pf() return type to bool

2020-06-15 Thread Vitaly Kuznetsov
-by: Sean Christopherson Signed-off-by: Vitaly Kuznetsov --- arch/s390/kvm/kvm-s390.c | 20 +--- arch/x86/kvm/mmu/mmu.c | 4 ++-- include/linux/kvm_host.h | 4 ++-- virt/kvm/async_pf.c | 16 ++-- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/arch

RE: hv_hypercall_pg page permissios

2020-06-15 Thread Vitaly Kuznetsov
KY Srinivasan >> ; Stephen Hemminger ; >> Andy Lutomirski ; Peter Zijlstra >> Subject: Re: hv_hypercall_pg page permissios >> >> >> > On Apr 7, 2020, at 12:38 AM, Christoph Hellwig wrote: >> > >> > On Tue, Apr 07, 2020 at 0

Re: [PATCH 1/2] KVM: async_pf: Cleanup kvm_setup_async_pf()

2020-06-11 Thread Vitaly Kuznetsov
Sean Christopherson writes: > > I'd also be in favor of changing the return type to a boolean. I think > you alluded to it earlier, the current semantics are quite confusing as they > invert the normal "return 0 on success". Yes, will do a follow-up. KVM/x86 code has an intertwined mix of: -

Re: [PATCH 2/2] KVM: async_pf: Inject 'page ready' event only if 'page not present' was previously injected

2020-06-11 Thread Vitaly Kuznetsov
Vivek Goyal writes: > On Wed, Jun 10, 2020 at 07:55:32PM +0200, Vitaly Kuznetsov wrote: >> 'Page not present' event may or may not get injected depending on >> guest's state. If the event wasn't injected, there is no need to >> inject the corresponding 'page ready' event

[PATCH 1/2] KVM: async_pf: Cleanup kvm_setup_async_pf()

2020-06-10 Thread Vitaly Kuznetsov
cleanup. gfn_to_pfn_async() mentioned in a comment does not currently exist and, moreover, we can check kvm_is_error_hva() at the very beginning, before we try to allocate work so 'retry_sync' label can go away completely. Signed-off-by: Vitaly Kuznetsov --- virt/kvm/async_pf.c | 19

[PATCH 2/2] KVM: async_pf: Inject 'page ready' event only if 'page not present' was previously injected

2020-06-10 Thread Vitaly Kuznetsov
-by: Vitaly Kuznetsov --- arch/s390/include/asm/kvm_host.h | 2 +- arch/s390/kvm/kvm-s390.c | 4 +++- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/x86.c | 7 +-- include/linux/kvm_host.h | 1 + virt/kvm/async_pf.c | 2 +- 6 files changed, 12

[PATCH] KVM: selftests: fix sync_with_host() in smm_test

2020-06-10 Thread Vitaly Kuznetsov
/output operand. While on it, make sync_with_host() static inline. Reported-by: Marcelo Bandeira Condotta Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/x86_64/smm_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64

[PATCH 1/2] KVM: selftests: do not substitute SVM/VMX check with KVM_CAP_NESTED_STATE check

2020-06-10 Thread Vitaly Kuznetsov
state_test/smm_test use KVM_CAP_NESTED_STATE check as an indicator for nested VMX/SVM presence and this is incorrect. Check for the required features dirrectly. Signed-off-by: Vitaly Kuznetsov --- .../testing/selftests/kvm/include/x86_64/svm_util.h | 1 + tools/testing/selftests/kvm/include

[PATCH 2/2] KVM: selftests: Don't probe KVM_CAP_HYPERV_ENLIGHTENED_VMCS when nested VMX is unsupported

2020-06-10 Thread Vitaly Kuznetsov
KVM_CAP_HYPERV_ENLIGHTENED_VMCS will be reported as supported even when nested VMX is not, fix evmcs_test/hyperv_cpuid tests to check for both. Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/x86_64/evmcs_test.c | 5 +++-- tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 3

[PATCH 0/2] KVM: selftests: avoid test failures with 'nested=0'

2020-06-10 Thread Vitaly Kuznetsov
n this situation. Vitaly Kuznetsov (2): KVM: selftests: do not substitute SVM/VMX check with KVM_CAP_NESTED_STATE check KVM: selftests: Don't probe KVM_CAP_HYPERV_ENLIGHTENED_VMCS when nested VMX is unsupported .../testing/selftests/kvm/include/x86_64/svm_util.h | 1 + tools/testing/selft

Re: [PATCH v2 05/10] KVM: x86: interrupt based APF 'page ready' event delivery

2020-06-10 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 09/06/20 21:10, Vivek Goyal wrote: >> Hi Vitaly, >> >> Have a question about page ready events. >> >> Now we deliver PAGE_NOT_PRESENT page faults only if guest is not in >> kernel mode. So say kernel tried to access a page and we halted cpu. >> When page is

Re: [PATCH] kvm: i8254: remove redundant assignment to pointer s

2020-06-10 Thread Vitaly Kuznetsov
(val & 0x20)) > pit_latch_count(pit, channel); Reviewed-by: Vitaly Kuznetsov -- Vitaly

Re: [PATCH] KVM: SVM: fix calls to is_intercept

2020-06-08 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > is_intercept takes an INTERCEPT_* constant, not SVM_EXIT_*; because > of this, the compiler was removing the body of the conditionals, > as if is_intercept returned 0. > > This unveils a latent bug: when clearing the VINTR intercept, > int_ctl must also be changed in the

[PATCH 2/2] KVM: selftests: fix vmx_preemption_timer_test build with GCC10

2020-06-08 Thread Vitaly Kuznetsov
("KVM: selftests: VMX preemption timer migration test") Reported-by: Marcelo Bandeira Condotta Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/include/x86_64/vmx.h | 4 .../testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c | 4 2 files

[PATCH 1/2] KVM: selftests: Add x86_64/debug_regs to .gitignore

2020-06-08 Thread Vitaly Kuznetsov
Add x86_64/debug_regs to .gitignore. Reported-by: Marcelo Bandeira Condotta Fixes: 449aa906e67e ("KVM: selftests: Add KVM_SET_GUEST_DEBUG test") Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/too

Re: [PATCH] KVM: let kvm_destroy_vm_debugfs clean up vCPU debugfs directories

2020-06-08 Thread Vitaly Kuznetsov
ct dentry *debugfs_dentry; > char dir_name[ITOA_MAX_LEN * 2]; > > if (!debugfs_initialized()) > return; > > snprintf(dir_name, sizeof(dir_name), "vcpu%d", vcpu->vcpu_id); > - vcpu->debugfs_dentry = debugfs_create_dir(dir_name, > - vcpu->kvm->debugfs_dentry); > + debugfs_dentry = debugfs_create_dir(dir_name, > + vcpu->kvm->debugfs_dentry); > > - kvm_arch_create_vcpu_debugfs(vcpu); > + kvm_arch_create_vcpu_debugfs(vcpu, debugfs_dentry); > #endif > } FWIW, Reviewed-by: Vitaly Kuznetsov Thanks! -- Vitaly

Re: [PATCH v2 1/2] KVM: nVMX: Properly handle kvm_read/write_guest_virt*() result

2020-06-08 Thread Vitaly Kuznetsov
Sean Christopherson writes: > On Fri, Jun 05, 2020 at 01:59:05PM +0200, Vitaly Kuznetsov wrote: >> Introduce vmx_handle_memory_failure() as an interim solution. > > Heh, "interim". I'll take the over on that :-D. > We just need a crazy but real use-case

[PATCH] KVM: selftests: Fix "make ARCH=x86_64" build with

2020-06-05 Thread Vitaly Kuznetsov
H=x86", however, works. The problem is that arch specific headers for x86_64 live in 'tools/arch/x86/include', not in 'tools/arch/x86_64/include'. Fixes: 66d69e081b52 ("selftests: fix kvm relocatable native/cross builds and installs") Reported-by: Marcelo Bandeira Condotta Signed-off-by

Re: general protection fault in start_creating

2020-06-05 Thread Vitaly Kuznetsov
syzbot writes: > syzbot has found a reproducer for the following crash on: > > HEAD commit:cb8e59cc Merge git://git.kernel.org/pub/scm/linux/kernel/g.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=170f49de10 > kernel config:

Re: [PATCH v2 1/2] KVM: nVMX: Properly handle kvm_read/write_guest_virt*() result

2020-06-05 Thread Vitaly Kuznetsov
Vitaly Kuznetsov writes: > Syzbot reports the following issue: Noticed while sending: the prefix of the patch should be "KVM: VMX:" as it is not only nested related... -- Vitaly

[PATCH v2 2/2] Revert "KVM: x86: work around leak of uninitialized stack contents"

2020-06-05 Thread Vitaly Kuznetsov
541ab2aeb28251bf7135c7961f3a6080eebcc705. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/x86.c | 7 --- 1 file changed, 7 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 9e41b5135340..0097a97d331f 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5647,13

[PATCH v2 1/2] KVM: nVMX: Properly handle kvm_read/write_guest_virt*() result

2020-06-05 Thread Vitaly Kuznetsov
e. We don't seem to have a good enum describing this tristate, just add "int *ret" to nested_vmx_get_vmptr() interface to pass the information. Reported-by: syzbot+2a7156e11dc199bdb...@syzkaller.appspotmail.com Suggested-by: Sean Christopherson Signed-off-by: Vitaly Kuznetsov --- arch

Re: [PATCH] KVM: nVMX: Inject #GP when nested_vmx_get_vmptr() fails to read guest memory

2020-06-04 Thread Vitaly Kuznetsov
Sean Christopherson writes: > On Thu, Jun 04, 2020 at 05:33:25PM +0200, Vitaly Kuznetsov wrote: >> Sean Christopherson writes: >> >> > On Thu, Jun 04, 2020 at 04:40:52PM +0200, Paolo Bonzini wrote: >> >> On 04/06/20 16:31, Vitaly Kuznetsov wrote: >> &g

Re: [PATCH] KVM: nVMX: Inject #GP when nested_vmx_get_vmptr() fails to read guest memory

2020-06-04 Thread Vitaly Kuznetsov
Sean Christopherson writes: > On Thu, Jun 04, 2020 at 04:40:52PM +0200, Paolo Bonzini wrote: >> On 04/06/20 16:31, Vitaly Kuznetsov wrote: > > ... > >> > KVM could've handled the request correctly by going to userspace and >> > performing I/O but

Re: [PATCH] KVM: nVMX: Inject #GP when nested_vmx_get_vmptr() fails to read guest memory

2020-06-04 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 04/06/20 16:31, Vitaly Kuznetsov wrote: >> Syzbot reports the following issue: >> >> WARNING: CPU: 0 PID: 6819 at arch/x86/kvm/x86.c:618 >> kvm_inject_emulated_page_fault+0x210/0x290 arch/x86/kvm/x86.c:618 >> ... &

[PATCH] KVM: nVMX: Inject #GP when nested_vmx_get_vmptr() fails to read guest memory

2020-06-04 Thread Vitaly Kuznetsov
VMXON/VMPTRLD/VMCLEAR with anything but normal memory. Just inject #GP to find insane ones. Reported-by: syzbot+2a7156e11dc199bdb...@syzkaller.appspotmail.com Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/vmx/nested.c | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-)

Re: WARNING in kvm_inject_emulated_page_fault

2020-06-04 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 04/06/20 12:53, Vitaly Kuznetsov wrote: >> Exception we're trying to inject comes from >> >> nested_vmx_get_vmptr() >> kvm_read_guest_virt() >>kvm_read_guest_virt_helper() >> vcpu->arch.walk_mmu->gva_to_gp

Re: WARNING in kvm_inject_emulated_page_fault

2020-06-04 Thread Vitaly Kuznetsov
syzbot writes: > Hello, > > syzbot found the following crash on: > > HEAD commit:cb8e59cc Merge git://git.kernel.org/pub/scm/linux/kernel/g.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=14dedfe210 > kernel config:

Re: [RFC 02/16] x86/kvm: Introduce KVM memory protection feature

2020-06-03 Thread Vitaly Kuznetsov
"Huang, Kai" writes: > On Wed, 2020-05-27 at 10:39 +0200, Vitaly Kuznetsov wrote: >> Sean Christopherson writes: >> >> > On Mon, May 25, 2020 at 06:15:25PM +0300, Kirill A. Shutemov wrote: >> > > On Mon, May 25, 2020 at 04:58:51PM +0200, Vitaly

[PATCH] xen: Fix build with recent suspend_hvm.c changes

2020-06-01 Thread Vitaly Kuznetsov
) Reported-by: kbuild test robot Signed-off-by: Vitaly Kuznetsov --- - I'm failing to see why this was compiling when 28447ea41542 ("xen: Move xen_setup_callback_vector() definition to include/xen/hvm.h") was submitted, just keeping playing whack-a-mole game fixing the immediate issue,

Re: [PATCH] KVM: x86: Initialize tdp_level during vCPU creation

2020-05-29 Thread Vitaly Kuznetsov
Sean Christopherson writes: > I'll looking into writing a script to run all selftests with a single > command, unless someone already has one laying around? Is 'make run_tests' in tools/testing/selftests/kvm/ what you're looking for? -- Vitaly

[tip: x86/entry] xen: Move xen_setup_callback_vector() definition to include/xen/hvm.h

2020-05-28 Thread tip-bot2 for Vitaly Kuznetsov
The following commit has been merged into the x86/entry branch of tip: Commit-ID: 28447ea4154239025044381144f849ff749ee9ef Gitweb: https://git.kernel.org/tip/28447ea4154239025044381144f849ff749ee9ef Author:Vitaly Kuznetsov AuthorDate:Wed, 20 May 2020 18:16:00 +02:00

Re: [PATCH v2 06/10] KVM: x86: acknowledgment mechanism for async pf page ready notifications

2020-05-28 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 25/05/20 16:41, Vitaly Kuznetsov wrote: >> +case MSR_KVM_ASYNC_PF_ACK: >> +if (data & 0x1) { >> +vcpu->arch.apf.pageready_pending = false; >> +

Re: [PATCH v2 10/10] KVM: x86: deprecate KVM_ASYNC_PF_SEND_ALWAYS

2020-05-28 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > On 25/05/20 16:41, Vitaly Kuznetsov wrote: >> Concerns were expressed around APF events delivery when CPU is not >> in user mode (KVM_ASYNC_PF_SEND_ALWAYS), e.g. >> https://lore.kernel.org/kvm/ed71d0967113a35f670a9625a058b8e6e0b2f104.158354799

Re: [PATCH v2 02/10] KVM: x86: extend struct kvm_vcpu_pv_apf_data with token info

2020-05-28 Thread Vitaly Kuznetsov
Vivek Goyal writes: > On Mon, May 25, 2020 at 04:41:17PM +0200, Vitaly Kuznetsov wrote: >> > > [..] >> diff --git a/arch/x86/include/asm/kvm_host.h >> b/arch/x86/include/asm/kvm_host.h >> index 0a6b35353fc7..c195f63c1086 100644 >> --- a/arch/x86/include/a

Re: [PATCH] KVM: x86/mmu: Set mmio_value to '0' if reserved #PF can't be generated

2020-05-27 Thread Vitaly Kuznetsov
= 52) > - mask &= ~1ull; > + if (shadow_phys_bits < 52) > + mask = BIT_ULL(51) | PT_PRESENT_MASK; > + else > + mask = 0; > > kvm_mmu_set_mmio_spte_mask(mask, mask, ACC_WRITE_MASK | ACC_USER_MASK); > } Nice cleanup, Reviewed-by: Vitaly Kuznetsov -- Vitaly

Re: [PATCH] KVM: x86: Initialize tdp_level during vCPU creation

2020-05-27 Thread Vitaly Kuznetsov
--- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -9414,6 +9414,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) > fx_init(vcpu); > > vcpu->arch.maxphyaddr = cpuid_query_maxphyaddr(vcpu); > + vcpu->arch.tdp_level = kvm_x86_ops.get_tdp_level(vcpu); > &

Re: [RFC 02/16] x86/kvm: Introduce KVM memory protection feature

2020-05-27 Thread Vitaly Kuznetsov
Sean Christopherson writes: > On Mon, May 25, 2020 at 06:15:25PM +0300, Kirill A. Shutemov wrote: >> On Mon, May 25, 2020 at 04:58:51PM +0200, Vitaly Kuznetsov wrote: >> > > @@ -727,6 +734,15 @@ static void __init kvm_init_platform(void) >> > >

[PATCH] mm/gup: correct pin_user_pages.rst location

2020-05-26 Thread Vitaly Kuznetsov
pin_user_pages.rst lives in Documentation/core-api/, not Documentation/vm/, adjust all links accordingly. Fixes: 3faa52c03f44 ("mm/gup: track FOLL_PIN pages") Fixes: eddb1c228f79 ("mm/gup: introduce pin_user_pages*() and FOLL_PIN") Signed-off-by: Vitaly Kuznetsov --- inc

Re: [PATCH 1/2] KVM: SVM: fix svn_pin_memory()'s use of get_user_pages_fast()

2020-05-26 Thread Vitaly Kuznetsov
av Petkov > Cc: Thomas Gleixner > Cc: Paolo Bonzini > Cc: Sean Christopherson > Cc: Vitaly Kuznetsov > Cc: Wanpeng Li > Cc: Jim Mattson > Cc: Joerg Roedel > Cc: H. Peter Anvin > Cc: x...@kernel.org > Cc: k...@vger.kernel.org > Signed-off-by: John Hubbard &

Re: [RFC 13/16] x86/kvmclock: Share hvclock memory with the host

2020-05-25 Thread Vitaly Kuznetsov
"Kirill A. Shutemov" writes: > On Mon, May 25, 2020 at 05:22:10PM +0200, Vitaly Kuznetsov wrote: >> "Kirill A. Shutemov" writes: >> >> > hvclock is shared between the guest and the hypervisor. It has to be >> > accessible

Re: [RFC 10/16] KVM: x86: Enabled protected memory extension

2020-05-25 Thread Vitaly Kuznetsov
"Kirill A. Shutemov" writes: > Wire up hypercalls for the feature and define VM_KVM_PROTECTED. > > Signed-off-by: Kirill A. Shutemov > --- > arch/x86/Kconfig | 1 + > arch/x86/kvm/cpuid.c | 3 +++ > arch/x86/kvm/x86.c | 9 + > include/linux/mm.h | 4 > 4 files changed, 17

Re: [RFC 09/16] KVM: Protected memory extension

2020-05-25 Thread Vitaly Kuznetsov
"Kirill A. Shutemov" writes: > Add infrastructure that handles protected memory extension. > > Arch-specific code has to provide hypercalls and define non-zero > VM_KVM_PROTECTED. > > Signed-off-by: Kirill A. Shutemov > --- > include/linux/kvm_host.h | 4 ++ > mm/mprotect.c| 1

Re: [RFC 13/16] x86/kvmclock: Share hvclock memory with the host

2020-05-25 Thread Vitaly Kuznetsov
"Kirill A. Shutemov" writes: > hvclock is shared between the guest and the hypervisor. It has to be > accessible by host. > > Signed-off-by: Kirill A. Shutemov > --- > arch/x86/kernel/kvmclock.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/kvmclock.c

Re: [RFC 06/16] KVM: Use GUP instead of copy_from/to_user() to access guest memory

2020-05-25 Thread Vitaly Kuznetsov
"Kirill A. Shutemov" writes: > New helpers copy_from_guest()/copy_to_guest() to be used if KVM memory > protection feature is enabled. > > Signed-off-by: Kirill A. Shutemov > --- > include/linux/kvm_host.h | 4 +++ > virt/kvm/kvm_main.c | 78 ++-- > 2

Re: [RFC 02/16] x86/kvm: Introduce KVM memory protection feature

2020-05-25 Thread Vitaly Kuznetsov
"Kirill A. Shutemov" writes: > Provide basic helpers, KVM_FEATURE and a hypercall. > > Host side doesn't provide the feature yet, so it is a dead code for now. > > Signed-off-by: Kirill A. Shutemov > --- > arch/x86/include/asm/kvm_para.h | 5 + > arch/x86/include/uapi/asm/kvm_para.h

[PATCH v2 07/10] KVM: x86: announce KVM_FEATURE_ASYNC_PF_INT

2020-05-25 Thread Vitaly Kuznetsov
Introduce new capability to indicate that KVM supports interrupt based delivery of 'page ready' APF events. This includes support for both MSR_KVM_ASYNC_PF_INT and MSR_KVM_ASYNC_PF_ACK. Signed-off-by: Vitaly Kuznetsov --- Documentation/virt/kvm/cpuid.rst | 6 ++ Documentation/virt/kvm

[PATCH v2 10/10] KVM: x86: deprecate KVM_ASYNC_PF_SEND_ALWAYS

2020-05-25 Thread Vitaly Kuznetsov
-by: Andy Lutomirski Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/include/uapi/asm/kvm_para.h | 2 +- arch/x86/kernel/kvm.c| 3 --- arch/x86/kvm/x86.c | 13 + 4 files changed, 10 insertions(+), 9 deletions

[PATCH v2 02/10] KVM: x86: extend struct kvm_vcpu_pv_apf_data with token info

2020-05-25 Thread Vitaly Kuznetsov
apf_put_user_ready() temporary puts both flags and token information, this will be changed to put token only when we switch to interrupt based notifications. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/include/asm/kvm_para.h | 4 ++-- arch/x86/include/uapi

[PATCH v2 01/10] Revert "KVM: async_pf: Fix #DF due to inject "Page not Present" and "Page Ready" exceptions simultaneously"

2020-05-25 Thread Vitaly Kuznetsov
n theory, we may erroneously drop two valid events. Revert the commit. Reviewed-by: Gavin Shan Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/x86.c | 23 +-- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c17e6eb9a

[PATCH v2 00/10] KVM: x86: Interrupt-based mechanism for async_pf 'page present' notifications

2020-05-25 Thread Vitaly Kuznetsov
to kvm_arch_can_dequeue_async_page_present [Vivek Goyal] - 'KVM: x86: deprecate KVM_ASYNC_PF_SEND_ALWAYS' patch added. v1: https://lore.kernel.org/kvm/20200511164752.2158645-1-vkuzn...@redhat.com/ QEMU patches for testing: https://github.com/vittyvk/qemu.git (async_pf2_v2 branch) Vitaly Kuznetsov (10): Revert "KVM: asy

[PATCH v2 06/10] KVM: x86: acknowledgment mechanism for async pf page ready notifications

2020-05-25 Thread Vitaly Kuznetsov
ate. Introduce kvm_arch_async_page_present_queued() and KVM_REQ_APF_READY to do the job. Signed-off-by: Vitaly Kuznetsov --- Documentation/virt/kvm/msr.rst | 16 +++- arch/s390/include/asm/kvm_host.h | 2 ++ arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/include/uapi/

[PATCH v2 04/10] KVM: introduce kvm_read_guest_offset_cached()

2020-05-25 Thread Vitaly Kuznetsov
We already have kvm_write_guest_offset_cached(), introduce read analogue. Signed-off-by: Vitaly Kuznetsov --- include/linux/kvm_host.h | 3 +++ virt/kvm/kvm_main.c | 19 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/linux/kvm_host.h b/include

[PATCH v2 05/10] KVM: x86: interrupt based APF 'page ready' event delivery

2020-05-25 Thread Vitaly Kuznetsov
events in the documentation as they are causing confusion. Use 'page not present' and 'page ready' everywhere instead. Signed-off-by: Vitaly Kuznetsov --- Documentation/virt/kvm/msr.rst | 102 +++ arch/x86/include/asm/kvm_host.h | 4 +- arch/x86/include/uapi

[PATCH v2 03/10] KVM: rename kvm_arch_can_inject_async_page_present() to kvm_arch_can_dequeue_async_page_present()

2020-05-25 Thread Vitaly Kuznetsov
er much. Signed-off-by: Vitaly Kuznetsov --- arch/s390/include/asm/kvm_host.h | 2 +- arch/s390/kvm/kvm-s390.c | 2 +- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/x86.c | 2 +- virt/kvm/async_pf.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) dif

[PATCH v2 08/10] KVM: x86: Switch KVM guest to using interrupts for page ready APF delivery

2020-05-25 Thread Vitaly Kuznetsov
KVM now supports using interrupt for 'page ready' APF event delivery and legacy mechanism was deprecated. Switch KVM guests to the new one. Signed-off-by: Vitaly Kuznetsov --- arch/x86/entry/entry_32.S | 5 arch/x86/entry/entry_64.S | 5 arch/x86/include/asm

[PATCH v2 09/10] KVM: x86: drop KVM_PV_REASON_PAGE_READY case from kvm_handle_page_fault()

2020-05-25 Thread Vitaly Kuznetsov
else this means that the underlying hypervisor is misbehaving. Leave WARN_ON_ONCE() to catch that. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/mmu/mmu.c | 17 ++--- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index

Re: [PATCH 2/8] KVM: x86: extend struct kvm_vcpu_pv_apf_data with token info

2020-05-23 Thread Vitaly Kuznetsov
Vivek Goyal writes: > On Mon, May 11, 2020 at 06:47:46PM +0200, Vitaly Kuznetsov wrote: >> Currently, APF mechanism relies on the #PF abuse where the token is being >> passed through CR2. If we switch to using interrupts to deliver page-ready >> notifications we need a

Re: [PATCH 2/8] KVM: x86: extend struct kvm_vcpu_pv_apf_data with token info

2020-05-21 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > However, interrupts for 'page ready' do have a bunch of advantages (more > control on what can be preempted by the notification, a saner check for > new page faults which is effectively a bug fix) so it makes sense to get > them in more quickly (probably 5.9 at this point

Re: [PATCH v2 03/22] KVM: SVM: immediately inject INTR vmexit

2020-05-21 Thread Vitaly Kuznetsov
Paolo Bonzini writes: > We can immediately leave SVM guest mode in svm_check_nested_events > now that we have the nested_run_pending mechanism. This makes > things easier because we can run the rest of inject_pending_event > with GIF=0, and KVM will naturally end up requesting the next >

Re: [PATCH v3] kvm/x86 : Remove redundant function implement

2020-05-21 Thread Vitaly Kuznetsov
彭浩(Richard) writes: > pic_in_kernel(),ioapic_in_kernel() and irqchip_kernel() have the > same implementation. 'pic_in_kernel()' name is misleading, one may think this is about lapic and it's not. Also, ioapic_in_kernel() doesn't have that many users, can we maybe converge on using irqchip_*()

Re: [PATCH 2/2] kvm/x86: don't expose MSR_IA32_UMWAIT_CONTROL unconditionally

2020-05-20 Thread Vitaly Kuznetsov
Maxim Levitsky writes: > On Wed, 2020-05-20 at 18:33 +0200, Vitaly Kuznetsov wrote: >> Maxim Levitsky writes: >> >> > This msr is only available when the host supports WAITPKG feature. >> > >> > This breaks a nested guest, if the L1 hypervisor i

Re: [PATCH 1/3] selftests: kvm: add a SVM version of state-test

2020-05-20 Thread Vitaly Kuznetsov
struct kvm_vm *vm; > @@ -136,8 +178,11 @@ int main(int argc, char *argv[]) > vcpu_regs_get(vm, VCPU_ID, ); > > if (kvm_check_cap(KVM_CAP_NESTED_STATE)) { > - vcpu_alloc_vmx(vm, _pages_gva); > - vcpu_args_set(vm, VCPU_ID, 1, vmx_pages_gva); > + if (kvm_get_supported_cpuid_entry(0x8001)->ecx & CPUID_SVM) > + vcpu_alloc_svm(vm, _gva); > + else > + vcpu_alloc_vmx(vm, _gva); > + vcpu_args_set(vm, VCPU_ID, 1, nested_gva); > } else { > pr_info("will skip nested state checks\n"); > vcpu_args_set(vm, VCPU_ID, 1, 0); With two nitpicks above, Reviewed-by: Vitaly Kuznetsov -- Vitaly

Re: [PATCH] KVM: x86: allow KVM_STATE_NESTED_MTF_PENDING in kvm_state flags

2020-05-20 Thread Vitaly Kuznetsov
D_EVMCS)) > + | KVM_STATE_NESTED_EVMCS | KVM_STATE_NESTED_MTF_PENDING)) > break; > > /* nested_run_pending implies guest_mode. */ Reviewed-by: Vitaly Kuznetsov -- Vitaly

Re: [PATCH 2/2] kvm/x86: don't expose MSR_IA32_UMWAIT_CONTROL unconditionally

2020-05-20 Thread Vitaly Kuznetsov
Maxim Levitsky writes: > This msr is only available when the host supports WAITPKG feature. > > This breaks a nested guest, if the L1 hypervisor is set to ignore > unknown msrs, because the only other safety check that the > kernel does is that it attempts to read the msr and > rejects it if it

Re: [PATCH 1/2] kvm: cosmetic: remove wrong braces in kvm_init_msr_list switch

2020-05-20 Thread Vitaly Kuznetsov
> min(INTEL_PMC_MAX_GENERIC, x86_pmu.num_counters_gp)) > continue; > - } > default: > break; > } Reviewed-by: Vitaly Kuznetsov -- Vitaly

[PATCH] xen: move xen_setup_callback_vector() definition to include/xen/hvm.h

2020-05-20 Thread Vitaly Kuznetsov
IG_X86 and the later is only compiled in when CONFIG_XEN_PVHVM. Resolve the issue by moving xen_setup_callback_vector() declaration to arch neutral 'include/xen/hvm.h' as the implementation lives in arch neutral drivers/xen/events/events_base.c. Reported-by: kbuild test robot Signed-off-by: Vitaly Kuz

Re: [tip:x86/entry 4/80] drivers/xen/events/events_base.c:1664:6: warning: no previous prototype for 'xen_setup_callback_vector'

2020-05-20 Thread Vitaly Kuznetsov
kbuild test robot writes: > tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/entry > head: 095b7a3e7745e6fb7cf0a1c09967c4f43e76f8f4 > commit: fad1940a6a856f59b073e8650e02052ce531154c [4/80] x86/xen: Split HVM > vector callback setup and interrupt gate allocation >

Re: [PATCH] x86/Hyper-V: Support for free page reporting

2020-05-20 Thread Vitaly Kuznetsov
Sunil Muthuswamy writes: > Linux has support for free page reporting now (36e66c554b5c) for > virtualized environment. On Hyper-V when virtually backed VMs are > configured, Hyper-V will advertise cold memory discard capability, > when supported. This patch adds the support to hook into the free

Re: [PATCH] KVM: x86: only do L1TF workaround on affected processors

2020-05-19 Thread Vitaly Kuznetsov
t_cpu_has_bug(X86_BUG_L1TF)); > + rsvd_bits(low_phys_bits, boot_cpu_data.x86_cache_bits - > 1); > + } > > shadow_nonpresent_or_rsvd_lower_gfn_mask = > GENMASK_ULL(low_phys_bits - 1, PAGE_SHIFT); This indeed seems to fix previously-completely-broken 'npt=0' case, checked with AMD EPYC 7401P. Tested-by: Vitaly Kuznetsov -- Vitaly

Re: [PATCH 0/2] Expose KVM API to Linux Kernel

2020-05-18 Thread Vitaly Kuznetsov
Anastassios Nanos writes: > Moreover, it doesn't involve *any* mode switch at all while printing > out the result of the addition of these two registers -- which I > guess for a simple use-case like this it isn't much. > But if we were to scale this to a large number of exits (and their >

Re: [PATCH RFC 0/5] KVM: x86: KVM_MEM_ALLONES memory

2020-05-15 Thread Vitaly Kuznetsov
Sean Christopherson writes: > On Thu, May 14, 2020 at 07:22:50PM -0400, Peter Xu wrote: >> On Thu, May 14, 2020 at 03:56:24PM -0700, Sean Christopherson wrote: >> > On Thu, May 14, 2020 at 06:05:16PM -0400, Peter Xu wrote: >> > > E.g., shm_open() with a handle and fill one 0xff page, then remap

Re: [PATCH RFC 4/5] KVM: x86: aggressively map PTEs in KVM_MEM_ALLONES slots

2020-05-15 Thread Vitaly Kuznetsov
Sean Christopherson writes: > On Thu, May 14, 2020 at 08:05:39PM +0200, Vitaly Kuznetsov wrote: >> All PTEs in KVM_MEM_ALLONES slots point to the same read-only page >> in KVM so instead of mapping each page upon first access we can map >> everything aggressively. >>

Re: [PATCH RFC 2/5] KVM: x86: introduce KVM_MEM_ALLONES memory

2020-05-15 Thread Vitaly Kuznetsov
Sean Christopherson writes: > On Thu, May 14, 2020 at 08:05:37PM +0200, Vitaly Kuznetsov wrote: >> PCIe config space can (depending on the configuration) be quite big but >> usually is sparsely populated. Guest may scan it by accessing individual >> device's page which, w

Re: [PATCH 0/8] KVM: x86: Interrupt-based mechanism for async_pf 'page present' notifications

2020-05-14 Thread Vitaly Kuznetsov
Vivek Goyal writes: > On Mon, May 11, 2020 at 06:47:44PM +0200, Vitaly Kuznetsov wrote: >> Concerns were expressed around (ab)using #PF for KVM's async_pf mechanism, >> it seems that re-using #PF exception for a PV mechanism wasn't a great >> idea after all. The Grand Plan

[PATCH RFC 2/5] KVM: x86: introduce KVM_MEM_ALLONES memory

2020-05-14 Thread Vitaly Kuznetsov
. This will free userspace of obligation to allocate real memory. Later, this will also allow us to speed up access to these holes as we can aggressively map the whole slot upon first fault. Suggested-by: Michael S. Tsirkin Signed-off-by: Vitaly Kuznetsov --- Documentation/virt/kvm/api.rst | 22

[PATCH RFC 1/5] KVM: rename labels in kvm_init()

2020-05-14 Thread Vitaly Kuznetsov
Label names in kvm_init() are horrible, rename them to make it obvious what we are going to do on the failure path. Signed-off-by: Vitaly Kuznetsov --- virt/kvm/kvm_main.c | 33 - 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/virt/kvm/kvm_main.c

[PATCH RFC 4/5] KVM: x86: aggressively map PTEs in KVM_MEM_ALLONES slots

2020-05-14 Thread Vitaly Kuznetsov
All PTEs in KVM_MEM_ALLONES slots point to the same read-only page in KVM so instead of mapping each page upon first access we can map everything aggressively. Suggested-by: Michael S. Tsirkin Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/mmu/mmu.c | 20 ++-- arch

[PATCH RFC 3/5] KVM: x86: move kvm_vcpu_gfn_to_memslot() out of try_async_pf()

2020-05-14 Thread Vitaly Kuznetsov
No functional change intended. We will need to analyze slot information to map PTEs for KVM_MEM_ALLONES slots aggressively. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/mmu/mmu.c | 14 -- arch/x86/kvm/mmu/paging_tmpl.h | 7 +-- 2 files changed, 13 insertions(+), 8

[PATCH RFC 5/5] KVM: selftests: add KVM_MEM_ALLONES test

2020-05-14 Thread Vitaly Kuznetsov
Test the newly introduced KVM_MEM_ALLONES memslots: - Reads from all pages return '0xff' - Writes to all pages cause KVM_EXIT_MMIO Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/Makefile | 1 + .../testing/selftests/kvm/include/kvm_util.h | 1 + tools/testing

[PATCH RFC 0/5] KVM: x86: KVM_MEM_ALLONES memory

2020-05-14 Thread Vitaly Kuznetsov
) on Intel/AMD with and wiuthout EPT/NPT. I haven't tested memslot modifications yet. Patches are against kvm/next. Vitaly Kuznetsov (5): KVM: rename labels in kvm_init() KVM: x86: introduce KVM_MEM_ALLONES memory KVM: x86: move kvm_vcpu_gfn_to_memslot() out of try_async_pf() KVM: x86

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