Skip to contentSkip to conversation

ppc fails to clear MSR_POW when incurring exception

Qemu-devel In review till 6 participants 17 messages Jul 21, 2010 – Oct 31, 2016

lore
Share & tools
lore

till

author
#0 lore raw

Public bug reported:

QEMU VERSION: 0.12.4

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so. Resetting the bit is necessary in order to bring the processor out of power-management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

** Affects: qemu
Importance: Undecided
Status: New

Signature · 12 lines
ppc fails to clear MSR_POW when incurring exception
https://bugs.launchpad.net/bugs/608107
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: New

Bug description:
QEMU VERSION: 0.12.4

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
Resetting the bit is necessary in order to bring the processor out of power-management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.
author
#1 lore raw

** Patch added: "Suggested fix"
http://launchpadlibrarian.net/52250654/ppc-msr_pow-clear.diff

Signature · 12 lines
ppc fails to clear MSR_POW when incurring exception
https://bugs.launchpad.net/bugs/608107
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: New

Bug description:
QEMU VERSION: 0.12.4

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
Resetting the bit is necessary in order to bring the processor out of power-management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.
#2 lore raw

PATCH 1/1 target-ppc: clear MSR_POW on interrupt

From: till <[email protected]>

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
Resetting the bit is necessary in order to bring the processor out of power management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

https://bugs.launchpad.net/qemu/+bug/608107

---
 target-ppc/helper.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
target-ppc/helper.c +1 -0
index f66fb30..0bb353e 100644
@@ -2578,6 +2578,7 @@ static inline void powerpc_excp(CPUState *env, int excp_model, int excp)
     if (new_msr & ((1 << MSR_IR) | (1 << MSR_DR)))
         tlb_flush(env, 1);
     /* reload MSR with correct bits */
+    new_msr &= ~((target_ulong)1 << MSR_POW);
     new_msr &= ~((target_ulong)1 << MSR_EE);
     new_msr &= ~((target_ulong)1 << MSR_PR);
     new_msr &= ~((target_ulong)1 << MSR_FP);
#3 lore raw

Re: [Qemu-devel] [PATCH] target-ppc: clear MSR_POW on interrupt

Quoted 10 lines · Thomas Monjalon

From: till <[email protected]>

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
Resetting the bit is necessary in order to bring the processor out of power management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

This doesn't look right. POW shouldn't even get stored in SRR1. Could you please redo the patch and make sure that mtmsr masks out MSR_POW?

Alex

#4 lore raw

Re: [Qemu-devel] [PATCH] target-ppc: clear MSR_POW on interrupt

Quoted 11 lines · Alexander Graf
Quoted 9 lines · Thomas Monjalon

From: till <[email protected]>

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
Resetting the bit is necessary in order to bring the processor out of power management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

Quoted 2 lines

This doesn't look right. POW shouldn't even get stored in SRR1. Could you please redo the patch and make sure that mtmsr masks out MSR_POW?

Could you point sections of the specification for these requirements ?

I think SRR1 can save any bits. Non significant bits can be overriden and are masked out when RFI occurs.

Signature · 1 line
Thomas
#5 lore raw

Re: [Qemu-devel] [PATCH] target-ppc: clear MSR_POW on interrupt

Quoted 14 lines · Thomas Monjalon
Quoted 12 lines · Alexander Graf
Quoted 10 lines · Thomas Monjalon

From: till <[email protected]>

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
Resetting the bit is necessary in order to bring the processor out of power management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

Quoted 9 lines
Quoted 3 lines

This doesn't look right. POW shouldn't even get stored in SRR1. Could you please redo the patch and make sure that mtmsr masks out MSR_POW?

Could you point sections of the specification for these requirements ?

I think SRR1 can save any bits. Non significant bits can be overriden and are masked out when RFI occurs.

