Re: [PATCH v8 1/7] xen/pvh: Split CONFIG_XEN_PVH into CONFIG_PVH and CONFIG_XEN_PVH

2018-12-07 Thread Paolo Bonzini
On 07/12/18 07:02, Juergen Gross wrote: > On 06/12/2018 23:11, Paolo Bonzini wrote: >> On 06/12/18 07:04, Maran Wilson wrote: >>> +config PVH >>> + bool "Support for running PVH guests" >>> + ---help--- >>> + This option

Re: [PATCH v8 7/7] KVM: x86: Allow Qemu/KVM to use PVH entry point

2018-12-06 Thread Paolo Bonzini
On 06/12/18 07:06, Maran Wilson wrote: > +config KVM_GUEST_PVH > + bool "Support for running as a KVM PVH guest" > + depends on KVM_GUEST > + select PVH > + ---help--- > + This option enables starting KVM guests via the PVH entry point as > + specified in the x86/HVM

Re: [RFC PATCH V2 00/11] Intel EPT-Based Sub-page Protection Support

2018-12-04 Thread Paolo Bonzini
On 04/12/18 07:35, Yi Zhang wrote: > On 2018-12-03 at 05:56:13 +0200, Mihai Donțu wrote: >>> Hi, >>> >>> I think the right thing to do here would be to first get VM >>> introspection in KVM, as SPP is mostly an introspection feature and it >>> should be controller by the introspector rather than

Re: [RFC PATCH V2 00/11] Intel EPT-Based Sub-page Protection Support

2018-11-30 Thread Paolo Bonzini
On 30/11/18 08:52, Zhang Yi wrote: > Here is a patch-series which adding EPT-Based Sub-page Write Protection > Support. > > Introduction: > > EPT-Based Sub-page Write Protection referred to as SPP, it is a capability > which > allow Virtual Machine Monitors(VMM) to specify write-permission for

Re: [PATCH] KVM: VMX: re-add ple_gap module parameter

2018-11-28 Thread Paolo Bonzini
On 28/11/18 17:11, Sasha Levin wrote: > On Wed, Nov 28, 2018 at 03:57:53PM +, Moger, Babu wrote: >> My bad.. Sorry about this. I think this should also go to >> sta...@vger.kernel.org > > Please actually add the stable tag in the commit message if you intend > for this patch to go in stable.

[GIT PULL] KVM fixes for 4.20-rc4

2018-11-28 Thread Paolo Bonzini
TED Paolo Bonzini (1): Merge tag 'kvm-ppc-fixes-4.20-1' of https://git.kernel.org/.../paulus/powerpc into HEAD Wanpeng Li (2): KVM: LAPIC: Fix pv ipis use-before-initialization KVM: X86: Fix scan ioapic use-before-initialization Wei Wang (1): svm: Add mutex_lock to prot

[PATCH 2/3] kvm: rename last argument to kvm_get_dirty_log_protect

2018-11-28 Thread Paolo Bonzini
what they have to do with it. Reviewed-by: Junaid Shahid Signed-off-by: Paolo Bonzini --- arch/mips/kvm/mips.c | 6 +++--- arch/x86/kvm/x86.c | 6 +++--- include/linux/kvm_host.h | 2 +- virt/kvm/arm/arm.c | 6 +++--- virt/kvm/kvm_main.c | 6 +++--- 5 files changed, 13 inserti

[PATCH 3/3] kvm: introduce manual dirty log reprotect

2018-11-28 Thread Paolo Bonzini
off-by: Paolo Bonzini --- Documentation/virtual/kvm/api.txt | 67 +++ arch/mips/kvm/mips.c | 23 arch/x86/kvm/x86.c | 27 + include/linux/kvm_host.h | 5 + include/uapi/li

[PATCH 1/3] kvm: make KVM_CAP_ENABLE_CAP_VM architecture agnostic

2018-11-28 Thread Paolo Bonzini
The first such capability to be handled in virt/kvm/ will be manual dirty page reprotection. Reviewed-by: Cornelia Huck Signed-off-by: Paolo Bonzini --- Documentation/virtual/kvm/api.txt | 13 + arch/powerpc/kvm/powerpc.c| 14 ++ arch/s390/kvm/kvm-s390.c

[PATCH v2 0/3] kvm: split retrieval and clearing of dirty log

2018-11-28 Thread Paolo Bonzini
Junaid] remark on userspace setting bits beyond the end of the memslot [Junaid] Paolo Bonzini (3): kvm: make KVM_CAP_ENABLE_CAP_VM architecture agnostic kvm: rename last argument to kvm_get_dirty_log_protect kvm: introduce manual dirty log reprotect Documentation/virtual/kvm/a

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

2018-11-28 Thread Paolo Bonzini
On 27/11/18 20:05, Roman Kagan wrote: >>> Capabilities are a well-established and unambiguous negotiation >>> mechanism, why invent another one? Besides, not all features map >>> conveniently onto cpuid bits, e.g. currently we have two versions of >>> SynIC support, which differ in the way the

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

2018-11-28 Thread Paolo Bonzini
On 27/11/18 19:48, Roman Kagan wrote: > On Tue, Nov 27, 2018 at 02:10:49PM +0100, Vitaly Kuznetsov wrote: >> Roman Kagan writes: >>> On Mon, Nov 26, 2018 at 04:47:29PM +0100, Vitaly Kuznetsov wrote: >>> I personally tend to prefer masks over bitfields, so I'd rather do the >>> consolidation in

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

