Re: [patch 3/5] KVM: MMU: notifiers support for pinned sptes

2014-06-18 Thread Gleb Natapov
On Wed, Jun 18, 2014 at 08:12:06PM -0300, mtosa...@redhat.com wrote: > Request KVM_REQ_MMU_RELOAD when deleting sptes from MMU notifiers. > > Keep pinned sptes intact if page aging. > > Signed-off-by: Marcelo Tosatti > > --- > arch/x86/kvm/mmu.c | 71 > ++

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
On 06/19/2014 03:30 PM, bharat.bhus...@freescale.com wrote: > > >> -Original Message- >> From: Linuxppc-dev [mailto:linuxppc-dev- >> bounces+bharat.bhushan=freescale@lists.ozlabs.org] On Behalf Of Alexey >> Kardashevskiy >> Sent: Thursday, June 19, 2014 9:18 AM >> To: Alex Williamson

RE: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread bharat.bhus...@freescale.com
> -Original Message- > From: Linuxppc-dev [mailto:linuxppc-dev- > bounces+bharat.bhushan=freescale@lists.ozlabs.org] On Behalf Of Alexey > Kardashevskiy > Sent: Thursday, June 19, 2014 9:18 AM > To: Alex Williamson > Cc: kvm@vger.kernel.org; Nikunj A Dadhania; linux-ker...@vger.kernel

Re: Nested paging in nested SVM setup

2014-06-18 Thread Valentine Sinitsyn
Hi all, If we want to provide useful nested SVM support, this must be feasible. If there is a bug, it has to be fixed. I did a quick look on KVM sources this morning, and although I can be wrong, this really looks like a bug. The reason is nested_svm_vmrun() doesn't do anything to host or gue

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
On 06/19/2014 11:50 AM, Alexey Kardashevskiy wrote: > On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: >> On 06/19/2014 04:35 AM, Alex Williamson wrote: >>> On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: VFIO exposes BARs to user space as a byte stream so userspace can

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: > On 06/19/2014 04:35 AM, Alex Williamson wrote: >> On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: >>> VFIO exposes BARs to user space as a byte stream so userspace can >>> read it using pread()/pwrite(). Since this is a byte strea

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
On 06/19/2014 10:50 AM, Alexey Kardashevskiy wrote: > On 06/19/2014 04:35 AM, Alex Williamson wrote: >> On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: >>> VFIO exposes BARs to user space as a byte stream so userspace can >>> read it using pread()/pwrite(). Since this is a byte strea

Re: [patch 0/5] KVM: support for pinning sptes

2014-06-18 Thread Andi Kleen
On Wed, Jun 18, 2014 at 08:12:03PM -0300, mtosa...@redhat.com wrote: > Required by PEBS support as discussed at > > Subject: [patch 0/5] Implement PEBS virtualization for Silvermont > Message-Id: <1401412327-14810-1-git-send-email-a...@firstfloor.org> Thanks marcelo. I'll give it a stress test h

[PATCH v8 2/4] arm: dirty page logging inital mem region write protect (w/no huge PUD support)

2014-06-18 Thread Mario Smarduch
Patch adds support for initial write protection VM memlsot. This patch series assumes that huge PUDs will not be used in 2nd stage tables. For ARMv8 nothing happens here. Signed-off-by: Mario Smarduch --- arch/arm/include/asm/kvm_host.h |1 + arch/arm/include/asm/kvm_mmu.h|

[PATCH v8 1/4] arm: add ARMv7 HYP API to flush VM TLBs without address param

2014-06-18 Thread Mario Smarduch
Patch adds HYP interface for global VM TLB invalidation without address parameter. Moved VM TLB flushing back to architecture layer. This patch depends on the unmap_range() patch, it needs to be applied first. No changes to ARMv8. Signed-off-by: Mario Smarduch --- arch/arm/include/asm/kvm_asm.h

[PATCH v8 0/4] arm: dirty page logging support for ARMv7

2014-06-18 Thread Mario Smarduch
This patch adds support for dirty page logging so far tested only on ARMv7, and verified to compile on ARMv8. With dirty page logging, GICv2 vGIC and arch timer save/restore support, live migration is supported. Dirty page logging support - - initially write protects VM RAM memory regions - 2nd s

[PATCH v8 3/4] arm: dirty log write protect management support

2014-06-18 Thread Mario Smarduch
This patch adds support for keeping track of VM dirty pages. As dirty page log is retrieved, the pages that have been written are write protected again for next write and log read. For ARMv8 read of dirty log returns invalid operation. Signed-off-by: Mario Smarduch --- arch/arm/include/asm/kvm_h

[PATCH v8 4/4] arm: dirty page logging 2nd stage page fault handling support

2014-06-18 Thread Mario Smarduch
This patch adds support for handling 2nd stage page faults during migration, it disables faulting in huge pages, and dissolves huge pages to page tables. In case migration is canceled huge pages will be used again. For ARMv8 logging is hardcoded to false. Signed-off-by: Mario Smarduch --- arch/a

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alexey Kardashevskiy
On 06/19/2014 04:35 AM, Alex Williamson wrote: > On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: >> VFIO exposes BARs to user space as a byte stream so userspace can >> read it using pread()/pwrite(). Since this is a byte stream, VFIO should >> not do byte swapping and simply return

