RE: [PATCH 2/3] KVM: PPC: booke: Allow multiple exception types

2012-08-10 Thread Bhushan Bharat-R65777


 -Original Message-
 From: kvm-ppc-ow...@vger.kernel.org [mailto:kvm-ppc-ow...@vger.kernel.org] On
 Behalf Of Alexander Graf
 Sent: Tuesday, August 07, 2012 4:16 PM
 To: Bhushan Bharat-R65777
 Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan Bharat-R65777
 Subject: Re: [PATCH 2/3] KVM: PPC: booke: Allow multiple exception types
 
 
 On 03.08.2012, at 09:08, Bharat Bhushan wrote:
 
  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 different macros for different handlers.
 
  Signed-off-by: Liu Yu yu@freescale.com
  [bharat.bhus...@freescale.com: Substantial changes]
  Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com
  ---
  arch/powerpc/include/asm/kvm_ppc.h  |2 -
  arch/powerpc/kvm/booke.c|9 ---
  arch/powerpc/kvm/booke.h|1 +
  arch/powerpc/kvm/booke_interrupts.S |   37 
  --
  arch/powerpc/kvm/e500.c |   13 +++
  5 files changed, 48 insertions(+), 14 deletions(-)
 
  diff --git a/arch/powerpc/include/asm/kvm_ppc.h
 b/arch/powerpc/include/asm/kvm_ppc.h
  index 1438a5e..deb55bd 100644
  --- a/arch/powerpc/include/asm/kvm_ppc.h
  +++ b/arch/powerpc/include/asm/kvm_ppc.h
  @@ -47,8 +47,6 @@ enum emulation_result {
 
  extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
  extern int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu 
  *vcpu);
  -extern char kvmppc_handlers_start[];
  -extern unsigned long kvmppc_handler_len;
  extern void kvmppc_handler_highmem(void);
 
  extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu);
  diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
  index aebbb8b..1338233 100644
  --- a/arch/powerpc/kvm/booke.c
  +++ b/arch/powerpc/kvm/booke.c
  @@ -1541,6 +1541,7 @@ int __init kvmppc_booke_init(void)
  {
  #ifndef CONFIG_KVM_BOOKE_HV
  unsigned long ivor[16];
  +   unsigned long *handler = kvmppc_booke_handler_addr;
  unsigned long max_ivor = 0;
  int i;
 
  @@ -1574,14 +1575,14 @@ int __init kvmppc_booke_init(void)
 
  for (i = 0; i  16; i++) {
  if (ivor[i]  max_ivor)
  -   max_ivor = ivor[i];
  +   max_ivor = i;
 
  memcpy((void *)kvmppc_booke_handlers + ivor[i],
  -  kvmppc_handlers_start + i * kvmppc_handler_len,
  -  kvmppc_handler_len);
  +  (void *)handler[i], handler[i + 1] - handler[i]);
  }
  flush_icache_range(kvmppc_booke_handlers,
  -  kvmppc_booke_handlers + max_ivor + 
  kvmppc_handler_len);
  +  kvmppc_booke_handlers + ivor[max_ivor] +
  +   handler[max_ivor + 1] - handler[max_ivor]);
  #endif /* !BOOKE_HV */
  return 0;
  }
  diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h
  index ba61974..de9e526 100644
  --- a/arch/powerpc/kvm/booke.h
  +++ b/arch/powerpc/kvm/booke.h
  @@ -65,6 +65,7 @@
