[v5][PATCH] KVM: PPC: Book3E HV: call RECONCILE_IRQ_STATE to sync the software state

2013-10-22 Thread Tiejun Chen
We enter with interrupts disabled in hardware, but we need to
call RECONCILE_IRQ_STATE anyway to ensure that the software state
is kept in sync instead of calling hard_irq_disable() directly.

Signed-off-by: Tiejun Chen tiejun.c...@windriver.com
---
v5:

Fix one typo in the comment.

v4:

Fix one typo in the patch description.

v3:

Base on the latest tree, now we can use RECONCILE_IRQ_STATE instead of 
SOFT_DISABLE_INTS.

v2:

Move SOFT_DISABLE_INTS[1] earlier to avoid clobbering the arguments we want to 
pass to kvmppc_handle_exit. 

 arch/powerpc/kvm/booke.c  |   11 ---
 arch/powerpc/kvm/bookehv_interrupts.S |   11 +++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 15d0149..0d211ff 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -899,17 +899,6 @@ int kvmppc_handle_exit(struct kvm_run *run, struct 
kvm_vcpu *vcpu,
int s;
int idx;
 
-#ifdef CONFIG_PPC64
-   WARN_ON(local_paca-irq_happened != 0);
-#endif
-
-   /*
-* We enter with interrupts disabled in hardware, but
-* we need to call hard_irq_disable anyway to ensure that
-* the software state is kept in sync.
-*/
-   hard_irq_disable();
-
/* update before a new last_exit_type is rewritten */
kvmppc_update_timing_stats(vcpu);
 
diff --git a/arch/powerpc/kvm/bookehv_interrupts.S 
b/arch/powerpc/kvm/bookehv_interrupts.S
index e8ed7d6..191c32b 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
@@ -465,6 +467,15 @@ _GLOBAL(kvmppc_resume_host)
mtspr   SPRN_EPCR, r3
isync
 
+#ifdef CONFIG_64BIT
+   /*
+* We enter with interrupts disabled in hardware, but
+* we need to call RECONCILE_IRQ_STATE anyway to ensure
+* that the software state is kept in sync.
+*/
+   RECONCILE_IRQ_STATE(r3,r5)
+#endif
+
/* Switch to kernel stack and jump to handler. */
PPC_LL  r3, HOST_RUN(r1)
mr  r5, r14 /* intno */
-- 
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


[v3] KVM: PPC: Book3E HV: call RECONCILE_IRQ_STATE to sync the software state

2013-10-21 Thread Tiejun Chen
We enter with interrupts disabled in hardware, but we need to
call SOFT_DISABLE_INTS anyway to ensure that the software state
is kept in sync instead of calling hard_irq_disable() directly.

Signed-off-by: Tiejun Chen tiejun.c...@windriver.com
---
v3:

Base on the latest tree, now we can use RECONCILE_IRQ_STATE instead of 
SOFT_DISABLE_INTS.

v2:

Move SOFT_DISABLE_INTS[1] earlier to avoid clobbering the arguments we want to 
pass to kvmppc_handle_exit.  

 arch/powerpc/kvm/booke.c  |   11 ---
 arch/powerpc/kvm/bookehv_interrupts.S |   11 +++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 15d0149..0d211ff 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -899,17 +899,6 @@ int kvmppc_handle_exit(struct kvm_run *run, struct 
kvm_vcpu *vcpu,
int s;
int idx;
 
-#ifdef CONFIG_PPC64
-   WARN_ON(local_paca-irq_happened != 0);
-#endif
-
-   /*
-* We enter with interrupts disabled in hardware, but
-* we need to call hard_irq_disable anyway to ensure that
-* the software state is kept in sync.
-*/
-   hard_irq_disable();
-
/* update before a new last_exit_type is rewritten */
kvmppc_update_timing_stats(vcpu);
 
diff --git a/arch/powerpc/kvm/bookehv_interrupts.S 
b/arch/powerpc/kvm/bookehv_interrupts.S
index e8ed7d6..4e867b1 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
@@ -465,6 +467,15 @@ _GLOBAL(kvmppc_resume_host)
mtspr   SPRN_EPCR, r3
isync
 
+#ifdef CONFIG_64BIT
+   /*
+* We enter with interrupts disabled in hardware, but
+* we need to call SOFT_DISABLE_INTS anyway to ensure
+* that the software state is kept in sync.
+*/
+   RECONCILE_IRQ_STATE(r3,r5)
+#endif
+
/* Switch to kernel stack and jump to handler. */
PPC_LL  r3, HOST_RUN(r1)
mr  r5, r14 /* intno */
-- 
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


[v4][PATCH] KVM: PPC: Book3E HV: call RECONCILE_IRQ_STATE to sync the software state

2013-10-21 Thread Tiejun Chen
We enter with interrupts disabled in hardware, but we need to
call RECONCILE_IRQ_STATE anyway to ensure that the software state
is kept in sync instead of calling hard_irq_disable() directly.

Signed-off-by: Tiejun Chen tiejun.c...@windriver.com
---
v4:

Fix one typo in the patch description.

v3:

Base on the latest tree, now we can use RECONCILE_IRQ_STATE instead of 
SOFT_DISABLE_INTS.

v2:

Move SOFT_DISABLE_INTS[1] earlier to avoid clobbering the arguments we want to 
pass to kvmppc_handle_exit. 

 arch/powerpc/kvm/booke.c  |   11 ---
 arch/powerpc/kvm/bookehv_interrupts.S |   11 +++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 15d0149..0d211ff 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -899,17 +899,6 @@ int kvmppc_handle_exit(struct kvm_run *run, struct 
kvm_vcpu *vcpu,
int s;
int idx;
 
-#ifdef CONFIG_PPC64
-   WARN_ON(local_paca-irq_happened != 0);
-#endif
-
-   /*
-* We enter with interrupts disabled in hardware, but
-* we need to call hard_irq_disable anyway to ensure that
-* the software state is kept in sync.
-*/
-   hard_irq_disable();
-
/* update before a new last_exit_type is rewritten */
kvmppc_update_timing_stats(vcpu);
 
diff --git a/arch/powerpc/kvm/bookehv_interrupts.S 
b/arch/powerpc/kvm/bookehv_interrupts.S
index e8ed7d6..4e867b1 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
@@ -465,6 +467,15 @@ _GLOBAL(kvmppc_resume_host)
mtspr   SPRN_EPCR, r3
isync
 
+#ifdef CONFIG_64BIT
+   /*
+* We enter with interrupts disabled in hardware, but
+* we need to call SOFT_DISABLE_INTS anyway to ensure
+* that the software state is kept in sync.
+*/
+   RECONCILE_IRQ_STATE(r3,r5)
+#endif
+
/* Switch to kernel stack and jump to handler. */
PPC_LL  r3, HOST_RUN(r1)
mr  r5, r14 /* intno */
-- 
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


[PATCH 2/2] KVM: PPC: Book3E HV: call SOFT_DISABLE_INTS to sync the software state

2013-08-06 Thread Tiejun Chen
We enter with interrupts disabled in hardware, but we need to
call SOFT_DISABLE_INTS anyway to ensure that the software state
is kept in sync.

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

diff --git a/arch/powerpc/kvm/bookehv_interrupts.S 
b/arch/powerpc/kvm/bookehv_interrupts.S
index e8ed7d6..4deaf2e 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
@@ -465,6 +467,14 @@ _GLOBAL(kvmppc_resume_host)
mtspr   SPRN_EPCR, r3
isync
 
+#ifdef CONFIG_64BIT
+   /*
+* We enter with interrupts disabled in hardware, but
+* we need to call SOFT_DISABLE_INTS anyway to ensure
+* that the software state is kept in sync.
+*/
+   SOFT_DISABLE_INTS(r3,r5)
+#endif
/* Switch to kernel stack and jump to handler. */
PPC_LL  r3, HOST_RUN(r1)
mr  r5, r14 /* intno */
-- 
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


[PATCH 0/2] KVM: PPC: Book3E HV: Rework to sync the software state

2013-08-06 Thread Tiejun Chen
For more detail please have a look at this :)

http://patchwork.ozlabs.org/patch/257974/
http://ns1.yosemitephotos.net/lists/kvm-ppc/msg07430.html 

Tiejun Chen (2):
  Revert kvm/ppc/booke64: Fix lazy ee handling in kvmppc_handle_exit()
  KVM: PPC: Book3E HV: call SOFT_DISABLE_INTS to sync the software state

 arch/powerpc/kvm/booke.c  |   11 ---
 arch/powerpc/kvm/bookehv_interrupts.S |   10 ++
 2 files changed, 10 insertions(+), 11 deletions(-)

Tiejun
--
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 1/2] Revert kvm/ppc/booke64: Fix lazy ee handling in kvmppc_handle_exit()

2013-08-06 Thread Tiejun Chen
We should revert this commit to rework.

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

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 17722d8..7653c9c 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -833,17 +833,6 @@ int kvmppc_handle_exit(struct kvm_run *run, struct 
kvm_vcpu *vcpu,
int s;
int idx;
 
-#ifdef CONFIG_PPC64
-   WARN_ON(local_paca-irq_happened != 0);
-#endif
-
-   /*
-* We enter with interrupts disabled in hardware, but
-* we need to call hard_irq_disable anyway to ensure that
-* the software state is kept in sync.
-*/
-   hard_irq_disable();
-
/* update before a new last_exit_type is rewritten */
kvmppc_update_timing_stats(vcpu);
 
-- 
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


[v1][PATCH 1/1] powerpc: to access local paca after hard irq disabled

2013-07-14 Thread Tiejun Chen
We can access paca directly after hard interrupt disabled, and
this can avoid accessing wrong paca when using get_paca() in
preempt case.

Signed-off-by: Tiejun Chen tiejun.c...@windriver.com
---
 arch/powerpc/include/asm/hw_irq.h |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/hw_irq.h 
b/arch/powerpc/include/asm/hw_irq.h
index ba713f1..10be1dd 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -96,10 +96,11 @@ static inline bool arch_irqs_disabled(void)
 #endif
 
 #define hard_irq_disable() do {\
-   u8 _was_enabled = get_paca()-soft_enabled; \
+   u8 _was_enabled;\
__hard_irq_disable();   \
-   get_paca()-soft_enabled = 0;   \
-   get_paca()-irq_happened |= PACA_IRQ_HARD_DIS;  \
+   _was_enabled = local_paca-soft_enabled;\
+   local_paca-soft_enabled = 0;   \
+   local_paca-irq_happened |= PACA_IRQ_HARD_DIS;  \
if (_was_enabled)   \
trace_hardirqs_off();   \
 } while(0)
-- 
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


[v1][PATCH 1/1] KVM: PPC: disable preemption when using hard_irq_disable()

2013-07-10 Thread Tiejun Chen
We should ensure the preemption cannot occur while calling get_paca()
insdide hard_irq_disable(), otherwise the paca_struct may be the
wrong one just after. And btw, we may update timing stats in this case.

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

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index dcc94f0..9dae25d 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -839,6 +839,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu 
*vcpu,
WARN_ON(local_paca-irq_happened != 0);
 #endif
 
+   preempt_disable();
/*
 * We enter with interrupts disabled in hardware, but
 * we need to call hard_irq_disable anyway to ensure that
@@ -848,6 +849,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu 
*vcpu,
 
/* update before a new last_exit_type is rewritten */
kvmppc_update_timing_stats(vcpu);
+   preempt_enable();
 
/* restart interrupts if they were meant for the host */
kvmppc_restart_interrupt(vcpu, exit_nr);
-- 
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


[v3][KVM][PATCH 1/1] kvm:ppc: control doorbell exception with CONFIG_PPC_DOORBELL

2013-05-12 Thread Tiejun Chen
We can only use CONFIG_PPC_DOORBELL to control whether
the doorbell exception should be enabled.

Signed-off-by: Tiejun Chen tiejun.c...@windriver.com
---
v3:

Just imporve the patch head.

v2: 

Use CONFIG_PPC_DOORBELL to replace CONFIG_KVM_E500MC as that control condition.


 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 ac7ab08..2d063c7 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -794,7 +794,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_DOORBELL)
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


