Re: [PATCH 21/23] KVM: PPC: Book3S PR: Use mmu_notifier_retry() in kvmppc_mmu_map_page()

2013-08-08 Thread Paul Mackerras
On Wed, Aug 07, 2013 at 08:31:04AM +, Bhushan Bharat-R65777 wrote:
 
 
  -Original Message-
  From: Paul Mackerras [mailto:pau...@samba.org]
  Sent: Wednesday, August 07, 2013 1:58 PM
  To: Bhushan Bharat-R65777
  Cc: Alexander Graf; Benjamin Herrenschmidt; kvm-ppc@vger.kernel.org;
  k...@vger.kernel.org
  Subject: Re: [PATCH 21/23] KVM: PPC: Book3S PR: Use mmu_notifier_retry() in
  kvmppc_mmu_map_page()
  
  On Wed, Aug 07, 2013 at 05:17:29AM +, Bhushan Bharat-R65777 wrote:
  
   Pauls, I am trying to understand the flow; does retry mean that we do not
  create the mapping and return to guest, which will fault again and then we 
  will
  retry?
  
  Yes, and you do put_page or kvm_release_pfn_clean for any page that you got.
 
 Ok, but what is the value to return back to guest when we know it is again 
 going to generate fault. 
 Cannot we retry within KVM?

You can, though you should make sure you include a preemption point.
Going back to the guest gets you a preemption point because of the
cond_resched() call in kvmppc_prepare_to_enter().

Paul.
--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RFC 0/5] Eliminate double-copying of FP/VMX/VSX state

2013-08-08 Thread Paul Mackerras
On Wed, Aug 07, 2013 at 08:37:24AM +, Caraman Mihai Claudiu-B02008 wrote:
 
 Nice work Paul! What do you suggest for KVM BookE AltiVec v2 patchset,
 should I wait for this RFC or should I go ahead with the version based
 on the existing infrastructure?

It's really up to you and whether you find that the changes I am
proposing would simplify your code.  If they would, please tell Alex
once he's back. :)

Paul.
--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH RFC 0/5] Eliminate double-copying of FP/VMX/VSX state

2013-08-08 Thread Caraman Mihai Claudiu-B02008
 -Original Message-
 From: Paul Mackerras [mailto:pau...@samba.org]
 Sent: Thursday, August 08, 2013 3:08 PM
 To: Caraman Mihai Claudiu-B02008
 Cc: Alexander Graf; Benjamin Herrenschmidt; kvm-ppc@vger.kernel.org;
 k...@vger.kernel.org
 Subject: Re: [PATCH RFC 0/5] Eliminate double-copying of FP/VMX/VSX state
 
 On Wed, Aug 07, 2013 at 08:37:24AM +, Caraman Mihai Claudiu-B02008
 wrote:
 
  Nice work Paul! What do you suggest for KVM BookE AltiVec v2 patchset,
  should I wait for this RFC or should I go ahead with the version based
  on the existing infrastructure?
 
 It's really up to you and whether you find that the changes I am
 proposing would simplify your code.  If they would, please tell Alex
 once he's back. :)

I am not sure it simplifies the code. It's a more natural (and optimized)
approach to have a common structure for kernel and KVM even though this implies
touching lot of code.

I don't like the idea to send the BookE AltiVec patchset just to be modified
afterward but on the other hand e6500 core support depends on it and I would
like to have it the next kernel release. As you suggested I would wait for Alex
to comment on this.

-Mike

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] powerpc/booke64: Add LRAT error exception handler

2013-08-08 Thread Mihai Caraman
LRAT (Logical to Real Address Translation) present in MMU v2 provides hardware
translation from a logical page number (LPN) to a real page number (RPN) when
tlbwe is executed by a guest or when a page table translation occurs from a
guest virtual address.

Add LRAT error exception handler to Booke3E 64-bit kernel and the basic KVM
handler to avoid build breakage. This is a prerequisite for KVM LRAT support
that will follow.

Signed-off-by: Mihai Caraman mihai.cara...@freescale.com
---
v2
  - squash patches for bisectability
  - set IVOR42 from setup_cpu

 arch/powerpc/include/asm/kvm_asm.h|1 +
 arch/powerpc/include/asm/reg_booke.h  |1 +
 arch/powerpc/kernel/cpu_setup_fsl_booke.S |   12 
 arch/powerpc/kernel/exceptions-64e.S  |   17 +
 arch/powerpc/kvm/bookehv_interrupts.S |2 ++
 5 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_asm.h 
b/arch/powerpc/include/asm/kvm_asm.h
index 851bac7..83b91e5 100644
--- a/arch/powerpc/include/asm/kvm_asm.h
+++ b/arch/powerpc/include/asm/kvm_asm.h
@@ -74,6 +74,7 @@
 #define BOOKE_INTERRUPT_GUEST_DBELL_CRIT 39
 #define BOOKE_INTERRUPT_HV_SYSCALL 40
 #define BOOKE_INTERRUPT_HV_PRIV 41
+#define BOOKE_INTERRUPT_LRAT_ERROR 42
 
 /* book3s */
 
diff --git a/arch/powerpc/include/asm/reg_booke.h 
b/arch/powerpc/include/asm/reg_booke.h
index b417de3..6b113e1 100644
--- a/arch/powerpc/include/asm/reg_booke.h
+++ b/arch/powerpc/include/asm/reg_booke.h
@@ -101,6 +101,7 @@
 #define SPRN_IVOR390x1B1   /* Interrupt Vector Offset Register 39 */
 #define SPRN_IVOR400x1B2   /* Interrupt Vector Offset Register 40 */
 #define SPRN_IVOR410x1B3   /* Interrupt Vector Offset Register 41 */