2018-11-27 Thread Paolo Bonzini
On 27/11/18 09:37, Roman Kagan wrote: > On Mon, Nov 26, 2018 at 05:44:24PM +0100, Paolo Bonzini wrote: >> On 26/11/18 16:47, Vitaly Kuznetsov wrote: >>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >>> index 5cd5647120f2..b21b5ceb8d26 100644 >>> --- a/a

Re: [PATCH 3/3] kvm: introduce manual dirty log reprotect

2018-11-27 Thread Paolo Bonzini
On 27/11/18 06:04, Junaid Shahid wrote: > There is a subtle point here which might be worth mentioning in a comment. > [...] You're absolutely right, it's subtle and should be mentioned. >> @@ -2945,6 +3012,9 @@ static long >> kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) >>

Re: [PATCH] kvm: selftests: fix spelling mistake "begining" -> "beginning"

2018-11-26 Thread Paolo Bonzini
On 26/11/18 17:08, Colin King wrote: > From: Colin Ian King > > The text in a TEST_ASSERT message contains a spelling mistake, fix it. > > Signed-off-by: Colin Ian King > --- > tools/testing/selftests/kvm/lib/elf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git

[PATCH 2/3] kvm: rename last argument to kvm_get_dirty_log_protect

2018-11-26 Thread Paolo Bonzini
what they have to do with it. Signed-off-by: Paolo Bonzini --- arch/mips/kvm/mips.c | 6 +++--- arch/x86/kvm/x86.c | 6 +++--- include/linux/kvm_host.h | 2 +- virt/kvm/arm/arm.c | 6 +++--- virt/kvm/kvm_main.c | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) di

[PATCH 1/3] kvm: make KVM_CAP_ENABLE_CAP_VM architecture agnostic

2018-11-26 Thread Paolo Bonzini
The first such capability to be handled in virt/kvm/ will be manual dirty page reprotection. Signed-off-by: Paolo Bonzini --- Documentation/virtual/kvm/api.txt | 13 + arch/powerpc/kvm/powerpc.c| 14 ++ arch/s390/kvm/kvm-s390.c | 11 +-- arch/x86

[PATCH 3/3] kvm: introduce manual dirty log reprotect

2018-11-26 Thread Paolo Bonzini
new KVM_CLEAR_DIRTY_LOG ioctl can operate on a 64-page granularity rather than requiring to sync a full memslot. This way the mmu_lock is taken for small amounts of time, and only a small amount of time will pass between write protection of pages and the sending of their content. Signed-off-by: Pa

[PATCH 0/3] kvm: split retrieval and clearing of dirty log

2018-11-26 Thread Paolo Bonzini
ely implemented in generic code, but only users of kvm_get_dirty_log_protect get the support (that is x86_64 and ARM). Paolo Bonzini (3): kvm: make KVM_CAP_ENABLE_CAP_VM architecture agnostic kvm: rename last argument to kvm_get_dirty_log_protect kvm: introduce manual dirty log reprot

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

2018-11-26 Thread Paolo Bonzini
On 26/11/18 16:47, Vitaly Kuznetsov wrote: > stimers_pending optimization only helps us to avoid multiple > kvm_make_request() calls. This doesn't happen very often and these > calls are very cheap in the first place, remove open-coded version of > stimer_mark_pending() from

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

2018-11-26 Thread Paolo Bonzini
On 26/11/18 16:47, Vitaly Kuznetsov wrote: > Changes since v1: > - avoid open-coding stimer_mark_pending() in kvm_hv_notify_acked_sint() and > kvm_hv_synic_send_eoi [Paolo Bonzini] > > Turns out Hyper-V on KVM (as of 2016) will only use synthetic timers > if direct

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

2018-11-26 Thread Paolo Bonzini
sion. > > Signed-off-by: Vitaly Kuznetsov > --- > - Changes since v1: avoid open-coding stimer_mark_pending() in > kvm_hv_synic_send_eoi() [Paolo Bonzini] > --- > arch/x86/kvm/hyperv.c| 67 +++- > arch/x86/kvm/trace.h | 10 +++--- > ar

Re: [PATCH v3 0/2] x86/kvm: Enable MCE injection in the guest

2018-11-26 Thread Paolo Bonzini
On 14/11/18 19:15, Borislav Petkov wrote: > From: Borislav Petkov > > Hi all, > > here's a rediff ontop of -rc2. No changes, only added Yazen's Tested-by. > > Please queue, > thx. > > Changelog: > == > > v2: > > here's v2, dropping patch 3 and incorporating hopefully all of Radim's

Re: [PATCH] KVM: x86: Trace changes to active TSC offset regardless if vCPU in guest-mode

2018-11-26 Thread Paolo Bonzini
On 25/11/18 22:38, Liran Alon wrote: > > >> On 25 Nov 2018, at 19:53, Paolo Bonzini wrote: >> >> For some reason, kvm_x86_ops->write_l1_tsc_offset() skipped trace >> of change to active TSC offset in case vCPU is in guest-mode. >> This patch changes writ

Re: [PATCH] KVM: x86: Trace changes to active TSC offset regardless if vCPU in guest-mode

2018-11-26 Thread Paolo Bonzini
On 25/11/18 22:38, Liran Alon wrote: > > >> On 25 Nov 2018, at 19:53, Paolo Bonzini wrote: >> >> For some reason, kvm_x86_ops->write_l1_tsc_offset() skipped trace >> of change to active TSC offset in case vCPU is in guest-mode. >> This patch changes writ

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

