Re: [PATCH 1/6] PPC: Add asm helpers for BE 32bit load/store

2014-06-17 Thread Alexander Graf
On 17.06.14 02:51, Paul Mackerras wrote: On Wed, Jun 11, 2014 at 12:33:46PM +0200, Alexander Graf wrote: >From assembly code we might not only have to explicitly BE access 64bit values, but sometimes also 32bit ones. Add helpers that allow for easy use of lwzx/stwx in their respective byte-reve

Re: [PATCH 5/6] KVM: PPC: Book3S HV: Access XICS in BE

2014-06-17 Thread Alexander Graf
On 17.06.14 03:02, Paul Mackerras wrote: On Wed, Jun 11, 2014 at 12:33:50PM +0200, Alexander Graf wrote: On the exit path from the guest we check what type of interrupt we received if we received one. This means we're doing hardware access to the XICS interrupt controller. However, when runnin

Re: [PATCH] powerpc/kvm: support to handle sw breakpoint

2014-06-17 Thread Alexander Graf
On 14.06.14 23:08, Madhavan Srinivasan wrote: This patch adds kernel side support for software breakpoint. Design is that, by using an illegal instruction, we trap to hypervisor via Emulation Assistance interrupt, where we check for the illegal instruction and accordingly we return to Host or Gu

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

2014-06-17 Thread Mihai Caraman
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 condition taking into account the logical partition id. With the

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

2014-06-17 Thread Alexander Graf
On 13.06.14 21:42, Scott Wood wrote: On Fri, 2014-06-13 at 16:55 +0200, Alexander Graf wrote: On 13.06.14 16:43, mihai.cara...@freescale.com wrote: -Original Message- From: Alexander Graf [mailto:ag...@suse.de] Sent: Thursday, June 12, 2014 8:05 PM To: Caraman Mihai Claudiu-B02008 Cc:

Re: [PATCH] KVM: PPC: Book3s PR: Disable AIL mode with OPAL

2014-06-17 Thread Alexander Graf
On 12.06.14 05:56, Paul Mackerras wrote: On Tue, Jun 10, 2014 at 07:23:00PM +0200, Alexander Graf wrote: When we're using PR KVM we must not allow the CPU to take interrupts in virtual mode, as the SLB does not contain host kernel mappings when running inside the guest context. To make sure we

Re: [PATCH] powerpc/kvm: support to handle sw breakpoint

2014-06-17 Thread Benjamin Herrenschmidt
On Tue, 2014-06-17 at 10:54 +0200, Alexander Graf wrote: > > Also, why don't we use twi always or something else that actually is > defined as illegal instruction? I would like to see this shared with > book3s_32 PR. twi will be directed to the guest on HV no ? We want a real illegal because th

Re: [PATCH] powerpc/kvm: support to handle sw breakpoint

2014-06-17 Thread Alexander Graf
On 17.06.14 11:22, Benjamin Herrenschmidt wrote: On Tue, 2014-06-17 at 10:54 +0200, Alexander Graf wrote: Also, why don't we use twi always or something else that actually is defined as illegal instruction? I would like to see this shared with book3s_32 PR. twi will be directed to the guest on

Re: [PATCH] powerpc/kvm: support to handle sw breakpoint

2014-06-17 Thread Benjamin Herrenschmidt
On Tue, 2014-06-17 at 11:25 +0200, Alexander Graf wrote: > On 17.06.14 11:22, Benjamin Herrenschmidt wrote: > > On Tue, 2014-06-17 at 10:54 +0200, Alexander Graf wrote: > >> Also, why don't we use twi always or something else that actually is > >> defined as illegal instruction? I would like to see

Re: [PATCH] powerpc/kvm: support to handle sw breakpoint

2014-06-17 Thread Alexander Graf
On 17.06.14 11:32, Benjamin Herrenschmidt wrote: On Tue, 2014-06-17 at 11:25 +0200, Alexander Graf wrote: On 17.06.14 11:22, Benjamin Herrenschmidt wrote: On Tue, 2014-06-17 at 10:54 +0200, Alexander Graf wrote: Also, why don't we use twi always or something else that actually is defined as i

