KVM: arm64: Add helpers to pin memory shared with the hypervisor at EL2
authorQuentin Perret <qperret@google.com>
Thu, 10 Nov 2022 19:02:41 +0000 (19:02 +0000)
committerMarc Zyngier <maz@kernel.org>
Fri, 11 Nov 2022 16:40:54 +0000 (16:40 +0000)
commit9926cfce8dcb880255f30ab9ac930add787e1ead
tree46a94d0137504131710e83f42b4189a8ec9b63b8
parent43c1ff8b75011bc3e3e923adf31ba815864a2494
KVM: arm64: Add helpers to pin memory shared with the hypervisor at EL2

Add helpers allowing the hypervisor to check whether a range of pages
are currently shared by the host, and 'pin' them if so by blocking host
unshare operations until the memory has been unpinned.

This will allow the hypervisor to take references on host-provided
data-structures (e.g. 'struct kvm') with the guarantee that these pages
will remain in a stable state until the hypervisor decides to release
them, for example during guest teardown.

Tested-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221110190259.26861-9-will@kernel.org
arch/arm64/kvm/hyp/include/nvhe/mem_protect.h
arch/arm64/kvm/hyp/include/nvhe/memory.h
arch/arm64/kvm/hyp/nvhe/mem_protect.c