[PATCH] powerpc: kvm: make the setup of hpte under the protection of KVMPPC_RMAP_LOCK_BIT

2014-07-28 Thread Liu Ping Fan
In current code, the setup of hpte is under the risk of race with mmu_notifier_invalidate, i.e we may setup a hpte with a invalid pfn. Resolve this issue by sync the two actions by KVMPPC_RMAP_LOCK_BIT. Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com ---

Re: [PATCH] powerpc: kvm: make the setup of hpte under the protection of KVMPPC_RMAP_LOCK_BIT

2014-07-28 Thread Benjamin Herrenschmidt
On Mon, 2014-07-28 at 14:09 +0800, Liu Ping Fan wrote: In current code, the setup of hpte is under the risk of race with mmu_notifier_invalidate, i.e we may setup a hpte with a invalid pfn. Resolve this issue by sync the two actions by KVMPPC_RMAP_LOCK_BIT. Please describe the race you think

Re: [PATCH] powerpc: kvm: make the setup of hpte under the protection of KVMPPC_RMAP_LOCK_BIT

2014-07-28 Thread Liu ping fan
Hope I am right. Take the following seq as an example if (hptep[0] HPTE_V_VALID) { /* HPTE was previously valid, so we need to invalidate it */ unlock_rmap(rmap); hptep[0] |= HPTE_V_ABSENT; kvmppc_invalidate_hpte(kvm, hptep, index); /* don't lose previous R and C bits */ r |= hptep[1]

RE: [PATCH 1/6 v2] KVM: PPC: Book3E: Use common defines for SPE/FP/AltiVec int numbers

2014-07-28 Thread mihai.cara...@freescale.com
-Original Message- From: Wood Scott-B07421 Sent: Saturday, July 26, 2014 3:11 AM To: Caraman Mihai Claudiu-B02008 Cc: Alexander Graf; kvm-ppc@vger.kernel.org; k...@vger.kernel.org; linuxppc-...@lists.ozlabs.org Subject: Re: [PATCH 1/6 v2] KVM: PPC: Book3E: Use common defines for

Re: [RFC PATCH 0/5] Improve PPC instruction emulation

2014-07-28 Thread Alexander Graf
On 19.07.14 12:14, Paul Mackerras wrote: This series aims to increase the range of instructions that KVM on PPC can emulate and reduce code duplication by using the existing instruction emulation code from arch/powerpc/lib/sstep.c for KVM. The ultimate goal is to make PR KVM run faster on the

Re: [RFC PATCH 1/5] powerpc: Split out instruction analysis part of emulate_step()

2014-07-28 Thread Alexander Graf
On 19.07.14 12:14, Paul Mackerras wrote: This splits out the instruction analysis part of emulate_step() into a separate analyse_instr() function, which decodes the instruction, but doesn't execute any load or store instructions. It does execute integer instructions and branches which can be

Re: [RFC PATCH 4/5] KVM: PPC: Use analyse_instr() in kvmppc_emulate_instruction()

2014-07-28 Thread Alexander Graf
On 19.07.14 12:14, Paul Mackerras wrote: This changes kvmppc_emulate_instruction() to use the common instruction decoding code from arch/powerpc/lib/sstep.c. This expands the set of instructions that we recognize to include all of the integer load and store instructions except for the string

Re: [RFC PATCH 5/5] KVM: PPC: Book3S: Make kvmppc_handle_load/store handle any load or store

2014-07-28 Thread Alexander Graf
On 19.07.14 12:14, Paul Mackerras wrote: At present, kvmppc_handle_load and kvmppc_handle_store only handle emulated MMIO loads and stores. This extends them to be able to handle loads and stores to guest memory as well. This is so that kvmppc_emulate_instruction can be used to emulate loads

Re: [PATCH 3/3] KVM: PPC: Book3S: Make kvmppc_ld return a more accurate error indication

2014-07-28 Thread Alexander Graf
On 19.07.14 09:59, Paul Mackerras wrote: At present, kvmppc_ld calls kvmppc_xlate, and if kvmppc_xlate returns any error indication, it returns -ENOENT, which is taken to mean an HPTE not found error. However, the error could have been a segment found (no SLB entry) or a permission error.

Re: [PATCH 0/3] Fixes for PPC Book3S KVM

2014-07-28 Thread Alexander Graf
On 19.07.14 09:59, Paul Mackerras wrote: Here are three small fixes for the PPC Book 3S code. The first should go into 3.16 if possible, I think, or if not, certainly 3.17. The remaining two are less urgent and should go into 3.17. The patch series is against Alex Graf's kvm-ppc-queue

Re: [PATCH v3] Use the POWER8 Micro Partition Prefetch Engine in KVM HV on POWER8

2014-07-28 Thread Alexander Graf
On 18.07.14 06:10, Stewart Smith wrote: Alexander Graf ag...@suse.de writes: diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 1eaea2d..5769497 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h @@ -305,6

Re: [PATCH v4 0/2] Use the POWER8 Micro Partition Prefetch Engine in KVM HV

2014-07-28 Thread Alexander Graf
On 18.07.14 06:18, Stewart Smith wrote: changes since v3: - use kvmppc namespace - MPP_BUFFER_ORDER of 3 not 4, as we only need 32k and it's already 32k aligned - split out kvmppc_vcore_create in separate patch - give a variable a better name: s/tmp/mpp_addr/ - logmpp becomes static inline

Re: [PATCH 2/6] KVM: PPC: BOOKE: Force MSR_DE in rfci if guest is under debug

2014-07-28 Thread Alexander Graf
On 11.07.14 10:38, Bharat Bhushan wrote: When userspace (QEMU) is using the debug resource to debug guest then we want MSR_DE to be always set. This patch adds missing MSR_DE setting in rfci instruction. Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com Shouldn't this be in

Re: [PATCH 6/6] KVM: PPC: BOOKE: Emulate debug registers and exception

2014-07-28 Thread Alexander Graf
On 11.07.14 10:39, Bharat Bhushan wrote: This patch emulates debug registers and debug exception to support guest using debug resource. This enables running gdb/kgdb etc in guest. On BOOKE architecture we cannot share debug resources between QEMU and guest because: When QEMU is using

Re: [PATCH] KVM: PPC: BOOK3S: HV: Update compute_tlbie_rb to handle 16MB base page

2014-07-28 Thread Alexander Graf
On 27.06.14 15:35, Aneesh Kumar K.V wrote: When calculating the lower bits of AVA field, use the shift count based on the base page size. Also add the missing segment size and remove stale comment. Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com Thanks, applied to

Re: [PATCH 00/33] KVM: PPC: Fix IRQ race in magic page code

2014-07-28 Thread Alexander Graf
On 25.06.14 02:21, Scott Wood wrote: On Wed, 2014-06-25 at 01:40 +0200, Alexander Graf wrote: On 25.06.14 01:15, Scott Wood wrote: On Wed, 2014-06-25 at 00:41 +0200, Alexander Graf wrote: On 24.06.14 20:53, Scott Wood wrote: The timer interrupt works, but I'm not fully convinced that it's a

[PATCH 0/7] KVM: PPC: Prepare for shared kernel / kvm emulation code

2014-07-28 Thread Alexander Graf
Paul recently posted a nice patch set that started to make kvm code use the already existing in-kernel instruction emulator. Some bits from my previous attempt to implement yet another instruction emulator can and should be reused for that approach as well. So this patch set gathers all the bits

[PATCH 3/7] KVM: PPC: Remove kvmppc_bad_hva()

2014-07-28 Thread Alexander Graf
We have a proper define for invalid HVA numbers. Use those instead of the ppc specific kvmppc_bad_hva(). Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/powerpc.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/powerpc/kvm/powerpc.c

[PATCH 7/7] KVM: PPC: Expose helper functions for data/inst faults

2014-07-28 Thread Alexander Graf
We're going to implement guest code interpretation in KVM for some rare corner cases. This code needs to be able to inject data and instruction faults into the guest when it encounters them. Expose generic APIs to do this in a reasonably subarch agnostic fashion. Signed-off-by: Alexander Graf

[PATCH 5/7] KVM: PPC: Handle magic page in kvmppc_ld/st

2014-07-28 Thread Alexander Graf
We use kvmppc_ld and kvmppc_st to emulate load/store instructions that may as well access the magic page. Special case it out so that we can properly access it. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/include/asm/kvm_book3s.h | 7 +++

[PATCH 6/7] KVM: PPC: Separate loadstore emulation from priv emulation

2014-07-28 Thread Alexander Graf
Today the instruction emulator can get called via 2 separate code paths. It can either be called by MMIO emulation detection code or by privileged instruction traps. This is bad, as both code paths prepare the environment differently. For MMIO emulation we already know the virtual address we

[PATCH 1/7] KVM: PPC: Implement kvmppc_xlate for all targets

2014-07-28 Thread Alexander Graf
We have a nice API to find the translated GPAs of a GVA including protection flags. So far we only use it on Book3S, but there's no reason the same shouldn't be used on BookE as well. Implement a kvmppc_xlate() version for BookE and clean it up to make it more readable in general. Signed-off-by:

[PATCH 2/7] KVM: PPC: Move kvmppc_ld/st to common code

2014-07-28 Thread Alexander Graf
We have enough common infrastructure now to resolve GVA-GPA mappings at runtime. With this we can move our book3s specific helpers to load / store in guest virtual address space to common code as well. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/include/asm/kvm_book3s.h | 2 +-

[PATCH] KVM: PPC: Remove 440 support

2014-07-28 Thread Alexander Graf
The 440 target hasn't been properly functioning for a few releases and before I was the only one who fixes a very serious bug that indicates to me that nobody used it before either. Furthermore KVM on 440 is slow to the extent of unusable. We don't have to carry along completely unused code.

Re: [PATCH 1/6] KVM: PPC: BOOKE: No need to set DBCR0_EDM in guest visible register

2014-07-28 Thread Scott Wood
On Fri, 2014-07-11 at 14:08 +0530, Bharat Bhushan wrote: This is not used and even I do not remember why this was added in first place. Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com --- arch/powerpc/kvm/booke.c | 2 -- 1 file changed, 2 deletions(-) diff --git

Re: [PATCH 2/6] KVM: PPC: BOOKE: Force MSR_DE in rfci if guest is under debug

2014-07-28 Thread Scott Wood
On Fri, 2014-07-11 at 14:08 +0530, Bharat Bhushan wrote: When userspace (QEMU) is using the debug resource to debug guest then we want MSR_DE to be always set. This patch adds missing MSR_DE setting in rfci instruction. Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com ---

Re: [PATCH 5/6] KVM: PPC: BOOKE: Allow guest to change MSR_DE

2014-07-28 Thread Scott Wood
On Fri, 2014-07-11 at 14:09 +0530, Bharat Bhushan wrote: When userspace is debugging guest then MSR_DE is always set and MSRP_DEP is set so that guest cannot change MSR_DE. Guest debug resources are not yet emulated, So there seems no reason we should stop guest controlling MSR_DE. Also a

Re: [PATCH 6/6] KVM: PPC: BOOKE: Emulate debug registers and exception

2014-07-28 Thread Scott Wood
On Fri, 2014-07-11 at 14:09 +0530, Bharat Bhushan wrote: This patch emulates debug registers and debug exception to support guest using debug resource. This enables running gdb/kgdb etc in guest. On BOOKE architecture we cannot share debug resources between QEMU and guest because: When

Re: [PATCH 6/6] KVM: PPC: BOOKE: Emulate debug registers and exception

2014-07-28 Thread Scott Wood
On Mon, 2014-07-28 at 16:04 +0200, Alexander Graf wrote: On 11.07.14 10:39, Bharat Bhushan wrote: This patch emulates debug registers and debug exception to support guest using debug resource. This enables running gdb/kgdb etc in guest. On BOOKE architecture we cannot share debug

Re: [PATCH 1/6 v2] KVM: PPC: Book3E: Use common defines for SPE/FP/AltiVec int numbers

2014-07-28 Thread Scott Wood
On Mon, 2014-07-28 at 03:54 -0500, Caraman Mihai Claudiu-B02008 wrote: -Original Message- From: Wood Scott-B07421 Sent: Saturday, July 26, 2014 3:11 AM To: Caraman Mihai Claudiu-B02008 Cc: Alexander Graf; kvm-ppc@vger.kernel.org; k...@vger.kernel.org;

Re: [PATCH 1/4] KVM: PPC: BOOK3S: PR: Emulate virtual timebase register

2014-07-28 Thread Stewart Smith
Alexander Graf ag...@suse.de writes: --- a/arch/powerpc/include/asm/reg.h +++ b/arch/powerpc/include/asm/reg.h @@ -25,7 +25,6 @@ #ifdef CONFIG_8xx #include asm/reg_8xx.h #endif /* CONFIG_8xx */ -#include asm/bug.h #define MSR_SF_LG 63 /* Enable 64 bit mode */