[patch 0/5] KVM: support for pinning sptes

2014-06-18 Thread mtosatti
Required by PEBS support as discussed at Subject: [patch 0/5] Implement PEBS virtualization for Silvermont Message-Id: <1401412327-14810-1-git-send-email-a...@firstfloor.org> Thread. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.k

[patch 1/5] KVM: x86: add pinned parameter to page_fault methods

2014-06-18 Thread mtosatti
To be used by next patch. Signed-off-by: Marcelo Tosatti --- arch/x86/include/asm/kvm_host.h |2 +- arch/x86/kvm/mmu.c | 11 ++- arch/x86/kvm/paging_tmpl.h |2 +- arch/x86/kvm/x86.c |2 +- 4 files changed, 9 insertions(+), 8 deletions(-) Ind

[patch 2/5] KVM: MMU: allow pinning spte translations (TDP-only)

2014-06-18 Thread mtosatti
Allow vcpus to pin spte translations by: 1) Creating a per-vcpu list of pinned ranges. 2) On mmu reload request: - Fault ranges. - Mark sptes with a pinned bit. - Mark shadow pages as pinned. 3) Then modify the following actions: - Page age => skip spte flush.

[patch 4/5] KVM: MMU: reload request from GET_DIRTY_LOG path

2014-06-18 Thread mtosatti
Reload remote vcpus MMU from GET_DIRTY_LOG codepath, before deleting a pinned spte. Signed-off-by: Marcelo Tosatti --- arch/x86/kvm/mmu.c |3 +++ 1 file changed, 3 insertions(+) Index: kvm.pinned-sptes/arch/x86/kvm/mmu.c === -

[patch 5/5] KVM: MMU: pinned sps are not candidates for deletion.

2014-06-18 Thread mtosatti
Skip pinned shadow pages when selecting pages to zap. Signed-off-by: Marcelo Tosatti --- arch/x86/kvm/mmu.c | 26 ++ 1 file changed, 18 insertions(+), 8 deletions(-) Index: kvm/arch/x86/kvm/mmu.c === ---

[patch 3/5] KVM: MMU: notifiers support for pinned sptes

2014-06-18 Thread mtosatti
Request KVM_REQ_MMU_RELOAD when deleting sptes from MMU notifiers. Keep pinned sptes intact if page aging. Signed-off-by: Marcelo Tosatti --- arch/x86/kvm/mmu.c | 71 ++--- 1 file changed, 62 insertions(+), 9 deletions(-) Index: kvm.pinned-spt

Re: [Qemu-devel] [qom-cpu PATCH 2/3] target-i386: Remove unsupported bits from all CPU models

