WSL2-Linux-Kernel/arch/powerpc
Benjamin Herrenschmidt 8d30c14cab powerpc/mm: Rework I$/D$ coherency (v3)
This patch reworks the way we do I and D cache coherency on PowerPC.

The "old" way was split in 3 different parts depending on the processor type:

   - Hash with per-page exec support (64-bit and >= POWER4 only) does it
at hashing time, by preventing exec on unclean pages and cleaning pages
on exec faults.

   - Everything without per-page exec support (32-bit hash, 8xx, and
64-bit < POWER4) does it for all page going to user space in update_mmu_cache().

   - Embedded with per-page exec support does it from do_page_fault() on
exec faults, in a way similar to what the hash code does.

That leads to confusion, and bugs. For example, the method using update_mmu_cache()
is racy on SMP where another processor can see the new PTE and hash it in before
we have cleaned the cache, and then blow trying to execute. This is hard to hit but
I think it has bitten us in the past.

Also, it's inefficient for embedded where we always end up having to do at least
one more page fault.

This reworks the whole thing by moving the cache sync into two main call sites,
though we keep different behaviours depending on the HW capability. The call
sites are set_pte_at() which is now made out of line, and ptep_set_access_flags()
which joins the former in pgtable.c

The base idea for Embedded with per-page exec support, is that we now do the
flush at set_pte_at() time when coming from an exec fault, which allows us
to avoid the double fault problem completely (we can even improve the situation
more by implementing TLB preload in update_mmu_cache() but that's for later).

If for some reason we didn't do it there and we try to execute, we'll hit
the page fault, which will do a minor fault, which will hit ptep_set_access_flags()
to do things like update _PAGE_ACCESSED or _PAGE_DIRTY if needed, we just make
this guys also perform the I/D cache sync for exec faults now. This second path
is the catch all for things that weren't cleaned at set_pte_at() time.

For cpus without per-pag exec support, we always do the sync at set_pte_at(),
thus guaranteeing that when the PTE is visible to other processors, the cache
is clean.

For the 64-bit hash with per-page exec support case, we keep the old mechanism
for now. I'll look into changing it later, once I've reworked a bit how we
use _PAGE_EXEC.

This is also a first step for adding _PAGE_EXEC support for embedded platforms

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2009-02-11 16:00:10 +11:00
..
boot powerpc/amigaone: Bootwrapper and serial console support for AmigaOne 2009-02-11 16:00:09 +11:00
configs powerpc/amigaone: Default config for AmigaOne boards 2009-02-11 16:00:10 +11:00
include/asm powerpc/mm: Rework I$/D$ coherency (v3) 2009-02-11 16:00:10 +11:00
kernel powerpc/pci: Move hose_list and pci_address_to_pio to pci-common 2009-02-11 16:00:07 +11:00
kvm KVM: Consolidate userspace memory capability reporting into common code 2008-12-31 16:55:46 +02:00
lib powerpc: Don't emulate mr. instructions 2009-02-10 14:39:07 +11:00
math-emu powerpc: Add SPE/EFP math emulation for E500v1/v2 processors. 2008-12-03 08:19:16 -06:00
mm powerpc/mm: Rework I$/D$ coherency (v3) 2009-02-11 16:00:10 +11:00
oprofile powerpc/cell: Add missing #include for oprofile 2009-02-10 14:39:08 +11:00
platforms powerpc/amigaone: Add platform support for AmigaOne 2009-02-11 16:00:08 +11:00
sysdev Merge commit 'kumar/next' into next 2009-02-11 13:37:44 +11:00
xmon powerpc: Prepare xmon_save_regs for use with kdump 2008-12-23 15:13:28 +11:00
Kconfig powerpc/fsl: Ensure PCI_QUIRKS are enabled for FSL_PCI 2009-01-28 18:17:02 -06:00
Kconfig.debug powerpc: Allow the max stack trace depth to be configured 2008-12-03 20:46:35 +11:00
Makefile powerpc: Remove unncessary SPE related compiler flag 2008-12-03 08:19:10 -06:00