From: Scott Wood <scottwood@freescale.com>
To: Jia Hongtao-B38951 <B38951@freescale.com>
Cc: Wood Scott-B07421 <B07421@freescale.com>,
David Laight <David.Laight@ACULAB.COM>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
Stuart Yoder <b08248@gmail.com>
Subject: Re: [PATCH V4] powerpc/85xx: Add machine check handler to fix PCIe erratum on mpc85xx
Date: Tue, 12 Mar 2013 16:24:12 -0500 [thread overview]
Message-ID: <1363123452.17135.13@snotra> (raw)
In-Reply-To: <412C8208B4A0464FA894C5F0C278CD5D01C15369@039-SN1MPN1-003.039d.mgd.msft.net> (from B38951@freescale.com on Tue Mar 12 02:40:39 2013)
On 03/12/2013 02:40:39 AM, Jia Hongtao-B38951 wrote:
>=20
>=20
> > -----Original Message-----
> > From: Wood Scott-B07421
> > Sent: Saturday, March 09, 2013 8:49 AM
> > To: Jia Hongtao-B38951
> > Cc: Wood Scott-B07421; David Laight; linuxppc-dev@lists.ozlabs.org;
> > Stuart Yoder
> > Subject: Re: [PATCH V4] powerpc/85xx: Add machine check handler to =20
> fix
> > PCIe erratum on mpc85xx
> >
> > On 03/08/2013 02:01:46 AM, Jia Hongtao-B38951 wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: Wood Scott-B07421
> > > > Sent: Friday, March 08, 2013 12:38 AM
> > > > To: Jia Hongtao-B38951
> > > > Cc: David Laight; Wood Scott-B07421; =20
> linuxppc-dev@lists.ozlabs.org;
> > > > Stuart Yoder
> > > > Subject: Re: [PATCH V4] powerpc/85xx: Add machine check handler =20
> to
> > > fix
> > > > PCIe erratum on mpc85xx
> > > >
> > > > On 03/07/2013 02:06:05 AM, Jia Hongtao-B38951 wrote:
> > > > > Here is the ideas from Scott:
> > > > > "
> > > > > > + if (is_in_pci_mem_space(addr)) {
> > > > > > + inst =3D *(unsigned int *)regs->nip;
> > > > >
> > > > > Be careful about taking a fault here. A simple TLB miss =20
> should be
> > > > > safe given that we shouldn't be accessing PCIe in the middle =20
> of
> > > > > exception code, but what if the mapping has gone away (e.g. a
> > > > > userspace driver had its code munmap()ed or swapped out)? =20
> What if
> > > > > permissions allow execute but not read (not sure if Linux will
> > > allow
> > > > > this, but the hardware does)?
> > > > >
> > > > > What if it happened in a KVM guest? You can't access guest
> > > addresses
> > > > > directly.
> > > > > "
> > > >
> > > > That means you need to be careful about how you read the
> > > instruction, not
> > > > that you shouldn't do it at all.
> > > >
> > > > -Scott
> > >
> > > I agree.
> > >
> > > Do you have a more secure way to get the instruction?
> > > Or what should be done to avoid permission break issue?
> >
> > probe_kernel_address() should take care of userspace issues. As for
> > KVM, if you see MSR_GS set, bail out and don't apply the workaround.
> > Let KVM/QEMU deal with it as it wishes (e.g. reflect to the guest =20
> and
> > let its machine check handler do the skipping). On PR-mode KVM =20
> (e.g.
> > on e500v2-based chips) there is no MSR_GS and it just looks like
> > userspace code -- for now just pretend it is user mode.
> >
> > -Scott
>=20
> Hi Scott,
>=20
> Is that OK if I use the following code?
>=20
> u32 inst;
> int ret;
>=20
> if (is_in_pci_mem_space(addr)) {
> if (!user_mode(regs)) {
> ret =3D probe_kernel_address(regs->nip, inst);
Hmm, seems there's no probe_user_address() -- for userspace we =20
basically want the same thing minus the KERNEL_DS. See =20
arch/powerpc/perf/callchain.c for an example.
You also need to skip this if (regs->msr & MSR_GS) as I mentioned above.
> if (!ret) {
> rd =3D get_rt(inst);
> regs->gpr[rd] =3D 0xffffffff;
> }
Check whether the instruction is a load, as David pointed out. Also =20
check the size of the load, whether it was load with update =20
instruction, etc.
-Scott=
next prev parent reply other threads:[~2013-03-12 21:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-04 8:40 [PATCH V4] powerpc/85xx: Add machine check handler to fix PCIe erratum on mpc85xx Jia Hongtao
2013-03-04 16:16 ` Stuart Yoder
2013-03-04 23:45 ` Scott Wood
2013-03-05 10:12 ` Jia Hongtao-B38951
2013-03-05 18:47 ` Scott Wood
2013-03-06 8:28 ` Jia Hongtao-B38951
2013-03-06 10:24 ` David Laight
2013-03-07 8:06 ` Jia Hongtao-B38951
2013-03-07 10:04 ` David Laight
2013-03-07 16:37 ` Scott Wood
2013-03-08 8:01 ` Jia Hongtao-B38951
2013-03-09 0:49 ` Scott Wood
2013-03-12 7:40 ` Jia Hongtao-B38951
2013-03-12 9:47 ` David Laight
2013-03-12 21:24 ` Scott Wood [this message]
2013-03-13 9:40 ` David Laight
2013-03-13 16:37 ` Scott Wood
2013-03-15 2:47 ` Jia Hongtao-B38951
2013-03-15 16:34 ` Scott Wood
2013-03-29 8:03 ` Jia Hongtao-B38951
2013-03-29 16:33 ` Scott Wood
2013-04-02 9:28 ` Jia Hongtao-B38951
2013-04-02 19:46 ` Scott Wood
2013-03-04 17:15 ` David Laight
2013-03-05 10:12 ` Jia Hongtao-B38951
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=1363123452.17135.13@snotra \
--to=scottwood@freescale.com \
--cc=B07421@freescale.com \
--cc=B38951@freescale.com \
--cc=David.Laight@ACULAB.COM \
--cc=b08248@gmail.com \
--cc=linuxppc-dev@lists.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).