2014-06-18 Thread Eric Blake
On 06/18/2014 01:55 PM, Eduardo Habkost wrote: > The following CPU features were never supported by neither TCG or KVM, > so they are useless on the CPU model definitions, today: > The overall idea of this series makes sense to me (yes, I'd love to get libvirt to the point that we can use enforce

Re: [PATCH v3 -next 0/9] CMA: generalize CMA reserved area management code

2014-06-18 Thread Andrew Morton
On Tue, 17 Jun 2014 10:25:07 +0900 Joonsoo Kim wrote: > > >v2: > > > - Although this patchset looks very different with v1, the end result, > > > that is, mm/cma.c is same with v1's one. So I carry Ack to patch 6-7. > > > > > >This patchset is based on linux-next 20140610. > > > > Thanks for

Re: [PATCH v3 -next 4/9] DMA, CMA: support arbitrary bitmap granularity

2014-06-18 Thread Andrew Morton
On Mon, 16 Jun 2014 14:40:46 +0900 Joonsoo Kim wrote: > PPC KVM's CMA area management requires arbitrary bitmap granularity, > since they want to reserve very large memory and manage this region > with bitmap that one bit for several pages to reduce management overheads. > So support arbitrary bi

[qom-cpu PATCH 0/3] target-i386: Make most CPU models work with "enforce" out of the box

2014-06-18 Thread Eduardo Habkost
Most of the bits that make "enforce" breaks were introduced in 2010 by commit 8560efed6a72a816c0115f41ddb9d79f7ce63f28. The intention behind that commit made sense, the only problem is that we can't guarantee guest ABI stability across hosts if we simply rely on trimming of CPU features based on ho

[qom-cpu PATCH 2/3] target-i386: Remove unsupported bits from all CPU models

2014-06-18 Thread Eduardo Habkost
The following CPU features were never supported by neither TCG or KVM, so they are useless on the CPU model definitions, today: * CPUID_DTS (DS) * CPUID_HT * CPUID_TM * CPUID_PBE * CPUID_EXT_DTES64 * CPUID_EXT_DSCPL * CPUID_EXT_EST * CPUID_EXT_TM2 * CPUID_EXT_XTPR * CPUID_EXT_PDCM * CPU

[qom-cpu PATCH 1/3] target-i386: Disable CPUID_ACPI by default on KVM mode

2014-06-18 Thread Eduardo Habkost
KVM never supported the CPUID_ACPI flag, so it doesn't make sense to have it enabled by default when KVM is enabled. The motivation here is exactly the same we had for the MONITOR flag. And like on the MONITOR flag case, we don't need machine-type compat code because it is currently impossible to

[qom-cpu PATCH 3/3] target-i386: Don't enable nested VMX by default

2014-06-18 Thread Eduardo Habkost
TCG doesn't support VMX, and nested VMX is not enabled by default on the KVM kernel module. So, there's no reason to have VMX enabled by default on the core2duo and coreduo CPU models, today. Even the newer Intel CPU model definitions don't have it enabled. In this case, we need machine-type comp

Re: [PATCH 05/11] qspinlock: Optimize for smaller NR_CPUS

2014-06-18 Thread Konrad Rzeszutek Wilk
On Sun, Jun 15, 2014 at 02:47:02PM +0200, Peter Zijlstra wrote: > From: Peter Zijlstra > > When we allow for a max NR_CPUS < 2^14 we can optimize the pending > wait-acquire and the xchg_tail() operations. > > By growing the pending bit to a byte, we reduce the tail to 16bit. > This means we can

Re: [PATCH 07/11] qspinlock: Use a simple write to grab the lock, if applicable

2014-06-18 Thread Konrad Rzeszutek Wilk
On Sun, Jun 15, 2014 at 02:47:04PM +0200, Peter Zijlstra wrote: > From: Waiman Long > > Currently, atomic_cmpxchg() is used to get the lock. However, this is > not really necessary if there is more than one task in the queue and > the queue head don't need to reset the queue code word. For that c

Re: [PATCH 08/11] qspinlock: Revert to test-and-set on hypervisors

2014-06-18 Thread Konrad Rzeszutek Wilk
On Sun, Jun 15, 2014 at 02:47:05PM +0200, Peter Zijlstra wrote: > When we detect a hypervisor (!paravirt, see later patches), revert to Please spell out the name of the patches. > a simple test-and-set lock to avoid the horrors of queue preemption. Heheh. > > Signed-off-by: Peter Zijlstra > --

Re: [PATCH 09/11] pvqspinlock, x86: Rename paravirt_ticketlocks_enabled

2014-06-18 Thread Konrad Rzeszutek Wilk
On Sun, Jun 15, 2014 at 02:47:06PM +0200, Peter Zijlstra wrote: > From: Waiman Long > > This patch renames the paravirt_ticketlocks_enabled static key to a > more generic paravirt_spinlocks_enabled name. > > Signed-off-by: Waiman Long > Signed-off-by: Peter Zijlstra Acked-by: Konrad Rzeszutek

Re: [PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-18 Thread Bandan Das
"Gabriel L. Somlo" writes: > On Wed, Jun 18, 2014 at 10:59:14AM -0700, Eric Northup wrote: >> On Wed, Jun 18, 2014 at 7:19 AM, Nadav Amit wrote: >> > mwait and monitor are currently handled as nop. Considering this behavior, >> > they >> > should still be handled correctly, i.e., check executio

Re: [PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-18 Thread Gabriel L. Somlo
On Wed, Jun 18, 2014 at 11:30:07AM -0700, Eric Northup wrote: > Quoting Gabriel's post http://www.spinics.net/lists/kvm/msg103792.html : > > [...] > > > E.g., OS X 10.5 *does* check CPUID, and panics if it doesn't find it. > > It needs the MONITOR cpuid flag to be on, *and* the actual > > instruc

Re: [PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-18 Thread Gabriel L. Somlo
On Wed, Jun 18, 2014 at 10:59:14AM -0700, Eric Northup wrote: > On Wed, Jun 18, 2014 at 7:19 AM, Nadav Amit wrote: > > mwait and monitor are currently handled as nop. Considering this behavior, > > they > > should still be handled correctly, i.e., check execution conditions and > > generate > >

Re: [PATCH] vfio: Fix endianness handling for emulated BARs

2014-06-18 Thread Alex Williamson
On Wed, 2014-06-18 at 21:36 +1000, Alexey Kardashevskiy wrote: > VFIO exposes BARs to user space as a byte stream so userspace can > read it using pread()/pwrite(). Since this is a byte stream, VFIO should > not do byte swapping and simply return values as it gets them from > PCI device. > > Inste

Re: [PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-18 Thread Eric Northup
Quoting Gabriel's post http://www.spinics.net/lists/kvm/msg103792.html : [...] > E.g., OS X 10.5 *does* check CPUID, and panics if it doesn't find it. > It needs the MONITOR cpuid flag to be on, *and* the actual > instructions to work. On Wed, Jun 18, 2014 at 11:23 AM, Nadav Amit wrote: > On

Re: [PATCH 04/11] qspinlock: Extract out the exchange of tail code word

2014-06-18 Thread Konrad Rzeszutek Wilk
> >>However, I *do* agree with you that it's simpler to just squash this patch > >>into 01/11. > >Uh, did I say that? Oh I said why don't make it right the first time! > > > >I meant in terms of seperating the slowpath (aka the bytelock on the pending > >bit) from the queue (MCS code). Or renaming

Re: [PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-18 Thread Nadav Amit
On 6/18/14, 8:59 PM, Eric Northup wrote: On Wed, Jun 18, 2014 at 7:19 AM, Nadav Amit wrote: mwait and monitor are currently handled as nop. Considering this behavior, they should still be handled correctly, i.e., check execution conditions and generate exceptions when required. mwait and monito

Re: [PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-18 Thread Eric Northup
On Wed, Jun 18, 2014 at 7:19 AM, Nadav Amit wrote: > mwait and monitor are currently handled as nop. Considering this behavior, > they > should still be handled correctly, i.e., check execution conditions and > generate > exceptions when required. mwait and monitor may also be executed in real-m

Re: [PATCH v2 9/9] KVM: vmx: vmx instructions handling does not consider cs.l

2014-06-18 Thread Nadav Amit
On Jun 18, 2014, at 7:06 PM, Paolo Bonzini wrote: > Il 18/06/2014 18:01, Nadav Amit ha scritto: >>> >> >> Perhaps I am missing something, but I don't see where my mistake is. >> The VMREAD source operand is always read as 64-bits and I made no >> changes there. Therefore, if bits 63:32 are not

Re: [PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-18 Thread Bandan Das
Paolo Bonzini writes: > Il 18/06/2014 18:43, Bandan Das ha scritto: >>> > mwait and monitor are currently handled as nop. Considering this >>> > behavior, they >>> > should still be handled correctly, i.e., check execution conditions and >>> > generate >>> > exceptions when required. mwait and

Re: [PATCH v4] KVM: PPC: e500mc: Enhance tlb invalidation condition on vcpu schedule

2014-06-18 Thread Scott Wood
On Wed, 2014-06-18 at 10:15 +0300, Mihai Caraman wrote: > On vcpu schedule, the condition checked for tlb pollution is too loose. > The tlb entries of a vcpu become polluted (vs stale) only when a different > vcpu within the same logical partition runs in-between. Optimize the tlb > invalidation co

Re: Nested paging in nested SVM setup

2014-06-18 Thread Valentine Sinitsyn
Hi Jan, If we want to provide useful nested SVM support, this must be feasible. If there is a bug, it has to be fixed. I was more concerned about if it is supported (and it means I do something wrong), or if it is not supported (at least, now). Maybe you can describe how you configured the i

Re: [PATCH v2 9/9] KVM: vmx: vmx instructions handling does not consider cs.l

2014-06-18 Thread Paolo Bonzini
Il 18/06/2014 18:01, Nadav Amit ha scritto: Perhaps I am missing something, but I don't see where my mistake is. The VMREAD source operand is always read as 64-bits and I made no changes there. Therefore, if bits 63:32 are not zero, the instruction should fail when attempting to access the fie

Re: [PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-18 Thread Paolo Bonzini
Il 18/06/2014 18:43, Bandan Das ha scritto: > mwait and monitor are currently handled as nop. Considering this behavior, they > should still be handled correctly, i.e., check execution conditions and generate > exceptions when required. mwait and monitor may also be executed in real-mode Is th

Re: [PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-18 Thread Bandan Das
Nadav Amit writes: > mwait and monitor are currently handled as nop. Considering this behavior, > they > should still be handled correctly, i.e., check execution conditions and > generate > exceptions when required. mwait and monitor may also be executed in real-mode Is this necessary ? They a

Re: [PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-18 Thread Paolo Bonzini
Il 18/06/2014 16:19, Nadav Amit ha scritto: mwait and monitor are currently handled as nop. Considering this behavior, they should still be handled correctly, i.e., check execution conditions and generate exceptions when required. mwait and monitor may also be executed in real-mode and are not ha

Re: [PATCH 2/3] KVM: x86: Emulator support for #UD on CPL>0

2014-06-18 Thread Paolo Bonzini
Il 18/06/2014 16:19, Nadav Amit ha scritto: Certain instructions (e.g., mwait and monitor) cause a #UD exception when they are executed in privilaged mode. It's actually "non-privileged mode" (Priv means the instruction is privileged, not the mode). So I've renamed the flag to PrivUD. Paolo

[PULL v2 043/106] Add kvm_eventfds_enabled function

2014-06-18 Thread Michael S. Tsirkin
From: Nikolay Nikolaev Add a function to check if the eventfd capability is present in KVM in the host kernel. Signed-off-by: Antonios Motakis Signed-off-by: Nikolay Nikolaev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Paolo Bonzini --- include/sysemu/kvm.h

Re: [PATCH 1/2] perf: ignore LBR and offcore_rsp.

2014-06-18 Thread Andi Kleen
Peter Zijlstra writes: > > This order indicates Andi is the author; but there's no corresponding > From. I wrote an early version of the patch, but Kan took it over and extended it. So both are authors. BTW Kan you may want to use git send-email to get standard format. > >> Signed-off-by: K

Re: [PATCH v2 9/9] KVM: vmx: vmx instructions handling does not consider cs.l

2014-06-18 Thread Nadav Amit
On 6/18/14, 6:41 PM, Paolo Bonzini wrote: Il 18/06/2014 16:19, Nadav Amit ha scritto: VMX instructions use 32-bit operands in 32-bit mode, and 64-bit operands in 64-bit mode. The current implementation is broken since it does not use the register operands correctly, and always uses 64-bit for r

[PATCH] KVM: PPC: Book3E: Unlock mmu_lock when setting caching atttribute

2014-06-18 Thread Mihai Caraman
The patch 08c9a188d0d0fc0f0c5e17d89a06bb59c493110f kvm: powerpc: use caching attributes as per linux pte do not handle properly the error case, letting mmu_lock locked. The lock will further generate a RCU stall from kvmppc_e500_emul_tlbwe() caller. In case of an error go to out label. Si

RE: [PATCH] KVM: PPC: Book3E: Unlock mmu_lock when setting caching atttribute

2014-06-18 Thread bharat.bhus...@freescale.com
> -Original Message- > From: Mihai Caraman [mailto:mihai.cara...@freescale.com] > Sent: Wednesday, June 18, 2014 9:15 PM > To: kvm-...@vger.kernel.org > Cc: kvm@vger.kernel.org; linuxppc-...@lists.ozlabs.org; Caraman Mihai Claudiu- > B02008; Bhushan Bharat-R65777 > Subject: [PATCH] KVM: P

Re: [PATCH 1/2] perf: ignore LBR and offcore_rsp.

2014-06-18 Thread Peter Zijlstra
On Wed, Jun 18, 2014 at 03:52:55PM +, Liang, Kan wrote: > perf ignore LBR and offcore_rsp. > > x86, perf: Protect LBR and offcore rsp against KVM lying > > With -cpu host, KVM reports LBR and offcore support, if the host has > support. > When the guest perf driver tries to ac

Re: [PATCH 04/11] qspinlock: Extract out the exchange of tail code word

2014-06-18 Thread Paolo Bonzini
Il 18/06/2014 17:46, Waiman Long ha scritto: The #1 patch is nice by itself - as it lays out the foundation of the MCS-similar code - and if Ingo decides he does not want this pending byte-lock bit business - it can be easily reverted or dropped. The pending bit code is needed for performance

Re: [PATCH 04/11] qspinlock: Extract out the exchange of tail code word

2014-06-18 Thread Waiman Long
On 06/18/2014 09:50 AM, Konrad Rzeszutek Wilk wrote: On Wed, Jun 18, 2014 at 01:37:45PM +0200, Paolo Bonzini wrote: Il 17/06/2014 22:55, Konrad Rzeszutek Wilk ha scritto: On Sun, Jun 15, 2014 at 02:47:01PM +0200, Peter Zijlstra wrote: From: Waiman Long This patch extracts the logic for the ex

Re: [PATCH v2 0/9] KVM: x86: More emulator bugs

2014-06-18 Thread Paolo Bonzini
Il 18/06/2014 16:19, Nadav Amit ha scritto: This patch-set resolves several emulator bugs. Each fix is independent of the others. The DR6 bug can occur during DR-access exit (regardless to unrestricted mode, MMIO and SPT). Changes in v2: Introduced kvm_register_readl and kvm_register_writel w

Re: [PATCH v2 9/9] KVM: vmx: vmx instructions handling does not consider cs.l

2014-06-18 Thread Paolo Bonzini
Il 18/06/2014 16:19, Nadav Amit ha scritto: VMX instructions use 32-bit operands in 32-bit mode, and 64-bit operands in 64-bit mode. The current implementation is broken since it does not use the register operands correctly, and always uses 64-bit for reads and writes. Moreover, write to memory

Re: [PATCH 10/11] qspinlock: Paravirt support

2014-06-18 Thread Waiman Long
On 06/18/2014 08:03 AM, Paolo Bonzini wrote: Il 17/06/2014 00:08, Waiman Long ha scritto: +void __pv_queue_unlock(struct qspinlock *lock) +{ +int val = atomic_read(&lock->val); + +native_queue_unlock(lock); + +if (val & _Q_LOCKED_SLOW) +___pv_kick_head(lock); +} + Again a r

Re: [PATCH 6/7] KVM: PPC: Book3S HV: Fix ABIv2 on LE

2014-06-18 Thread Alexander Graf
On 18.06.14 17:21, Aneesh Kumar K.V wrote: Alexander Graf writes: We use ABIv2 on Little Endian systems which gets rid of the dotted function names. Branch to the actual functions when we see such a system. Signed-off-by: Alexander Graf As per patches sent by anton we don't need this. We c

Re: [PATCH 6/7] KVM: PPC: Book3S HV: Fix ABIv2 on LE

2014-06-18 Thread Aneesh Kumar K.V
Alexander Graf writes: > We use ABIv2 on Little Endian systems which gets rid of the dotted function > names. Branch to the actual functions when we see such a system. > > Signed-off-by: Alexander Graf As per patches sent by anton we don't need this. We can branch to the function rathen than th

Re: [Qemu-devel] Why I advise against using ivshmem

2014-06-18 Thread Paolo Bonzini
Il 18/06/2014 16:57, David Marchand ha scritto: Hello Stefan, On 06/18/2014 12:48 PM, Stefan Hajnoczi wrote: One more thing to add to the list: static void ivshmem_read(void *opaque, const uint8_t * buf, int flags) The "flags" argument should be "size". Size should be checked before accessin

Re: Fwd: KVM_SYSTEM_TIME clock is marked unstable on a modern single-socket system

2014-06-18 Thread Marcelo Tosatti
On Wed, Jun 18, 2014 at 01:38:09PM +0200, Tomasz Grabiec wrote: > Hi, > > I'm working on OSv (https://github.com/cloudius-systems/osv), a guest > operating system. Right, please add a "tsc_matched" field to kvm_vcpu_arch (to keep track per-vcpu) and then increment the global counter only once per

Re: [PATCH v5 00/12] KVM Support for MIPS32 Processors

2014-06-18 Thread Paolo Bonzini
Il 18/06/2014 00:10, James Hogan ha scritto: The patchset depends on v4 of "target-mips: implement UserLocal Register". I'm aiming for QEMU 2.1, hopefully it isn't too late to get some final review. Thanks to everybody who has already taken part in review. This patchset implements KVM support f

Re: [Qemu-devel] Why I advise against using ivshmem

2014-06-18 Thread Andreas Färber
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 18.06.2014 12:48, schrieb Stefan Hajnoczi: > On Tue, Jun 17, 2014 at 11:44:11AM +0200, Paolo Bonzini wrote: >> Il 17/06/2014 11:03, David Marchand ha scritto: Unless someone steps up and maintains ivshmem, I think it should be deprecated a

[PATCH kvm-unit-tests 1/5] x86: Testing nop instruction on 64-bit

2014-06-18 Thread Nadav Amit
Previously, nop instruction emulation on 64-bit caused RAX bits [63:32] to be cleared. This test checks the behavior is correct and RAX is unmodified. Signed-off-by: Nadav Amit --- x86/emulator.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/x86/emulator.c b/x86/emulator.c ind

Re: [Qemu-devel] Why I advise against using ivshmem

2014-06-18 Thread David Marchand
On 06/18/2014 12:51 PM, Stefan Hajnoczi wrote: Actually, you can avoid this memory copy using frameworks like DPDK. I guess it's careful to allocate all packets in the mmapped BAR? Yes. That's fine if you can modify applications but doesn't work for unmodified applications using regular n

Re: [Qemu-devel] Why I advise against using ivshmem

2014-06-18 Thread David Marchand
Hello Stefan, On 06/18/2014 12:48 PM, Stefan Hajnoczi wrote: One more thing to add to the list: static void ivshmem_read(void *opaque, const uint8_t * buf, int flags) The "flags" argument should be "size". Size should be checked before accessing buf. You are welcome to send a fix and I will

Re: [RFC PATCH 6/6] arm/arm64: KVM: vgic: Clarify and correct vgic documentation

2014-06-18 Thread Eric Auger
On 06/14/2014 10:51 PM, Christoffer Dall wrote: > The VGIC virtual distributor implementation documentation was written a > very long time ago, before the true nature of the beast had been > partially absorbed into my bloodstream. I think this amalgamates the > two evil beings (myself and the code

[PATCH kvm-unit-tests 2/5] x86: test xadd with two identical operands

2014-06-18 Thread Nadav Amit
Previously, KVM emulated xadd incorrectly when the source and destination operands were identical. The expected result is that the register would hold the sum (2x) and not the previous value (x). This test checks this behavior. It should be executed with a disabled unrestricted mode. Signed-off-

[PATCH kvm-unit-tests 3/5] x86: Test btcq with operand larger than 64

2014-06-18 Thread Nadav Amit
Previously, KVM did not calculate the offset for bit-operations correctly when quad-word operands were used. This test checks btcq when operand is larger than 64 in order to check this scenario. Signed-off-by: Nadav Amit --- x86/emulator.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion

[PATCH v2 0/9] KVM: x86: More emulator bugs

2014-06-18 Thread Nadav Amit
This patch-set resolves several emulator bugs. Each fix is independent of the others. The DR6 bug can occur during DR-access exit (regardless to unrestricted mode, MMIO and SPT). Changes in v2: Introduced kvm_register_readl and kvm_register_writel which consider long-mode and cs.l when reading

[PATCH v2 4/9] KVM: x86: emulation of dword cmov on long-mode should clear [63:32]

2014-06-18 Thread Nadav Amit
Even if the condition of cmov is not satisfied, bits[63:32] should be cleared. This is clearly stated in Intel's CMOVcc documentation. The solution is to reassign the destination onto itself if the condition is unsatisfied. For that matter the original destination value needs to be read. Signed-

Re: [RFC PATCH 1/6] arm/arm64: KVM: Rename irq_state to irq_pending

2014-06-18 Thread Eric Auger
On 06/14/2014 10:51 PM, Christoffer Dall wrote: > The irq_state field on the distributor struct is ambiguous in its > meaning; the comment says it's the level of the input put, but that > doesn't make much sense for edge-triggered interrupts. The code > actually uses this state variable to check i

[PATCH v2 8/9] KVM: vmx: handle_cr ignores 32/64-bit mode

2014-06-18 Thread Nadav Amit
On 32-bit mode only bits [31:0] of the CR should be used for setting the CR value. Otherwise, the host may incorrectly assume the value is invalid if bits [63:32] are not zero. Moreover, the CR is currently being read twice when CR8 is used. Last, nested mov-cr exiting is modified to handle the

[PATCH v2 3/9] KVM: x86: Inter privilage level ret emulation is not implemeneted

2014-06-18 Thread Nadav Amit
Return unhandlable error on inter-privilage level ret instruction. This is since the current emulation does not check the privilage level correctly when loading the CS, and does not pop RSP/SS as needed. Signed-off-by: Nadav Amit --- arch/x86/kvm/emulate.c | 4 1 file changed, 4 insertions

[PATCH v2 2/9] KVM: x86: Wrong emulation on 'xadd X, X'

2014-06-18 Thread Nadav Amit
The emulator does not emulate the xadd instruction correctly if the two operands are the same. In this (unlikely) situation the result should be the sum of X and X (2X) when it is currently X. The solution is to first perform writeback to the source, before writing to the destination. The only i

[PATCH kvm-unit-tests 5/5] x86: Test monitor and mwait on real-mode

2014-06-18 Thread Nadav Amit
monitor and mwait are now considered to behave as nop. New patch enables monitor and mwait in realmode as well. This test checks whether they are handled as nop in realmode as well. Signed-off-by: Nadav Amit --- x86/realmode.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/x8

[PATCH kvm-unit-tests 4/5] x86: check cmov instruction on 64-bit

2014-06-18 Thread Nadav Amit
cmov instruction on 64-bit with dword destination register operand should clear bits [63:32]. This test checks this behavior due to previous KVM bug. Signed-off-by: Nadav Amit --- x86/emulator.c | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/x86/emulator.c b/

[PATCH kvm-unit-tests 0/5] x86: Tests for recent emulator bugs

2014-06-18 Thread Nadav Amit
This patch-set checks recent emulator bugs as well as monitor-mwait emulation in real-mode. Nadav Amit (5): x86: Testing nop instruction on 64-bit x86: test xadd with two identical operands x86: Test btcq with operand larger than 64 x86: check cmov instruction on 64-bit x86: Test monitor

[PATCH v2 6/9] KVM: x86: check DR6/7 high-bits are clear only on long-mode

2014-06-18 Thread Nadav Amit
From: Nadav Amit When the guest sets DR6 and DR7, KVM asserts the high 32-bits are clear, and otherwise injects a #GP exception. This exception should only be injected only if running in long-mode. Signed-off-by: Nadav Amit --- arch/x86/kvm/vmx.c | 2 +- arch/x86/kvm/x86.h | 18 ++

[PATCH v2 7/9] KVM: x86: Hypercall handling does not considers opsize correctly

2014-06-18 Thread Nadav Amit
Currently, the hypercall handling routine only considers LME as an indication to whether the guest uses 32/64-bit mode. This is incosistent with hyperv hypercalls handling and against the common sense of considering cs.l as well. This patch uses is_64_bit_mode instead of is_long_mode for that matte

[PATCH v2 1/9] KVM: x86: bit-ops emulation ignores offset on 64-bit

2014-06-18 Thread Nadav Amit
The current emulation of bit operations ignores the offset from the destination on 64-bit target memory operands. This patch fixes this behavior. Signed-off-by: Nadav Amit --- arch/x86/kvm/emulate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/emulate.c b/a

[PATCH v2 5/9] KVM: x86: NOP emulation clears (incorrectly) the high 32-bits of RAX

2014-06-18 Thread Nadav Amit
On long-mode the current NOP (0x90) emulation still writes back to RAX. As a result, EAX is zero-extended and the high 32-bits of RAX are cleared. Signed-off-by: Nadav Amit --- arch/x86/kvm/emulate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/emulate.c

[PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-18 Thread Nadav Amit
mwait and monitor are currently handled as nop. Considering this behavior, they should still be handled correctly, i.e., check execution conditions and generate exceptions when required. mwait and monitor may also be executed in real-mode and are not handled in that case. This patch performs the e

[PATCH v2 9/9] KVM: vmx: vmx instructions handling does not consider cs.l

2014-06-18 Thread Nadav Amit
VMX instructions use 32-bit operands in 32-bit mode, and 64-bit operands in 64-bit mode. The current implementation is broken since it does not use the register operands correctly, and always uses 64-bit for reads and writes. Moreover, write to memory in vmwrite only considers long-mode, so it ign

[PATCH 1/3] KVM: x86: Emulator flag for instruction with no big real mode

2014-06-18 Thread Nadav Amit
Certain instructions, such as monitor and xsave do not support big real mode and cause a #GP exception if any of the accessed bytes effective address are not within [0, 0x]. This patch introduces a flag to mark these instructions, including the necassary checks. Signed-off-by: Nadav Amit ---

[PATCH 0/3] Correct monitor-mwait emulation as nop

2014-06-18 Thread Nadav Amit
KVM handles monitor-mwait as nop, but does not check any of the preconditions for the instructions. These instructions may generate all kind of exceptions (#UD, #PF, #GP, #SS). They can also be executed in real-mode. This patch-set moves the handling of monitor-mwait to the emulator, to allow the

Re: [RFC PATCH 4/6] arm/arm64: KVM: vgic: Improve handling of GICD_I{CS}PENDRn

2014-06-18 Thread Eric Auger
On 06/14/2014 10:51 PM, Christoffer Dall wrote: > The handling of writes to the GICD_ISPENDRn and GICD_ICPENDRn is > currently not handled correctly for level-triggered interrupts. Hi Christoffer, Thanks for this patch serie. I can confirm it fixes my QEMU/VFIO issue where all IRQs were pending cl

[PATCH 2/3] KVM: x86: Emulator support for #UD on CPL>0

2014-06-18 Thread Nadav Amit
Certain instructions (e.g., mwait and monitor) cause a #UD exception when they are executed in privilaged mode. This is in contrast to the regular privilaged instructions which cause #GP. In order not to mess with SVM interception of mwait and monitor which assumes privilage level assertions take p

[PATCH] KVM: x86: Increase the number of fixed MTRR regs to 10

2014-06-18 Thread Nadav Amit
Recent Intel CPUs have 10 variable range MTRRs. Since operating systems sometime make assumptions on CPUs while they ignore capability MSRs, it is better for KVM to be consistent with recent CPUs. Reporting more MTRRs than actually supported has no functional implications. Signed-off-by: Nadav Ami

Re: [PATCH 04/11] qspinlock: Extract out the exchange of tail code word

2014-06-18 Thread Konrad Rzeszutek Wilk
On Wed, Jun 18, 2014 at 01:37:45PM +0200, Paolo Bonzini wrote: > Il 17/06/2014 22:55, Konrad Rzeszutek Wilk ha scritto: > >On Sun, Jun 15, 2014 at 02:47:01PM +0200, Peter Zijlstra wrote: > >>From: Waiman Long > >> > >>This patch extracts the logic for the exchange of new and previous tail > >>code

Re: [PATCH 03/11] qspinlock: Add pending bit

2014-06-18 Thread Konrad Rzeszutek Wilk
On Wed, Jun 18, 2014 at 01:29:48PM +0200, Paolo Bonzini wrote: > Il 17/06/2014 22:36, Konrad Rzeszutek Wilk ha scritto: > >+/* One more attempt - but if we fail mark it as pending. */ > >+if (val == _Q_LOCKED_VAL) { > >+new = Q_LOCKED_VAL |_Q_PENDING_VAL; > >+ > >+ol

Re: Nested paging in nested SVM setup

2014-06-18 Thread Jan Kiszka
On 2014-06-18 13:36, Valentine Sinitsyn wrote: > Hi all, > > I'm using a KVM/Qemu nested SVM setup to debug another hypervisor > (Jailhouse) I contribute to. IOW, the scheme is: AMD64 Linux host > running [paravirtualized] AMD64 Linux guest (the same kernel as the > host) running Jailhouse. > > J

Re: [PATCH 10/11] qspinlock: Paravirt support

2014-06-18 Thread Paolo Bonzini
Il 15/06/2014 14:47, Peter Zijlstra ha scritto: #if !defined(CONFIG_X86_OOSTORE) && !defined(CONFIG_X86_PPRO_FENCE) -#definequeue_spin_unlock queue_spin_unlock /** * queue_spin_unlock - release a queue spinlock * @lock : Pointer to queue spinlock structure * * An effective sm

Re: [PATCH 10/11] qspinlock: Paravirt support

2014-06-18 Thread Paolo Bonzini
Il 17/06/2014 00:08, Waiman Long ha scritto: +void __pv_queue_unlock(struct qspinlock *lock) +{ + int val = atomic_read(&lock->val); + + native_queue_unlock(lock); + + if (val & _Q_LOCKED_SLOW) + ___pv_kick_head(lock); +} + Again a race can happen here between th

Re: [PATCH 06/11] qspinlock: Optimize pending bit

2014-06-18 Thread Paolo Bonzini
Il 15/06/2014 14:47, Peter Zijlstra ha scritto: XXX: merge into the pending bit patch.. Agree, or if not move it right after the pending bit patch, before the NR_CPUS optimization. Paolo It is possible so observe the pending bit without the locked bit when the last owner has just released

Re: [PATCH 05/11] qspinlock: Optimize for smaller NR_CPUS

2014-06-18 Thread Paolo Bonzini
Il 15/06/2014 14:47, Peter Zijlstra ha scritto: - for (;;) { - new = (val & ~_Q_PENDING_MASK) | _Q_LOCKED_VAL; - - old = atomic_cmpxchg(&lock->val, val, new); - if (old == val) - break; - - val = old; - } +

Re: [PATCH 04/11] qspinlock: Extract out the exchange of tail code word

2014-06-18 Thread Paolo Bonzini
Il 17/06/2014 22:55, Konrad Rzeszutek Wilk ha scritto: On Sun, Jun 15, 2014 at 02:47:01PM +0200, Peter Zijlstra wrote: From: Waiman Long This patch extracts the logic for the exchange of new and previous tail code words into a new xchg_tail() function which can be optimized in a later patch.

Fwd: KVM_SYSTEM_TIME clock is marked unstable on a modern single-socket system

2014-06-18 Thread Tomasz Grabiec
Hi, I'm working on OSv (https://github.com/cloudius-systems/osv), a guest operating system. I've been investigating a phenomena of KVM_SYSTEM_TIME being marked as unstable (PVCLOCK_TSC_STABLE_BIT cleared) by KVM on a modern single-socket CPU since the very beginning of guest's life time. Accordin

  1   2   >