KVM: arm64: Add generic hyp_memcache helpers
authorQuentin Perret <qperret@google.com>
Thu, 10 Nov 2022 19:02:50 +0000 (19:02 +0000)
committerMarc Zyngier <maz@kernel.org>
Fri, 11 Nov 2022 17:16:25 +0000 (17:16 +0000)
commit717a7eebac106a5cc5d5493f8eef9cf4ae6edf19
treea2432ed078534d5e217a84b8d12ad21221bf9a62
parent13e248aab73d2f1c27b458ef09d38b44f3e5bf2e
KVM: arm64: Add generic hyp_memcache helpers

The host at EL1 and the pKVM hypervisor at EL2 will soon need to
exchange memory pages dynamically for creating and destroying VM state.

Indeed, the hypervisor will rely on the host to donate memory pages it
can use to create guest stage-2 page-tables and to store VM and vCPU
metadata. In order to ease this process, introduce a
'struct hyp_memcache' which is essentially a linked list of available
pages, indexed by physical addresses so that it can be passed
meaningfully between the different virtual address spaces configured at
EL1 and EL2.

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-18-will@kernel.org
arch/arm64/include/asm/kvm_host.h
arch/arm64/kvm/hyp/include/nvhe/mem_protect.h
arch/arm64/kvm/hyp/nvhe/mm.c
arch/arm64/kvm/mmu.c