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.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 233587962
Change-Id: I3e0d1d31877acf3978e82350ebbe92136919507c
This commit is contained in:
Marc Zyngier
2022-04-26 09:29:17 +00:00
committed by Will Deacon
parent 2ab0cf79ec
commit 5c41ce5227

View File

@@ -457,7 +457,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;
}