diff mbox

powerpc: Invalidate ERAT on powersave wakeup for POWER9

Message ID 20170622172616.7598-1-mikey@neuling.org (mailing list archive)
State Superseded
Headers show

Commit Message

Michael Neuling June 22, 2017, 5:26 p.m. UTC
On POWER9 the ERAT may be incorrect on wakeup from some stop states
that lose state. This causes random segvs and illegal instructions
when these stop states are enabled.

This patch invalidates the ERAT on wakeup on POWER9 to prevent this
from causing a problem.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 arch/powerpc/kernel/idle_book3s.S | 3 +++
 1 file changed, 3 insertions(+)

Comments

Stewart Smith June 23, 2017, 12:50 a.m. UTC | #1
Michael Neuling <mikey@neuling.org> writes:
> On POWER9 the ERAT may be incorrect on wakeup from some stop states
> that lose state. This causes random segvs and illegal instructions
> when these stop states are enabled.
>
> This patch invalidates the ERAT on wakeup on POWER9 to prevent this
> from causing a problem.
>
> Signed-off-by: Michael Neuling <mikey@neuling.org>

CC: stable?
Michael Neuling June 23, 2017, 2:12 a.m. UTC | #2
Yes please... Would be helpful


On 22 Jun. 2017 7:50 pm, "Stewart Smith" <stewart@linux.vnet.ibm.com> wrote:

> Michael Neuling <mikey@neuling.org> writes:
> > On POWER9 the ERAT may be incorrect on wakeup from some stop states
> > that lose state. This causes random segvs and illegal instructions
> > when these stop states are enabled.
> >
> > This patch invalidates the ERAT on wakeup on POWER9 to prevent this
> > from causing a problem.
> >
> > Signed-off-by: Michael Neuling <mikey@neuling.org>
>
> CC: stable?
>
> --
> Stewart Smith
> OPAL Architect, IBM.
>
>
Michael Neuling June 23, 2017, 3:09 a.m. UTC | #3
On Fri, 2017-06-23 at 10:50 +1000, Stewart Smith wrote:
> Michael Neuling <mikey@neuling.org> writes:
> > On POWER9 the ERAT may be incorrect on wakeup from some stop states
> > that lose state. This causes random segvs and illegal instructions
> > when these stop states are enabled.
> > 
> > This patch invalidates the ERAT on wakeup on POWER9 to prevent this
> > from causing a problem.
> > 
> > Signed-off-by: Michael Neuling <mikey@neuling.org>
> 
> CC: stable?

Yes please!

Mikey
Michael Ellerman June 23, 2017, 9:33 a.m. UTC | #4
Michael Neuling <mikey@neuling.org> writes:

> On POWER9 the ERAT may be incorrect on wakeup from some stop states
> that lose state. This causes random segvs and illegal instructions
> when these stop states are enabled.

Incorrect how?

Because with the ERAT flush where you've put it, there's still a good
amount of code executed prior to the flush isn't there?

ie. we come in at 0x100, do some of the prolog, do IDLE_TEST which takes
us to pnv_powersave_wakeup, which then restores state from the paca
(memory), that returns and then we check KVM ... and then finally we end
up at pnv_wakeup_loss.

Or is there some other path? Or is the ERAT incorrect in some specific
way which means we only need to flush there?

cheers

> diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
> index 1ea14b96f1..ace2ad50c8 100644
> --- a/arch/powerpc/kernel/idle_book3s.S
> +++ b/arch/powerpc/kernel/idle_book3s.S
> @@ -793,6 +793,9 @@ fastsleep_workaround_at_exit:
>   */
>  .global pnv_wakeup_loss
>  pnv_wakeup_loss:
> +BEGIN_FTR_SECTION
> +	PPC_INVALIDATE_ERAT
> +END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
>  	ld	r1,PACAR1(r13)
>  BEGIN_FTR_SECTION
>  	CHECK_HMI_INTERRUPT
> -- 
> 2.11.0
Anshuman Khandual June 23, 2017, 10:22 a.m. UTC | #5
On 06/22/2017 10:56 PM, Michael Neuling wrote:
> On POWER9 the ERAT may be incorrect on wakeup from some stop states
> that lose state. This causes random segvs and illegal instructions
> when these stop states are enabled.
> 
> This patch invalidates the ERAT on wakeup on POWER9 to prevent this
> from causing a problem.