+#define SPRN_IVOR420x1B4   /* Interrupt Vector Offset Register 42 */
 #define SPRN_GIVOR20x1B8   /* Guest IVOR2 */
 #define SPRN_GIVOR30x1B9   /* Guest IVOR3 */
 #define SPRN_GIVOR40x1BA   /* Guest IVOR4 */
diff --git a/arch/powerpc/kernel/cpu_setup_fsl_booke.S 
b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
index 0b9af01..754a11d 100644
--- a/arch/powerpc/kernel/cpu_setup_fsl_booke.S
+++ b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
@@ -57,6 +57,12 @@ _GLOBAL(__setup_cpu_e6500)
mflrr6
 #ifdef CONFIG_PPC64
bl  .setup_altivec_ivors
+   /* Touch IVOR42 only if the CPU supports E.HV category */
+   mfspr   r10,SPRN_MMUCFG
+   rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
+   beq 1f
+   bl  .setup_lrat_ivor
+1:
 #endif
bl  __setup_cpu_e5500
mtlrr6
@@ -119,6 +125,12 @@ _GLOBAL(__setup_cpu_e5500)
 _GLOBAL(__restore_cpu_e6500)
mflrr5
bl  .setup_altivec_ivors
+   /* Touch IVOR42 only if the CPU supports E.HV category */
+   mfspr   r10,SPRN_MMUCFG
+   rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
+   beq 1f
+   bl  .setup_lrat_ivor
+1:
bl  __restore_cpu_e5500
mtlrr5
blr
diff --git a/arch/powerpc/kernel/exceptions-64e.S 
b/arch/powerpc/kernel/exceptions-64e.S
index 645170a..9e4a506 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -308,6 +308,7 @@ interrupt_base_book3e:  
/* fake trap */
EXCEPTION_STUB(0x2e0, guest_doorbell_crit)
EXCEPTION_STUB(0x300, hypercall)
EXCEPTION_STUB(0x320, ehpriv)
+   EXCEPTION_STUB(0x340, lrat_error)
 
.globl interrupt_end_book3e
 interrupt_end_book3e:
@@ -675,6 +676,17 @@ kernel_dbg_exc:
bl  .unknown_exception
b   .ret_from_except
 
+/* LRAT Error interrupt */
+   START_EXCEPTION(lrat_error);
+   NORMAL_EXCEPTION_PROLOG(0x340, BOOKE_INTERRUPT_LRAT_ERROR,
+   PROLOG_ADDITION_NONE)
+   EXCEPTION_COMMON(0x340, PACA_EXGEN, INTS_KEEP)
+   addir3,r1,STACK_FRAME_OVERHEAD
+   bl  .save_nvgprs
+   INTS_RESTORE_HARD
+   bl  .unknown_exception
+   b   .ret_from_except
+
 /*
  * An interrupt came in while soft-disabled; We mark paca-irq_happened
  * accordingly and if the interrupt is level sensitive, we hard disable
@@ -857,6 +869,7 @@ BAD_STACK_TRAMPOLINE(0x2e0)
 BAD_STACK_TRAMPOLINE(0x300)
 BAD_STACK_TRAMPOLINE(0x310)
 BAD_STACK_TRAMPOLINE(0x320)
+BAD_STACK_TRAMPOLINE(0x340)
 BAD_STACK_TRAMPOLINE(0x400)
 BAD_STACK_TRAMPOLINE(0x500)
 BAD_STACK_TRAMPOLINE(0x600)
@@ -1412,3 +1425,7 @@ _GLOBAL(setup_ehv_ivors)
SET_IVOR(38, 0x2c0) /* Guest Processor Doorbell */
SET_IVOR(39, 0x2e0) /* Guest Processor Doorbell Crit/MC */
blr
+
+_GLOBAL(setup_lrat_ivor)
+   SET_IVOR(42, 0x340) /* LRAT Error */
+   blr
diff --git a/arch/powerpc/kvm/bookehv_interrupts.S 
b/arch/powerpc/kvm/bookehv_interrupts.S
index e8ed7d6..a0d6929 100644
--- a/arch/powerpc/kvm/bookehv_interrupts.S
+++ b/arch/powerpc/kvm/bookehv_interrupts.S
@@ -319,6 +319,8 @@ kvm_handler BOOKE_INTERRUPT_DEBUG, EX_PARAMS(DBG), \
SPRN_DSRR0, 

Re: [PATCH 02/23] KVM: PPC: Book3S PR: Don't corrupt guest state when kernel uses VMX

2013-08-08 Thread Aneesh Kumar K.V
Paul Mackerras pau...@samba.org writes:

 @@ -575,8 +577,6 @@ static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, 
 unsigned int exit_nr,
   printk(KERN_INFO Loading up ext 0x%lx\n, msr);
  #endif
  
 - current-thread.regs-msr |= msr;
 -
   if (msr  MSR_FP) {
   for (i = 0; i  ARRAY_SIZE(vcpu-arch.fpr); i++)
   thread_fpr[get_fpr_index(i)] = vcpu_fpr[i];
 @@ -598,12 +598,32 @@ static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, 
 unsigned int exit_nr,
  #endif
   }
  
 + current-thread.regs-msr |= msr;
   vcpu-arch.guest_owned_ext |= msr;
   kvmppc_recalc_shadow_msr(vcpu);
  
   return RESUME_GUEST;
  }

Any specific reason you are doing the above ?

-aneesh

--
To unsubscribe from this list: send the line unsubscribe kvm-ppc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html