ANDROID: KVM: arm64: Donate memory to protected guests

Instead of sharing memory with protected guests, which still leaves the
host with r/w access, donate the underlying pages so that they are
unmapped from the host stage-2.

Bug: 357781595
Change-Id: I3e0d1d31877acf3978e82350ebbe92136919507c
Signed-off-by: Marc Zyngier <maz@kernel.org>
This commit is contained in:
Marc Zyngier
2022-04-26 09:29:17 +00:00
committed by Keir Fraser
parent 6c5b8ce1e1
commit 493594b0e4
+4 -1
View File
@@ -517,7 +517,10 @@ static void handle___pkvm_host_map_guest(struct kvm_cpu_context *host_ctxt)
if (ret)
goto out;
ret = __pkvm_host_share_guest(pfn, gfn, hyp_vcpu);
if (pkvm_hyp_vcpu_is_protected(hyp_vcpu))
ret = __pkvm_host_donate_guest(pfn, gfn, hyp_vcpu);
else
ret = __pkvm_host_share_guest(pfn, gfn, hyp_vcpu);
out:
cpu_reg(host_ctxt, 1) = ret;
}