From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Kevin Hao <haokexin@gmail.com>
Cc: Wang Dongsheng-B40534 <B40534@freescale.com>,
linuxppc <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH] powerpc: add the missing required isync for the coherent icache flush
Date: Mon, 19 Aug 2013 22:45:35 +1000 [thread overview]
Message-ID: <1376916335.25016.72.camel@pasglop> (raw)
In-Reply-To: <20130819115029.GD20146@pek-khao-d1.corp.ad.wrs.com>
On Mon, 2013-08-19 at 19:50 +0800, Kevin Hao wrote:
> On Mon, Aug 19, 2013 at 01:37:17PM +1000, Benjamin Herrenschmidt wrote:
> > On Mon, 2013-08-19 at 13:36 +1000, Benjamin Herrenschmidt wrote:
> >
> > > The semantic of this function is to make data executable. Even if the
> > > implementation has a snooping icache, it *still* needs to make sure
> > > prefetched code is tossed out of the pipeline which is what isync
> > > should provide.
> > >
> > > The architecture actually specifies that.
> >
> > In fact, on P5 and later, I think we are supposed to do a single dummy
> > icbi followed by sync and isync.
>
> Do you mean something like this? But why?
It has to do with making sure prefetched and/or speculated instructions
are properly tossed.
My understanding is that icbi basically tells the ifetch buffers to drop
it, sync orders the icbi and isync ensures its execution has been
synchronized. At least I *think* that's the required sequence, I have to
dbl check the arch, maybe tomorrow. I wouldn't be surprise if we also
need a sync before the icbi to order the actual stores to memory that
might have modified instructions with the icbi.
Cheers,
Ben.
> diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
> index d74fefb..8fcdec7 100644
> --- a/arch/powerpc/kernel/misc_64.S
> +++ b/arch/powerpc/kernel/misc_64.S
> @@ -69,6 +69,8 @@ PPC64_CACHES:
>
> _KPROBE(flush_icache_range)
> BEGIN_FTR_SECTION
> + icbi 0,r3
> + sync
> isync
> blr
> END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
> @@ -209,6 +211,8 @@ _GLOBAL(flush_inval_dcache_range)
> */
> _GLOBAL(__flush_dcache_icache)
> BEGIN_FTR_SECTION
> + icbi 0,r3
> + sync
> isync
> blr
> END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
>
> Thanks,
> Kevin
>
> >
> > Cheers,
> > Ben.
> >
> > > Cheers,
> > > Ben.
> > >
> > > > > blr
> > > > > END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
> > > > > rlwinm r3,r3,0,0,31-PAGE_SHIFT /* Get page base address
> > > > > */
> > > > > @@ -474,6 +475,7 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_TYPE_44x)
> > > > > */
> > > > > _GLOBAL(__flush_dcache_icache_phys)
> > > > > BEGIN_FTR_SECTION
> > > > > + isync
> > > > > blr /* for 601, do nothing */
> > > > > END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
> > > > > mfmsr r10
> > > > > diff --git a/arch/powerpc/kernel/misc_64.S
> > > > > b/arch/powerpc/kernel/misc_64.S
> > > > > index 992a78e..d74fefb 100644
> > > > > --- a/arch/powerpc/kernel/misc_64.S
> > > > > +++ b/arch/powerpc/kernel/misc_64.S
> > > > > @@ -69,6 +69,7 @@ PPC64_CACHES:
> > > > >
> > > > > _KPROBE(flush_icache_range)
> > > > > BEGIN_FTR_SECTION
> > > > > + isync
> > > > > blr
> > > > > END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
> > > > > /*
> > > > > --
> > > > > 1.8.3.1
> > > > >
> > > > > _______________________________________________
> > > > > Linuxppc-dev mailing list
> > > > > Linuxppc-dev@lists.ozlabs.org
> > > > > https://lists.ozlabs.org/listinfo/linuxppc-dev
> > > >
> > >
> >
> >
next prev parent reply other threads:[~2013-08-19 12:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-15 11:56 [PATCH] powerpc: add the missing required isync for the coherent icache flush Kevin Hao
2013-08-19 3:24 ` Wang Dongsheng-B40534
2013-08-19 3:36 ` Benjamin Herrenschmidt
2013-08-19 3:37 ` Benjamin Herrenschmidt
2013-08-19 11:50 ` Kevin Hao
2013-08-19 12:45 ` Benjamin Herrenschmidt [this message]
2013-08-20 12:16 ` Kevin Hao
2013-08-20 21:28 ` Benjamin Herrenschmidt
2013-08-21 11:49 ` Kevin Hao
2013-08-22 1:30 ` [PATCH v2] powerpc: purge all the prefetched instructions " Kevin Hao
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=1376916335.25016.72.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=B40534@freescale.com \
--cc=haokexin@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).