[PATCH] arm64: kernel: avoid literal load of virtual address with MMU off
mark.rutland at arm.com
Wed Aug 17 10:22:18 PDT 2016
On Wed, Aug 17, 2016 at 06:11:34PM +0100, Catalin Marinas wrote:
> On Wed, Aug 17, 2016 at 05:54:41PM +0200, Ard Biesheuvel wrote:
> > Literal loads of virtual addresses are subject to runtime relocation when
> > CONFIG_RELOCATABLE=y, and given that the relocation routines run with the
> > MMU and caches enabled, literal loads of relocated values performed with
> > the MMU off are not guaranteed to return the latest value unless the
> > memory covering the literal is cleaned to the PoC explicitly.
> > So defer the literal load until after the MMU has been enabled, just like
> > we do for primary_switch() and secondary_switch() in head.S.
> I think for consistency with head.S the patch is fine but do we actually
> expect a literal pool value to be inconsistent between cache and PoC?
> Presumably, the first time the kernel image was loaded it had to be
> cleaned to PoC but after that we wouldn't expect modifications of the
> literal pool data.
The kernel modifies literal pool values within itself, at boot time,
after having enabled the MMU. This is after any loader has cleaned the
kernel Image to the PoC and branched to it with the MMU off.
See __primary_switch in head.S
With upcoming patches , resuming from hibernation can also leave
stale data at the PoC for relocated literals like this.
More information about the linux-arm-kernel