(1  BOOKE_IRQPRIO_CRITICAL))
 
  extern unsigned long kvmppc_booke_handlers;
  +extern unsigned long kvmppc_booke_handler_addr[];
 
  void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
  void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
  diff --git a/arch/powerpc/kvm/booke_interrupts.S
 b/arch/powerpc/kvm/booke_interrupts.S
  index bb46b32..3539805 100644
  --- a/arch/powerpc/kvm/booke_interrupts.S
  +++ b/arch/powerpc/kvm/booke_interrupts.S
  @@ -73,6 +73,14 @@ _GLOBAL(kvmppc_handler_\ivor_nr)
  bctr
  .endm
 
  +.macro KVM_HANDLER_ADDR ivor_nr
  +   .long   kvmppc_handler_\ivor_nr
  +.endm
  +
  +.macro KVM_HANDLER_END
  +   .long   kvmppc_handlers_end
  +.endm
  +
  _GLOBAL(kvmppc_handlers_start)
  KVM_HANDLER BOOKE_INTERRUPT_CRITICAL SPRN_SPRG_RSCRATCH_CRIT SPRN_CSRR0
  KVM_HANDLER BOOKE_INTERRUPT_MACHINE_CHECK  SPRN_SPRG_RSCRATCH_MC SPRN_MCSRR0
  @@ -93,9 +101,7 @@ KVM_HANDLER BOOKE_INTERRUPT_DEBUG SPRN_SPRG_RSCRATCH_CRIT
 SPRN_CSRR0
  KVM_HANDLER BOOKE_INTERRUPT_SPE_UNAVAIL SPRN_SPRG_RSCRATCH0 SPRN_SRR0
  KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_DATA SPRN_SPRG_RSCRATCH0 SPRN_SRR0
  KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_ROUND SPRN_SPRG_RSCRATCH0 SPRN_SRR0
  -
  -_GLOBAL(kvmppc_handler_len)
  -   .long kvmppc_handler_1 - kvmppc_handler_0
  +_GLOBAL(kvmppc_handlers_end)
 
  /* Registers:
   *  SPRG_SCRATCH0: guest r4
  @@ -463,6 +469,31 @@ lightweight_exit:
  lwz r4, VCPU_GPR(R4)(r4)
  rfi
 
  +   .data
  +   .align  4
  +   .globl  kvmppc_booke_handler_addr
  +kvmppc_booke_handler_addr:
  +KVM_HANDLER_ADDR BOOKE_INTERRUPT_CRITICAL
  +KVM_HANDLER_ADDR BOOKE_INTERRUPT_MACHINE_CHECK
  +KVM_HANDLER_ADDR BOOKE_INTERRUPT_DATA_STORAGE
  +KVM_HANDLER_ADDR BOOKE_INTERRUPT_INST_STORAGE
  +KVM_HANDLER_ADDR 

RE: [PATCH 3/3] KVM: PPC: booke: Added debug handler

2012-08-10 Thread Bhushan Bharat-R65777


 -Original Message-
 From: kvm-ppc-ow...@vger.kernel.org [mailto:kvm-ppc-ow...@vger.kernel.org] On
 Behalf Of Alexander Graf
 Sent: Wednesday, August 08, 2012 4:41 PM
 To: Bhushan Bharat-R65777
 Cc: Wood Scott-B07421; kvm-ppc@vger.kernel.org; k...@vger.kernel.org
 Subject: Re: [PATCH 3/3] KVM: PPC: booke: Added debug handler
 
 
 On 08.08.2012, at 03:02, Bhushan Bharat-R65777 wrote:
 
 
 
  -Original Message-
  From: Wood Scott-B07421
  Sent: Wednesday, August 08, 2012 2:15 AM
  To: Alexander Graf
  Cc: Bhushan Bharat-R65777; kvm-ppc@vger.kernel.org;
  k...@vger.kernel.org; Bhushan
  Bharat-R65777
  Subject: Re: [PATCH 3/3] KVM: PPC: booke: Added debug handler
 
  On 08/07/2012 05:47 AM, Alexander Graf wrote:
  diff --git a/arch/powerpc/kvm/booke_interrupts.S
  b/arch/powerpc/kvm/booke_interrupts.S
  index 3539805..890673c 100644
  --- a/arch/powerpc/kvm/booke_interrupts.S
  +++ b/arch/powerpc/kvm/booke_interrupts.S
  @@ -73,6 +73,51 @@ _GLOBAL(kvmppc_handler_\ivor_nr)
   bctr
  .endm
 
  +.macro KVM_DBG_HANDLER ivor_nr scratch srr0
 
  This is a lot of asm code. Any chance to share a good share of it
  with the
  generic handler?
 
  That entire file could use an update to lok more like
  bookehv_interrupts.S and its use of asm macros.
 
  In booke there is assumption that size of KVM IVORs will not me more than 
  host
 IVORs size so that only IVPR is changed.
 
  I tried to give it that shape of bookehv_interrupts.S  and found that size 
  of
 some IVORs become more than host IVORs.
 
 We can always jump off to another (more generic?) function and only have a 
 small
 stub in the IVOR referenced code.

What extra KVM_DBG_HANDLER have from KVM_HANDLER is the handing of debug single 
step (which is similar to host).
So do you want a jump in assembly for handling the debug single step? Or you 
really think of moving something from the KVM_HANDLER to more generic?

Thanks
-Bharat

--
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 2/3] KVM: PPC: booke: Allow multiple exception types

2012-08-10 Thread Alexander Graf

On 10.08.2012, at 08:38, Bhushan Bharat-R65777 wrote:

 
 
 -Original Message-
 From: kvm-ppc-ow...@vger.kernel.org [mailto:kvm-ppc-ow...@vger.kernel.org] On
 Behalf Of Alexander Graf
 Sent: Tuesday, August 07, 2012 4:16 PM
 To: Bhushan Bharat-R65777
 Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan Bharat-R65777
 Subject: Re: [PATCH 2/3] KVM: PPC: booke: Allow multiple exception types
 
 
 On 03.08.2012, at 09:08, Bharat Bhushan wrote:
 
 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 different macros for different handlers.
 
 Signed-off-by: Liu Yu yu@freescale.com
 [bharat.bhus...@freescale.com: Substantial changes]
 Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com
 ---
 arch/powerpc/include/asm/kvm_ppc.h  |2 -
 arch/powerpc/kvm/booke.c|9 ---
 arch/powerpc/kvm/booke.h|1 +
 arch/powerpc/kvm/booke_interrupts.S |   37 
 --
 arch/powerpc/kvm/e500.c |   13 +++
 5 files changed, 48 insertions(+), 14 deletions(-)
 
 diff --git a/arch/powerpc/include/asm/kvm_ppc.h
 b/arch/powerpc/include/asm/kvm_ppc.h
 index 1438a5e..deb55bd 100644
 --- a/arch/powerpc/include/asm/kvm_ppc.h
 +++ b/arch/powerpc/include/asm/kvm_ppc.h
 @@ -47,8 +47,6 @@ enum emulation_result {
 
 extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
 extern int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu 
 *vcpu);
 -extern char kvmppc_handlers_start[];
 -extern unsigned long kvmppc_handler_len;
 extern void kvmppc_handler_highmem(void);
 
 extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu);
 diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
 index aebbb8b..1338233 100644
 --- a/arch/powerpc/kvm/booke.c
 +++ b/arch/powerpc/kvm/booke.c
 @@ -1541,6 +1541,7 @@ int __init kvmppc_booke_init(void)
 {
 #ifndef CONFIG_KVM_BOOKE_HV
 unsigned long ivor[16];
 +   unsigned long *handler = kvmppc_booke_handler_addr;
 unsigned long max_ivor = 0;
 int i;
 
 @@ -1574,14 +1575,14 @@ int __init kvmppc_booke_init(void)
 
 for (i = 0; i  16; i++) {
 if (ivor[i]  max_ivor)
 -   max_ivor = ivor[i];
 +   max_ivor = i;
 
 memcpy((void *)kvmppc_booke_handlers + ivor[i],
 -  kvmppc_handlers_start + i * kvmppc_handler_len,
 -  kvmppc_handler_len);
 +  (void *)handler[i], handler[i + 1] - handler[i]);
 }
 flush_icache_range(kvmppc_booke_handlers,
 -  kvmppc_booke_handlers + max_ivor + 
 kvmppc_handler_len);
 +  kvmppc_booke_handlers + ivor[max_ivor] +
 +   handler[max_ivor + 1] - handler[max_ivor]);
 #endif /* !BOOKE_HV */
 return 0;
 }
 diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h
 index ba61974..de9e526 100644
 --- a/arch/powerpc/kvm/booke.h
 +++ b/arch/powerpc/kvm/booke.h
 @@ -65,6 +65,7 @@
   (1  BOOKE_IRQPRIO_CRITICAL))
 
 extern unsigned long kvmppc_booke_handlers;
 +extern unsigned long kvmppc_booke_handler_addr[];
 
 void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
 void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
 diff --git a/arch/powerpc/kvm/booke_interrupts.S
 b/arch/powerpc/kvm/booke_interrupts.S
 index bb46b32..3539805 100644
 --- a/arch/powerpc/kvm/booke_interrupts.S
 +++ b/arch/powerpc/kvm/booke_interrupts.S
 @@ -73,6 +73,14 @@ _GLOBAL(kvmppc_handler_\ivor_nr)
 bctr
 .endm
 
 +.macro KVM_HANDLER_ADDR ivor_nr
 +   .long   kvmppc_handler_\ivor_nr
 +.endm
 +
 +.macro KVM_HANDLER_END
 +   .long   kvmppc_handlers_end
 +.endm
 +
 _GLOBAL(kvmppc_handlers_start)
 KVM_HANDLER BOOKE_INTERRUPT_CRITICAL SPRN_SPRG_RSCRATCH_CRIT SPRN_CSRR0
 KVM_HANDLER BOOKE_INTERRUPT_MACHINE_CHECK  SPRN_SPRG_RSCRATCH_MC SPRN_MCSRR0
 @@ -93,9 +101,7 @@ KVM_HANDLER BOOKE_INTERRUPT_DEBUG SPRN_SPRG_RSCRATCH_CRIT
 SPRN_CSRR0
 KVM_HANDLER BOOKE_INTERRUPT_SPE_UNAVAIL SPRN_SPRG_RSCRATCH0 SPRN_SRR0
 KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_DATA SPRN_SPRG_RSCRATCH0 SPRN_SRR0
 KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_ROUND SPRN_SPRG_RSCRATCH0 SPRN_SRR0
 -
 -_GLOBAL(kvmppc_handler_len)
 -   .long kvmppc_handler_1 - kvmppc_handler_0
 +_GLOBAL(kvmppc_handlers_end)
 
 /* Registers:
 *  SPRG_SCRATCH0: guest r4
 @@ -463,6 +469,31 @@ lightweight_exit:
 lwz r4, VCPU_GPR(R4)(r4)
 rfi
 
 +   .data
 +   .align  4
 +   .globl  kvmppc_booke_handler_addr
 +kvmppc_booke_handler_addr:
 +KVM_HANDLER_ADDR BOOKE_INTERRUPT_CRITICAL
 +KVM_HANDLER_ADDR BOOKE_INTERRUPT_MACHINE_CHECK
 +KVM_HANDLER_ADDR BOOKE_INTERRUPT_DATA_STORAGE
 +KVM_HANDLER_ADDR BOOKE_INTERRUPT_INST_STORAGE
 +KVM_HANDLER_ADDR BOOKE_INTERRUPT_EXTERNAL
 +KVM_HANDLER_ADDR 

Re: [PATCH 3/3] KVM: PPC: booke: Added debug handler

2012-08-10 Thread Alexander Graf

On 10.08.2012, at 08:55, Bhushan Bharat-R65777 wrote:

 
 
 -Original Message-
 From: kvm-ppc-ow...@vger.kernel.org [mailto:kvm-ppc-ow...@vger.kernel.org] On
 Behalf Of Alexander Graf
 Sent: Wednesday, August 08, 2012 4:41 PM
 To: Bhushan Bharat-R65777
 Cc: Wood Scott-B07421; kvm-ppc@vger.kernel.org; k...@vger.kernel.org
 Subject: Re: [PATCH 3/3] KVM: PPC: booke: Added debug handler
 
 
 On 08.08.2012, at 03:02, Bhushan Bharat-R65777 wrote:
 
 
 
 -Original Message-
 From: Wood Scott-B07421
 Sent: Wednesday, August 08, 2012 2:15 AM
 To: Alexander Graf
 Cc: Bhushan Bharat-R65777; kvm-ppc@vger.kernel.org;
 k...@vger.kernel.org; Bhushan
 Bharat-R65777
 Subject: Re: [PATCH 3/3] KVM: PPC: booke: Added debug handler
 
 On 08/07/2012 05:47 AM, Alexander Graf wrote:
 diff --git a/arch/powerpc/kvm/booke_interrupts.S
 b/arch/powerpc/kvm/booke_interrupts.S
 index 3539805..890673c 100644
 --- a/arch/powerpc/kvm/booke_interrupts.S
 +++ b/arch/powerpc/kvm/booke_interrupts.S
 @@ -73,6 +73,51 @@ _GLOBAL(kvmppc_handler_\ivor_nr)
  bctr
 .endm
 
 +.macro KVM_DBG_HANDLER ivor_nr scratch srr0
 
 This is a lot of asm code. Any chance to share a good share of it
 with the
 generic handler?
 
 That entire file could use an update to lok more like
 bookehv_interrupts.S and its use of asm macros.
 
 In booke there is assumption that size of KVM IVORs will not me more than 
 host
 IVORs size so that only IVPR is changed.
 
 I tried to give it that shape of bookehv_interrupts.S  and found that size 
 of
 some IVORs become more than host IVORs.
 
 We can always jump off to another (more generic?) function and only have a 
 small
 stub in the IVOR referenced code.
 
 What extra KVM_DBG_HANDLER have from KVM_HANDLER is the handing of debug 
 single step (which is similar to host).
 So do you want a jump in assembly for handling the debug single step? Or you 
 really think of moving something from the KVM_HANDLER to more generic?

I'm thinking of if we don't have enough space in block A, create another block 
B that has more space to handle things again :). I'll leave the implementation 
details to you :D


Alex

--
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 0/5] Improve memory slot handling and other fixes

2012-08-10 Thread Alexander Graf

On 06.08.2012, at 12:02, Paul Mackerras wrote:

 This series of 5 patches starts off with two fixes that I have posted
 previously but not got any response to, and then has 3 patches to
 improve our handling of memory slots on PPC.  The first of those 3
 makes HV-style KVM able to handle deletion and modification of memory
 slots properly.  The second one adds proper SRCU read-locking around
 accesses to memslot data for HV KVM, and the third adds SRCU
 read-locking around accesses to memslot data for the other styles of
 KVM on PPC.
 
 These patches are against Avi's next branch as of today.

Thanks, applied 1/5 and 2/5 to kvm-ppc-next. The others are still subject of 
discussions :)


Alex

--
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: [RFC PATCH 5/5] KVM: PPC: Take the SRCU lock around memslot use

2012-08-10 Thread Alexander Graf

On 10.08.2012, at 02:37, Paul Mackerras wrote:

 On Thu, Aug 09, 2012 at 03:27:17PM -0300, Marcelo Tosatti wrote:
 On Mon, Aug 06, 2012 at 08:08:16PM +1000, Paul Mackerras wrote:
 The generic KVM code uses SRCU (sleeping RCU) to protect accesses
 to the memslots data structures against updates due to userspace
 adding, modifying or removing memory slots.  We need to do that too,
 both to avoid accessing stale copies of the memslots and to avoid
 lockdep warnings.  This therefore adds srcu_read_lock/unlock pairs
 around code that accesses and uses memslots in the Book 3S PR code
 and the Book E (44x and e500) code.
 
 Signed-off-by: Paul Mackerras pau...@samba.org
 ---
 Compile-tested only.
 
 arch/powerpc/kvm/44x_tlb.c   |6 ++
 arch/powerpc/kvm/book3s_pr.c |6 ++
 arch/powerpc/kvm/e500_tlb.c  |6 ++
 3 files changed, 18 insertions(+)
 
 On top of the previous comment:
 
 x86 calls srcu_read_lock at the beginning of the KVM_RUN ioctl handler
 (__vcpu_run in arch/x86/kvm/x86.c), unlocks srcu on guest entry, locks
 on guest exit before any potential use of memslots, and unlocks on
 exit to userspace.
 
 This has the advantage of not sprinkling srcu lock/unlock calls all over
 (except from other ioctls, of course). Its low maintenance.
 
 Perhaps doing the same on PPC is not a bad idea.
 
 Perhaps... these changes are to areas of the PPC KVM code that I don't
 use or maintain, so they're really more a suggestion of one way to fix
 the problem than anything else.  That's why I put RFC in the subject
 line.  It would be up to Alex whether he wants to fix it like this or
 by taking the SRCU lock at a higher level.

My general approach to these things is keep it as close to x86 as we can, 
because that'll make it easier for generic code to work. I don't know if the 
above scheme would work for you though, since you probably want the lock held 
in real mode, right?


Alex

--
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 2/3] KVM: PPC: booke: Allow multiple exception types

2012-08-10 Thread Bhushan Bharat-R65777


 -Original Message-
 From: kvm-ow...@vger.kernel.org [mailto:kvm-ow...@vger.kernel.org] On Behalf 
 Of
 Alexander Graf
 Sent: Friday, August 10, 2012 2:49 PM
 To: Bhushan Bharat-R65777
 Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org
 Subject: Re: [PATCH 2/3] KVM: PPC: booke: Allow multiple exception types
 
 
 On 10.08.2012, at 08:38, Bhushan Bharat-R65777 wrote:
 
 
 
  -Original Message-
  From: kvm-ppc-ow...@vger.kernel.org
  [mailto:kvm-ppc-ow...@vger.kernel.org] On Behalf Of Alexander Graf
  Sent: Tuesday, August 07, 2012 4:16 PM
  To: Bhushan Bharat-R65777
  Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan
  Bharat-R65777
  Subject: Re: [PATCH 2/3] KVM: PPC: booke: Allow multiple exception
  types
 
 
  On 03.08.2012, at 09:08, Bharat Bhushan wrote:
 
  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
  different macros for different handlers.
 
  Signed-off-by: Liu Yu yu@freescale.com
  [bharat.bhus...@freescale.com: Substantial changes]
  Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com
  ---
  arch/powerpc/include/asm/kvm_ppc.h  |2 -
  arch/powerpc/kvm/booke.c|9 ---
  arch/powerpc/kvm/booke.h|1 +
  arch/powerpc/kvm/booke_interrupts.S |   37 
  -
 -
  arch/powerpc/kvm/e500.c |   13 +++
  5 files changed, 48 insertions(+), 14 deletions(-)
 
  diff --git a/arch/powerpc/include/asm/kvm_ppc.h
  b/arch/powerpc/include/asm/kvm_ppc.h
  index 1438a5e..deb55bd 100644
  --- a/arch/powerpc/include/asm/kvm_ppc.h
  +++ b/arch/powerpc/include/asm/kvm_ppc.h
  @@ -47,8 +47,6 @@ enum emulation_result {
 
  extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu
  *vcpu); extern int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct
  kvm_vcpu *vcpu); -extern char kvmppc_handlers_start[]; -extern
  unsigned long kvmppc_handler_len; extern void
  kvmppc_handler_highmem(void);
 
  extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu); diff --git
  a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index
  aebbb8b..1338233 100644
  --- a/arch/powerpc/kvm/booke.c
  +++ b/arch/powerpc/kvm/booke.c
  @@ -1541,6 +1541,7 @@ int __init kvmppc_booke_init(void) { #ifndef
  CONFIG_KVM_BOOKE_HV
unsigned long ivor[16];
  + unsigned long *handler = kvmppc_booke_handler_addr;
unsigned long max_ivor = 0;
int i;
 
  @@ -1574,14 +1575,14 @@ int __init kvmppc_booke_init(void)
 
for (i = 0; i  16; i++) {
if (ivor[i]  max_ivor)
  - max_ivor = ivor[i];
  + max_ivor = i;
 
memcpy((void *)kvmppc_booke_handlers + ivor[i],
  -kvmppc_handlers_start + i * kvmppc_handler_len,
  -kvmppc_handler_len);
  +(void *)handler[i], handler[i + 1] - handler[i]);
}
flush_icache_range(kvmppc_booke_handlers,
  -kvmppc_booke_handlers + max_ivor + 
  kvmppc_handler_len);
  +kvmppc_booke_handlers + ivor[max_ivor] +
  +   handler[max_ivor + 1] -
  +handler[max_ivor]);
  #endif /* !BOOKE_HV */