[PATCH v2] KVM: PPC: Book3s PR: Disable AIL mode with OPAL

2014-06-17 Thread Alexander Graf
When we're using PR KVM we must not allow the CPU to take interrupts in virtual mode, as the SLB does not contain host kernel mappings when running inside the guest context. To make sure we get good performance for non-KVM tasks but still properly functioning PR KVM, let's just disable AIL wheneve

Re: [PATCH v2] KVM: PPC: Book3s PR: Disable AIL mode with OPAL

2014-06-17 Thread Paul Mackerras
On Tue, Jun 17, 2014 at 12:03:58PM +0200, Alexander Graf wrote: > When we're using PR KVM we must not allow the CPU to take interrupts > in virtual mode, as the SLB does not contain host kernel mappings > when running inside the guest context. > > To make sure we get good performance for non-KVM t

Re: [PATCH 5/6] KVM: PPC: Book3S HV: Access XICS in BE

2014-06-17 Thread Alexander Graf
On 17.06.14 10:37, Alexander Graf wrote: On 17.06.14 03:02, Paul Mackerras wrote: On Wed, Jun 11, 2014 at 12:33:50PM +0200, Alexander Graf wrote: On the exit path from the guest we check what type of interrupt we received if we received one. This means we're doing hardware access to the XICS

Re: [PATCH] powerpc/kvm: support to handle sw breakpoint

2014-06-17 Thread Madhavan Srinivasan
On Tuesday 17 June 2014 02:24 PM, Alexander Graf wrote: > > On 14.06.14 23:08, Madhavan Srinivasan wrote: >> This patch adds kernel side support for software breakpoint. >> Design is that, by using an illegal instruction, we trap to hypervisor >> via Emulation Assistance interrupt, where we check

Re: [PATCH] powerpc/kvm: support to handle sw breakpoint

2014-06-17 Thread Alexander Graf
On 17.06.14 13:07, Madhavan Srinivasan wrote: On Tuesday 17 June 2014 02:24 PM, Alexander Graf wrote: On 14.06.14 23:08, Madhavan Srinivasan wrote: This patch adds kernel side support for software breakpoint. Design is that, by using an illegal instruction, we trap to hypervisor via Emulation

Re: [PATCH] powerpc/kvm: support to handle sw breakpoint

2014-06-17 Thread Madhavan Srinivasan
On Tuesday 17 June 2014 03:02 PM, Benjamin Herrenschmidt wrote: > On Tue, 2014-06-17 at 11:25 +0200, Alexander Graf wrote: >> On 17.06.14 11:22, Benjamin Herrenschmidt wrote: >>> On Tue, 2014-06-17 at 10:54 +0200, Alexander Graf wrote: Also, why don't we use twi always or something else that a

Re: [PATCH] powerpc/kvm: support to handle sw breakpoint

2014-06-17 Thread Madhavan Srinivasan
On Tuesday 17 June 2014 03:13 PM, Alexander Graf wrote: > > On 17.06.14 11:32, Benjamin Herrenschmidt wrote: >> On Tue, 2014-06-17 at 11:25 +0200, Alexander Graf wrote: >>> On 17.06.14 11:22, Benjamin Herrenschmidt wrote: On Tue, 2014-06-17 at 10:54 +0200, Alexander Graf wrote: > Also, wh

Re: [PATCH] powerpc/kvm: support to handle sw breakpoint

2014-06-17 Thread Madhavan Srinivasan
On Tuesday 17 June 2014 04:38 PM, Alexander Graf wrote: > > On 17.06.14 13:07, Madhavan Srinivasan wrote: >> On Tuesday 17 June 2014 02:24 PM, Alexander Graf wrote: >>> On 14.06.14 23:08, Madhavan Srinivasan wrote: This patch adds kernel side support for software breakpoint. Design is th

Re: [PATCH] powerpc/kvm: support to handle sw breakpoint