2018-11-26 Thread Paolo Bonzini
On 13/11/18 16:22, Vitaly Kuznetsov wrote: > Turns out Hyper-V on KVM (as of 2016) will only use synthetic timers > if direct mode is available. With direct mode we notify the guest by > asserting APIC irq instead of sending a SynIC message. > > The implementation uses existing vec_bitmap for

[PATCH] KVM: x86: Trace changes to active TSC offset regardless if vCPU in guest-mode

2018-11-25 Thread Paolo Bonzini
ich is in my opinion nicer. Based on a patch by Liran Alon. Signed-off-by: Paolo Bonzini --- Untested still, but throwing it out because it seems pretty obvious... arch/x86/kvm/svm.c | 9 + arch/x86/kvm/vmx.c | 34 +- 2 files changed,

Re: [PATCH] x86/kvm/vmx: fix old-style function declaration

2018-11-25 Thread Paolo Bonzini
On 08/11/18 04:22, Yi Wang wrote: > The inline keyword which is not at the beginning of the function > declaration may trigger the following build warnings, so let's fix it: > > arch/x86/kvm/vmx.c:1309:1: warning: ‘inline’ is not at beginning of > declaration [-Wold-style-declaration] >

Re: [PATCH] KVM: x86: fix empty-body warnings

2018-11-25 Thread Paolo Bonzini
On 08/11/18 09:48, Yi Wang wrote: > We get the following warnings about empty statements when building > with 'W=1': > > arch/x86/kvm/lapic.c:632:53: warning: suggest braces around empty body in an > ‘if’ statement [-Wempty-body] > arch/x86/kvm/lapic.c:1907:42: warning: suggest braces around

Re: [PATCH] svm: Add mutex_lock to protect apic_access_page_done on AMD systems

2018-11-25 Thread Paolo Bonzini
On 12/11/18 14:37, j...@8bytes.org wrote: > On Mon, Nov 12, 2018 at 12:23:14PM +, Suthikulpanit, Suravee wrote: >> From: Wei Wang >> >> There is a race condition when accessing kvm->arch.apic_access_page_done. >> Due to it, x86_set_memory_region will fail when creating the second vcpu >> for

Re: [PATCH] KVM: LAPIC: Fix pv ipis use-before-initialization

