arm64: kaslr: ignore modulo offset when validating virtual displacement
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 18 Aug 2017 17:42:30 +0000 (18:42 +0100)
committerWill Deacon <will.deacon@arm.com>
Tue, 22 Aug 2017 17:15:42 +0000 (18:15 +0100)
commit4a23e56ad6549d0b8c0fac6d9eb752884379c391
treebe09ef1ef45c2eeede655b2b5f51623e99910cc7
parent289d07a2dc6c6b6f3e4b8a62669320d99dbe6c3d
arm64: kaslr: ignore modulo offset when validating virtual displacement

In the KASLR setup routine, we ensure that the early virtual mapping
of the kernel image does not cover more than a single table entry at
the level above the swapper block level, so that the assembler routines
involved in setting up this mapping can remain simple.

In this calculation we add the proposed KASLR offset to the values of
the _text and _end markers, and reject it if they would end up falling
in different swapper table sized windows.

However, when taking the addresses of _text and _end, the modulo offset
(the physical displacement modulo 2 MB) is already accounted for, and
so adding it again results in incorrect results. So disregard the modulo
offset from the calculation.

Fixes: 08cdac619c81 ("arm64: relocatable: deal with physically misaligned ...")
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/kernel/head.S
arch/arm64/kernel/kaslr.c