2014-06-17 Thread Alexander Graf
On 17.06.14 13:20, Madhavan Srinivasan wrote: On Tuesday 17 June 2014 03:13 PM, Alexander Graf wrote: On 17.06.14 11:32, Benjamin Herrenschmidt wrote: On Tue, 2014-06-17 at 11:25 +0200, Alexander Graf wrote: On 17.06.14 11:22, Benjamin Herrenschmidt wrote: On Tue, 2014-06-17 at 10:54 +0200,

RE: [PATCH] KVM: PPC: e500mc: Relax tlb invalidation condition on vcpu schedule

2014-06-17 Thread mihai.cara...@freescale.com
> -Original Message- > From: Alexander Graf [mailto:ag...@suse.de] > Sent: Tuesday, June 17, 2014 12:09 PM > To: Wood Scott-B07421 > Cc: Caraman Mihai Claudiu-B02008; kvm-ppc@vger.kernel.org; > k...@vger.kernel.org; linuxppc-...@lists.ozlabs.org > Subject: Re: [PATCH] KVM: PPC: e500mc: Rela

Re: [PATCH 5/6] KVM: PPC: Book3S HV: Access XICS in BE

2014-06-17 Thread Paul Mackerras
On Tue, Jun 17, 2014 at 12:22:32PM +0200, Alexander Graf wrote: > > Eh, no. What we do is we read (good on BE, byte reversed) into r0. Then we > swab32() from r0 to r3 on LE, mr from r0 to r3 on BE. > > r3 gets truncated along the way. > > The reason we maintain r0 as wrong-endian is that we wri

Re: [PATCH 5/6] KVM: PPC: Book3S HV: Access XICS in BE

2014-06-17 Thread Alexander Graf
On 17.06.14 14:13, Paul Mackerras wrote: On Tue, Jun 17, 2014 at 12:22:32PM +0200, Alexander Graf wrote: Eh, no. What we do is we read (good on BE, byte reversed) into r0. Then we swab32() from r0 to r3 on LE, mr from r0 to r3 on BE. r3 gets truncated along the way. The reason we maintain r0

Re: [PATCH] powerpc/kvm: support to handle sw breakpoint

2014-06-17 Thread Alexander Graf
On 17.06.14 13:13, Madhavan Srinivasan wrote: On Tuesday 17 June 2014 04:38 PM, Alexander Graf wrote: On 17.06.14 13:07, Madhavan Srinivasan wrote: On Tuesday 17 June 2014 02:24 PM, Alexander Graf wrote: On 14.06.14 23:08, Madhavan Srinivasan wrote: This patch adds kernel side support for so

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

2014-06-17 Thread Scott Wood
On Tue, 2014-06-17 at 12:02 +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: [PATCH] KVM: PPC: e500mc: Relax tlb invalidation condition on vcpu schedule