return 0;
  }
  diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h
  index ba61974..de9e526 100644
  --- a/arch/powerpc/kvm/booke.h
  +++ b/arch/powerpc/kvm/booke.h
  @@ -65,6 +65,7 @@
  (1  BOOKE_IRQPRIO_CRITICAL))
 
  extern unsigned long kvmppc_booke_handlers;
  +extern unsigned long kvmppc_booke_handler_addr[];
 
  void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr); void
  kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr); diff
  --git a/arch/powerpc/kvm/booke_interrupts.S
  b/arch/powerpc/kvm/booke_interrupts.S
  index bb46b32..3539805 100644
  --- a/arch/powerpc/kvm/booke_interrupts.S
  +++ b/arch/powerpc/kvm/booke_interrupts.S
  @@ -73,6 +73,14 @@ _GLOBAL(kvmppc_handler_\ivor_nr)
bctr
  .endm
 
  +.macro KVM_HANDLER_ADDR ivor_nr
  + .long   kvmppc_handler_\ivor_nr
  +.endm
  +
  +.macro KVM_HANDLER_END
  + .long   kvmppc_handlers_end
  +.endm
  +
  _GLOBAL(kvmppc_handlers_start)
  KVM_HANDLER BOOKE_INTERRUPT_CRITICAL SPRN_SPRG_RSCRATCH_CRIT
  SPRN_CSRR0 KVM_HANDLER BOOKE_INTERRUPT_MACHINE_CHECK
  SPRN_SPRG_RSCRATCH_MC SPRN_MCSRR0 @@ -93,9 +101,7 @@ KVM_HANDLER
  BOOKE_INTERRUPT_DEBUG SPRN_SPRG_RSCRATCH_CRIT
  SPRN_CSRR0
  KVM_HANDLER BOOKE_INTERRUPT_SPE_UNAVAIL SPRN_SPRG_RSCRATCH0
  SPRN_SRR0 KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_DATA
  SPRN_SPRG_RSCRATCH0 SPRN_SRR0 KVM_HANDLER
  BOOKE_INTERRUPT_SPE_FP_ROUND SPRN_SPRG_RSCRATCH0 SPRN_SRR0
  -
  -_GLOBAL(kvmppc_handler_len)
  - .long kvmppc_handler_1 - kvmppc_handler_0
  +_GLOBAL(kvmppc_handlers_end)
 
  /* Registers:
  *  SPRG_SCRATCH0: guest r4
  @@ -463,6 +469,31 @@ lightweight_exit:
lwz r4, 

Re: [PATCH 2/3] KVM: PPC: booke: Allow multiple exception types

2012-08-10 Thread Alexander Graf

On 10.08.2012, at 12:41, Bhushan Bharat-R65777 wrote:

 
 
 -Original Message-
 From: kvm-ow...@vger.kernel.org [mailto:kvm-ow...@vger.kernel.org] On Behalf 
 Of
 Alexander Graf
 Sent: Friday, August 10, 2012 2:49 PM
 To: Bhushan Bharat-R65777
 Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org
 Subject: Re: [PATCH 2/3] KVM: PPC: booke: Allow multiple exception types
 
 
 On 10.08.2012, at 08:38, Bhushan Bharat-R65777 wrote:
 
 
 
 -Original Message-
 From: kvm-ppc-ow...@vger.kernel.org
 [mailto:kvm-ppc-ow...@vger.kernel.org] On Behalf Of Alexander Graf
 Sent: Tuesday, August 07, 2012 4:16 PM
 To: Bhushan Bharat-R65777
 Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan
 Bharat-R65777
 Subject: Re: [PATCH 2/3] KVM: PPC: booke: Allow multiple exception
 types
 
 
 On 03.08.2012, at 09:08, Bharat Bhushan wrote:
 
 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
 different macros for different handlers.
 
 Signed-off-by: Liu Yu yu@freescale.com
 [bharat.bhus...@freescale.com: Substantial changes]
 Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com
 ---
 arch/powerpc/include/asm/kvm_ppc.h  |2 -
 arch/powerpc/kvm/booke.c|9 ---
 arch/powerpc/kvm/booke.h|1 +
 arch/powerpc/kvm/booke_interrupts.S |   37 
 -
 -
 arch/powerpc/kvm/e500.c |   13 +++
 5 files changed, 48 insertions(+), 14 deletions(-)
 
 diff --git a/arch/powerpc/include/asm/kvm_ppc.h
 b/arch/powerpc/include/asm/kvm_ppc.h
 index 1438a5e..deb55bd 100644
 --- a/arch/powerpc/include/asm/kvm_ppc.h
 +++ b/arch/powerpc/include/asm/kvm_ppc.h
 @@ -47,8 +47,6 @@ enum emulation_result {
 
 extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu
 *vcpu); extern int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct
 kvm_vcpu *vcpu); -extern char kvmppc_handlers_start[]; -extern
 unsigned long kvmppc_handler_len; extern void
 kvmppc_handler_highmem(void);
 
 extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu); diff --git
 a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index
 aebbb8b..1338233 100644
 --- a/arch/powerpc/kvm/booke.c
 +++ b/arch/powerpc/kvm/booke.c
 @@ -1541,6 +1541,7 @@ int __init kvmppc_booke_init(void) { #ifndef
 CONFIG_KVM_BOOKE_HV
   unsigned long ivor[16];
 + unsigned long *handler = kvmppc_booke_handler_addr;
   unsigned long max_ivor = 0;
   int i;
 
 @@ -1574,14 +1575,14 @@ int __init kvmppc_booke_init(void)
 
   for (i = 0; i  16; i++) {
   if (ivor[i]  max_ivor)
 - max_ivor = ivor[i];
 + max_ivor = i;
 
   memcpy((void *)kvmppc_booke_handlers + ivor[i],
 -kvmppc_handlers_start + i * kvmppc_handler_len,
 -kvmppc_handler_len);
 +(void *)handler[i], handler[i + 1] - handler[i]);
   }
   flush_icache_range(kvmppc_booke_handlers,
 -kvmppc_booke_handlers + max_ivor + 
 kvmppc_handler_len);
 +kvmppc_booke_handlers + ivor[max_ivor] +
 +   handler[max_ivor + 1] -
 +handler[max_ivor]);
 #endif /* !BOOKE_HV */
   return 0;
 }
 diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h
 index ba61974..de9e526 100644
 --- a/arch/powerpc/kvm/booke.h
 +++ b/arch/powerpc/kvm/booke.h
 @@ -65,6 +65,7 @@
 (1  BOOKE_IRQPRIO_CRITICAL))
 
 extern unsigned long kvmppc_booke_handlers;
 +extern unsigned long kvmppc_booke_handler_addr[];
 
 void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr); void
 kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr); diff
 --git a/arch/powerpc/kvm/booke_interrupts.S
 b/arch/powerpc/kvm/booke_interrupts.S
 index bb46b32..3539805 100644
 --- a/arch/powerpc/kvm/booke_interrupts.S
 +++ b/arch/powerpc/kvm/booke_interrupts.S
 @@ -73,6 +73,14 @@ _GLOBAL(kvmppc_handler_\ivor_nr)
   bctr
 .endm
 
 +.macro KVM_HANDLER_ADDR ivor_nr
 + .long   kvmppc_handler_\ivor_nr
 +.endm
 +
 +.macro KVM_HANDLER_END
 + .long   kvmppc_handlers_end
 +.endm
 +
 _GLOBAL(kvmppc_handlers_start)
 KVM_HANDLER BOOKE_INTERRUPT_CRITICAL SPRN_SPRG_RSCRATCH_CRIT
 SPRN_CSRR0 KVM_HANDLER BOOKE_INTERRUPT_MACHINE_CHECK
 SPRN_SPRG_RSCRATCH_MC SPRN_MCSRR0 @@ -93,9 +101,7 @@ KVM_HANDLER
 BOOKE_INTERRUPT_DEBUG SPRN_SPRG_RSCRATCH_CRIT
 SPRN_CSRR0
 KVM_HANDLER BOOKE_INTERRUPT_SPE_UNAVAIL SPRN_SPRG_RSCRATCH0
 SPRN_SRR0 KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_DATA
 SPRN_SPRG_RSCRATCH0 SPRN_SRR0 KVM_HANDLER
 BOOKE_INTERRUPT_SPE_FP_ROUND SPRN_SPRG_RSCRATCH0 SPRN_SRR0
 -
 -_GLOBAL(kvmppc_handler_len)
 - .long kvmppc_handler_1 - kvmppc_handler_0
 +_GLOBAL(kvmppc_handlers_end)
 
 /* Registers:
 *  SPRG_SCRATCH0: guest r4
 @@ -463,6 +469,31 @@ lightweight_exit:
   lwz r4, VCPU_GPR(R4)(r4)
   rfi
 
 + .data
 + .align  4
 + 

RE: [PATCH 2/3] KVM: PPC: booke: Allow multiple exception types

2012-08-10 Thread Bhushan Bharat-R65777


 -Original Message-
 From: Alexander Graf [mailto:ag...@suse.de]
 Sent: Friday, August 10, 2012 4:27 PM
 To: Bhushan Bharat-R65777
 Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org
 Subject: Re: [PATCH 2/3] KVM: PPC: booke: Allow multiple exception types
 
 
 On 10.08.2012, at 12:41, Bhushan Bharat-R65777 wrote:
 
 
 
  -Original Message-
  From: kvm-ow...@vger.kernel.org [mailto:kvm-ow...@vger.kernel.org] On
  Behalf Of Alexander Graf
  Sent: Friday, August 10, 2012 2:49 PM
  To: Bhushan Bharat-R65777
  Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org
  Subject: Re: [PATCH 2/3] KVM: PPC: booke: Allow multiple exception
  types
 
 
  On 10.08.2012, at 08:38, Bhushan Bharat-R65777 wrote:
 
 
 
  -Original Message-
  From: kvm-ppc-ow...@vger.kernel.org
  [mailto:kvm-ppc-ow...@vger.kernel.org] On Behalf Of Alexander Graf
  Sent: Tuesday, August 07, 2012 4:16 PM
  To: Bhushan Bharat-R65777
  Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan
  Bharat-R65777
  Subject: Re: [PATCH 2/3] KVM: PPC: booke: Allow multiple exception
  types
 
 
  On 03.08.2012, at 09:08, Bharat Bhushan wrote:
 
  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 different macros for different handlers.
 
  Signed-off-by: Liu Yu yu@freescale.com
  [bharat.bhus...@freescale.com: Substantial changes]
  Signed-off-by: Bharat Bhushan bharat.bhus...@freescale.com
  ---
  arch/powerpc/include/asm/kvm_ppc.h  |2 -
  arch/powerpc/kvm/booke.c|9 ---
  arch/powerpc/kvm/booke.h|1 +
  arch/powerpc/kvm/booke_interrupts.S |   37
 -
  -
  arch/powerpc/kvm/e500.c |   13 +++
  5 files changed, 48 insertions(+), 14 deletions(-)
 
  diff --git a/arch/powerpc/include/asm/kvm_ppc.h
  b/arch/powerpc/include/asm/kvm_ppc.h
  index 1438a5e..deb55bd 100644
  --- a/arch/powerpc/include/asm/kvm_ppc.h
  +++ b/arch/powerpc/include/asm/kvm_ppc.h
  @@ -47,8 +47,6 @@ enum emulation_result {
 
  extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct
  kvm_vcpu *vcpu); extern int __kvmppc_vcpu_run(struct kvm_run
  *kvm_run, struct kvm_vcpu *vcpu); -extern char
  kvmppc_handlers_start[]; -extern unsigned long kvmppc_handler_len;
  extern void kvmppc_handler_highmem(void);
 
  extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu); diff --git
  a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index
  aebbb8b..1338233 100644
  --- a/arch/powerpc/kvm/booke.c
  +++ b/arch/powerpc/kvm/booke.c
  @@ -1541,6 +1541,7 @@ int __init kvmppc_booke_init(void) { #ifndef
  CONFIG_KVM_BOOKE_HV
  unsigned long ivor[16];
  +   unsigned long *handler = kvmppc_booke_handler_addr;
  unsigned long max_ivor = 0;
  int i;
 
  @@ -1574,14 +1575,14 @@ int __init kvmppc_booke_init(void)
 
  for (i = 0; i  16; i++) {
  if (ivor[i]  max_ivor)
  -   max_ivor = ivor[i];
  +   max_ivor = i;
 
  memcpy((void *)kvmppc_booke_handlers + ivor[i],
  -  kvmppc_handlers_start + i * kvmppc_handler_len,
  -  kvmppc_handler_len);
  +  (void *)handler[i], handler[i + 1] - handler[i]);
  }
  flush_icache_range(kvmppc_booke_handlers,
  -  kvmppc_booke_handlers + max_ivor +
 kvmppc_handler_len);
  +  kvmppc_booke_handlers + ivor[max_ivor] +
  +   handler[max_ivor + 1] -
  +handler[max_ivor]);
  #endif /* !BOOKE_HV */
  return 0;
  }
  diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h
  index ba61974..de9e526 100644
  --- a/arch/powerpc/kvm/booke.h
  +++ b/arch/powerpc/kvm/booke.h
  @@ -65,6 +65,7 @@
