Skip to content
  • Will Deacon's avatar
    arm64: mm: ensure patched kernel text is fetched from PoU · 8ec41987
    Will Deacon authored
    
    
    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: default avatarMark Rutland <mark.rutland@arm.com>
    Tested-by: default avatarMark Rutland <mark.rutland@arm.com>
    Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
    8ec41987