2018-11-25 Thread Paolo Bonzini
een initialized, the testcase > triggers pv_send_ipi interface by vmcall which results in kvm->arch.apic_map > is dereferenced. This patch fixes it by checking whether or not apic map is > NULL and bailing out immediately if that is the case. > > Fixes: 4180bf1b65 (KVM: X86:

Re: [PATCH] KVM: X86: Fix scan ioapic use-before-initialization

2018-11-25 Thread Paolo Bonzini
x2e\xaf\x22" > > "\xfa\xab\xb7\xe4\x42\x67\xd0\xaf\x06\x1c\x6a\x35\x67\x10\x55\xcb", > 106); > syscall(__NR_ioctl, r[2], 0x4008ae89, 0x2080); > syscall(__NR_ioctl, r[2], 0xae80, 0); > return 0; > } > > Thi

Re: KVM selftests are failing

2018-11-16 Thread Paolo Bonzini
On 16/11/18 13:00, Ahmed Soliman wrote: > 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

Re: [PATCH v7 0/7] KVM: x86: Allow Qemu/KVM to use PVH entry point

2018-11-16 Thread Paolo Bonzini
On 17/04/18 01:09, Maran Wilson wrote: > For certain applications it is desirable to rapidly boot a KVM virtual > machine. In cases where legacy hardware and software support within the > guest is not needed, Qemu should be able to boot directly into the > uncompressed Linux kernel binary without

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

2018-11-14 Thread Paolo Bonzini
On 12/11/2018 15:39, Vitaly Kuznetsov wrote: >> Is it worth having a set of VMCS shadowing bitmaps per-vCPU, in order >> to make better use of this feature? > Per CPU or not, to improve the feature we'll probably need some sort of > an 'adaptive' algorithm picking which fields to shadow. I

Re: [PATCH 17/23] x86/fpu: Eager switch PKRU state

2018-11-08 Thread Paolo Bonzini
On 07/11/2018 20:48, Sebastian Andrzej Siewior wrote: > index 375226055a413..5b33985d9f475 100644 > --- a/arch/x86/kernel/fpu/xstate.c > +++ b/arch/x86/kernel/fpu/xstate.c > @@ -811,7 +811,7 @@ void fpu__resume_cpu(void) > * > * Note: does not work for compacted buffers. > */ The comment is

Re: KMSAN: kernel-infoleak in kvm_vcpu_write_guest_page

2018-11-07 Thread Paolo Bonzini
On 07/11/2018 13:58, Liran Alon wrote: > > >> On 7 Nov 2018, at 14:47, Paolo Bonzini wrote: >> >> On 07/11/2018 13:10, Alexander Potapenko wrote: >>> This appears to be a real bug in KVM. >>> Please see a simplified reproducer attached. >> >&

Re: KMSAN: kernel-infoleak in kvm_vcpu_write_guest_page

2018-11-07 Thread Paolo Bonzini
On 07/11/2018 13:10, Alexander Potapenko wrote: > This appears to be a real bug in KVM. > Please see a simplified reproducer attached. Thanks, I agree it's a reael bug. The basic issue is that the kvm_state->size member is too small (1040) in the KVM_SET_NESTED_STATE ioctl, aka 0x4080aebf. One

Re: [RFC PATCH] kvm: Use huge pages for DAX-backed files

2018-11-06 Thread Paolo Bonzini
On 06/11/2018 22:05, Barret Rhoden wrote: > On 2018-10-29 at 17:07 Barret Rhoden wrote: >> Another issue is that kvm_mmu_zap_collapsible_spte() also uses >> PageTransCompoundMap() to detect huge pages, but we don't have a way to >> get the HVA easily. Can we just aggressively zap DAX pages

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-31 Thread Paolo Bonzini
On 31/10/2018 15:21, Alexander Shishkin wrote: > Paolo Bonzini writes: > >> On 31/10/2018 12:38, Alexander Shishkin wrote: >>>> There is no standard way to tell the guest that the host overrode its >>>> choice to use PT. However, the host will get a PGD/PGE p

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-31 Thread Paolo Bonzini
On 31/10/2018 12:38, Alexander Shishkin wrote: >> There is no standard way to tell the guest that the host overrode its >> choice to use PT. However, the host will get a PGD/PGE packet around >> vmentry and vmexit, so there _will_ be an indication that the guest >> owned the MSRs for that period

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-31 Thread Paolo Bonzini
On 30/10/2018 12:26, Alexander Shishkin wrote: >>> affects directly whether the tracing CPUID leaf can be added to the >>> guest. Therefore it's not perf that can decide whether to turn it on; >>> KVM must know it when /dev/kvm is opened, which is why it is a module >>> parameter. > > There is a

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-31 Thread Paolo Bonzini
On 30/10/2018 11:00, Thomas Gleixner wrote: > On Mon, 29 Oct 2018, Paolo Bonzini wrote: >> On 24/10/2018 12:13, Alexander Shishkin wrote: >>> Luwei Kang writes: >>>> + /* >>>> + * Set guest state of MSR_IA32_RTIT_CTL MSR (PT will be disabled >&g

Re: [PATCH v13 06/12] KVM: x86: Add Intel PT virtualization work mode

2018-10-30 Thread Paolo Bonzini
On 30/10/2018 10:30, Thomas Gleixner wrote: >> This part is in the " Intel® Architecture Instruction Set Extensions and >> Future Features Programming Reference" >> https://software.intel.com/sites/default/files/managed/c5/15/architecture-instruction-set-extensions-programming-reference.pdf >> >

Re: [PATCH v13 08/12] KVM: x86: Add Intel PT context switch for each vcpu

2018-10-29 Thread Paolo Bonzini
On 24/10/2018 12:13, Alexander Shishkin wrote: > Luwei Kang writes: > >> +static void pt_guest_enter(struct vcpu_vmx *vmx) >> +{ >> +if (pt_mode == PT_MODE_SYSTEM) >> +return; >> + >> +/* Save host state before VM entry */ >> +rdmsrl(MSR_IA32_RTIT_CTL,

Re: [GIT PULL] KVM updates for Linux 4.20-rc1

2018-10-24 Thread Paolo Bonzini
On 24/10/2018 13:14, Radim Krčmář wrote: > Linus, > > there are conflicts with the ARM tree as we didn't have a topic branch and > some > with 4.19 fixes. Future merge of the selftests tree will also have a > conflict, > https://lkml.org/lkml/2018/10/18/273. All should be resolved as in next

Re: KASAN: use-after-free Read in kvm_put_kvm

2018-10-21 Thread Paolo Bonzini
On 20/10/2018 18:57, syzbot wrote: > Hello, > > syzbot found the following crash on: > > HEAD commit:    8c60c36d0b8c Add linux-next specific files for 20181019 > git tree:   linux-next > console output: https://syzkaller.appspot.com/x/log.txt?x=12d808b540 > kernel config: 

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

2018-10-19 Thread Paolo Bonzini
er-V without Enlightened VMCS) access it pretty > often. > > Suggested-by: Paolo Bonzini > Signed-off-by: Vitaly Kuznetsov Queued, thanks. Paolo > --- > arch/x86/kvm/vmx.c | 10 +- > arch/x86/kvm/vmx_shadow_fields.h | 5 + > 2 files c

Re: [PATCH] selftests/kvm: add missing executables to .gitignore

2018-10-19 Thread Paolo Bonzini
On 19/10/2018 16:38, Anders Roxell wrote: > Fixes: 18178ff86217 ("KVM: selftests: add Enlightened VMCS test") > Signed-off-by: Anders Roxell > --- > tools/testing/selftests/kvm/.gitignore | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/testing/selftests/kvm/.gitignore >

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-19 Thread Paolo Bonzini
On 18/10/2018 22:46, Andy Lutomirski wrote: >> [0] drivers/usb/gadget/function/f_fs.c::ffs_user_copy_worker() >> >> Sebastian > I think we need an entirely new API: > > user_mm_ctx_t ctx = user_mm_ctx_get(); > > ... > > use_user_mm_ctx(ctx); > unuse_user_mm_ctx(ctx); > > ... > >

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

2018-10-18 Thread Paolo Bonzini
On 18/10/2018 13:14, Vitaly Kuznetsov wrote: > > Based on that my suggestion would be to shadow GUEST_SS_AR_BYTES, keep > GUEST_SS_AR_BYTES and unshadow the rest (GUEST_ES_BASE, > GUEST_CS_SELECTOR, GUEST_CS_LIMIT, GUEST_CS_BASE). I can do this as a > separate patch as I see this series is

Re: linux-next: manual merge of the kselftest tree with the kvm tree

2018-10-18 Thread Paolo Bonzini
ase of my patch, but you never know... ;D) > > Output of get_maintainer.pl on tools/testing/selftests/kvm/: > > Before: > > Shuah Khan (maintainer:KERNEL SELFTEST > FRAMEWORK,commit_signer:5/23=22%) > Paolo Bonzini > (commit_signer:20/23=87%,authored:10/23=43%) > P