(1  BOOKE_IRQPRIO_CRITICAL))
 
  extern unsigned long kvmppc_booke_handlers;
  +extern unsigned long kvmppc_booke_handler_addr[];
 
  void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr); void
  kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr); diff
  --git a/arch/powerpc/kvm/booke_interrupts.S
  b/arch/powerpc/kvm/booke_interrupts.S
  index bb46b32..3539805 100644
  --- a/arch/powerpc/kvm/booke_interrupts.S
  +++ b/arch/powerpc/kvm/booke_interrupts.S
  @@ -73,6 +73,14 @@ _GLOBAL(kvmppc_handler_\ivor_nr)
  bctr
  .endm
 
  +.macro KVM_HANDLER_ADDR ivor_nr
  +   .long   kvmppc_handler_\ivor_nr
  +.endm
  +
  +.macro KVM_HANDLER_END
  +   .long   kvmppc_handlers_end
  +.endm
  +
  _GLOBAL(kvmppc_handlers_start)
  KVM_HANDLER BOOKE_INTERRUPT_CRITICAL SPRN_SPRG_RSCRATCH_CRIT
  SPRN_CSRR0 KVM_HANDLER BOOKE_INTERRUPT_MACHINE_CHECK
  SPRN_SPRG_RSCRATCH_MC SPRN_MCSRR0 @@ -93,9 +101,7 @@ KVM_HANDLER
  BOOKE_INTERRUPT_DEBUG 