[v2][KVM][PATCH 1/1] kvm:ppc: enable doorbell exception with CONFIG_PPC_DOORBELL

2013-05-07 Thread Tiejun Chen
CONFIG_PPC_DOORBELL is enough to cover all variants.

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..62d4ece 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_DOORBELL)
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


[v1][KVM][PATCH 1/1] kvm:ppc:booehv: direct ISI exception to Guest

2013-05-07 Thread Tiejun Chen
We also can direct ISI exception to Guest like DSI.

Signed-off-by: Tiejun Chen tiejun.c...@windriver.com
---
 arch/powerpc/kvm/booke_emulate.c |3 +++
 arch/powerpc/kvm/e500mc.c|3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c
index 27a4b28..33b14e9 100644
--- a/arch/powerpc/kvm/booke_emulate.c
+++ b/arch/powerpc/kvm/booke_emulate.c
@@ -197,6 +197,9 @@ int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int 
sprn, ulong spr_val)
break;
case SPRN_IVOR3:
vcpu-arch.ivor[BOOKE_IRQPRIO_INST_STORAGE] = spr_val;
+#ifdef CONFIG_KVM_BOOKE_HV
+   mtspr(SPRN_GIVOR3, spr_val);
+#endif
break;
case SPRN_IVOR4:
vcpu-arch.ivor[BOOKE_IRQPRIO_EXTERNAL] = spr_val;
diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
index c3bdc0a..acf546a 100644
--- a/arch/powerpc/kvm/e500mc.c
+++ b/arch/powerpc/kvm/e500mc.c
@@ -123,6 +123,7 @@ void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 
mtspr(SPRN_GIVPR, vcpu-arch.ivpr);
mtspr(SPRN_GIVOR2, vcpu-arch.ivor[BOOKE_IRQPRIO_DATA_STORAGE]);
+   mtspr(SPRN_GIVOR3, vcpu-arch.ivor[BOOKE_IRQPRIO_INST_STORAGE]);
mtspr(SPRN_GIVOR8, vcpu-arch.ivor[BOOKE_IRQPRIO_SYSCALL]);
mtspr(SPRN_GSPRG0, (unsigned long)vcpu-arch.shared-sprg0);
mtspr(SPRN_GSPRG1, (unsigned long)vcpu-arch.shared-sprg1);
@@ -185,7 +186,7 @@ int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu)
struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
 
