KVM: arm/arm64: fix HYP ID map extension to 52 bits
authorKristina Martsenko <kristina.martsenko@arm.com>
Mon, 15 Jan 2018 15:23:49 +0000 (15:23 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Mon, 15 Jan 2018 18:20:26 +0000 (18:20 +0000)
commit98732d1b189b626a7593afd02dc3d2dc3f6c545a
tree480e6be8c4dd28aaf7d29ba8f5e6445fdd739737
parent6a205420758af5625429a2e77a2654abbf59ac09
KVM: arm/arm64: fix HYP ID map extension to 52 bits

Commit fa2a8445b1d3 incorrectly masks the index of the HYP ID map pgd
entry, causing a non-VHE kernel to hang during boot. This happens when
VA_BITS=48 and the ID map text is in 52-bit physical memory. In this
case we don't need an extra table level but need more entries in the
top-level table, so we need to map into hyp_pgd and need to use
__kvm_idmap_ptrs_per_pgd to mask in the extra bits. However,
__create_hyp_mappings currently masks by PTRS_PER_PGD instead.

Fix it so that we always use __kvm_idmap_ptrs_per_pgd for the HYP ID
map. This ensures that we use the larger mask for the top-level ID map
table when it has more entries. In all other cases, PTRS_PER_PGD is used
as normal.

Fixes: fa2a8445b1d3 ("arm64: allow ID map to be extended to 52 bits")
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Kristina Martsenko <kristina.martsenko@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
virt/kvm/arm/mmu.c