KVM: arm64: Implement do_share() helper for sharing memory
authorWill Deacon <will@kernel.org>
Wed, 15 Dec 2021 16:12:27 +0000 (16:12 +0000)
committerMarc Zyngier <maz@kernel.org>
Thu, 16 Dec 2021 12:58:57 +0000 (12:58 +0000)
commite82edcc75c4e2389a3d7223c4ef1737bd9a07e5d
tree8067bd77451a49c0669653d9f5bc3fc7d9dfa380
parent61d99e33e757a21b47b8b130e49dcbdfaa5d2b1c
KVM: arm64: Implement do_share() helper for sharing memory

By default, protected KVM isolates memory pages so that they are
accessible only to their owner: be it the host kernel, the hypervisor
at EL2 or (in future) the guest. Establishing shared-memory regions
between these components therefore involves a transition for each page
so that the owner can share memory with a borrower under a certain set
of permissions.

Introduce a do_share() helper for safely sharing a memory region between
two components. Currently, only host-to-hyp sharing is implemented, but
the code is easily extended to handle other combinations and the
permission checks for each component are reusable.

Reviewed-by: Andrew Walbran <qwandor@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211215161232.1480836-11-qperret@google.com
arch/arm64/kvm/hyp/nvhe/mem_protect.c