Re: [PATCH 4/4] vfio powerpc: added real mode support

2013-02-14 Thread Paul Mackerras
On Mon, Feb 11, 2013 at 11:12:43PM +1100, a...@ozlabs.ru wrote: > From: Alexey Kardashevskiy > > The patch allows the host kernel to handle H_PUT_TCE request > without involving QEMU in it what should save time on switching > from the kernel to QEMU and back. > > The patch adds an IOMMU ID param

Re: [PATCH 2/4] powerpc kvm: added multiple TCEs requests support

2013-02-14 Thread Paul Mackerras
On Mon, Feb 11, 2013 at 11:12:41PM +1100, a...@ozlabs.ru wrote: > +static long emulated_h_put_tce(struct kvmppc_spapr_tce_table *stt, > + unsigned long ioba, unsigned long tce) > +{ > + unsigned long idx = ioba >> SPAPR_TCE_SHIFT; > + struct page *page; > + u64 *tbl; > + >

Re: [PATCH 3/4] powerpc: preparing to support real mode optimization

2013-02-14 Thread Paul Mackerras
On Mon, Feb 11, 2013 at 11:12:42PM +1100, a...@ozlabs.ru wrote: > From: Alexey Kardashevskiy > > he current VFIO-on-POWER implementation supports only user mode > driven mapping, i.e. QEMU is sending requests to map/unmap pages. > However this approach is really slow in really fast hardware so >

Re: [PATCH 1/4] powerpc: lookup_linux_pte has been made public

2013-02-14 Thread Paul Mackerras
On Mon, Feb 11, 2013 at 11:12:40PM +1100, a...@ozlabs.ru wrote: > From: Alexey Kardashevskiy > > The lookup_linux_pte() function returns a linux PTE which > is required to convert KVM guest physical address into host real > address in real mode. > > This convertion will be used by upcoming suppo

[PATCH 07/12] KVM: PPC: E500: Make clear_tlb_refs and clear_tlb1_bitmap static

2013-02-14 Thread Alexander Graf
Host shadow TLB flushing is logic that the guest TLB code should have no insight about. Declare the internal clear_tlb_refs and clear_tlb1_bitmap functions static to the host TLB handling file. Instead of these, we can use the already exported kvmppc_core_flush_tlb(). This gives us a common API ac

[PATCH 06/12] KVM: PPC: e500: Implement TLB1-in-TLB0 mapping

2013-02-14 Thread Alexander Graf
When a host mapping fault happens in a guest TLB1 entry today, we map the translated guest entry into the host's TLB1. This isn't particularly clever when the guest is mapped by normal 4k pages, since these would be a lot better to put into TLB0 instead. This patch adds the required logic to map

[PATCH 08/12] KVM: PPC: E500: Remove kvmppc_e500_tlbil_all usage from guest TLB code

2013-02-14 Thread Alexander Graf
The guest TLB handling code should not have any insight into how the host TLB shadow code works. kvmppc_e500_tlbil_all() is a function that is used for distinction between e500v2 and e500mc (E.HV) on how to flush shadow entries. This function really is private between the e500.c/e500mc.c file and

[PATCH 09/12] KVM: PPC: booke: use vcpu reference from thread_struct

2013-02-14 Thread Alexander Graf
From: Bharat Bhushan Like other places, use thread_struct to get vcpu reference. Signed-off-by: Bharat Bhushan Signed-off-by: Alexander Graf --- arch/powerpc/include/asm/reg.h |2 -- arch/powerpc/kernel/asm-offsets.c |2 +- arch/powerpc/kvm/booke_interrupts.S |6 ++ 3 f

[PATCH 10/12] KVM: PPC: booke: Allow multiple exception types

2013-02-14 Thread Alexander Graf
From: Bharat Bhushan Current kvmppc_booke_handlers uses the same macro (KVM_HANDLER) and all handlers are considered to be the same size. This will not be the case if we want to use different macros for different handlers. This patch improves the kvmppc_booke_handler so that it can support diffe

[PATCH 02/12] KVM: PPC: E500: Explicitly mark shadow maps invalid

2013-02-14 Thread Alexander Graf
When we invalidate shadow TLB maps on the host, we don't mark them as not valid. But we should. Fix this by removing the E500_TLB_VALID from their flags when invalidating. Signed-off-by: Alexander Graf --- arch/powerpc/kvm/e500_tlb.c | 13 ++--- 1 files changed, 10 insertions(+), 3 de

[PATCH 11/12] booke: Added DBCR4 SPR number

2013-02-14 Thread Alexander Graf
From: Bharat Bhushan Signed-off-by: Bharat Bhushan Signed-off-by: Alexander Graf --- arch/powerpc/include/asm/reg_booke.h |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/reg_booke.h b/arch/powerpc/include/asm/reg_booke.h index e07e6af..b417de3

[PATCH 03/12] KVM: PPC: E500: Propagate errors when shadow mapping

2013-02-14 Thread Alexander Graf
When shadow mapping a page, mapping this page can fail. In that case we don't have a shadow map. Take this case into account, otherwise we might end up writing bogus TLB entries into the host TLB. While at it, also move the write_stlbe() calls into the respective TLBn handlers. Signed-off-by: Al

[PATCH 12/12] KVM: PPC: BookE: Handle alignment interrupts

2013-02-14 Thread Alexander Graf
When the guest triggers an alignment interrupt, we don't handle it properly today and instead BUG_ON(). This really shouldn't happen. Instead, we should just pass the interrupt back into the guest so it can deal with it. Reported-by: Gao Guanhua-B22826 Tested-by: Gao Guanhua-B22826 Signed-off-b

[PATCH 01/12] KVM: PPC: E500: Move write_stlbe higher

2013-02-14 Thread Alexander Graf
Later patches want to call the function and it doesn't have dependencies on anything below write_host_tlbe. Move it higher up in the file. Signed-off-by: Alexander Graf --- arch/powerpc/kvm/e500_tlb.c | 32 1 files changed, 16 insertions(+), 16 deletions(-) d

[PATCH 04/12] KVM: PPC: e500: Call kvmppc_mmu_map for initial mapping

2013-02-14 Thread Alexander Graf
When emulating tlbwe, we want to automatically map the entry that just got written in our shadow TLB map, because chances are quite high that it's going to be used very soon. Today this happens explicitly, duplicating all the logic that is in kvmppc_mmu_map() already. Just call that one instead.

[PULL 00/14] ppc patch queue 2013-02-15

2013-02-14 Thread Alexander Graf
Hi Marcelo / Gleb, This is my current patch queue for ppc. Please pull. Highlights of this queue drop are: - BookE: Fast mapping support for 4k backed memory - BookE: Handle alignment interrupts Alex The following changes since commit cbd29cb6e38af6119df2cdac0c58acf0e85c177e: Jan Kiszk

[PATCH 7/9] KVM: PPC: Book3S HV: Add support for real mode ICP in XICS emulation

2013-02-14 Thread Paul Mackerras
From: Benjamin Herrenschmidt This adds an implementation of the XICS hypercalls in real mode for HV KVM, which allows us to avoid exiting the guest MMU context on all threads for a variety of operations such as fetching a pending interrupt, EOI of messages, IPIs, etc. Signed-off-by: Benjamin Her

[PATCH 6/9] KVM: PPC: Book3S HV: Speed up wakeups of CPUs on HV KVM

2013-02-14 Thread Paul Mackerras
From: Benjamin Herrenschmidt Currently, we wake up a CPU by sending a host IPI with smp_send_reschedule() to thread 0 of that core, which will take all threads out of the guest, and cause them to re-evaluate their interrupt status on the way back in. This adds a mechanism to differentiate real h

[PATCH 2/9] KVM: PPC: Remove unused argument to kvmppc_core_dequeue_external

2013-02-14 Thread Paul Mackerras
Currently kvmppc_core_dequeue_external() takes a struct kvm_interrupt * argument and does nothing with it, in any of its implementations. This removes it in order to make things easier for forthcoming in-kernel interrupt controller emulation code. Signed-off-by: Paul Mackerras --- arch/powerpc/i

[PATCH 3/9] KVM: PPC: Book3S: Add kernel emulation for the XICS interrupt controller

2013-02-14 Thread Paul Mackerras
From: Benjamin Herrenschmidt This adds in-kernel emulation of the XICS (eXternal Interrupt Controller Specification) interrupt controller specified by PAPR, for both HV and PR KVM guests. This adds a new KVM_CREATE_IRQCHIP_ARGS ioctl, which is like KVM_CREATE_IRQCHIP in that it indicates that th

[PATCH 0/9] In-kernel XICS interrupt controller emulation

2013-02-14 Thread Paul Mackerras
This patch series implements in-kernel emulation of the XICS interrupt controller architecture defined in PAPR (Power Architecture Platform Requirements, the document that defines IBM's pSeries platform architecture). One of the things I have done in this version is to provide a way for this to co

[PATCH 5/9] KVM: PPC: Book3S: Facilities to save/restore XICS presentation ctrler state

2013-02-14 Thread Paul Mackerras
This adds the ability for userspace to save and restore the state of the XICS interrupt presentation controllers (ICPs) via the KVM_GET/SET_ONE_REG interface. Since there is one ICP per vcpu, we simply define a new 64-bit register in the ONE_REG space for the ICP state. The state includes the CPU

[PATCH 4/9] KVM: PPC: Book3S: Generalize interfaces to interrupt controller emulation

2013-02-14 Thread Paul Mackerras
This makes the XICS interrupt controller emulation code export a struct containing function pointers for the various calls into the XICS code. The generic book3s code then uses these function pointers instead of calling directly into the XICS code (except for the XICS instantiation function). This

[PATCH 8/9] KVM: PPC: Book3S HV: Improve real-mode handling of external interrupts

2013-02-14 Thread Paul Mackerras
This streamlines our handling of external interrupts that come in while we're in the guest. First, when waking up a hardware thread that was napping, we split off the "napping due to H_CEDE" case earlier, and use the code that handles an external interrupt (0x500) in the guest to handle that too.

[PATCH 1/9] KVM: PPC: Book3S: Add infrastructure to implement kernel-side RTAS calls

2013-02-14 Thread Paul Mackerras
From: Michael Ellerman For pseries machine emulation, in order to move the interrupt controller code to the kernel, we need to intercept some RTAS calls in the kernel itself. This adds an infrastructure to allow in-kernel handlers to be registered for RTAS services by name. A new ioctl, KVM_PPC_

[PATCH 9/9] KVM: PPC: Book3S: Add support for ibm,int-on/off RTAS calls

2013-02-14 Thread Paul Mackerras
This adds support for the ibm,int-on and ibm,int-off RTAS calls to the in-kernel XICS emulation and corrects the handling of the saved priority by the ibm,set-xive RTAS call. With this, ibm,int-off sets the specified interrupt's priority in its saved_priority field and sets the priority to 0xff (t