Re: [PATCH 3/5] KVM: PPC: Book3S HV: Handle memory slot deletion and modification correctly

2012-08-10 Thread Marcelo Tosatti
On Fri, Aug 10, 2012 at 11:09:09AM +0900, Takuya Yoshikawa wrote:
 On Thu, 9 Aug 2012 22:25:32 -0300
 Marcelo Tosatti mtosa...@redhat.com wrote:
 
  I'll send a patch to flush per memslot in the next days, you can work
  out the PPC details in the meantime.

Not anymore.

 Are you going to implement that using slot_bitmap?
 
 Since I'm now converting kvm_mmu_slot_remove_write_access() to
 rmap based protection, I'd like to hear your plan.
 
 If you can use the stale memslot to restrict the flush, that
 should live with rmap based protection.

There's no plan. I just wanted to confirm this before converting 
to per-memslot flush.

1) __kvm_set_memory_region line 807:

 *  - gfn_to_hva (kvm_read_guest, gfn_to_pfn)
 *  - kvm_is_visible_gfn (mmu_check_roots)
 */
kvm_arch_flush_shadow(kvm);
kfree(old_memslots);
}

This can be converted to per-memslot flush.

2) __kvm_set_memory_region line 846:

/*
 * If the new memory slot is created, we need to clear all
 * mmio sptes.
 */
