linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Neuling <mikey@neuling.org>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org,
	Nicholas Piggin <npiggin@gmail.com>,
	paulus@ozlabs.org, benh@kernel.crashing.org,
	Breno Leitao <leitao@debian.org>,
	 aneesh.kumar@linux.vnet.ibm.com
Subject: Re: [PATCH] powerpc/tm: Avoid possible userspace r1 corruption on reclaim
Date: Wed, 26 Sep 2018 13:46:56 +1000	[thread overview]
Message-ID: <cc2f3d4526039cf71e4dac1c0a231e27d59cb4c0.camel@neuling.org> (raw)
In-Reply-To: <87d0t14wiz.fsf@concordia.ellerman.id.au>

On Tue, 2018-09-25 at 22:00 +1000, Michael Ellerman wrote:
> Michael Neuling <mikey@neuling.org> writes:
> > Current we store the userspace r1 to PACATMSCRATCH before finally
> > saving it to the thread struct.
> >=20
> > In theory an exception could be taken here (like a machine check or
> > SLB miss) that could write PACATMSCRATCH and hence corrupt the
> > userspace r1. The SLB fault currently doesn't touch PACATMSCRATCH, but
> > others do.
> >=20
> > We've never actually seen this happen but it's theoretically
> > possible. Either way, the code is fragile as it is.
> >=20
> > This patch saves r1 to the kernel stack (which can't fault) before we
> > turn MSR[RI] back on. PACATMSCRATCH is still used but only with
> > MSR[RI] off. We then copy r1 from the kernel stack to the thread
> > struct once we have MSR[RI] back on.
> >=20
> > Suggested-by: Breno Leitao <leitao@debian.org>
> > Signed-off-by: Michael Neuling <mikey@neuling.org>
> > ---
> >  arch/powerpc/kernel/tm.S | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >=20
> > diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S
> > index 701b0f5b09..8207816a1e 100644
> > --- a/arch/powerpc/kernel/tm.S
> > +++ b/arch/powerpc/kernel/tm.S
> > @@ -178,6 +178,12 @@ _GLOBAL(tm_reclaim)
> > =20
> >  	std	r11, GPR11(r1)			/* Temporary stash */
> > =20
> > +	/* Move r1 to kernel stack in case PACATMSCRATCH is used once
> > +	 * we turn on RI
> > +	 */
>=20
> I see we still need to send you to Comment Formatting Re-Education Camp.

The rest of that file has they style, so I'm just keeping with that.  I can
submit a patch later to fix them all up.

> I rewrote it a bit too, to hopefully be clearer?
>=20
> 	/*
> 	 * Move the saved user r1 to the kernel stack in case PACATMSCRATCH is
> 	 * clobbered by an exception once we turn on MSR_RI below.
> 	 */
> 	ld	r11, PACATMSCRATCH(r13)
> 	std	r11, GPR1(r1)

Yeah, that's clearer... thanks.

Mikey

  reply	other threads:[~2018-09-26  3:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-25  9:36 [PATCH] powerpc/tm: Avoid possible userspace r1 corruption on reclaim Michael Neuling
2018-09-25 12:00 ` Michael Ellerman
2018-09-26  3:46   ` Michael Neuling [this message]
2018-09-27  6:41     ` Michael Ellerman
2018-09-26 12:13 ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc2f3d4526039cf71e4dac1c0a231e27d59cb4c0.camel@neuling.org \
    --to=mikey@neuling.org \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=leitao@debian.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=paulus@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).