From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [patch 0/2] ARM: Disable outer cache before kexec call
Date: Thu, 01 Jul 2010 18:34:55 +0100 [thread overview]
Message-ID: <1278005695.7482.41.camel@e102109-lin.cambridge.arm.com> (raw)
In-Reply-To: <20100701172128.GB15162@n2100.arm.linux.org.uk>
On Thu, 2010-07-01 at 18:21 +0100, Russell King - ARM Linux wrote:
> On Thu, Jul 01, 2010 at 06:06:53PM +0100, Russell King - ARM Linux wrote:
> > On Thu, Jul 01, 2010 at 10:08:37PM +0530, Shilimkar, Santosh wrote:
> > > > -----Original Message-----
> > > > From: linux-arm-kernel-bounces at lists.infradead.org [mailto:linux-arm-
> > > > kernel-bounces at lists.infradead.org] On Behalf Of Thomas Gleixner
> > > > To: Catalin Marinas
> > > > Cc: LAK
> > > >
> > > > Catalin,
> > > >
> > > > But it can disable the inner caches? That's weird.
> > > >
> > > If the C bit is disabled then it is as good as L1 and L2 are disabled.
> >
> > However, if L2 contains valid cache lines which haven't been written
> > back, the result of disabling the C bit effectively is instantaneous
> > memory corruption.
> >
> > We know that some L2 caches aren't searched if the C bit in the MMU
> > tables is disabled, and for those caches I'd imagine the same thing
> > happens when you clear the C bit in the SCTLR when turning off the
> > MMU. What we currently do for L1 is:
> >
> > - disable interrupts
> > - clean all caches (optionally invalidating)
> > - turn off I & C bits
> > - invalidate all caches
> >
> > The 'clean' is there to push dirty data out of the caches back into
> > memory. We then turn off the I & C bits, ensuring that no new cache
> > lines are read in. At this point, some caches are no longer searched.
> >
> > We then invalidate all caches to ensure that when _something_ later
> > re-enables the caches, that they don't see our stale data.
> >
> > As L2 needs this same handling, what I propose is, for both
> > machine_restart() and machine_kexec():
> >
> > 1. we move the IRQ (and FIQ) disable out of each CPUs proc_fin()
> > 2. call flush_cache_all() immediately after IRQs are disabled
> > (removing any cache flushing from proc_fin() implementations.)
> > 3. call outer_flush_all() (new function) after that
> > 4. call proc_fin() to disable the C & I bits.
> > 5. call flush_cache_all() again to invalidate the inner caches
> > 6. call outer_flush_all() again to invalidate the outer caches
> > 7. whatever's next after the existing cpu_proc_fin()...
> >
> > The only potential problem I see with this is that (5) and (6) may end
> > up writing back some dirty data associated with the stack, and one of
> > these functions may overwrite its return address - thereby causing us
> > to loop back to (2) or (3). I don't think that's a problem as the next
> > time around this 'loop' we won't be creating new dirty cache lines, and
> > we should get to step 7.
>
> Right, something like this. I've not made an effort to fix the L2 bits,
> but I have marked the places where attention is required. The interesting
> bit is the first two files.
>
> The next question this provokes is whether we need a dsb() between steps 3
> and 4, and maybe again between 4 and 5, and possibly after 6 ?
We don't need a dsb() after 3 and 6. The outer_flush_all() function
would need to do a cache_sync (which polls a register) since that's a
background operation on the L2 cache. DSB doesn't have any effect on the
L2 cache.
As for between 4 and 5, we may need an ISB as well (not sure about DSB).
It's worth checking the recommended MMU disabling sequences in the ARM
ARM (if any).
--
Catalin
next prev parent reply other threads:[~2010-07-01 17:34 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-01 16:05 [patch 0/2] ARM: Disable outer cache before kexec call Thomas Gleixner
2010-07-01 16:05 ` [patch 1/2] arm: Disable outer (L2) cache in kexec Thomas Gleixner
2010-07-01 16:05 ` [patch 2/2] arm: Implement l2x0 cache disable function Thomas Gleixner
[not found] ` <AANLkTillHUsJF8brOtHh8tl9Us493GsWfpjhXXsFExY7@mail.gmail.com>
2010-07-02 11:23 ` srinidhi
2010-07-02 11:47 ` Catalin Marinas
2010-07-02 15:29 ` Thomas Gleixner
2010-07-02 16:10 ` Catalin Marinas
2010-07-02 16:39 ` Thomas Gleixner
2010-07-02 16:51 ` Shilimkar, Santosh
2010-07-02 16:54 ` Catalin Marinas
2010-07-02 17:23 ` Russell King - ARM Linux
2010-07-03 7:01 ` Shilimkar, Santosh
2010-07-04 14:07 ` Catalin Marinas
2010-07-04 15:31 ` Shilimkar, Santosh
2010-07-04 19:09 ` Russell King - ARM Linux
2010-07-05 9:12 ` Catalin Marinas
2010-07-02 17:21 ` Russell King - ARM Linux
2010-07-02 16:48 ` Shilimkar, Santosh
2010-07-01 16:14 ` [patch 0/2] ARM: Disable outer cache before kexec call Catalin Marinas
2010-07-01 16:28 ` Thomas Gleixner
2010-07-01 16:35 ` Catalin Marinas
2010-07-01 16:52 ` Thomas Gleixner
2010-07-01 17:14 ` Catalin Marinas
2010-07-02 10:58 ` Tony Lindgren
2010-07-01 16:38 ` Shilimkar, Santosh
2010-07-01 16:41 ` Catalin Marinas
2010-07-01 16:44 ` Shilimkar, Santosh
2010-07-01 17:06 ` Russell King - ARM Linux
2010-07-01 17:21 ` Russell King - ARM Linux
2010-07-01 17:34 ` Catalin Marinas [this message]
2010-07-01 17:48 ` Russell King - ARM Linux
2010-07-01 20:08 ` Thomas Gleixner
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=1278005695.7482.41.camel@e102109-lin.cambridge.arm.com \
--to=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.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).