]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
arm64: efi: correctly map runtime regions
authorMark Rutland <mark.rutland@arm.com>
Mon, 23 Nov 2015 11:09:11 +0000 (11:09 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 25 Nov 2015 15:49:17 +0000 (15:49 +0000)
commit3b12acf4c999abaf93023af4bd78d931bce2520c
tree7bf0412af9084fed43fe428a4726586ba1fe245f
parentc03784ee8aa99bf6a412e3febf8801c3df86e0ba
arm64: efi: correctly map runtime regions

The kernel may use a page granularity of 4K, 16K, or 64K depending on
configuration.

When mapping EFI runtime regions, we use memrange_efi_to_native to round
the physical base address of a region down to a kernel page boundary,
and round the size up to a kernel page boundary, adding the residue left
over from rounding down the physical base address. We do not round down
the virtual base address.

In __create_mapping we account for the offset of the virtual base from a
granule boundary, adding the residue to the size before rounding the
base down to said granule boundary.

Thus we account for the residue twice, and when the residue is non-zero
will cause __create_mapping to map an additional page at the end of the
region. Depending on the memory map, this page may be in a region we are
not intended/permitted to map, or may clash with a different region that
we wish to map. In typical cases, mapping the next item in the memory
map will overwrite the erroneously created entry, as we sort the memory
map in the stub.

As __create_mapping can cope with base addresses which are not page
aligned, we can instead rely on it to map the region appropriately, and
simplify efi_virtmap_init by removing the unnecessary code.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/efi.c