[PATCH 0/5] Some fixes and improvements for PR KVM

2013-06-22 Thread Paul Mackerras
This series of 5 patches is against the KVM next branch. It fixes some bugs in PR-style KVM on Book 3S PPC and adds support for the guest using 1TB segments as well as 256MB segments. My ultimate goal is to make it possible to configure both HV and PR KVM into the same kernel binary, and this is

[PATCH 3/5] KVM: PPC: Book3S PR: Don't keep scanning HPTEG after we find a match

2013-06-22 Thread Paul Mackerras
The loop in kvmppc_mmu_book3s_64_xlate() that looks up a translation in the guest hashed page table (HPT) keeps going if it finds an HPTE that matches but doesn't allow access. This is incorrect; it is different from what the hardware does, and there should never be more than one matching HPTE any

[PATCH 5/5] KVM: PPC: Book3S PR: Allow guest to use 1TB segments

2013-06-22 Thread Paul Mackerras
With this, the guest can use 1TB segments as well as 256MB segments. Since we now have the situation where a single emulated guest segment could correspond to multiple shadow segments (as the shadow segments are still 256MB segments), this adds a new kvmppc_mmu_flush_segment() to scan for all shado

[PATCH 2/5] KVM: PPC: Book3S PR: Fix invalidation of SLB entry 0 on guest entry

2013-06-22 Thread Paul Mackerras
On entering a PR KVM guest, we invalidate the whole SLB before loading up the guest entries. We do this using an slbia instruction, which invalidates all entries except entry 0, followed by an slbie to invalidate entry 0. However, the slbie turns out to be ineffective in some circumstances (speci

[PATCH 4/5] KVM: PPC: Book3S PR: Invalidate SLB entries properly

2013-06-22 Thread Paul Mackerras
At present, if the guest creates a valid SLB (segment lookaside buffer) entry with the slbmte instruction, then invalidates it with the slbie instruction, then reads the entry with the slbmfee/slbmfev instructions, the result of the slbmfee will have the valid bit set, even though the entry is not

[PATCH 1/5] KVM: PPC: Book3S PR: Fix proto-VSID calculations

2013-06-22 Thread Paul Mackerras
This makes sure the calculation of the proto-VSIDs used by PR KVM is done with 64-bit arithmetic. Since vcpu3s->context_id[] is int, when we do vcpu3s->context_id[0] << ESID_BITS the shift will be done with 32-bit instructions, possibly leading to significant bits getting lost, as the context id c

Re: [PATCH 3/4] KVM: PPC: Add support for IOMMU in-kernel handling

2013-06-22 Thread Alexey Kardashevskiy
On 06/21/2013 12:55 AM, Alex Williamson wrote: > On Thu, 2013-06-20 at 18:48 +1000, Alexey Kardashevskiy wrote: >> On 06/20/2013 05:47 PM, Benjamin Herrenschmidt wrote: >>> On Thu, 2013-06-20 at 15:28 +1000, David Gibson wrote: > Just out of curiosity - would not get_file() and fput_atomic() on

Re: [PATCH 3/4] KVM: PPC: Add support for IOMMU in-kernel handling

2013-06-22 Thread David Gibson
On Thu, Jun 20, 2013 at 08:55:13AM -0600, Alex Williamson wrote: > On Thu, 2013-06-20 at 18:48 +1000, Alexey Kardashevskiy wrote: > > On 06/20/2013 05:47 PM, Benjamin Herrenschmidt wrote: > > > On Thu, 2013-06-20 at 15:28 +1000, David Gibson wrote: > > >>> Just out of curiosity - would not get_file

Re: [PATCH 3/4] KVM: PPC: Add support for IOMMU in-kernel handling

2013-06-22 Thread Alex Williamson
On Sat, 2013-06-22 at 22:03 +1000, David Gibson wrote: > On Thu, Jun 20, 2013 at 08:55:13AM -0600, Alex Williamson wrote: > > On Thu, 2013-06-20 at 18:48 +1000, Alexey Kardashevskiy wrote: > > > On 06/20/2013 05:47 PM, Benjamin Herrenschmidt wrote: > > > > On Thu, 2013-06-20 at 15:28 +1000, David G

Re: [PATCH 3/5] KVM: PPC: Book3S PR: Don't keep scanning HPTEG after we find a match

2013-06-22 Thread Alexander Graf
On 22.06.2013, at 09:14, Paul Mackerras wrote: > The loop in kvmppc_mmu_book3s_64_xlate() that looks up a translation > in the guest hashed page table (HPT) keeps going if it finds an > HPTE that matches but doesn't allow access. This is incorrect; it > is different from what the hardware does,

Re: [PATCH 4/5] KVM: PPC: Book3S PR: Invalidate SLB entries properly

2013-06-22 Thread Alexander Graf
On 22.06.2013, at 09:15, Paul Mackerras wrote: > At present, if the guest creates a valid SLB (segment lookaside buffer) > entry with the slbmte instruction, then invalidates it with the slbie > instruction, then reads the entry with the slbmfee/slbmfev instructions, > the result of the slbmfee w

Re: [PATCH 0/5] Some fixes and improvements for PR KVM

2013-06-22 Thread Alexander Graf
On 22.06.2013, at 09:12, Paul Mackerras wrote: > This series of 5 patches is against the KVM next branch. It fixes > some bugs in PR-style KVM on Book 3S PPC and adds support for the > guest using 1TB segments as well as 256MB segments. My ultimate goal > is to make it possible to configure bot

Re: [PATCH 3/4] KVM: PPC: Add support for IOMMU in-kernel handling

2013-06-22 Thread Benjamin Herrenschmidt
On Sat, 2013-06-22 at 22:03 +1000, David Gibson wrote: > I think the interface should not take the group fd, but the container > fd. Holding a reference to *that* would keep the necessary things > around. But more to the point, it's the right thing semantically: > > The container is essentially

Re: [PATCH 4/5] KVM: PPC: Book3S PR: Invalidate SLB entries properly

2013-06-22 Thread Paul Mackerras
On Sat, Jun 22, 2013 at 07:48:05PM +0200, Alexander Graf wrote: > > On 22.06.2013, at 09:15, Paul Mackerras wrote: > > > At present, if the guest creates a valid SLB (segment lookaside buffer) > > entry with the slbmte instruction, then invalidates it with the slbie > > instruction, then reads th

Re: [PATCH 4/5] KVM: PPC: Book3S PR: Invalidate SLB entries properly

2013-06-22 Thread Alexander Graf
On 23.06.2013, at 01:30, Paul Mackerras wrote: > On Sat, Jun 22, 2013 at 07:48:05PM +0200, Alexander Graf wrote: >> >> On 22.06.2013, at 09:15, Paul Mackerras wrote: >> >>> At present, if the guest creates a valid SLB (segment lookaside buffer) >>> entry with the slbmte instruction, then invali