if (npages  old.base_gfn != mem-guest_phys_addr  PAGE_SHIFT)
kvm_arch_flush_shadow(kvm);

This must flush all translations in the new and old GPA ranges:
a) to remove any mmio sptes that existed in the new GPA range
   (see ce88decffd17bf9f373cc233c for a description).
b) to remove any translations in the old range (this is
   necessary because change of GPA base is allowed).

Alex/Paul, slot creation should be rare (and modification of GPA base
should not be used, even though it is supported). But if you really need
a new callback, the two points above are what the second call needs (x86
will flush everything).

The other two kvm_arch_flush_shadow in kvm_mmu_notifier_release and
kvm_destroy_vm must remove all sptes obviously.

--
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] powerpc/epapr: export epapr_hypercall_start

2012-08-10 Thread Scott Wood
This fixes breakage introduced by the following commit:

  commit 6d2d82627f4f1e96a33664ace494fa363e0495cb
  Author: Liu Yu-B13201 yu@freescale.com
  Date:   Tue Jul 3 05:48:56 2012 +

PPC: Don't use hardcoded opcode for ePAPR hcall invocation

when a driver that uses ePAPR hypercalls is built as a module.

Reported-by: Geert Uytterhoeven ge...@linux-m68k.org
Signed-off-by: Scott Wood scottw...@freescale.com
---
Sending to Alex even though this isn't KVM-specific since the commit it
fixes is still only in his tree (and linux-next).

 arch/powerpc/kernel/ppc_ksyms.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 3e40315..e597dde 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -43,6 +43,7 @@
 #include asm/dcr.h
 #include asm/ftrace.h
 #include asm/switch_to.h
