]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
arm64: mm: ensure patched kernel text is fetched from PoU
authorWill Deacon <will.deacon@arm.com>
Tue, 4 Aug 2015 16:49:36 +0000 (17:49 +0100)
committerWill Deacon <will.deacon@arm.com>
Wed, 5 Aug 2015 09:05:20 +0000 (10:05 +0100)
commit8ec41987436d566f7c4559c6871738b869f7ef07
tree385d1fc297fc0521fd22ab0120751f0e76e3053d
parent04b8637be92f284409651088f3856f4290a931d8
arm64: mm: ensure patched kernel text is fetched from PoU

The arm64 booting document requires that the bootloader has cleaned the
kernel image to the PoC. However, when a CPU re-enters the kernel due to
either a CPU hotplug "on" event or resuming from a low-power state (e.g.
cpuidle), the kernel text may in-fact be dirty at the PoU due to things
like alternative patching or even module loading.

Thanks to I-cache speculation with the MMU off, stale instructions could
be fetched prior to enabling the MMU, potentially leading to crashes
when executing regions of code that have been modified at runtime.

This patch addresses the issue by ensuring that the local I-cache is
invalidated immediately after a CPU has enabled its MMU but before
jumping out of the identity mapping. Any stale instructions fetched from
the PoC will then be discarded and refetched correctly from the PoU.
Patching kernel text executed prior to the MMU being enabled is
prohibited, so the early entry code will always be clean.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/kernel/head.S
arch/arm64/kernel/sleep.S
arch/arm64/mm/proc.S