vcpu-arch.shadow_epcr = SPRN_EPCR_DSIGS | SPRN_EPCR_DGTMI | \
-SPRN_EPCR_DUVD;
+SPRN_EPCR_DUVD | SPRN_EPCR_ISIGS;
 #ifdef CONFIG_64BIT
vcpu-arch.shadow_epcr |= SPRN_EPCR_ICM;
 #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


[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


[PATCH 1/1] kvm:book3e: Fix a build error

2013-04-25 Thread Tiejun Chen
Commit cd66cc2e, powerpc/85xx: Add AltiVec support for e6500, adds
support for AltiVec on a Book-E class processor, but while compiling 
in the CONFIG_PPC_BOOK3E_64 and CONFIG_VIRTUALIZATION case, this
introduce the following error:

arch/powerpc/kernel/exceptions-64e.S:402: undefined reference to 
`kvmppc_handler_42_0x01B'
arch/powerpc/kernel/built-in.o: In function `exc_altivec_assist_book3e':
arch/powerpc/kernel/exceptions-64e.S:424: undefined reference to 
`kvmppc_handler_43_0x01B'
make: *** [vmlinux] Error 1

Looks we should add these altivec kvm handlers.

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

diff --git a/arch/powerpc/kvm/bookehv_interrupts.S 
b/arch/powerpc/kvm/bookehv_interrupts.S
index e8ed7d6..fa9c78a 100644
--- a/arch/powerpc/kvm/bookehv_interrupts.S
+++ b/arch/powerpc/kvm/bookehv_interrupts.S
@@ -319,6 +319,11 @@ kvm_handler BOOKE_INTERRUPT_DEBUG, EX_PARAMS(DBG), \
SPRN_DSRR0, SPRN_DSRR1, 0
 kvm_handler BOOKE_INTERRUPT_DEBUG, EX_PARAMS(CRIT), \
SPRN_CSRR0, SPRN_CSRR1, 0
+/* altivec */
+kvm_handler BOOKE_INTERRUPT_ALTIVEC_UNAVAIL, EX_PARAMS(GEN), \
+   SPRN_SRR0, SPRN_SRR1, 0
+kvm_handler BOOKE_INTERRUPT_ALTIVEC_ASSIST, EX_PARAMS(GEN), \
+   SPRN_SRR0, SPRN_SRR1, 0
 #else
 /*
  * For input register values, see arch/powerpc/include/asm/kvm_booke_hv_asm.h
-- 
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


[PATCH] KVM/PPC: emulate ehpriv

2013-04-18 Thread Tiejun Chen
We can provide this emulation to simplify more extension later.

Signed-off-by: Tiejun Chen tiejun.c...@windriver.com
---
 arch/powerpc/include/asm/disassemble.h |4 
 arch/powerpc/kvm/e500_emulate.c|   17 +
 2 files changed, 21 insertions(+)

diff --git a/arch/powerpc/include/asm/disassemble.h 
b/arch/powerpc/include/asm/disassemble.h
index 9b198d1..856f8de 100644
--- a/arch/powerpc/include/asm/disassemble.h
+++ b/arch/powerpc/include/asm/disassemble.h
@@ -77,4 +77,8 @@ static inline unsigned int get_d(u32 inst)
return inst  0x;
 }
 
+static inline unsigned int get_oc(u32 inst)
+{
+   return (inst  11)  0x7fff;
+}
 #endif /* __ASM_PPC_DISASSEMBLE_H__ */
diff --git a/arch/powerpc/kvm/e500_emulate.c b/arch/powerpc/kvm/e500_emulate.c
index e78f353..36492cf 100644
--- a/arch/powerpc/kvm/e500_emulate.c
+++ b/arch/powerpc/kvm/e500_emulate.c
@@ -26,6 +26,7 @@
 #define XOP_TLBRE   946
 #define XOP_TLBWE   978
 #define XOP_TLBILX  18
+#define XOP_EHPRIV  270
 
 #ifdef CONFIG_KVM_E500MC
 static int dbell2prio(ulong param)
@@ -80,6 +81,18 @@ static int kvmppc_e500_emul_msgsnd(struct kvm_vcpu *vcpu, 
int rb)
 
return EMULATE_DONE;
 }
+
+static int kvmppc_e500_emul_ehpriv(struct kvm_run *run, struct kvm_vcpu *vcpu,
+   unsigned int inst)
+{
+   int emulated = EMULATE_DONE;
+
+   switch (get_oc(inst)) {
+   default:
+   emulated = EMULATE_FAIL;
+   }
+   return emulated;
+}
 #endif
 
 int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
@@ -130,6 +143,10 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct 
kvm_vcpu *vcpu,
emulated = kvmppc_e500_emul_tlbivax(vcpu, ea);
break;
 
+   case XOP_EHPRIV:
+   emulated = kvmppc_e500_emul_ehpriv(run, vcpu, inst);
+   break;
+
default:
emulated = EMULATE_FAIL;
}
-- 
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