* [PATCH] powerpc: Invalidate ERAT on powersave wakeup for POWER9
@ 2017-06-22 17:26 Michael Neuling
2017-06-23 0:50 ` Stewart Smith
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Michael Neuling @ 2017-06-22 17:26 UTC (permalink / raw)
To: mpe; +Cc: linuxppc-dev, Nicholas Piggin, benh, Michael Neuling
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(+)
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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] powerpc: Invalidate ERAT on powersave wakeup for POWER9
2017-06-22 17:26 [PATCH] powerpc: Invalidate ERAT on powersave wakeup for POWER9 Michael Neuling
@ 2017-06-23 0:50 ` Stewart Smith
2017-06-23 2:12 ` Michael Neuling
2017-06-23 3:09 ` Michael Neuling
2017-06-23 9:33 ` Michael Ellerman
` (2 subsequent siblings)
3 siblings, 2 replies; 11+ messages in thread
From: Stewart Smith @ 2017-06-23 0:50 UTC (permalink / raw)
To: Michael Neuling, mpe; +Cc: Michael Neuling, linuxppc-dev, Nicholas Piggin
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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] powerpc: Invalidate ERAT on powersave wakeup for POWER9
2017-06-23 0:50 ` Stewart Smith
@ 2017-06-23 2:12 ` Michael Neuling
2017-06-23 3:09 ` Michael Neuling
1 sibling, 0 replies; 11+ messages in thread
From: Michael Neuling @ 2017-06-23 2:12 UTC (permalink / raw)
To: Stewart Smith; +Cc: linuxppc-dev, Michael Ellerman, Nicholas Piggin
[-- Attachment #1: Type: text/plain, Size: 569 bytes --]
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.
>
>
[-- Attachment #2: Type: text/html, Size: 1045 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] powerpc: Invalidate ERAT on powersave wakeup for POWER9
2017-06-23 0:50 ` Stewart Smith
2017-06-23 2:12 ` Michael Neuling
@ 2017-06-23 3:09 ` Michael Neuling
1 sibling, 0 replies; 11+ messages in thread
From: Michael Neuling @ 2017-06-23 3:09 UTC (permalink / raw)
To: Stewart Smith, mpe; +Cc: linuxppc-dev, Nicholas Piggin
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.
> >=20
> > This patch invalidates the ERAT on wakeup on POWER9 to prevent this
> > from causing a problem.
> >=20
> > Signed-off-by: Michael Neuling <mikey@neuling.org>
>=20
> CC: stable?
Yes please!
Mikey
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] powerpc: Invalidate ERAT on powersave wakeup for POWER9
2017-06-22 17:26 [PATCH] powerpc: Invalidate ERAT on powersave wakeup for POWER9 Michael Neuling
2017-06-23 0:50 ` Stewart Smith
@ 2017-06-23 9:33 ` Michael Ellerman
2017-06-23 10:24 ` Nicholas Piggin
2017-06-23 10:45 ` Benjamin Herrenschmidt
2017-06-23 10:22 ` Anshuman Khandual
2017-06-24 17:29 ` [PATCH v2] " Benjamin Herrenschmidt
3 siblings, 2 replies; 11+ messages in thread
From: Michael Ellerman @ 2017-06-23 9:33 UTC (permalink / raw)
To: Michael Neuling; +Cc: linuxppc-dev, Nicholas Piggin, benh, Michael Neuling
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] powerpc: Invalidate ERAT on powersave wakeup for POWER9
2017-06-22 17:26 [PATCH] powerpc: Invalidate ERAT on powersave wakeup for POWER9 Michael Neuling
2017-06-23 0:50 ` Stewart Smith
2017-06-23 9:33 ` Michael Ellerman
@ 2017-06-23 10:22 ` Anshuman Khandual
2017-06-24 17:29 ` [PATCH v2] " Benjamin Herrenschmidt
3 siblings, 0 replies; 11+ messages in thread
From: Anshuman Khandual @ 2017-06-23 10:22 UTC (permalink / raw)
To: Michael Neuling, mpe; +Cc: linuxppc-dev, Nicholas Piggin
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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] powerpc: Invalidate ERAT on powersave wakeup for POWER9
2017-06-23 9:33 ` Michael Ellerman
@ 2017-06-23 10:24 ` Nicholas Piggin
2017-06-23 10:45 ` Benjamin Herrenschmidt
1 sibling, 0 replies; 11+ messages in thread
From: Nicholas Piggin @ 2017-06-23 10:24 UTC (permalink / raw)
To: Michael Ellerman; +Cc: Michael Neuling, linuxppc-dev, benh, Paul Mackerras
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] powerpc: Invalidate ERAT on powersave wakeup for POWER9
2017-06-23 9:33 ` Michael Ellerman
2017-06-23 10:24 ` Nicholas Piggin
@ 2017-06-23 10:45 ` Benjamin Herrenschmidt
1 sibling, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2017-06-23 10:45 UTC (permalink / raw)
To: Michael Ellerman, Michael Neuling; +Cc: linuxppc-dev, Nicholas Piggin
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2] powerpc: Invalidate ERAT on powersave wakeup for POWER9
2017-06-22 17:26 [PATCH] powerpc: Invalidate ERAT on powersave wakeup for POWER9 Michael Neuling
` (2 preceding siblings ...)
2017-06-23 10:22 ` Anshuman Khandual
@ 2017-06-24 17:29 ` Benjamin Herrenschmidt
2017-06-25 5:18 ` Nicholas Piggin
2017-06-29 12:21 ` [v2] " Michael Ellerman
3 siblings, 2 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2017-06-24 17:29 UTC (permalink / raw)
To: Michael Neuling, mpe; +Cc: linuxppc-dev, Nicholas Piggin
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>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2. [BenH] Move to a place before we branch off to KVM if the
core was in a guest. Also add a comment about the
SRR1 bit extraction.
---
arch/powerpc/kernel/exceptions-64s.S | 4 +++-
arch/powerpc/kernel/idle_book3s.S | 7 +++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index ae418b85c17c..b4b2c3a344c4 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -99,7 +99,9 @@ EXC_VIRT_NONE(0x4000, 0x100)
#ifdef CONFIG_PPC_P7_NAP
/*
* If running native on arch 2.06 or later, check if we are waking up
- * from nap/sleep/winkle, and branch to idle handler.
+ * from nap/sleep/winkle, and branch to idle handler. This tests
+ * SRR1 bits 46:47. A non-0 value indicates that we are coming from
+ * a power saving state.
*/
#define IDLETEST(n) \
BEGIN_FTR_SECTION ; \
diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
index 4898d676dcae..3fd65739e105 100644
--- a/arch/powerpc/kernel/idle_book3s.S
+++ b/arch/powerpc/kernel/idle_book3s.S
@@ -489,6 +489,13 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_300)
*/
pnv_restore_hyp_resource_arch300:
/*
+ * Workaround for POWER9, if we lost resources, the ERAT
+ * might have been mixed up and needs flushing.
+ */
+ blt cr3,1f
+ PPC_INVALIDATE_ERAT
+1:
+ /*
* POWER ISA 3. Use PSSCR to determine if we
* are waking up from deep idle state
*/
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2] powerpc: Invalidate ERAT on powersave wakeup for POWER9
2017-06-24 17:29 ` [PATCH v2] " Benjamin Herrenschmidt
@ 2017-06-25 5:18 ` Nicholas Piggin
2017-06-29 12:21 ` [v2] " Michael Ellerman
1 sibling, 0 replies; 11+ messages in thread
From: Nicholas Piggin @ 2017-06-25 5:18 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: Michael Neuling, mpe, linuxppc-dev
On Sat, 24 Jun 2017 12:29:01 -0500
Benjamin Herrenschmidt <benh@kernel.crashing.org> 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.
>
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>
> v2. [BenH] Move to a place before we branch off to KVM if the
> core was in a guest. Also add a comment about the
> SRR1 bit extraction.
This looks a bit safer to me now (avoiding KVM). My understanding is
the real-mode i- and d-ERAT entries are still valid and usable,
which is why this works.
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> arch/powerpc/kernel/exceptions-64s.S | 4 +++-
> arch/powerpc/kernel/idle_book3s.S | 7 +++++++
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
> index ae418b85c17c..b4b2c3a344c4 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -99,7 +99,9 @@ EXC_VIRT_NONE(0x4000, 0x100)
> #ifdef CONFIG_PPC_P7_NAP
> /*
> * If running native on arch 2.06 or later, check if we are waking up
> - * from nap/sleep/winkle, and branch to idle handler.
> + * from nap/sleep/winkle, and branch to idle handler. This tests
> + * SRR1 bits 46:47. A non-0 value indicates that we are coming from
> + * a power saving state.
> */
> #define IDLETEST(n) \
> BEGIN_FTR_SECTION ; \
> diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
> index 4898d676dcae..3fd65739e105 100644
> --- a/arch/powerpc/kernel/idle_book3s.S
> +++ b/arch/powerpc/kernel/idle_book3s.S
> @@ -489,6 +489,13 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_300)
> */
> pnv_restore_hyp_resource_arch300:
> /*
> + * Workaround for POWER9, if we lost resources, the ERAT
> + * might have been mixed up and needs flushing.
> + */
> + blt cr3,1f
> + PPC_INVALIDATE_ERAT
> +1:
> + /*
> * POWER ISA 3. Use PSSCR to determine if we
> * are waking up from deep idle state
> */
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [v2] powerpc: Invalidate ERAT on powersave wakeup for POWER9
2017-06-24 17:29 ` [PATCH v2] " Benjamin Herrenschmidt
2017-06-25 5:18 ` Nicholas Piggin
@ 2017-06-29 12:21 ` Michael Ellerman
1 sibling, 0 replies; 11+ messages in thread
From: Michael Ellerman @ 2017-06-29 12:21 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Michael Neuling; +Cc: linuxppc-dev, Nicholas Piggin
On Sat, 2017-06-24 at 17:29:01 UTC, Benjamin Herrenschmidt 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.
>
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/ba6d334ac230065243a92bb7cb3fd6
cheers
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2017-06-29 12:21 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-22 17:26 [PATCH] powerpc: Invalidate ERAT on powersave wakeup for POWER9 Michael Neuling
2017-06-23 0:50 ` Stewart Smith
2017-06-23 2:12 ` Michael Neuling
2017-06-23 3:09 ` Michael Neuling
2017-06-23 9:33 ` Michael Ellerman
2017-06-23 10:24 ` Nicholas Piggin
2017-06-23 10:45 ` Benjamin Herrenschmidt
2017-06-23 10:22 ` Anshuman Khandual
2017-06-24 17:29 ` [PATCH v2] " Benjamin Herrenschmidt
2017-06-25 5:18 ` Nicholas Piggin
2017-06-29 12:21 ` [v2] " Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).