All of lore.kernel.org
 help / color / mirror / Atom feed
* break_cow and cache flushing
@ 2002-10-16 23:53 Kip Walker
  2002-10-17  2:04 ` Ralf Baechle
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kip Walker @ 2002-10-16 23:53 UTC (permalink / raw)
  To: linux-mips


Can anyone comment on the following observations:

1) 'flush_cache_page' seems to be intended for flushing virtually
indexed dcaches when a virtual->physical mapping changes (based on
PAddr)
2) 'flush_page_to_ram' is also related to avoiding virtual aliasing in
the dcache (based on VAddr)
3) 'flush_icache_page' seems to be intended for making the icache
coherent with the dcache after an executable page has been filled
4) 'break_cow' may copy an executable page that is marked executable,
for example a stack page (which has VM_EXEC) and might contain a live
signal trampoline

On a CPU with writeback physically indexed/tagged dcache and virtually
indexed icache that isn't coherent with the dcache, (1) and (2) are NOPs
and (3) must writeback the dcache and flush the icache.

BUT either my understanding of (1) or (2) is wrong, or 'break_cow' needs
to do a 'flush_icache_page' when the page is executable.  Consider the
following (evil) case.

A process takes a signal, and calls 'fork' from the handler.  The signal
trampoline is sitting in the stack, and both processes end up with the
stack page COW.  The parent ends up breaking the COW and so it gets the
new copy of the page, but if the caches aren't flushed, it may execute
garbage from the old contents of the new stack page.

Whew.

I've verified that doing a 'flush_icache_page' in 'break_cow' whenever
an executable page is copied (which shouldn't be too often, I'd guess)
and leaving 'flush_cache_page' and 'flush_page_to_ram' as NOPs seems
stable (and fixes the previously crashing case described above).

Kip

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-10-17  3:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-16 23:53 break_cow and cache flushing Kip Walker
2002-10-17  2:04 ` Ralf Baechle
2002-10-17  2:09 ` Ralf Baechle
2002-10-17  2:49 ` Nigel Weeks
2002-10-17  2:49   ` Nigel Weeks

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.