Skip to contentSkip to conversation

spapr: ignore decr interrupts when MSR_EE is disabled

PATCH In review Nikunj A Dadhania 3 participants 3 messages Jul 14, 2017 – Jul 15, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 spapr: ignore decr interrupts when MSR_EE is disabled

Rebooting a SMP TCG guest is broken for both single/multi threaded TCG.

When reset happens, all the CPUs are in halted state. First CPU is brought out of reset and secondary CPUs would be initialized by the guest kernel using a rtas call start-cpu.

However, in case of TCG, decrementer interrupts keep on coming and waking the secondary CPUs up.

These secondary CPUs would see the decrementer interrupt pending, which makes cpu::has_work() to bring them out of wait loop and start executing tcg_exec_cpu().

The problem with this is all the CPUs wake up and start booting SLOF image, causing the following exception(4 CPUs TCG VM):

[   81.440850] reboot: Restarting system

SLOF
S
SLOF
SLOFLOF[0[0m **********************************************************************
QEMU Starting
Build Date = Mar 3 2017 13:29:19
FW Version = git-66d250ef0fd06bb8
[0m **********************************************************************
QEMU Starting
Build Date = Mar 3 2017 13:29:19
FW Version = git-66d250ef0fd06bb8
[0m *************************************m**********[?25l ********************************************************************** QEMU Starting
Build Date = Mar 3 2017 13:29:19
FW Version = git-66d250ef0fd06bb8
***********************
QEMU Starting
Build Date = Mar 3 2017 13:29:19
FW Version = git-66d250ef0fd06bb8
ERROR: Flatten device tree not available!

exception 300
SRR0 = 00000000000060e4 SRR1 = 800000008000000000000000 SPRG2 = 0000000000400000 SPRG3 = 0000000000004bd8
ERROR: Flatten device tree not available!

exception 300
SRR0 = 00000000000060e4 SRR1 = 800000008000000000000000 SPRG2 = 0000000000400000 SPRG3 = 0000000000004bd8

---
 target/ppc/translate_init.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
target/ppc/translate_init.c +6 -3
index 783bf98..8b98076 100644
@@ -8536,7 +8536,8 @@ static bool cpu_has_work_POWER7(CPUState *cs)
         }
         if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
             (env->spr[SPR_LPCR] & LPCR_P7_PECE1)) {
-            return true;
+            /* Return true only when MSR_EE is enabled */
+            return msr_ee;
         }
         if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) &&
             (env->spr[SPR_LPCR] & LPCR_P7_PECE2)) {
@@ -8693,7 +8694,8 @@ static bool cpu_has_work_POWER8(CPUState *cs)
         }
         if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
             (env->spr[SPR_LPCR] & LPCR_P8_PECE3)) {
-            return true;
+            /* Return true only when MSR_EE is enabled */
+            return msr_ee;
         }
         if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) &&
             (env->spr[SPR_LPCR] & LPCR_P8_PECE4)) {
@@ -8876,7 +8878,8 @@ static bool cpu_has_work_POWER9(CPUState *cs)
         /* Decrementer Exception */
         if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
             (env->spr[SPR_LPCR] & LPCR_DEE)) {
-            return true;
+            /* Return true only when MSR_EE is enabled */
+            return msr_ee;
         }
         /* Machine Check or Hypervisor Maintenance Exception */
         if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK |
Signature · 1 line
2.9.3
#1 lore raw
Quoted 9 lines · Nikunj A Dadhania

Rebooting a SMP TCG guest is broken for both single/multi threaded TCG.

When reset happens, all the CPUs are in halted state. First CPU is brought out of reset and secondary CPUs would be initialized by the guest kernel using a rtas call start-cpu.

However, in case of TCG, decrementer interrupts keep on coming and waking the secondary CPUs up.

Quoted 6 lines

These secondary CPUs would see the decrementer interrupt pending, which makes cpu::has_work() to bring them out of wait loop and start executing tcg_exec_cpu().

The problem with this is all the CPUs wake up and start booting SLOF image, causing the following exception(4 CPUs TCG VM):

This patch isn't right....

target/ppc/translate_init.c static bool cpu_has_work_POWER7(CPUState *cs) · line 8541

Quoted 10 lines
target/ppc/translate_init.c +2 -1
@@ -8536,7 +8536,8 @@ static bool cpu_has_work_POWER7(CPUState *cs)
         }
         if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
             (env->spr[SPR_LPCR] & LPCR_P7_PECE1)) {
-            return true;
+            /* Return true only when MSR_EE is enabled */
+            return msr_ee;
         }

No, the HW will not check MSR_EE, in fact, MSR_EE can purposefully be left off and we might expect a wakeup still.

I think the right fix is for reset to clear the LPCR PECE bits.

Cheers
Ben.

Quoted 22 lines
Quoted 1 line
         if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) &&
             (env->spr[SPR_LPCR] & LPCR_P7_PECE2)) {
target/ppc/translate_init.c +4 -2
@@ -8693,7 +8694,8 @@ static bool cpu_has_work_POWER8(CPUState *cs)
         }
         if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
             (env->spr[SPR_LPCR] & LPCR_P8_PECE3)) {
-            return true;
+            /* Return true only when MSR_EE is enabled */
+            return msr_ee;
         }
         if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) &&
             (env->spr[SPR_LPCR] & LPCR_P8_PECE4)) {
@@ -8876,7 +8878,8 @@ static bool cpu_has_work_POWER9(CPUState *cs)
         /* Decrementer Exception */
         if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
             (env->spr[SPR_LPCR] & LPCR_DEE)) {
-            return true;
+            /* Return true only when MSR_EE is enabled */
+            return msr_ee;
         }
         /* Machine Check or Hypervisor Maintenance Exception */
         if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK |
#2 lore raw

On 15-Jul-2017 8:10 AM, "Benjamin Herrenschmidt" <[email protected]> wrote:

Quoted 3 lines · Nikunj A Dadhania

Rebooting a SMP TCG guest is broken for both single/multi threaded TCG.

When reset happens, all the CPUs are in halted state. First CPU is

brought out

Quoted 1 line

of reset and secondary CPUs would be initialized by the guest kernel

using a

Quoted 3 lines

rtas call start-cpu.

However, in case of TCG, decrementer interrupts keep on coming and waking

the

Quoted 3 lines

secondary CPUs up.

These secondary CPUs would see the decrementer interrupt pending, which

makes

Quoted 4 lines

cpu::has_work() to bring them out of wait loop and start executing tcg_exec_cpu().

The problem with this is all the CPUs wake up and start booting SLOF

image,

Quoted 1 line

causing the following exception(4 CPUs TCG VM):

This patch isn't right....

target/ppc/translate_init.c static bool cpu_has_work_POWER7(CPUState *cs) · line 8541

Quoted 10 lines
target/ppc/translate_init.c +2 -1
@@ -8536,7 +8536,8 @@ static bool cpu_has_work_POWER7(CPUState *cs)
         }
         if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) &&
             (env->spr[SPR_LPCR] & LPCR_P7_PECE1)) {
-            return true;
+            /* Return true only when MSR_EE is enabled */
+            return msr_ee;
         }

No, the HW will not check MSR_EE, in fact, MSR_EE can purposefully be left off and we might expect a wakeup still.

Here we had a decr timer callback which is started during machine init and remains on even during reset.

In case of HW, does the decr stop on reset?

I think the right fix is for reset to clear the LPCR PECE bits.

Ok, let me try that out.

Regards
Nikunj