Cant there be any real genuine ERAT error on the wake up path
from these states ? Just being curious.
Nicholas Piggin June 23, 2017, 10:24 a.m. UTC | #6
On Fri, 23 Jun 2017 19:33:23 +1000
Michael Ellerman <mpe@ellerman.id.au> wrote:

> Michael Neuling <mikey@neuling.org> writes:
> 
> > On POWER9 the ERAT may be incorrect on wakeup from some stop states
> > that lose state. This causes random segvs and illegal instructions
> > when these stop states are enabled.  
> 
> Incorrect how?

It can have stale ERAT entries from another idle thread.

> 
> Because with the ERAT flush where you've put it, there's still a good
> amount of code executed prior to the flush isn't there?
> 
> ie. we come in at 0x100, do some of the prolog, do IDLE_TEST which takes
> us to pnv_powersave_wakeup, which then restores state from the paca
> (memory), that returns and then we check KVM ... and then finally we end
> up at pnv_wakeup_loss.

In the case of an HMI, we could call into OPAL as well.

> Or is there some other path? Or is the ERAT incorrect in some specific
> way which means we only need to flush there?

I think we're in real mode until returning from pnv_wakeup_loss so those
ERATs should be the same.

Except KVM, which can go to guest and switch on the MMU. My bad, I
suggested putting it into pnv_wakeup_loss.

Flushing at the start of pnv_powersave_wakeup should be safest. I guess
we can avoid it for non-state-loss wakeups if cr3 is lt.

Thanks,
Nick
Benjamin Herrenschmidt June 23, 2017, 10:45 a.m. UTC | #7
On Fri, 2017-06-23 at 19:33 +1000, Michael Ellerman wrote:
> Michael Neuling <mikey@neuling.org> writes:
> 
> > On POWER9 the ERAT may be incorrect on wakeup from some stop states
> > that lose state. This causes random segvs and illegal instructions
> > when these stop states are enabled.
> 
> Incorrect how?

As in stale. Not sure about the details.

> Because with the ERAT flush where you've put it, there's still a good
> amount of code executed prior to the flush isn't there?

In real mode, should be ok.

> ie. we come in at 0x100, do some of the prolog, do IDLE_TEST which takes
> us to pnv_powersave_wakeup, which then restores state from the paca
> (memory), that returns and then we check KVM ... and then finally we end
> up at pnv_wakeup_loss.
> 
> Or is there some other path? Or is the ERAT incorrect in some specific
> way which means we only need to flush there?

I think real mode translations are ok but I'll ask around.

Cheers,
Ben.

> cheers
> 
> > diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
> > index 1ea14b96f1..ace2ad50c8 100644
> > --- a/arch/powerpc/kernel/idle_book3s.S
> > +++ b/arch/powerpc/kernel/idle_book3s.S
> > @@ -793,6 +793,9 @@ fastsleep_workaround_at_exit:
> >   */
> >  .global pnv_wakeup_loss
> >  pnv_wakeup_loss:
> > +BEGIN_FTR_SECTION
> > +	PPC_INVALIDATE_ERAT
> > +END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
> >  	ld	r1,PACAR1(r13)
> >  BEGIN_FTR_SECTION
> >  	CHECK_HMI_INTERRUPT
> > -- 
> > 2.11.0
diff mbox

Patch

diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
index 1ea14b96f1..ace2ad50c8 100644
--- a/arch/powerpc/kernel/idle_book3s.S
+++ b/arch/powerpc/kernel/idle_book3s.S
@@ -793,6 +793,9 @@  fastsleep_workaround_at_exit:
  */
 .global pnv_wakeup_loss
 pnv_wakeup_loss:
+BEGIN_FTR_SECTION
+	PPC_INVALIDATE_ERAT
+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
 	ld	r1,PACAR1(r13)
 BEGIN_FTR_SECTION
 	CHECK_HMI_INTERRUPT