KVM: arm64: Fix HYP idmap unmap when using 52bit PA
authorMarc Zyngier <marc.zyngier@arm.com>
Wed, 14 Mar 2018 15:17:33 +0000 (15:17 +0000)
committerMarc Zyngier <marc.zyngier@arm.com>
Mon, 19 Mar 2018 13:04:26 +0000 (13:04 +0000)
commit3ddd45565373604d4f49cb0496fc0168e3863c1f
treed55a4a8f85e969183d096700813b83bb676fc591
parent46fef158f10d255dfe47cf3a0ab5f0965b66b1da
KVM: arm64: Fix HYP idmap unmap when using 52bit PA

Unmapping the idmap range using 52bit PA is quite broken, as we
don't take into account the right number of PGD entries, and rely
on PTRS_PER_PGD. The result is that pgd_index() truncates the
address, and we end-up in the weed.

Let's introduce a new unmap_hyp_idmap_range() that knows about this,
together with a kvm_pgd_index() helper, which hides a bit of the
complexity of the issue.

Fixes: 98732d1b189b ("KVM: arm/arm64: fix HYP ID map extension to 52 bits")
Reported-by: James Morse <james.morse@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
virt/kvm/arm/mmu.c