+#include asm/epapr_hcalls.h
 
 #ifdef CONFIG_PPC32
 extern void transfer_to_handler(void);
@@ -192,3 +193,7 @@ EXPORT_SYMBOL(__arch_hweight64);
 #ifdef CONFIG_PPC_BOOK3S_64
 EXPORT_SYMBOL_GPL(mmu_psize_defs);
 #endif
+
+#ifdef CONFIG_EPAPR_PARAVIRT
+EXPORT_SYMBOL(epapr_hypercall_start);
+#endif
-- 
1.7.9.5

--
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 3/5] KVM: PPC: Book3S HV: Handle memory slot deletion and modification correctly

2012-08-10 Thread Paul Mackerras
On Fri, Aug 10, 2012 at 03:35:53PM -0300, Marcelo Tosatti wrote:
 There's no plan. I just wanted to confirm this before converting 
 to per-memslot flush.
 
 1) __kvm_set_memory_region line 807:
 
  *  - gfn_to_hva (kvm_read_guest, gfn_to_pfn)
  *  - kvm_is_visible_gfn (mmu_check_roots)
  */
 kvm_arch_flush_shadow(kvm);
 kfree(old_memslots);
 }
 
 This can be converted to per-memslot flush.

Yes, that would be good.

 2) __kvm_set_memory_region line 846:
 
 /*
  * If the new memory slot is created, we need to clear all
  * mmio sptes.
  */
 if (npages  old.base_gfn != mem-guest_phys_addr  PAGE_SHIFT)
 kvm_arch_flush_shadow(kvm);
 
 This must flush all translations in the new and old GPA ranges:
   a) to remove any mmio sptes that existed in the new GPA range
  (see ce88decffd17bf9f373cc233c for a description).

