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: Fri, 29 Mar 2013 11:33:59 -0500 [thread overview]
Message-ID: <1364574839.13310.0@snotra> (raw)
In-Reply-To: <412C8208B4A0464FA894C5F0C278CD5D01C2EBEA@039-SN1MPN1-003.039d.mgd.msft.net> (from B38951@freescale.com on Fri Mar 29 03:03:51 2013)
On 03/29/2013 03:03:51 AM, Jia Hongtao-B38951 wrote:
>=20
>=20
> > -----Original Message-----
> > From: Wood Scott-B07421
> > Sent: Saturday, March 16, 2013 12:35 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/14/2013 09:47:58 PM, Jia Hongtao-B38951 wrote:
> > >
> > > > -----Original Message-----
> > > > From: Wood Scott-B07421
> > > > Sent: Thursday, March 14, 2013 12:38 AM
> > > > To: David Laight
> > > > Cc: Jia Hongtao-B38951; Wood Scott-B07421;
> > > 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/13/2013 04:40:40 AM, David Laight wrote:
> > > > > > Hmm, seems there's no probe_user_address() -- for userspace =20
> we
> > > > > > basically want the same thing minus the KERNEL_DS. See
> > > > > > arch/powerpc/perf/callchain.c for an example.
> > > > >
> > > > > Isn't that just copy_from_user() ?
> > > >
> > > > Plus pagefault_disable/enable().
> > > >
> > > > -Scott
> > >
> > > pagefault_disable() is identical to preempt_disable(). So I think =20
> this
> > > could not avoid other cpu to swap out the instruction we want to =20
> read
> > > back.
> > > probe_kernel_address() also have the same issue.
> >
> > That's not the point -- the point is to let the page fault handler =20
> know
> > that it should go directly to bad_page_fault(). Do not pass
> > handle_mm_fault(). Do not collect a page from disk.
> >
> > Granted, we're already in atomic context which will have that effect
> > due to being in the machine check handler, but it's better to be
> > explicit about it and not depend on how pagefault_diasble() is
> > implemented.
> >
> > -Scott
>=20
>=20
> Based on the comments I updated the machine check handler.
>=20
> Changes from last version:
> * Check MSR_GS state
> * Check if the instruction is LD
> * Handle the user space issue
>=20
> The updated machine check handler is as following:
>=20
> int fsl_pci_mcheck_exception(struct pt_regs *regs)
> {
> unsigned int op, rd;
> u32 inst;
> int ret;
> phys_addr_t addr =3D 0;
>=20
> /* Let KVM/QEMU deal with the exception */
> if (regs->msr & MSR_GS)
> return 0;
>=20
> #ifdef CONFIG_PHYS_64BIT
> addr =3D mfspr(SPRN_MCARU);
> addr <<=3D 32;
> #endif
> addr +=3D mfspr(SPRN_MCAR);
>=20
> if (is_in_pci_mem_space(addr)) {
> if (user_mode(regs)) {
> pagefault_disable();
> ret =3D copy_from_user(&(inst), (u32 __user =20
> *)regs->nip, sizeof(inst));
> pagefault_enable();
You could use get_user() instead of copy_from_user().
> } else {
> ret =3D probe_kernel_address(regs->nip, inst);
> }
>=20
> op =3D get_op(inst);
> /* Check if the instruction is LD */
> if (!ret && (op =3D=3D 111010)) {
> rd =3D get_rt(inst);
> regs->gpr[rd] =3D 0xffffffff;
> }
>=20
> regs->nip +=3D 4;
> return 1;
> }
>=20
> return 0;
> }
>=20
> BTW, I'm still not sure how to deal with LD instruction with update.
You would need to do the update yourself. Or just say that's a case =20
you don't handle, and return 0.
Again, please check for the size of the load operation.
-Scott=
next prev parent reply other threads:[~2013-03-29 16:34 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
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 [this message]
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=1364574839.13310.0@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.