arm64: kdump: protect crash dump kernel memory
authorTakahiro Akashi <takahiro.akashi@linaro.org>
Mon, 3 Apr 2017 02:24:34 +0000 (11:24 +0900)
committerAKASHI Takahiro <takahiro.akashi@linaro.org>
Mon, 19 Jun 2017 06:09:04 +0000 (15:09 +0900)
commit32dcc8e7a247830df1e1a795cdf4b857fa712c4c
tree7e3e88067dec803d2af1fb5b663927bdee34a4f3
parent8d8d32ab8f8bc41cdf00c2c44c50041cb93a3dc4
arm64: kdump: protect crash dump kernel memory

arch_kexec_protect_crashkres() and arch_kexec_unprotect_crashkres()
are meant to be called by kexec_load() in order to protect the memory
allocated for crash dump kernel once the image is loaded.

The protection is implemented by unmapping the relevant segments in crash
dump kernel memory, rather than making it read-only as other archs do,
to prevent coherency issues due to potential cache aliasing (with
mismatched attributes).

Page-level mappings are consistently used here so that we can change
the attributes of segments in page granularity as well as shrink the region
also in page granularity through /sys/kernel/kexec_crash_size, putting
the freed memory back to buddy system.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Conflicts:
arch/arm64/mm/mmu.c
The file has been heavily refactored in v4.12, in particular, by
    commit 951366d4b7 ("arm64/mmu: replace 'page_mappings_only' parameter
       with flags argument")
    commit f14c66ce81b5 ("arm64: mm: replace 'block_mappings_allowed' with
 'page_mappings_only'")
    commit 5ea5306c3235 ("arm64: alternatives: apply boot time fixups via
 the linear mapping")
arch/arm64/kernel/machine_kexec.c
arch/arm64/mm/mmu.c