KVM: arm64: Try stage2 block mapping for host device MMIO
authorKeqian Zhu <zhukeqian1@huawei.com>
Fri, 7 May 2021 11:03:22 +0000 (19:03 +0800)
committerMarc Zyngier <maz@kernel.org>
Tue, 1 Jun 2021 11:01:47 +0000 (12:01 +0100)
commit2aa53d68cee6603931f73b28ef6b51ff3fde9397
tree662ec20e1c78f7695a0bddea24f1c07520887e91
parentfd6f17bade2147b31198ad00b22d3acf5a398aec
KVM: arm64: Try stage2 block mapping for host device MMIO

The MMIO region of a device maybe huge (GB level), try to use
block mapping in stage2 to speedup both map and unmap.

Compared to normal memory mapping, we should consider two more
points when try block mapping for MMIO region:

1. For normal memory mapping, the PA(host physical address) and
HVA have same alignment within PUD_SIZE or PMD_SIZE when we use
the HVA to request hugepage, so we don't need to consider PA
alignment when verifing block mapping. But for device memory
mapping, the PA and HVA may have different alignment.

2. For normal memory mapping, we are sure hugepage size properly
fit into vma, so we don't check whether the mapping size exceeds
the boundary of vma. But for device memory mapping, we should pay
attention to this.

This adds get_vma_page_shift() to get page shift for both normal
memory and device MMIO region, and check these two points when
selecting block mapping size for MMIO region.

Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210507110322.23348-3-zhukeqian1@huawei.com
arch/arm64/kvm/mmu.c