I assume that mmio sptes are ones that are created for accesses to
guest physical addresses where there is no memslot.  On Book3S HV we
trap those accesses (on POWER7 at least) but we don't create any
hardware PTEs for them.  So I don't have anything to do here.

   b) to remove any translations in the old range (this is
necessary because change of GPA base is allowed).

In fact I need to remove any translations in the old range *before*
the new memslot gets committed, whereas this happens after that.
This is why I was doing the flush in kvm_arch_prepare_memory_region.

If the new memslot got committed while there were still some
translations left in the hardware page table, it's possible that the
guest could ask to remove one of those hardware PTEs.  As part of that
process, I get the GPA that the HPTE referred to, look up which
memslot it belongs to, and use the offset from the base_gfn of the
memslot to index into the memslot's rmap array.  If the base_gfn has
been changed then I will hit the wrong rmap entry, or possibly not
find the memslot at all, and bad things will happen.

Basically, the rmap array has to be empty before we commit the new
memslot.

 Alex/Paul, slot creation should be rare (and modification of GPA base
 should not be used, even though it is supported). But if you really need
 a new callback, the two points above are what the second call needs (x86
 will flush everything).
 
 The other two kvm_arch_flush_shadow in kvm_mmu_notifier_release and
 kvm_destroy_vm must remove all sptes obviously.

Will these be the only remaining call sites for kvm_arch_flush_shadow?
I can see an optimization here if no vcpus are running (which should
be the case) -- I can set a flag to say that the hardware page table
is completely invalid, and if any vcpu ever does try to run again,
clear out the hardware page table and flush all TLBs at that point.

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