2014-06-17 Thread Scott Wood
On Thu, 2014-06-12 at 19:04 +0200, Alexander Graf wrote: > On 06/12/2014 04:00 PM, Mihai Caraman wrote: > > @@ -140,12 +142,24 @@ static void kvmppc_core_vcpu_load_e500mc(struct > > kvm_vcpu *vcpu, int cpu) > > mtspr(SPRN_GDEAR, vcpu->arch.shared->dar); > > mtspr(SPRN_GESR, vcpu->arch.shar

[PATCH] KVM: PPC: Book3S PR: Handle hyp doorbell exits

2014-06-17 Thread Alexander Graf
If we're running PR KVM in HV mode, we may get hypervisor doorbell interrupts. Handle those the same way we treat normal doorbells. Signed-off-by: Alexander Graf --- arch/powerpc/kvm/book3s_pr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/b

Re: [PATCH 3/4] KVM: PPC: Book3S HV: Fix ABIv2 indirect branch issue

2014-06-17 Thread Alexander Graf
On 12.06.14 10:16, Anton Blanchard wrote: To establish addressability quickly, ABIv2 requires the target address of the function being called to be in r12. Signed-off-by: Anton Blanchard Thanks, applied to kvm-ppc-queue. Alex --- Index: b/arch/powerpc/kvm/book3s_hv_rmhandlers.S

Re: [PATCH 4/4] KVM: PPC: Assembly functions exported to modules need _GLOBAL_TOC()

2014-06-17 Thread Alexander Graf
On 12.06.14 10:16, Anton Blanchard wrote: Both kvmppc_hv_entry_trampoline and kvmppc_entry_trampoline are assembly functions that are exported to modules and also require a valid r2. As such we need to use _GLOBAL_TOC so we provide a global entry point that establishes the TOC (r2). Signed-off

[PATCH] KVM: PPC: Book3S PR: Fix ABIv2 on LE

2014-06-17 Thread Alexander Graf
We switched to ABIv2 on Little Endian systems now which gets rid of the dotted function names. Branch to the actual functions when we see such a system. Signed-off-by: Alexander Graf diff --git a/arch/powerpc/kvm/book3s_interrupts.S b/arch/powerpc/kvm/book3s_interrupts.S index e2c29e3..d044b8b

[PATCH] KVM: PPC: Book3S PR: Fix sparse endian checks

2014-06-17 Thread Alexander Graf
While sending sparse with endian checks over the code base, it triggered at some places that were missing casts or had wrong types. Fix them up. Signed-off-by: Alexander Graf diff --git a/arch/powerpc/kvm/book3s_pr_papr.c b/arch/powerpc/kvm/book3s_pr_papr.c index 52a63bf..f7c25c6 100644 --- a/a

[PATCH 0/7] KVM: PPC: Book3S HV: Enable on little endian hosts

2014-06-17 Thread Alexander Graf
So far we've been able to successfully run HV KVM on big endian hosts, but once you dive into little endian land things start to fall apart. This patch set enables HV KVM for little endian hosts. This should be the final piece left missing to get little endian systems fully en par with big endian

[PATCH 3/7] KVM: PPC: Book3S HV: Access guest VPA in BE

2014-06-17 Thread Alexander Graf
There are a few shared data structures between the host and the guest. Most of them get registered through the VPA interface. These data structures are defined to always be in big endian byte order, so let's make sure we always access them in big endian. Signed-off-by: Alexander Graf --- v1 ->

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

2014-06-17 Thread Alexander Graf
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 --- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 22 ++ 1 file changed, 14 insertions(+), 8 deletions(-) di

[PATCH 4/7] KVM: PPC: Book3S HV: Access host lppaca and shadow slb in BE

2014-06-17 Thread Alexander Graf
Some data structures are always stored in big endian. Among those are the LPPACA fields as well as the shadow slb. These structures might be shared with a hypervisor. So whenever we access those fields, make sure we do so in big endian byte order. Signed-off-by: Alexander Graf --- arch/powerpc/

[PATCH 1/7] PPC: Add asm helpers for BE 32bit load/store

2014-06-17 Thread Alexander Graf
>From assembly code we might not only have to explicitly BE access 64bit values, but sometimes also 32bit ones. Add helpers that allow for easy use of lwzx/stwx in their respective byte-reverse or native form. Signed-off-by: Alexander Graf CC: Benjamin Herrenschmidt --- v1 -> v2: - fix typo

[PATCH 2/7] KVM: PPC: Book3S HV: Make HTAB code LE host aware

2014-06-17 Thread Alexander Graf
When running on an LE host all data structures are kept in little endian byte order. However, the HTAB still needs to be maintained in big endian. So every time we access any HTAB we need to make sure we do so in the right byte order. Fix up all accesses to manually byte swap. Signed-off-by: Alex

[PATCH 7/7] KVM: PPC: Book3S HV: Enable for little endian hosts

2014-06-17 Thread Alexander Graf
Now that we've fixed all the issues that HV KVM code had on little endian hosts, we can enable it in the kernel configuration for users to play with. Signed-off-by: Alexander Graf --- arch/powerpc/kvm/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/powerpc/kvm/Kconfig b/arch/powe

[PATCH 5/7] KVM: PPC: Book3S HV: Access XICS in BE

2014-06-17 Thread Alexander Graf
On the exit path from the guest we check what type of interrupt we received if we received one. This means we're doing hardware access to the XICS interrupt controller. However, when running on a little endian system, this access is byte reversed. So let's make sure to swizzle the bytes back agai

RE: [PATCH v2] KVM: PPC: e500mc: Enhance tlb invalidation condition on vcpu schedule

2014-06-17 Thread mihai.cara...@freescale.com
> -Original Message- > From: Wood Scott-B07421 > Sent: Tuesday, June 17, 2014 6:36 PM > To: Caraman Mihai Claudiu-B02008 > Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; linuxppc- > d...@lists.ozlabs.org > Subject: Re: [PATCH v2] KVM: PPC: e500mc: Enhance tlb invalidation > condition on

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

2014-06-17 Thread Scott Wood
On Tue, 2014-06-17 at 14:04 -0500, Caraman Mihai Claudiu-B02008 wrote: > > -Original Message- > > From: Wood Scott-B07421 > > Sent: Tuesday, June 17, 2014 6:36 PM > > To: Caraman Mihai Claudiu-B02008 > > Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; linuxppc- > > d...@lists.ozlabs.org

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

2014-06-17 Thread Mihai Caraman
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 condition keeping last_vcpu_on_cpu per logical partition id. With

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

2014-06-17 Thread Scott Wood
On Tue, 2014-06-17 at 22:09 +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: [PATCH v3] KVM: PPC: e500mc: Enhance tlb invalidation condition on vcpu schedule

2014-06-17 Thread mihai.cara...@freescale.com
> > -static DEFINE_PER_CPU(struct kvm_vcpu *, last_vcpu_on_cpu); > > +static DEFINE_PER_CPU(struct kvm_vcpu * [KVMPPC_NR_LPIDS], > last_vcpu_on_cpu); > > Hmm, I didn't know you could express types like that. Is this special > syntax that only works for typeof? Yes, AFAIK. > No space after * Ch

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

2014-06-17 Thread Scott Wood
On Tue, 2014-06-17 at 14:42 -0500, Caraman Mihai Claudiu-B02008 wrote: > > > -static DEFINE_PER_CPU(struct kvm_vcpu *, last_vcpu_on_cpu); > > > +static DEFINE_PER_CPU(struct kvm_vcpu * [KVMPPC_NR_LPIDS], > > last_vcpu_on_cpu); > > > > Hmm, I didn't know you could express types like that. Is this

RE: [PATCH v3] KVM: PPC: e500mc: Enhance tlb invalidation condition on vcpu schedule

2014-06-17 Thread mihai.cara...@freescale.com
> -Original Message- > From: Wood Scott-B07421 > Sent: Tuesday, June 17, 2014 10:48 PM > To: Caraman Mihai Claudiu-B02008 > Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; linuxppc- > d...@lists.ozlabs.org > Subject: Re: [PATCH v3] KVM: PPC: e500mc: Enhance tlb invalidation > condition o

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

2014-06-17 Thread Scott Wood
On Tue, 2014-06-17 at 15:02 -0500, Caraman Mihai Claudiu-B02008 wrote: > > -Original Message- > > From: Wood Scott-B07421 > > Sent: Tuesday, June 17, 2014 10:48 PM > > To: Caraman Mihai Claudiu-B02008 > > Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; linuxppc- > > d...@lists.ozlabs.org

RE: [PATCH v3] KVM: PPC: e500mc: Enhance tlb invalidation condition on vcpu schedule

2014-06-17 Thread mihai.cara...@freescale.com
> -Original Message- > From: Wood Scott-B07421 > Sent: Tuesday, June 17, 2014 11:05 PM > To: Caraman Mihai Claudiu-B02008 > Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; linuxppc- > d...@lists.ozlabs.org > Subject: Re: [PATCH v3] KVM: PPC: e500mc: Enhance tlb invalidation > condition o

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

2014-06-17 Thread Alexander Graf
On 17.06.14 22:36, mihai.cara...@freescale.com wrote: -Original Message- From: Wood Scott-B07421 Sent: Tuesday, June 17, 2014 11:05 PM To: Caraman Mihai Claudiu-B02008 Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; linuxppc- d...@lists.ozlabs.org Subject: Re: [PATCH v3] KVM: PPC: e50