Re: [PATCH] kvm: fix to update memslots properly

2015-03-09 Thread Chen, Tiejun
On 2015/3/10 4:54, Marcelo Tosatti wrote: On Sat, Dec 27, 2014 at 09:41:45PM +0100, Paolo Bonzini wrote: diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index f528343..6e52f3f 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -672,6 +672,7 @@ static void update_memslots(struct

[PATCH] x86: irq_comm: Add check for RH bit in kvm_set_msi_irq

2015-03-09 Thread James Sullivan
Hi folks, This is a small patch that implements logic to handle the RH bit being set in the msi message address register. Currently the DM bit is the only thing used to decide irq->dest_mode (logical when DM set, physical when unset). Documentation indicates that the DM bit will be ignored when th

Re: [PATCH v2] virtio-balloon: do not call blocking ops when !TASK_RUNNING

2015-03-09 Thread Rusty Russell
Thomas Huth writes: > On Wed, 25 Feb 2015 16:11:27 +0100 > Cornelia Huck wrote: > >> On Wed, 25 Feb 2015 15:36:02 +0100 >> "Michael S. Tsirkin" wrote: >> >> > virtio balloon has this code: >> > wait_event_interruptible(vb->config_change, >> > (diff = tow

Re: virtio balloon: do not call blocking ops when !TASK_RUNNING

2015-03-09 Thread Rusty Russell
Cornelia Huck writes: > On Wed, 4 Mar 2015 11:25:56 +0100 > "Michael S. Tsirkin" wrote: > >> On Wed, Mar 04, 2015 at 04:44:54PM +1030, Rusty Russell wrote: >> > "Michael S. Tsirkin" writes: >> > > On Mon, Mar 02, 2015 at 10:37:26AM +1030, Rusty Russell wrote: >> > >> Thomas Huth writes: >> > >>

Re: [PATCHv2 0/9] Fix possible warnings and errors for kvm_main.c

2015-03-09 Thread Xiubo Li
On 10/03/2015 07:07, Marcelo Tosatti wrote: On Fri, Feb 27, 2015 at 03:18:17PM +0800, Xiubo Li wrote: There are to much warning/error noise in kvm_main.c when gernerating and checking new patches. This patch series fix most of these warnings and errors to reduce possible noise. Change in v2:

Re: [PATCH] x86: svm: make wbinvd faster

2015-03-09 Thread Marcelo Tosatti
On Fri, Feb 27, 2015 at 06:19:18PM -0600, Joel Schopp wrote: > From: David Kaplan > No need to re-decode WBINVD since we know what it is from the intercept. > > Signed-off-by: David Kaplan > [extracted from larger unlrelated patch, forward ported, tested] > Signed-off-by: Joel Schopp Can't you

Re: [PATCHv2 0/9] Fix possible warnings and errors for kvm_main.c

2015-03-09 Thread Marcelo Tosatti
On Fri, Feb 27, 2015 at 03:18:17PM +0800, Xiubo Li wrote: > > There are to much warning/error noise in kvm_main.c when gernerating and > checking new patches. > > This patch series fix most of these warnings and errors to reduce possible > noise. > > > Change in v2: > - Accept Thomas Huth's adv

[GIT PULL] KVM fixes for 4.0-rc3

2015-03-09 Thread Marcelo Tosatti
Linus, Please pull from git://git.kernel.org/pub/scm/virt/kvm/kvm.git master To receive the following KVM S/390 bug fixes Christian Borntraeger (1): KVM: s390/cpacf: Fix kernel bug under z/VM Marcelo Tosatti (1): Merge tag 'kvm-s390-master-20150303' of git://git.kernel.org/.../k

Re: [PATCH] KVM: Get rid of kvm_kvfree()

2015-03-09 Thread Marcelo Tosatti
On Tue, Feb 24, 2015 at 09:29:25PM +0100, Thomas Huth wrote: > kvm_kvfree() provides exactly the same functionality as the > new common kvfree() function - so let's simply replace the > kvm function with the common function. > > Signed-off-by: Thomas Huth Applied, thanks. -- To unsubscribe from

Re: [PATCH] KVM: make halt_poll_ns static

2015-03-09 Thread Marcelo Tosatti
On Fri, Feb 27, 2015 at 04:50:10PM +0100, Christian Borntraeger wrote: > halt_poll_ns is used only locally. Make it static. > > Signed-off-by: Christian Borntraeger > --- > virt/kvm/kvm_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Applied, thanks. -- To unsubscribe from this

Re: [PATCH] kvm: fix to update memslots properly

2015-03-09 Thread Marcelo Tosatti
On Sat, Dec 27, 2014 at 09:41:45PM +0100, Paolo Bonzini wrote: > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > > index f528343..6e52f3f 100644 > > --- a/virt/kvm/kvm_main.c > > +++ b/virt/kvm/kvm_main.c > > @@ -672,6 +672,7 @@ static void update_memslots(struct kvm_memslots *slots, > >

[PATCH trivial] KVM: s390: Spelling s/intance/instance/

2015-03-09 Thread Geert Uytterhoeven
Signed-off-by: Geert Uytterhoeven --- arch/s390/kvm/kvm-s390.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h index fda3f3146eb636d3..83f32a147d72c0f3 100644 --- a/arch/s390/kvm/kvm-s390.h +++ b/arch/s390/kvm/kvm-s390.h @@ -

[PATCH kvm-unit-test] x86: vmx: Check #UD triggering of vmmcall

2015-03-09 Thread Jan Kiszka
KVM tends to patch and emulated vmmcall on Intel. But that must not happen for L2. Signed-off-by: Jan Kiszka --- If the recently posted fixed for KVM are applied, this test passes. x86/vmx_tests.c | 40 1 file changed, 40 insertions(+) diff --git a/x86

[PATCH] KVM: nVMX: Do not emulate #UD while in guest mode

2015-03-09 Thread Jan Kiszka
While in L2, leave all #UD to L2 and do not try to emulate it. If L1 is interested in doing this, it reports its interest via the exception bitmap, and we never get into handle_exception of L0 anyway. Signed-off-by: Jan Kiszka --- Noticed while wondering where the vmmcall of a misconfigured L2 w

Re: [PATCH v2 1/5] arm: KVM: export vcpi->pause state via MP_STATE ioctls

2015-03-09 Thread Peter Maydell
On 10 March 2015 at 04:29, Christoffer Dall wrote: > On Mon, Mar 09, 2015 at 04:34:21PM +, Alex Bennée wrote: >> - Boot >> - Power on secondary CPUs >> - Power off one secondary CPU >> - Migrate to file (cpu_powered reflects state of each CPU) >> >> - Start fresh QEMU >> - Restore from file (c

Re: 2 CPU Conformance Issue in KVM/x86

2015-03-09 Thread Avi Kivity
On 03/09/2015 09:33 PM, Paolo Bonzini wrote: On 09/03/2015 18:08, Avi Kivity wrote: Is the issue emulating a higher MAXPHYADDR on the guest than is available on the host? I don't think there's any need to support that. No, indeed. The only problem is that the failure mode is quite horrible (y

Re: 2 CPU Conformance Issue in KVM/x86

2015-03-09 Thread Avi Kivity
On 03/09/2015 09:38 PM, Paolo Bonzini wrote: On 09/03/2015 20:19, Avi Kivity wrote: I can't think of one with reasonable performance either. Perhaps the maintainers could raise the issue with Intel. It looks academic but it can happen in real life -- KVM for example used to rely on reserved b

Re: 2 CPU Conformance Issue in KVM/x86

2015-03-09 Thread Paolo Bonzini
On 09/03/2015 20:19, Avi Kivity wrote: > I can't think of one with reasonable performance either. Perhaps the > maintainers could raise the issue with Intel. It looks academic but it > can happen in real life -- KVM for example used to rely on reserved bits > faults (it set all bits in the PTE

Re: 2 CPU Conformance Issue in KVM/x86

2015-03-09 Thread Paolo Bonzini
On 09/03/2015 18:08, Avi Kivity wrote: > Is the issue emulating a higher MAXPHYADDR on the guest than is > available on the host? I don't think there's any need to support that. No, indeed. The only problem is that the failure mode is quite horrible (you get a triple fault, possibly while the g

Re: [PATCH 5/6] target-arm/kvm64: fix save/restore of SPSR regs

2015-03-09 Thread Christoffer Dall
On Mon, Mar 09, 2015 at 10:31:19PM +0900, Peter Maydell wrote: > On 9 March 2015 at 21:56, Christoffer Dall > wrote: > > this function, however, is not used only when migration, but should > > generally cover the case where you want to synchronize QEMU's state into > > KVM's state, right? So whi

Re: [PATCH v2 1/5] arm: KVM: export vcpi->pause state via MP_STATE ioctls

2015-03-09 Thread Christoffer Dall
On Mon, Mar 09, 2015 at 04:34:21PM +, Alex Bennée wrote: > > Christoffer Dall writes: > > > Hi Alex, > > > > The subject of this change has a typo, and I also think it's not about > > exposing the pause state (that's just an internal name/concept), but > > about exposing the PSCI state, or s

[PATCH] KVM: x86: Fix re-execution of patched vmmcall

2015-03-09 Thread Jan Kiszka
For a very long time (since 2b3d2a20), the path handling a vmmcall instruction of the guest on an Intel host only applied the patch but no longer handled the hypercall. The reverse case, vmcall on AMD hosts, is fine. As both em_vmcall and em_vmmcall actually have to do the same, we can fix the issu

Re: 2 CPU Conformance Issue in KVM/x86

2015-03-09 Thread Avi Kivity
On 03/09/2015 09:07 PM, Nadav Amit wrote: Avi Kivity wrote: On 03/09/2015 07:51 PM, Nadav Amit wrote: Avi Kivity wrote: On 03/03/2015 11:52 AM, Paolo Bonzini wrote: In this case, the VM might expect exceptions when PTE bits which are higher than the maximum (reported) address width are se

Re: 2 CPU Conformance Issue in KVM/x86

2015-03-09 Thread Nadav Amit
Avi Kivity wrote: > On 03/09/2015 07:51 PM, Nadav Amit wrote: >> Avi Kivity wrote: >> >>> On 03/03/2015 11:52 AM, Paolo Bonzini wrote: > In this > case, the VM might expect exceptions when PTE bits which are higher than > the > maximum (reported) address width are set, and it w

Re: 2 CPU Conformance Issue in KVM/x86

2015-03-09 Thread Avi Kivity
On 03/09/2015 07:51 PM, Nadav Amit wrote: Avi Kivity wrote: On 03/03/2015 11:52 AM, Paolo Bonzini wrote: In this case, the VM might expect exceptions when PTE bits which are higher than the maximum (reported) address width are set, and it would not get such exceptions. This problem can easily

[PATCH kvm-unit-test] x86/emulator: Fix inline assembler warning

2015-03-09 Thread Jan Kiszka
Code compiles to the same binary, but now with one warning less. Signed-off-by: Jan Kiszka --- x86/emulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x86/emulator.c b/x86/emulator.c index 0964e6a..e5c1c6b 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -838,7 +838

Re: 2 CPU Conformance Issue in KVM/x86

2015-03-09 Thread Nadav Amit
Avi Kivity wrote: > On 03/03/2015 11:52 AM, Paolo Bonzini wrote: >>> In this >>> case, the VM might expect exceptions when PTE bits which are higher than the >>> maximum (reported) address width are set, and it would not get such >>> exceptions. This problem can easily be experienced by small cha

Re: 2 CPU Conformance Issue in KVM/x86

2015-03-09 Thread Avi Kivity
On 03/03/2015 11:52 AM, Paolo Bonzini wrote: In this case, the VM might expect exceptions when PTE bits which are higher than the maximum (reported) address width are set, and it would not get such exceptions. This problem can easily be experienced by small change to the existing KVM unit-tests.

Re: [PATCH v2 2/5] arm/arm64: KVM: Implement support for unqueueing active IRQs

2015-03-09 Thread Alex Bennée
Christoffer Dall writes: > On Mon, Mar 02, 2015 at 01:29:01PM +, Alex Bennée wrote: >> From: Christoffer Dall >> >> Migrating active interrupts causes the active state to be lost >> completely. This implements some additional bitmaps to track the active >> state on the distributor and expo

Re: [PATCH v2 1/5] arm: KVM: export vcpi->pause state via MP_STATE ioctls

2015-03-09 Thread Alex Bennée
Christoffer Dall writes: > Hi Alex, > > The subject of this change has a typo, and I also think it's not about > exposing the pause state (that's just an internal name/concept), but > about exposing the PSCI state, or simply the VCPU power state. arm: KVM: export VCPU power state via MP_STATE i

Re: [PATCH 5/6] target-arm/kvm64: fix save/restore of SPSR regs

2015-03-09 Thread Alex Bennée
Peter Maydell writes: > On 9 March 2015 at 21:56, Christoffer Dall > wrote: >> this function, however, is not used only when migration, but should >> generally cover the case where you want to synchronize QEMU's state into >> KVM's state, right? So while it may not be harmful in currently >>

Re: [PATCH] KVM: Get rid of kvm_kvfree()

2015-03-09 Thread Paolo Bonzini
On 09/03/2015 16:39, Thomas Huth wrote: > On Tue, 24 Feb 2015 21:29:25 +0100 > Thomas Huth wrote: > >> kvm_kvfree() provides exactly the same functionality as the >> new common kvfree() function - so let's simply replace the >> kvm function with the common function. >> >> Signed-off-by: Thomas

Re: [PATCH v2] x86: svm: use cr_interception for SVM_EXIT_CR0_SEL_WRITE

2015-03-09 Thread Radim Krčmář
2015-03-06 14:44-0600, Joel Schopp: > From: David Kaplan > > Another patch in my war on emulate_on_interception() use as a svm exit > handler. > > These were pulled out of a larger patch at the suggestion of Radim Krcmar, see > https://lkml.org/lkml/2015/2/25/559 > > Changes since v1: >

Re: [RFC/RFT PATCH 0/3] arm64: KVM: work around incoherency with uncached guest mappings

2015-03-09 Thread Mario Smarduch
On 03/09/2015 07:26 AM, Andrew Jones wrote: > On Fri, Mar 06, 2015 at 01:08:29PM -0800, Mario Smarduch wrote: >> On 03/05/2015 09:43 AM, Paolo Bonzini wrote: >>> >>> >>> On 05/03/2015 15:58, Catalin Marinas wrote: > It would especially suck if the user has a cluster with different > machine

Re: [PATCH] KVM: Get rid of kvm_kvfree()

2015-03-09 Thread Thomas Huth
On Tue, 24 Feb 2015 21:29:25 +0100 Thomas Huth wrote: > kvm_kvfree() provides exactly the same functionality as the > new common kvfree() function - so let's simply replace the > kvm function with the common function. > > Signed-off-by: Thomas Huth > --- > arch/x86/kvm/x86.c |8 -

Re: [PATCH v2 3/5] arm: KVM: add a common vgic_queue_irq_to_lr fn

2015-03-09 Thread Christoffer Dall
On Mon, Mar 02, 2015 at 01:29:02PM +, Alex Bennée wrote: > This helps re-factor away some of the repetitive code and makes the code > flow more nicely. > > Signed-off-by: Alex Bennée > Reviewed-by: Christoffer Dall -- To unsubscribe from this list: send the line "unsubscribe kvm" in the bod

Re: [PATCH v2 2/5] arm/arm64: KVM: Implement support for unqueueing active IRQs

2015-03-09 Thread Christoffer Dall
On Mon, Mar 02, 2015 at 01:29:01PM +, Alex Bennée wrote: > From: Christoffer Dall > > Migrating active interrupts causes the active state to be lost > completely. This implements some additional bitmaps to track the active > state on the distributor and export this to user space. > > Signed-

[PATCH v5 15/29] vfio: powerpc/spapr: powerpc/powernv/ioda2: Rework IOMMU ownership control

2015-03-09 Thread Alexey Kardashevskiy
At the moment the iommu_table struct has a set_bypass() which enables/ disables DMA bypass on IODA2 PHB. This is exposed to POWERPC IOMMU code which calls this callback when external IOMMU users such as VFIO are about to get over a PHB. The set_bypass() callback is not really an iommu_table functi

[PATCH v5 10/29] powerpc/powernv: Do not set "read" flag if direction==DMA_NONE

2015-03-09 Thread Alexey Kardashevskiy
Normally a bitmap from the iommu_table is used to track what TCE entry is in use. Since we are going to use iommu_table without its locks and do xchg() instead, it becomes essential not to put bits which are not implied in the direction flag. This adds iommu_direction_to_tce_perm() (its counterpar

[PATCH v5 20/29] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_create_table/pnc_pci_free_table

2015-03-09 Thread Alexey Kardashevskiy
This is a part of moving TCE table allocation into an iommu_ops callback to support multiple IOMMU groups per one VFIO container. This enforce window size to be a power of two. This is a pretty mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c

[PATCH v5 23/29] powerpc/powernv: Implement multilevel TCE tables

2015-03-09 Thread Alexey Kardashevskiy
TCE tables might get too big in case of 4K IOMMU pages and DDW enabled on huge guests (hundreds of GB of RAM) so the kernel might be unable to allocate contiguous chunk of physical memory to store the TCE table. To address this, POWER8 CPU (actually, IODA2) supports multi-level TCE tables, up to 5

[PATCH v5 16/29] powerpc/iommu: Fix IOMMU ownership control functions

2015-03-09 Thread Alexey Kardashevskiy
This adds missing locks in iommu_take_ownership()/ iommu_release_ownership(). This marks all pages busy in iommu_table::it_map in order to catch errors if there is an attempt to use this table while ownership over it is taken. This only clears TCE content if there is no page marked busy in it_map

[PATCH v5 24/29] powerpc/powernv: Change prototypes to receive iommu

2015-03-09 Thread Alexey Kardashevskiy
This changes few functions to receive a iommu_table_group pointer rather than PE as they are going to be a part of upcoming iommu_table_group_ops callback set. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 13 - 1 file changed, 8 insertions(+), 5

[PATCH v5 25/29] powerpc/powernv/ioda: Define and implement DMA table/window management callbacks

2015-03-09 Thread Alexey Kardashevskiy
This extends iommu_table_group_ops by a set of callbacks to support dynamic DMA windows management. query() returns IOMMU capabilities such as default DMA window address and supported number of DMA windows and TCE table levels. create_table() creates a TCE table with specific parameters. it recei

Re: [RFC/RFT PATCH 0/3] arm64: KVM: work around incoherency with uncached guest mappings

2015-03-09 Thread Andrew Jones
On Fri, Mar 06, 2015 at 01:08:29PM -0800, Mario Smarduch wrote: > On 03/05/2015 09:43 AM, Paolo Bonzini wrote: > > > > > > On 05/03/2015 15:58, Catalin Marinas wrote: > >>> It would especially suck if the user has a cluster with different > >>> machines, some of them coherent and others non-coher

[PATCH v5 01/29] vfio: powerpc/spapr: Move page pinning from arch code to VFIO IOMMU driver

2015-03-09 Thread Alexey Kardashevskiy
This moves page pinning (get_user_pages_fast()/put_page()) code out of the platform IOMMU code and puts it to VFIO IOMMU driver where it belongs to as the platform code does not deal with page pinning. This makes iommu_take_ownership()/iommu_release_ownership() deal with the IOMMU table bitmap onl

[PATCH v5 04/29] vfio: powerpc/spapr: Use it_page_size

2015-03-09 Thread Alexey Kardashevskiy
This makes use of the it_page_size from the iommu_table struct as page size can differ. This replaces missing IOMMU_PAGE_SHIFT macro in commented debug code as recently introduced IOMMU_PAGE_XXX macros do not include IOMMU_PAGE_SHIFT. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson

[PATCH v5 19/29] poweppc/powernv/ioda2: Rework iommu_table creation

2015-03-09 Thread Alexey Kardashevskiy
This moves iommu_table creation to the beginning. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-

[PATCH v5 26/29] vfio: powerpc/spapr: Define v2 IOMMU

2015-03-09 Thread Alexey Kardashevskiy
The existing IOMMU code takes/releases ownership over the existing IOMMU tables created by the platform code, i.e. the tables remain in memory all the time. Also, the existing IOMMU requires VFIO_IOMMU_ENABLE call to start working as that's where we check the rlimit for locked pages. New IOMMU wil

[PATCH v5 00/29] powerpc/iommu/vfio: Enable Dynamic DMA windows

2015-03-09 Thread Alexey Kardashevskiy
This enables sPAPR defined feature called Dynamic DMA windows (DDW). Each Partitionable Endpoint (IOMMU group) has an address range on a PCI bus where devices are allowed to do DMA. These ranges are called DMA windows. By default, there is a single DMA window, 1 or 2GB big, mapped at zero on a PC

[PATCH v5 03/29] vfio: powerpc/spapr: Check that TCE page size is equal to it_page_size

2015-03-09 Thread Alexey Kardashevskiy
This checks that the TCE table page size is not bigger that the size of a page we just pinned and going to put its physical address to the table. Otherwise the hardware gets unwanted access to physical memory between the end of the actual page and the end of the aligned up TCE page. Since compoun

[PATCH v5 11/29] powerpc/iommu: Move tce_xxx callbacks from ppc_md to iommu_table

2015-03-09 Thread Alexey Kardashevskiy
This adds a iommu_table_ops struct and puts pointer to it into the iommu_table struct. This moves tce_build/tce_free/tce_get/tce_flush callbacks from ppc_md to the new struct where they really belong to. This adds the requirement for @it_ops to be initialized before calling iommu_init_table() to m

[PATCH v5 07/29] vfio: powerpc/spapr: Moving pinning/unpinning to helpers

2015-03-09 Thread Alexey Kardashevskiy
This is a pretty mechanical patch to make next patches simpler. New tce_iommu_unuse_page() helper does put_page() now but it might skip that after the memory registering patch applied. As we are here, this removes unnecessary checks for a value returned by pfn_to_page() as it cannot possibly retu

[PATCH v5 05/29] vfio: powerpc/spapr: Move locked_vm accounting to helpers

2015-03-09 Thread Alexey Kardashevskiy
There moves locked pages accounting to helpers. Later they will be reused for Dynamic DMA windows (DDW). This reworks debug messages to show the current value and the limit. This stores the locked pages number in the container so when unlocking the iommu table pointer won't be needed. This does n

[PATCH v5 09/29] vfio: powerpc/spapr: Rework attach/detach

2015-03-09 Thread Alexey Kardashevskiy
This is to make extended ownership and multiple groups support patches simpler for review. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 38 ++--- 1 file changed, 23 insertions(+), 15 deletions(-) diff

[PATCH v5 08/29] vfio: powerpc/spapr: Register memory

2015-03-09 Thread Alexey Kardashevskiy
The existing implementation accounts the whole DMA window in the locked_vm counter which is going to be even worse with multiple containers and huge DMA windows. This introduces 2 ioctls to register/unregister DMA memory which receive user space address and size of a memory region which needs to b

[PATCH v5 13/29] powerpc/spapr: vfio: Switch from iommu_table to new iommu_table_group

2015-03-09 Thread Alexey Kardashevskiy
Modern IBM POWERPC systems support multiple (currently two) TCE tables per IOMMU group (a.k.a. PE). This adds a iommu_table_group container for TCE tables. Right now just one table is supported. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 18 +++-- arch

[PATCH v5 29/29] vfio: powerpc/spapr: Support Dynamic DMA windows

2015-03-09 Thread Alexey Kardashevskiy
This adds create/remove window ioctls to create and remove DMA windows. sPAPR defines a Dynamic DMA windows capability which allows para-virtualized guests to create additional DMA windows on a PCI bus. The existing linux kernels use this new window to map the entire guest memory and switch to the

[PATCH v5 12/29] powerpc/iommu: Introduce iommu_table_alloc() helper

2015-03-09 Thread Alexey Kardashevskiy
This replaces multiple calls of kzalloc_node() with a new iommu_table_alloc() helper. Right now it calls kzalloc_node() but later it will be modified to allocate a iommu_table_group struct with a single iommu_table in it. Later the helper will allocate a iommu_table_group struct which embeds the i

[PATCH v5 14/29] vfio: powerpc/spapr: powerpc/iommu: Rework IOMMU ownership control

2015-03-09 Thread Alexey Kardashevskiy
This replaces iommu_take_ownership()/iommu_release_ownership() calls with the callback calls and it is up to the platform code to call iommu_take_ownership()/iommu_release_ownership() if needed. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 4 +-- arch/powerpc/ke

[PATCH v5 28/29] vfio: powerpc/spapr: Support multiple groups in one container if possible

2015-03-09 Thread Alexey Kardashevskiy
At the moment only one group per container is supported. POWER8 CPUs have more flexible design and allows naving 2 TCE tables per IOMMU group so we can relax this limitation and support multiple groups per container. This adds TCE table descriptors to a container and uses iommu_table_group_ops to

[PATCH v5 18/29] powerpc/iommu/powernv: Release replaced TCE

2015-03-09 Thread Alexey Kardashevskiy
At the moment writing new TCE value to the IOMMU table fails with EBUSY if there is a valid entry already. However PAPR specification allows the guest to write new TCE value without clearing it first. Another problem this patch is addressing is the use of pool locks for external IOMMU users such a

[PATCH v5 21/29] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_set_window

2015-03-09 Thread Alexey Kardashevskiy
This is a part of moving DMA window programming to an iommu_ops callback. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 85 --- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/arch/powe

[PATCH v5 17/29] powerpc/powernv/ioda/ioda2: Rework tce_build()/tce_free()

2015-03-09 Thread Alexey Kardashevskiy
The pnv_pci_ioda_tce_invalidate() helper invalidates TCE cache. It is supposed to be called on IODA1/2 and not called on p5ioc2. It receives start and end host addresses of TCE table. This approach makes it possible to get pnv_pci_ioda_tce_invalidate() unintentionally called on p5ioc2. Another issu

[PATCH v5 27/29] vfio: powerpc/spapr: powerpc/powernv/ioda2: Rework ownership

2015-03-09 Thread Alexey Kardashevskiy
Before the IOMMU user would take control over the IOMMU table belonging to a specific IOMMU group. This approach did not allow sharing tables between IOMMU groups attached to the same container. This introduces a new IOMMU ownership flavour when the user can not just control the existing IOMMU tab

[PATCH v5 22/29] powerpc/iommu: Split iommu_free_table into 2 helpers

2015-03-09 Thread Alexey Kardashevskiy
The iommu_free_table helper release memory it is using (the TCE table and @it_map) and release the iommu_table struct as well. We might not want the very last step as we store iommu_table in parent structures. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 1 + arch/

[PATCH v5 06/29] vfio: powerpc/spapr: Disable DMA mappings on disabled container

2015-03-09 Thread Alexey Kardashevskiy
At the moment DMA map/unmap requests are handled irrespective to the container's state. This allows the user space to pin memory which it might not be allowed to pin. This adds checks to MAP/UNMAP that the container is enabled, otherwise -EPERM is returned. Signed-off-by: Alexey Kardashevskiy --

[PATCH v5 02/29] vfio: powerpc/spapr: Do cleanup when releasing the group

2015-03-09 Thread Alexey Kardashevskiy
This clears the TCE table when a container is being closed as this is a good thing to leave the table clean before passing the ownership back to the host kernel. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 14 +++--- 1 file changed, 11 insertions(+), 3 d

Re: [PATCH v2 1/5] arm: KVM: export vcpi->pause state via MP_STATE ioctls

2015-03-09 Thread Christoffer Dall
Hi Alex, The subject of this change has a typo, and I also think it's not about exposing the pause state (that's just an internal name/concept), but about exposing the PSCI state, or simply the VCPU power state. On Mon, Mar 02, 2015 at 01:29:00PM +, Alex Bennée wrote: > To cleanly restore an

Re: [PATCH 5/6] target-arm/kvm64: fix save/restore of SPSR regs

2015-03-09 Thread Peter Maydell
On 9 March 2015 at 21:56, Christoffer Dall wrote: > this function, however, is not used only when migration, but should > generally cover the case where you want to synchronize QEMU's state into > KVM's state, right? So while it may not be harmful in currently > supported use cases, is there ever

Re: [PATCH v2 5/6] target-arm: kvm64 fix save/restore of SPSR regs

2015-03-09 Thread Christoffer Dall
On Wed, Mar 04, 2015 at 02:35:52PM +, Alex Bennée wrote: > From: Christoffer Dall > > The current code was negatively indexing the cpu state array and not > synchronizing banked spsr register state with the current mode's spsr > state, causing occasional failures with migration. > > Some mun

Re: [PATCH 5/6] target-arm/kvm64: fix save/restore of SPSR regs

2015-03-09 Thread Christoffer Dall
On Tue, Mar 03, 2015 at 11:28:21AM +, Alex Bennée wrote: > > Christoffer Dall writes: > > > Hi Alex, > > > > Seems like you accidentally sent out two copies of this patch, hopefully > > I'm reviewing the right one... > > Oops, perils of not wiping your output directory. I think it was just

Re: [PATCH] KVM: make halt_poll_ns static

2015-03-09 Thread Christian Borntraeger
Am 03.03.2015 um 22:46 schrieb Christian Borntraeger: [...] > > halt_poll_ns is used only locally. Make it static and remove > the initializer. > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 34310a8..58bc2a9 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@

Re: virtio fixes pull for 4.0?

2015-03-09 Thread Cornelia Huck
On Mon, 09 Mar 2015 17:43:19 +1030 Rusty Russell wrote: > "Michael S. Tsirkin" writes: > > virtio-balloon: do not call blocking ops when !TASK_RUNNING > > > > Rusty, it seems you prefer a different fix for this issue, > > while Cornelia prefers mine. Maybe both me and Cornelia misunderstand

Re: [PATCH] virtio_rpmsg: set DRIVER_OK before using device

2015-03-09 Thread Michael S. Tsirkin
On Sat, Mar 07, 2015 at 08:06:56PM +0100, Michael S. Tsirkin wrote: > virtio spec requires that all drivers set DRIVER_OK > before using devices. While rpmsg isn't yet > included in the virtio 1 spec, previous spec versions > also required this. > > virtio rpmsg violates this rule: is calls kick >

Re: [PATCH] virtio_rpmsg: set DRIVER_OK before using device

2015-03-09 Thread Michael S. Tsirkin
On Mon, Mar 09, 2015 at 05:39:20PM +1030, Rusty Russell wrote: > "Michael S. Tsirkin" writes: > > virtio spec requires that all drivers set DRIVER_OK > > before using devices. While rpmsg isn't yet > > included in the virtio 1 spec, previous spec versions > > also required this. > > > > virtio rpm

Re: virtio fixes pull for 4.0?

2015-03-09 Thread Rusty Russell
"Michael S. Tsirkin" writes: > Hi Rusty! > There are a bunch of (mostly virtio 1.0 related) fixes for virtio > that need to go into 4.0 I think. > virtio_blk: typo fix > virtio_blk: fix comment for virtio 1.0 OK, I've added these two. I tend to be overcautious after the merge window.

Re: [PATCH] virtio_rpmsg: set DRIVER_OK before using device

2015-03-09 Thread Rusty Russell
"Michael S. Tsirkin" writes: > virtio spec requires that all drivers set DRIVER_OK > before using devices. While rpmsg isn't yet > included in the virtio 1 spec, previous spec versions > also required this. > > virtio rpmsg violates this rule: is calls kick > before setting DRIVER_OK. > > The fix