I'm not saying I'm 100% sure on this, but take a look at the e300 reference manual
(http://cache.freescale.com/files/32bit/doc/ref_manual/e300coreRM.pdf)
section 5.2.3. POW is bit 13 in this notion. I don't see it getting saved to SRR1.

Alex

#6 lore raw

Re: [Qemu-devel] [PATCH] target-ppc: clear MSR_POW on interrupt

Quoted 18 lines · Alexander Graf
Quoted 17 lines · Thomas Monjalon
Quoted 11 lines · Alexander Graf
Quoted 9 lines · Thomas Monjalon

From: till <[email protected]>

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
Resetting the bit is necessary in order to bring the processor out of power management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

Quoted 2 lines

This doesn't look right. POW shouldn't even get stored in SRR1. Could you please redo the patch and make sure that mtmsr masks out MSR_POW?

Could you point sections of the specification for these requirements ?

Quoted 8 lines
Quoted 2 lines

I think SRR1 can save any bits. Non significant bits can be overriden and are masked out when RFI occurs.

I'm not saying I'm 100% sure on this, but take a look at the e300 reference manual
(http://cache.freescale.com/files/32bit/doc/ref_manual/e300coreRM.pdf)
section 5.2.3. POW is bit 13 in this notion. I don't see it getting saved to SRR1.

The current implementation (commit c3d420e) save all the bits and restore only the needed ones (excluding POW). So POW is cleared after an interrupt.

But the subject of this patch wasn't on saved bits. It is to clear POW in the interrupt context. For an unknown reason, it's not done and it's clearly a bug to fix.

Signature · 1 line
Thomas
#7 lore raw

Re: [Qemu-devel] [PATCH] target-ppc: clear MSR_POW on interrupt

Quoted 33 lines · Thomas Monjalon
Quoted 21 lines · Alexander Graf
Quoted 19 lines · Thomas Monjalon
Quoted 12 lines · Alexander Graf
Quoted 10 lines · Thomas Monjalon

From: till <[email protected]>

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
Resetting the bit is necessary in order to bring the processor out of power management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

Quoted 3 lines

This doesn't look right. POW shouldn't even get stored in SRR1. Could you please redo the patch and make sure that mtmsr masks out MSR_POW?

Could you point sections of the specification for these requirements ?

Quoted 9 lines
Quoted 3 lines

I think SRR1 can save any bits. Non significant bits can be overriden and are masked out when RFI occurs.

I'm not saying I'm 100% sure on this, but take a look at the e300 reference manual
(http://cache.freescale.com/files/32bit/doc/ref_manual/e300coreRM.pdf)
section 5.2.3. POW is bit 13 in this notion. I don't see it getting saved to SRR1.

Quoted 7 lines

The current implementation (commit c3d420e) save all the bits and restore only the needed ones (excluding POW). So POW is cleared after an interrupt.

But the subject of this patch wasn't on saved bits. It is to clear POW in the interrupt context. For an unknown reason, it's not done and it's clearly a bug to fix.

I completely agree. In fact, the mere fact that a bit can slip through this loop indicates that something goes wrong.

As far as SRR1 goes, PowerISA 2.06 draws an even more complicated
picture: Page 816 says that SRR1 bits 42:44 indicate the power save exit reason while 46:47 indicate how much state was transferred. Bit 45 would be MSR_POW which is defined as "set to 0".

Because that means that we'll have to set MSR_POW in to 0 in SRR1 and the interrupt switching function, we can just set it to 0 on mtmsr. That was my point :).

Alex

#8 lore raw

Re: [Qemu-devel] [PATCH] target-ppc: clear MSR_POW on interrupt

Quoted 45 lines · Alexander Graf
Quoted 33 lines · Thomas Monjalon
Quoted 21 lines · Alexander Graf
Quoted 19 lines · Thomas Monjalon
Quoted 12 lines · Alexander Graf
Quoted 10 lines · Thomas Monjalon

From: till <[email protected]>

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
Resetting the bit is necessary in order to bring the processor out of power management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

Quoted 3 lines

This doesn't look right. POW shouldn't even get stored in SRR1. Could you please redo the patch and make sure that mtmsr masks out MSR_POW?

Could you point sections of the specification for these requirements ?

Quoted 9 lines
Quoted 3 lines

I think SRR1 can save any bits. Non significant bits can be overriden and are masked out when RFI occurs.

I'm not saying I'm 100% sure on this, but take a look at the e300 reference manual
(http://cache.freescale.com/files/32bit/doc/ref_manual/e300coreRM.pdf)
section 5.2.3. POW is bit 13 in this notion. I don't see it getting saved to SRR1.

Quoted 7 lines

The current implementation (commit c3d420e) save all the bits and restore only the needed ones (excluding POW). So POW is cleared after an interrupt.

But the subject of this patch wasn't on saved bits. It is to clear POW in the interrupt context. For an unknown reason, it's not done and it's clearly a bug to fix.

I completely agree. In fact, the mere fact that a bit can slip through this loop indicates that something goes wrong.

Quoted 8 lines

As far as SRR1 goes, PowerISA 2.06 draws an even more complicated
picture: Page 816 says that SRR1 bits 42:44 indicate the power save exit reason while 46:47 indicate how much state was transferred. Bit 45 would be MSR_POW which is defined as "set to 0".

Because that means that we'll have to set MSR_POW in to 0 in SRR1 and the interrupt switching function, we can just set it to 0 on mtmsr. That was my point :).

Hi,

I'm not very familiar with PPC but the way I interpret it, we should clear the POW bit in both MSR and SRR1 when the interrupt waking the CPU is taken. While the CPU is sleeping, the POW bit should remain set in MSR though.

As Alex comments, the submited patch fails to make sure the SRR1 bit 13 is cleared when taking the interrupt, but I don't think clearing MSR[POW] in mtmsr is the right thing. In practice it probably doesn't matter much, possibly a bit annoying if you inspect the sleeping state from a debugger or similar.

I think mtmsr should set MSR[POW] and powerpc_excp() should clear MSR[POW] prior to copying MSR into SRR1.

Not sure, but thats the way I interpret it...

Cheers

#9 lore raw

Re: [Qemu-devel] [PATCH] target-ppc: clear MSR_POW on interrupt

Am 10.09.2010 um 18:08 schrieb "Edgar E. Iglesias" <[email protected]>:

Quoted 68 lines · Alexander Graf
Quoted 45 lines
Quoted 33 lines · Thomas Monjalon
Quoted 21 lines · Alexander Graf
Quoted 19 lines · Thomas Monjalon
Quoted 12 lines · Alexander Graf
Quoted 10 lines · Thomas Monjalon

From: till <[email protected]>

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
Resetting the bit is necessary in order to bring the processor out of power management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

Quoted 3 lines

This doesn't look right. POW shouldn't even get stored in SRR1. Could you please redo the patch and make sure that mtmsr masks out MSR_POW?

Could you point sections of the specification for these requirements ?

Quoted 9 lines
Quoted 3 lines

I think SRR1 can save any bits. Non significant bits can be overriden and are masked out when RFI occurs.

I'm not saying I'm 100% sure on this, but take a look at the e300 reference manual
(http://cache.freescale.com/files/32bit/doc/ref_manual/e300coreRM.pdf)
section 5.2.3. POW is bit 13 in this notion. I don't see it getting saved to SRR1.

Quoted 7 lines

The current implementation (commit c3d420e) save all the bits and restore only the needed ones (excluding POW). So POW is cleared after an interrupt.

But the subject of this patch wasn't on saved bits. It is to clear POW in the interrupt context. For an unknown reason, it's not done and it's clearly a bug to fix.

I completely agree. In fact, the mere fact that a bit can slip through this loop indicates that something goes wrong.

Quoted 8 lines

As far as SRR1 goes, PowerISA 2.06 draws an even more complicated
picture: Page 816 says that SRR1 bits 42:44 indicate the power save exit reason while 46:47 indicate how much state was transferred. Bit 45 would be MSR_POW which is defined as "set to 0".

Because that means that we'll have to set MSR_POW in to 0 in SRR1 and the interrupt switching function, we can just set it to 0 on mtmsr. That was my point :).

Hi,

I'm not very familiar with PPC but the way I interpret it, we should clear the POW bit in both MSR and SRR1 when the interrupt waking the CPU is taken. While the CPU is sleeping, the POW bit should remain set in MSR though.

As Alex comments, the submited patch fails to make sure the SRR1 bit 13 is cleared when taking the interrupt, but I don't think clearing MSR[POW] in mtmsr is the right thing. In practice it probably doesn't matter much, possibly a bit annoying if you inspect the sleeping state from a debugger or similar.

Quoted 4 lines

I think mtmsr should set MSR[POW] and powerpc_excp() should clear MSR[POW] prior to copying MSR into SRR1.

Not sure, but thats the way I interpret it...

Agreed.

Alex

Quoted 1 line
#10 lore raw

Re: [Qemu-devel] [PATCH] target-ppc: clear MSR_POW on interrupt

Quoted 1 line · Alexander Graf

Am 10.09.2010 um 18:08 schrieb "Edgar E. Iglesias"

<[email protected]>:

Quoted 65 lines
Quoted 65 lines · Alexander Graf
Quoted 42 lines
Quoted 30 lines · Thomas Monjalon
Quoted 20 lines · Alexander Graf
Quoted 19 lines · Thomas Monjalon
Quoted 11 lines · Alexander Graf
Quoted 9 lines · Thomas Monjalon

From: till <[email protected]>

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so. Resetting the bit is necessary in order to bring the processor out of power management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

Quoted 3 lines

This doesn't look right. POW shouldn't even get stored in SRR1. Could you please redo the patch and make sure that mtmsr masks out MSR_POW?

Could you point sections of the specification for these requirements ?

Quoted 8 lines
Quoted 2 lines

I think SRR1 can save any bits. Non significant bits can be overriden and are masked out when RFI occurs.

I'm not saying I'm 100% sure on this, but take a look at the e300 reference manual
(http://cache.freescale.com/files/32bit/doc/ref_manual/e300coreRM.pdf)
section 5.2.3. POW is bit 13 in this notion. I don't see it getting saved to SRR1.

Quoted 7 lines

The current implementation (commit c3d420e) save all the bits and restore only the needed ones (excluding POW). So POW is cleared after an interrupt.

But the subject of this patch wasn't on saved bits. It is to clear POW in the interrupt context. For an unknown reason, it's not done and it's clearly a bug to fix.

I completely agree. In fact, the mere fact that a bit can slip through this loop indicates that something goes wrong.

Quoted 8 lines

As far as SRR1 goes, PowerISA 2.06 draws an even more complicated
picture: Page 816 says that SRR1 bits 42:44 indicate the power save exit reason while 46:47 indicate how much state was transferred. Bit 45 would be MSR_POW which is defined as "set to 0".

Because that means that we'll have to set MSR_POW in to 0 in SRR1 and the interrupt switching function, we can just set it to 0 on mtmsr. That was my point :).

Hi,

I'm not very familiar with PPC but the way I interpret it, we should clear the POW bit in both MSR and SRR1 when the interrupt waking the CPU is taken. While the CPU is sleeping, the POW bit should remain set in MSR though.

As Alex comments, the submited patch fails to make sure the SRR1 bit 13 is cleared when taking the interrupt, but I don't think clearing MSR[POW] in mtmsr is the right thing. In practice it probably doesn't matter much, possibly a bit annoying if you inspect the sleeping state from a debugger or similar.

Quoted 8 lines
Quoted 4 lines

I think mtmsr should set MSR[POW] and powerpc_excp() should clear MSR[POW] prior to copying MSR into SRR1.

Not sure, but thats the way I interpret it...

Agreed.

Alex

I think we should first ack and commit this patch as it is sure it is needed.

Regarding the SRR1 question, it can be another patch because it is more general than the POW bit.
In the commit c3d420e which was about MSR restoring in RFI, I have removed the clearing of bits in SRR1. But I am OK to redo it after check that some exceptions doesn't rely on the presence of these bits. I mean clearing bits in SRR1 can be architecture-specific and exception-specific. Each exception has its own scheme for SRR1 clearing.

Signature · 1 line
Thomas
#11 lore raw

Re: [Qemu-devel] [PATCH] target-ppc: clear MSR_POW on interrupt

Quoted 79 lines · Thomas Monjalon
Quoted 1 line · Alexander Graf

Am 10.09.2010 um 18:08 schrieb "Edgar E. Iglesias"

<[email protected]>:

Quoted 65 lines
Quoted 65 lines · Alexander Graf
Quoted 42 lines
Quoted 30 lines · Thomas Monjalon
Quoted 20 lines · Alexander Graf
Quoted 19 lines · Thomas Monjalon
Quoted 11 lines · Alexander Graf
Quoted 9 lines · Thomas Monjalon

From: till <[email protected]>

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so. Resetting the bit is necessary in order to bring the processor out of power management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

Quoted 3 lines

This doesn't look right. POW shouldn't even get stored in SRR1. Could you please redo the patch and make sure that mtmsr masks out MSR_POW?

Could you point sections of the specification for these requirements ?

Quoted 8 lines
Quoted 2 lines

I think SRR1 can save any bits. Non significant bits can be overriden and are masked out when RFI occurs.

I'm not saying I'm 100% sure on this, but take a look at the e300 reference manual
(http://cache.freescale.com/files/32bit/doc/ref_manual/e300coreRM.pdf)
section 5.2.3. POW is bit 13 in this notion. I don't see it getting saved to SRR1.

Quoted 7 lines

The current implementation (commit c3d420e) save all the bits and restore only the needed ones (excluding POW). So POW is cleared after an interrupt.

But the subject of this patch wasn't on saved bits. It is to clear POW in the interrupt context. For an unknown reason, it's not done and it's clearly a bug to fix.

I completely agree. In fact, the mere fact that a bit can slip through this loop indicates that something goes wrong.

Quoted 8 lines

As far as SRR1 goes, PowerISA 2.06 draws an even more complicated
picture: Page 816 says that SRR1 bits 42:44 indicate the power save exit reason while 46:47 indicate how much state was transferred. Bit 45 would be MSR_POW which is defined as "set to 0".

Because that means that we'll have to set MSR_POW in to 0 in SRR1 and the interrupt switching function, we can just set it to 0 on mtmsr. That was my point :).

Hi,

I'm not very familiar with PPC but the way I interpret it, we should clear the POW bit in both MSR and SRR1 when the interrupt waking the CPU is taken. While the CPU is sleeping, the POW bit should remain set in MSR though.

As Alex comments, the submited patch fails to make sure the SRR1 bit 13 is cleared when taking the interrupt, but I don't think clearing MSR[POW] in mtmsr is the right thing. In practice it probably doesn't matter much, possibly a bit annoying if you inspect the sleeping state from a debugger or similar.

Quoted 8 lines
Quoted 4 lines

I think mtmsr should set MSR[POW] and powerpc_excp() should clear MSR[POW] prior to copying MSR into SRR1.

Not sure, but thats the way I interpret it...

Agreed.

Alex

I think we should first ack and commit this patch as it is sure it is needed.

Quoted 8 lines

Regarding the SRR1 question, it can be another patch because it is more general than the POW bit.

In the commit c3d420e which was about MSR restoring in RFI, I have removed the clearing of bits in SRR1. But I am OK to redo it after check that some exceptions doesn't rely on the presence of these bits. I mean clearing bits in SRR1 can be architecture-specific and exception-specific. Each exception has its own scheme for SRR1 clearing.

But the MSR[POW] should be cleared prior to beeing copied to SRR1. I dont see the point in submitting a followup patch that moves the clearing a couple of lines up the c-file.

What about the following?

commit 7022e89d74a4299dbb431c89a684a428119242ab

Author: Edgar E. Iglesias <[email protected]>
Date:   Fri Sep 10 21:36:09 2010 +0200

powerpc: Clear MSR[POW] when taking exceptions

When taking exceptions, clear the POW or WE bit to inditcate that the CPU is awake. Do it prior to saving the MSR into SRR1.

target-ppc/helper.c +2 -0
index d342b09..c25c610 100644
@@ -2075,6 +2075,8 @@ static inline void powerpc_excp(CPUState *env, int excp_model, int excp)
     qemu_log_mask(CPU_LOG_INT, "Raise exception at " TARGET_FMT_lx
                   " => %08x (%02x)\n", env->nip, excp, env->error_code);
     msr = env->msr;
+    /* Taking an exception wakes up the core, clear the POW/WE bit.  */
+    msr &= ~((target_ulong)1 << MSR_POW);
     new_msr = msr;
     srr0 = SPR_SRR0;
     srr1 = SPR_SRR1;
#12 lore raw

Re: [Qemu-devel] [PATCH] target-ppc: clear MSR_POW on interrupt

In reply to Thomas Monjalon
Quoted 79 lines · Thomas Monjalon
Quoted 1 line · Alexander Graf

Am 10.09.2010 um 18:08 schrieb "Edgar E. Iglesias"

<[email protected]>:

Quoted 65 lines
Quoted 65 lines · Alexander Graf
Quoted 42 lines
Quoted 30 lines · Thomas Monjalon
Quoted 20 lines · Alexander Graf
Quoted 19 lines · Thomas Monjalon
Quoted 11 lines · Alexander Graf
Quoted 9 lines · Thomas Monjalon

From: till <[email protected]>

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so. Resetting the bit is necessary in order to bring the processor out of power management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

Quoted 3 lines

This doesn't look right. POW shouldn't even get stored in SRR1. Could you please redo the patch and make sure that mtmsr masks out MSR_POW?

Could you point sections of the specification for these requirements ?

Quoted 8 lines
Quoted 2 lines

I think SRR1 can save any bits. Non significant bits can be overriden and are masked out when RFI occurs.

I'm not saying I'm 100% sure on this, but take a look at the e300 reference manual
(http://cache.freescale.com/files/32bit/doc/ref_manual/e300coreRM.pdf)
section 5.2.3. POW is bit 13 in this notion. I don't see it getting saved to SRR1.

Quoted 7 lines

The current implementation (commit c3d420e) save all the bits and restore only the needed ones (excluding POW). So POW is cleared after an interrupt.

But the subject of this patch wasn't on saved bits. It is to clear POW in the interrupt context. For an unknown reason, it's not done and it's clearly a bug to fix.

I completely agree. In fact, the mere fact that a bit can slip through this loop indicates that something goes wrong.

Quoted 8 lines

As far as SRR1 goes, PowerISA 2.06 draws an even more complicated
picture: Page 816 says that SRR1 bits 42:44 indicate the power save exit reason while 46:47 indicate how much state was transferred. Bit 45 would be MSR_POW which is defined as "set to 0".

Because that means that we'll have to set MSR_POW in to 0 in SRR1 and the interrupt switching function, we can just set it to 0 on mtmsr. That was my point :).

Hi,

I'm not very familiar with PPC but the way I interpret it, we should clear the POW bit in both MSR and SRR1 when the interrupt waking the CPU is taken. While the CPU is sleeping, the POW bit should remain set in MSR though.

As Alex comments, the submited patch fails to make sure the SRR1 bit 13 is cleared when taking the interrupt, but I don't think clearing MSR[POW] in mtmsr is the right thing. In practice it probably doesn't matter much, possibly a bit annoying if you inspect the sleeping state from a debugger or similar.

Quoted 8 lines
Quoted 4 lines

I think mtmsr should set MSR[POW] and powerpc_excp() should clear MSR[POW] prior to copying MSR into SRR1.

Not sure, but thats the way I interpret it...

Agreed.

Alex

I think we should first ack and commit this patch as it is sure it is needed.

Quoted 7 lines

Regarding the SRR1 question, it can be another patch because it is more general than the POW bit.
In the commit c3d420e which was about MSR restoring in RFI, I have removed the clearing of bits in SRR1. But I am OK to redo it after check that some exceptions doesn't rely on the presence of these bits. I mean clearing bits in SRR1 can be architecture-specific and exception-specific. Each exception has its own scheme for SRR1 clearing.

I'm really torn on this one. While you're right, I'd really like to see both issues fixed. To be honest, I don't think the whole function as is makes too much sense. Why would the MSR of an exception handler be based off the MSR we had before?

Alex

#13 lore raw
In reply to till

** Changed in: qemu
Status: New => Confirmed

Signature · 12 lines
ppc fails to clear MSR_POW when incurring exception
https://bugs.launchpad.net/bugs/608107
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: Confirmed

Bug description:
QEMU VERSION: 0.12.4

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
Resetting the bit is necessary in order to bring the processor out of power-management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.
author
#14 lore raw
In reply to till

I'm afraid I don't understand. My the problem and fix doesn't address mtmsr at all. It just makes sure MSR_POW is cleared in MSR when an exception occurs.

Do you mean MSR_POW should masked from MSR before saving it to SRR1? That's already taken care of (target-ppc/helper.c:2074 [qemu-0.12.4]).

Signature · 12 lines
ppc fails to clear MSR_POW when incurring exception
https://bugs.launchpad.net/bugs/608107
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: Confirmed

Bug description:
QEMU VERSION: 0.12.4

According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
Resetting the bit is necessary in order to bring the processor out of power-management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.
#15 lore raw
In reply to till

** Tags added: ppc

Signature · 18 lines
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/608107

Title:
  ppc fails to clear MSR_POW when incurring exception

Status in QEMU:
  Confirmed

Bug description:
  QEMU VERSION: 0.12.4

  According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
  Resetting the bit is necessary in order to bring the processor out of power-management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/608107/+subscriptions
#16 lore raw
In reply to till

As far as I can see, this problem has been fixed by this commit here:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=41557447d30eeb944e4
... so I'm setting the status to "Fix released" now.

** Changed in: qemu
Status: Confirmed => Fix Released

Signature · 18 lines
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/608107

Title:
  ppc fails to clear MSR_POW when incurring exception

Status in QEMU:
  Fix Released

Bug description:
  QEMU VERSION: 0.12.4

  According to FreeScale's 'Programming Environments Manual for 32-bit Implementations of the PowerPC Architecture' [MPCFPE32B, Rev.3, 9/2005], section 6.5, table 6-7, an interrupt resets MSR_POW to zero but qemu-0.12.4 fails to do so.
  Resetting the bit is necessary in order to bring the processor out of power-management since otherwise it goes to sleep right away in the exception handler, i.e., it is impossible to leave PM-mode.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/608107/+subscriptions