Re: [PATCH] kvm/ppc/booke64: Hard disable interrupts when entering the guest

2013-05-05 Thread Benjamin Herrenschmidt
On Fri, 2013-05-03 at 18:45 -0500, Scott Wood wrote:
 kvmppc_lazy_ee_enable() was causing interrupts to be soft-enabled
 (albeit hard-disabled) in kvmppc_restart_interrupt().  This led to
 warnings, and possibly breakage if the interrupt state was later saved
 and then restored (leading to interrupts being hard-and-soft enabled
 when they should be at least soft-disabled).
 
 Simply removing kvmppc_lazy_ee_enable() leaves interrupts only
 soft-disabled when we enter the guest, but they will be hard-disabled
 when we exit the guest -- without PACA_IRQ_HARD_DIS ever being set, so
 the local_irq_enable() fails to hard-enable.
 
 While we could just set PACA_IRQ_HARD_DIS after an exit to compensate,
 instead hard-disable interrupts before entering the guest.  This way,
 we won't have to worry about interactions if we take an interrupt
 during the guest entry code.  While I don't see any obvious
 interactions, it could change in the future (e.g. it would be bad if
 the non-hv code were used on 64-bit or if 32-bit guest lazy interrupt
 disabling, since the non-hv code changes IVPR among other things).

Shouldn't the interrupts be marked soft-enabled (even if hard disabled)
when entering the guest ?

Ie. The last stage of entry will hard enable, so they should be
soft-enabled too... if not, latency trackers will consider the whole
guest periods as interrupt disabled...

Now, kvmppc_lazy_ee_enable() seems to be clearly bogus to me. It will
unconditionally set soft_enabled and clear irq_happened from a
soft-disabled state, thus potentially losing a pending event.

Book3S HV seems to be keeping interrupts fully enabled all the way
until the asm hard disables, which would be fine except that I'm worried
we are racy vs. need_resched  signals.

One thing you may be able to do is call prep_irq_for_idle(). This will
tell you if something happened, giving you a chance to abort/re-enable
before you go the guest.

Ben.


--
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


[v1][KVM][PATCH 1/1] kvm:ppc: enable doorbell exception with E500MC

2013-05-05 Thread Tiejun Chen
Actually E500MC also support doorbell exception, and CONFIG_PPC_E500MC
can cover BOOK3E/BOOK3E_64 as well.

Signed-off-by: Tiejun Chen tiejun.c...@windriver.com
---
 arch/powerpc/kvm/booke.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 1020119..dc1f590 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -795,7 +795,7 @@ static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
kvmppc_fill_pt_regs(regs);
timer_interrupt(regs);
break;
-#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3E_64)
+#if defined(CONFIG_PPC_E500MC)
case BOOKE_INTERRUPT_DOORBELL:
kvmppc_fill_pt_regs(regs);
doorbell_exception(regs);
-- 
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


[RFC][KVM][PATCH 1/1] kvm:ppc:booke-64: soft-disable interrupts

2013-05-05 Thread Tiejun Chen
For the external interrupt, the decrementer exception and the doorbell
excpetion, we also need to soft-disable interrupts while doing as host
interrupt handlers since the DO_KVM hook is always performed to skip
EXCEPTION_COMMON then miss this original chance with the 'ints' (INTS_DISABLE).

Signed-off-by: Tiejun Chen tiejun.c...@windriver.com
---
 arch/powerpc/kvm/bookehv_interrupts.S |9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/powerpc/kvm/bookehv_interrupts.S 
b/arch/powerpc/kvm/bookehv_interrupts.S
index e8ed7d6..2fd62bf 100644
--- a/arch/powerpc/kvm/bookehv_interrupts.S
+++ b/arch/powerpc/kvm/bookehv_interrupts.S
@@ -33,6 +33,8 @@
 
 #ifdef CONFIG_64BIT
 #include asm/exception-64e.h
+#include asm/hw_irq.h
+#include asm/irqflags.h
 #else
 #include ../kernel/head_booke.h /* for THREAD_NORMSAVE() */
 #endif
@@ -469,6 +471,13 @@ _GLOBAL(kvmppc_resume_host)
PPC_LL  r3, HOST_RUN(r1)
mr  r5, r14 /* intno */
mr  r14, r4 /* Save vcpu pointer. */
+#ifdef CONFIG_64BIT
+   /* Should we soft-disable interrupts? */
+   andi.   r6, r5, BOOKE_INTERRUPT_EXTERNAL | BOOKE_INTERRUPT_DECREMENTER 
| BOOKE_INTERRUPT_DOORBELL
+   beq skip_soft_dis
+   SOFT_DISABLE_INTS(r7,r8)
+skip_soft_dis:
+#endif
bl  kvmppc_handle_exit
 
/* Restore vcpu pointer and the nonvolatiles we used. */
-- 
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: [RFC][KVM][PATCH 1/1] kvm:ppc:booke-64: soft-disable interrupts

2013-05-05 Thread tiejun.chen

On 05/06/2013 11:10 AM, Tiejun Chen wrote:

For the external interrupt, the decrementer exception and the doorbell
excpetion, we also need to soft-disable interrupts while doing as host
interrupt handlers since the DO_KVM hook is always performed to skip
EXCEPTION_COMMON then miss this original chance with the 'ints' (INTS_DISABLE).


Sorry, miss to send Ben.

Tiejun



Signed-off-by: Tiejun Chen tiejun.c...@windriver.com
---
  arch/powerpc/kvm/bookehv_interrupts.S |9 +
  1 file changed, 9 insertions(+)

diff --git a/arch/powerpc/kvm/bookehv_interrupts.S 
b/arch/powerpc/kvm/bookehv_interrupts.S
index e8ed7d6..2fd62bf 100644
--- a/arch/powerpc/kvm/bookehv_interrupts.S
+++ b/arch/powerpc/kvm/bookehv_interrupts.S
@@ -33,6 +33,8 @@

  #ifdef CONFIG_64BIT
  #include asm/exception-64e.h
+#include asm/hw_irq.h
+#include asm/irqflags.h
  #else
  #include ../kernel/head_booke.h /* for THREAD_NORMSAVE() */
  #endif
@@ -469,6 +471,13 @@ _GLOBAL(kvmppc_resume_host)
PPC_LL  r3, HOST_RUN(r1)
mr  r5, r14 /* intno */
mr  r14, r4 /* Save vcpu pointer. */
+#ifdef CONFIG_64BIT
+   /* Should we soft-disable interrupts? */
+   andi.   r6, r5, BOOKE_INTERRUPT_EXTERNAL | BOOKE_INTERRUPT_DECREMENTER 
| BOOKE_INTERRUPT_DOORBELL
+   beq skip_soft_dis
+   SOFT_DISABLE_INTS(r7,r8)
+skip_soft_dis:
+#endif
bl  kvmppc_handle_exit

/* Restore vcpu pointer and the nonvolatiles we used. */



--
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