Re: linux-next: manual merge of the kselftest tree with the kvm tree

2018-10-18 Thread Paolo Bonzini
On 18/10/2018 06:50, Stephen Rothwell wrote: > Hi Shuah, > > Today's linux-next merge of the kselftest tree got a conflict in: > > tools/testing/selftests/kvm/dirty_log_test.c > > between commit: > > fff8dcd7b4a2 ("kvm: selftests: port dirty_log_test to aarch64") > > from the kvm tree and

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

2018-10-17 Thread Paolo Bonzini
d, Oct 17, 2018 at 10:02 AM, Paolo Bonzini wrote: >> On 17/10/2018 16:47, Vitaly Kuznetsov wrote: >>>>> + if (!hv_evmcs || !(hv_evmcs->hv_clean_fields & >>>>> + HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2)) { >>>>> +

Re: [PATCH 3/3] kvm: don't redefine flags as something else

2018-10-17 Thread Paolo Bonzini
On 17/10/2018 19:05, Sebastian Andrzej Siewior wrote: > The function irqfd_wakeup() has flags defined as __poll_t and then it > has additional flags which is used for irqflags. > > Redefine the inner flags variable as iflags so it does not shadow the > outer flags. > > Cc

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

2018-10-17 Thread Paolo Bonzini
On 17/10/2018 16:47, Vitaly Kuznetsov wrote: >>> + if (!hv_evmcs || !(hv_evmcs->hv_clean_fields & >>> + HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2)) { >>> + vmcs_write16(GUEST_CS_SELECTOR, vmcs12->guest_cs_selector); >>> + vmcs_write32(GUEST_CS_LIMIT,

[PATCH] KVM: VMX: enable nested virtualization by default

2018-10-16 Thread Paolo Bonzini
not offer much in terms of ABI guarantees. Therefore we are still in time to break things and conform as much as possible to the interface used for VMX. Suggested-by: Jim Mattson Suggested-by: Liran Alon Signed-off-by: Paolo Bonzini --- arch/x86/kvm/vmx.c | 2 +- 1 file changed, 1 insertion

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

2018-10-16 Thread Paolo Bonzini
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_SELECTOR, vmcs12->guest_cs_selector); > + vmcs_write32(GUEST_CS_LIMIT,

Re: [PATCH] kvm/x86 : avoid shifting signed 32-bit value by 31 bits

2018-10-15 Thread Paolo Bonzini
On 15/10/2018 19:16, H. Peter Anvin wrote: > On 10/7/18 6:04 PM, peng.h...@zte.com.cn wrote: > \> >> #define AVIC_LOGICAL_ID_ENTRY_GUEST_PHYSICAL_ID_MASK(0xFF) >> -#define AVIC_LOGICAL_ID_ENTRY_VALID_MASK(1 << 31) >> +#define AVIC_LOGICAL_ID_ENTRY_VALID_MASK(1UL

Re: [PATCH V5 0/3] introduce coalesced pio support

2018-10-15 Thread Paolo Bonzini
On 14/10/2018 01:09, Peng Hao wrote: > Coalesced pio is based on coalesced mmio and can be used for some port > like rtc port, pci-host config port and so on. > > Specially in case of rtc as coalesced pio, some versions of windows guest > access rtc frequently because of rtc as system tick. guest

Re: [PATCH] KVM: x86: fix failure of injecting exceptionsinx86_emulate_instruction

2018-10-15 Thread Paolo Bonzini
On 09/10/2018 04:51, peng.h...@zte.com.cn wrote: > ping > patch ;https://patchwork.kernel.org/patch/10604977/ > test case :https://patchwork.kernel.org/patch/10631781/ I need to understand the double fault I'm seeing before applying this patch. Paolo

Re: [PATCH] kvm/x86 : avoid shifting signed 32-bit value by 31 bits

2018-10-15 Thread Paolo Bonzini
On 08/10/2018 04:25, Wei Yang wrote: > On Mon, Oct 08, 2018 at 09:04:34AM +0800, peng.h...@zte.com.cn wrote: >>> On Sat, Oct 06, 2018 at 11:31:04AM +0800, peng.h...@zte.com.cn wrote: > On Thu, Oct 04, 2018 at 01:47:18PM -0400, Peng Hao wrote: >> >> From: Peng Hao >> >> modify

Re: [PATCH] kvm/x86 : fix some typo

2018-10-15 Thread Paolo Bonzini
On 04/10/2018 17:45, Peng Hao wrote: > From: Peng Hao > > Signed-off-by: Peng Hao > --- > arch/x86/kvm/mmu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c > index d7e9bce..281e20e 100644 > --- a/arch/x86/kvm/mmu.c > +++

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

2018-10-15 Thread Paolo Bonzini
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-test.c too. Paolo > --- > arch/x86/kvm/vmx.c | 15 --- >

Re: [PATCH V4 6/15] KVM/MMU: Flush tlb directly in the kvm_set_pte_rmapp()

2018-10-15 Thread Paolo Bonzini
On 13/10/2018 16:53, lantianyu1...@gmail.com wrote: > @@ -1781,6 +1781,11 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, struct > kvm_rmap_head *rmap_head, > } > } > > + if (need_flush && kvm_available_flush_tlb_with_range()) { > +

Re: [PATCH V4 11/15] KVM/MMU: Replace tlb flush function with range list flush function

2018-10-15 Thread Paolo Bonzini
On 13/10/2018 16:54, lantianyu1...@gmail.com wrote: > while (mmu_unsync_walk(parent, )) { > bool protected = false; > + LIST_HEAD(flush_list); > > - for_each_sp(pages, sp, parents, i) > + for_each_sp(pages, sp, parents, i) { >

Re: [PATCH V4 14/15] KVM/VMX: Change hv flush logic when ept tables are mismatched.

2018-10-15 Thread Paolo Bonzini
On 13/10/2018 16:54, lantianyu1...@gmail.com wrote: > From: Lan Tianyu > > If ept table pointers are mismatched, flushing tlb for each vcpus via > hv flush interface still helps to reduce vmexits which are triggered > by IPI and INEPT emulation. > > Signed-off-by: Lan Tianyu > --- >

Re: [PATCH V4 12/15] x86/hyper-v: Add HvFlushGuestAddressList hypercall support

2018-10-15 Thread Paolo Bonzini
On 13/10/2018 16:54, lantianyu1...@gmail.com wrote: > > +static int fill_flush_list(union hv_gpa_page_range gpa_list[], > + int offset, u64 start_gfn, u64 pages) Pass the entire struct hv_guest_mapping_flush_list to this function, it's simpler and it hides the gpa_list argument from

Re: [PATCH V4 9/15] KVM: Add flush_link and parent_pte in the struct kvm_mmu_page

2018-10-15 Thread Paolo Bonzini
On 13/10/2018 16:54, lantianyu1...@gmail.com wrote: > From: Lan Tianyu > > PV EPT tlb flush function will accept a list of flush ranges and > use struct kvm_mmu_page as the list entry. > > Signed-off-by: Lan Tianyu > --- > arch/x86/include/asm/kvm_host.h | 1 + > 1 file changed, 1

Re: [PATCH V4 7/15] KVM/MMU: Flush tlb directly in the kvm_zap_gfn_range()

2018-10-15 Thread Paolo Bonzini
On 13/10/2018 16:53, lantianyu1...@gmail.com wrote: > + bool flush = false; > int i; > > spin_lock(>mmu_lock); > @@ -5654,18 +5655,27 @@ void kvm_zap_gfn_range(struct kvm *kvm, gfn_t > gfn_start, gfn_t gfn_end) > slots = __kvm_memslots(kvm, i); >

[GIT PULL] KVM fixes for 4.19-rc8

2018-10-13 Thread Paolo Bonzini
): ARM: KVM: Correctly order SGI register entries in the cp15 array Paolo Bonzini (2): KVM: x86: support CONFIG_KVM_AMD=y with CONFIG_CRYPTO_DEV_CCP_DD=m Merge tag 'kvmarm-fixes-for-4.19-2' of git://git.kernel.org/.../kvmarm/kvmarm into kvm-master Vitaly Kuznetsov (1): KVM

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

2018-10-13 Thread Paolo Bonzini
On 11/10/2018 15:00, Vitaly Kuznetsov wrote: >> Yes. that need to rename ept_pointer. >> > Honestly, I would prefer to keep more information cached, e.g. if > someone needs EPT configuration data later he can easily get it from > ept_pointer and by putting raw cr3 there we'll just keep less. > >

Re: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-13 Thread Paolo Bonzini
On 12/10/2018 18:30, Andi Kleen wrote: >> 4. Results >> - Without this optimization, the guest pmi handling time is >> ~450 ns, and the max sampling rate is reduced to 250. >> - With this optimization, the guest pmi handling time is ~9000 ns >> (i.e. 1 / 500 of the

Re: [PATCH] mm: Speed up mremap on large regions

2018-10-12 Thread Paolo Bonzini
On 12/10/2018 05:21, Jann Horn wrote: > I don't know how this interacts with shadow paging implementations. Shadow paging simply uses MMU notifiers and that does not assume that PTE invalidation is atomic. The invalidate_range_start and invalidate_range_end calls are not affected by Joel's

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

2018-10-11 Thread Paolo Bonzini
On 10/10/2018 09:57, syzbot wrote: > Hello, > > syzbot found the following crash on: > > HEAD commit:    570b7bdeaf18 Add linux-next specific files for 20181009 > git tree:   linux-next > console output: https://syzkaller.appspot.com/x/log.txt?x=15f2795940 > kernel config: 

Re: kernel BUG at arch/x86/kvm/x86.c:LINE! (2)

2018-10-11 Thread Paolo Bonzini
On 11/10/2018 04:57, Du Changbin wrote: > I think the issue is that using vmx instructions after vmx off. The > scenario is: > 1. kernel is rebooting and vmx is turned off by notification handler > kvm_reboot(), >    and 'kvm_rebooting' is set. > 2. But there is a pending KVM_CREATE_VCPU ioctl

Re: WARNING: refcount bug in kvm_vm_ioctl

2018-10-11 Thread Paolo Bonzini
On 10/10/2018 09:58, syzbot wrote: >  do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:316 >  invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:993 > RIP: 0010:refcount_inc_checked+0x5d/0x70 lib/refcount.c:153 >  kvm_get_kvm arch/x86/kvm/../../../virt/kvm/kvm_main.c:766 [inline] >  

Re: linux-next: manual merge of the kvm-ppc tree with the kvm-arm tree

2018-10-11 Thread Paolo Bonzini
On 11/10/2018 04:06, Stephen Rothwell wrote: > Hi all, > > On Wed, 10 Oct 2018 13:22:24 +1100 Stephen Rothwell > wrote: >> >> Today's linux-next merge of the kvm-ppc tree got a conflict in: >> >> include/uapi/linux/kvm.h >> >> between commit: >> >> 233a7cb23531 ("kvm: arm64: Allow tuning

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

2018-10-10 Thread Paolo Bonzini
ru_bitmask(),..) Try solving the > issue by splitting L1-normal and L1-nested MMUs and checking if MMU reset > is really needed. This spares us about 1000 cpu cycles on nested vmexit. > > Brief look at SVM makes me think it can be optimized the exact same way, > I'll do this in a

Re: [PATCH v2] KVM: LAPIC: Tune lapic_timer_advance_ns automatically

2018-10-09 Thread Paolo Bonzini
his patch reduces latency > (kvm-unit-tests/tscdeadline_latency, busy waits, preemption_timer enabled) > from ~2600 cyles to ~1200 cyles on our Skylake server. > > Cc: Paolo Bonzini > Cc: Radim Krčmář > Cc: Liran Alon > Signed-off-by: Wanpeng Li > --- > v1 -> v2: &

[PATCH] KVM: x86: support CONFIG_KVM_AMD=y with CONFIG_CRYPTO_DEV_CCP_DD=m

2018-10-09 Thread Paolo Bonzini
sev_hardware_setup() is. This patch adds two CONFIG_KVM_AMD_SEV checks that gate all the remaining SEV code; it fixes this particular configuration, and drops 5 KiB of code when CONFIG_KVM_AMD_SEV=n. Reported-by: Guenter Roeck Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm.c | 6 +- 1

Re: [PATCH] KVM: X86: Add missing KVM_AMD dependency

2018-10-09 Thread Paolo Bonzini
On 08/10/2018 19:32, Borislav Petkov wrote: > On Mon, Oct 08, 2018 at 02:52:46PM +, Singh, Brijesh wrote: >> Does it make sense to move all the SEV specific code in svm-sev.c ? >> I am looking to add SEV migration support very soon, and can see >> myself adding more SEV command handling which

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

2018-10-08 Thread Paolo Bonzini
On 08/10/2018 15:04, Vitaly Kuznetsov wrote: > kernel test robot writes: > >> [31mFAIL[0m vmx_EPT_AD_disabled (19 tests, 1 unexpected failures) > > It seems the test is buggy: MMIO access is tested by reading ACPI > version from 0xfee00030 without putting APIC to xAPIC mode first. I'll > double

Re: [PATCH] KVM: X86: Add missing KVM_AMD dependency

2018-10-08 Thread Paolo Bonzini
On 06/10/2018 22:43, Guenter Roeck wrote: >> Maybe this works as well?  I haven't tested it yet: >>> I am sure there are many possible solutions. I would personally >>> prefer one >>> that enforces KVM_AMD=m with CRYPTO_DEV_CCP_DD=m, but that is just me. >> >> Well, KVM_AMD=y is a

Re: [PATCH] KVM: X86: Add missing KVM_AMD dependency

2018-10-05 Thread Paolo Bonzini
On 06/10/2018 00:03, Guenter Roeck wrote: >> This should be handled by >> >> config KVM_AMD_SEV >> def_bool y >> bool "AMD Secure Encrypted Virtualization (SEV) support" >> depends on KVM_AMD && X86_64 >> depends on CRYPTO_DEV_SP_PSP && !(KVM_AMD=y &&

Re: [PATCH] KVM: X86: Add missing KVM_AMD dependency

2018-10-05 Thread Paolo Bonzini
On 05/10/2018 20:46, Guenter Roeck wrote: > Analysis shows that commit 59414c9892208 ("KVM: SVM: Add support for > KVM_SEV_LAUNCH_START command") added a dependency of KVM_AMD on > CRYPTO_DEV_CCP_DD if CRYPTO_DEV_SP_PSP is enabled: If CRYPTO_DEV_CCP_DD > is built as module, KVM_AMD must be built

[GIT PULL] KVM changes for 4.19-rc7

2018-10-05 Thread Paolo Bonzini
ion of VM_ENTRY_LOAD_BNDCFGS Paolo Bonzini (4): KVM: x86: never trap MSR_KERNEL_GS_BASE KVM: VMX: hide flexpriority from guest when disabled at the module level kvm: nVMX: fix entry with pending interrupt if APICv is enabled Merge tag 'kvm-ppc-fixes-4.19-3' of git://git.kernel.org/.../pau

[PATCH v2] kvm: nVMX: fix entry with pending interrupt if APICv is enabled

2018-10-03 Thread Paolo Bonzini
>0. Fixes: b5861e5cf2fcf83031ea3e26b0a69d887adf7d21 Cc: Nikita Leshchenko Cc: Sean Christopherson Cc: Liran Alon Cc: Radim Krčmář Signed-off-by: Paolo Bonzini --- arch/x86/kvm/vmx.c | 38 ++ 1 file changed, 26 insertions(+), 12 deletions(-) diff --

Re: [PATCH] kvm: nVMX: fix entry with pending interrupt if APICv is enabled

2018-10-03 Thread Paolo Bonzini
On 03/10/2018 16:53, Sean Christopherson wrote: > Isn't enable_apicv redundant with kvm_vcpu_apicv_active()? And since > getting RVI requires a VMREAD, I think it would make sense to only > fall into this code if !evaluate_pending_interrupts, e.g.: > > if (!evaluate_pending_interrupts &&

Re: [PATCH] kvm: nVMX: fix entry with pending interrupt if APICv is enabled

2018-10-03 Thread Paolo Bonzini
On 03/10/2018 16:36, Nikita Leshenko wrote: > On Wed, 2018-10-03 at 13:47 +0200, Paolo Bonzini wrote: >> Commit b5861e5cf2fcf83031ea3e26b0a69d887adf7d21 introduced a check on >> the interrupt-window and NMI-window CPU execution controls in order to >> inject an external in

Re: [PATCH] kvm: nVMX: fix entry with pending interrupt if APICv is enabled

2018-10-03 Thread Paolo Bonzini
On 03/10/2018 16:36, Nikita Leshenko wrote: > On Wed, 2018-10-03 at 13:47 +0200, Paolo Bonzini wrote: >> Commit b5861e5cf2fcf83031ea3e26b0a69d887adf7d21 introduced a check on >> the interrupt-window and NMI-window CPU execution controls in order to >> inject an external in

[PATCH] kvm: nVMX: fix entry with pending interrupt if APICv is enabled

2018-10-03 Thread Paolo Bonzini
>0. Fixes: b5861e5cf2fcf83031ea3e26b0a69d887adf7d21 Cc: Nikita Leshchenko Cc: Sean Christopherson Cc: Liran Alon Cc: Radim Krčmář Signed-off-by: Paolo Bonzini --- arch/x86/kvm/vmx.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/a

Re: [PATCH v6 7/7] KVM: x86: hyperv: implement PV IPI send hypercalls

2018-10-01 Thread Paolo Bonzini
On 01/10/2018 18:20, Vitaly Kuznetsov wrote: > Paolo Bonzini writes: > >> On 27/09/2018 13:07, Roman Kagan wrote: > ... >>> >>> I must say that now it looks even more tempting to follow the same >>> pattern as your kvm_hv_flush_tlb: define a function tha

Re: [PATCH v6 7/7] KVM: x86: hyperv: implement PV IPI send hypercalls

2018-10-01 Thread Paolo Bonzini
On 27/09/2018 13:07, Roman Kagan wrote: > On Wed, Sep 26, 2018 at 07:02:59PM +0200, Vitaly Kuznetsov wrote: >> Using hypercall for sending IPIs is faster because this allows to specify >> any number of vCPUs (even > 64 with sparse CPU set), the whole procedure >> will take only one VMEXIT. >> >>

Re: [PATCH v6 4/7] KVM: x86: hyperv: keep track of mismatched VP indexes

2018-10-01 Thread Paolo Bonzini
On 27/09/2018 11:17, Vitaly Kuznetsov wrote: > Roman Kagan writes: > >> On Wed, Sep 26, 2018 at 07:02:56PM +0200, Vitaly Kuznetsov wrote: >>> In most common cases VP index of a vcpu matches its vcpu index. Userspace >>> is, however, free to set any mapping it wishes and we need to account for

Re: [PATCH V3 2/13] KVM/MMU: Add tlb flush with range helper function

2018-10-01 Thread Paolo Bonzini
On 27/09/2018 05:48, Tianyu Lan wrote: > + > + if (range && kvm_x86_ops->tlb_remote_flush_with_range) { > + /* > + * Read tlbs_dirty before flushing tlbs in order > + * to track dirty tlbs during flushing. > + */ > + long

Re: [PATCH V3 4/13] KVM/MMU: Flush tlb directly in the kvm_handle_hva_range()

2018-10-01 Thread Paolo Bonzini
On 27/09/2018 05:49, Tianyu Lan wrote: > This patch is to flush tlb directly in the kvm_handle_hva_range() > when range flush is available. > > Signed-off-by: Lan Tianyu > --- > arch/x86/kvm/mmu.c | 7 +++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/x86/kvm/mmu.c

Re: [PATCH] kvm/x86 : set meaningful return value

2018-10-01 Thread Paolo Bonzini
On 28/09/2018 18:41, Peng Hao wrote: > From: Peng Hao > > kvm_irq_delivery_to_apic_fast()--> > kvm_apic_map_get_dest_lapic()--> > kvm_apic_disabled_lapic_found() > kvm_apic_map_get_dest_lapic return with bitmap==0 and dst[i]==NULL, > then (*r == -1) will be returned to qemu and "KVM:

Re: [PATCH] KVM/VMX: Remve unused function is_external_interrupt().

2018-10-01 Thread Paolo Bonzini
On 28/09/2018 14:45, Tianyu Lan wrote: > is_external_interrupt() is not used now and so remove it. > > Signed-off-by: Lan Tianyu > --- > arch/x86/kvm/vmx.c | 6 -- > 1 file changed, 6 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 70e1f916bfc9..619307b3e6bb

Re: [PATCH] KVM: LAPIC: Tune lapic_timer_advance_ns automatically

2018-10-01 Thread Paolo Bonzini
> (kvm-unit-tests/tscdeadline_latency, busy waits, preemption_timer enabled) > from ~2600 cyles to ~1200 cyles on our Skylake server. > > Cc: Paolo Bonzini > Cc: Radim Krčmář > Signed-off-by: Wanpeng Li > --- > arch/x86/kvm/lapic.c | 7 +++ > arch/x86/kvm/x86.c |

  1   2   3   4   5   6   7   8   9   10   >