From 8d6a327d52d98f84bb448e808f8ea27bd5ed77ac Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Wed, 5 Jan 2022 18:39:37 +0000 Subject: [PATCH] ANDROID: KVM: arm64: pkvm: Share memory with non-protected guests Instead of donating memory to non-pVMs, share the memory, which gives us a good enough approximation of the usual behaviour. Signed-off-by: Marc Zyngier Bug: 209580772 Change-Id: I47213754613110a6fb8157806eb96ddf92ead346 Signed-off-by: Will Deacon --- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c index ff0a4f9fb09f..c3faad28e701 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -734,8 +734,12 @@ static void handle___pkvm_host_donate_guest(struct kvm_cpu_context *host_ctxt) /* Topup shadow memcache with the host's */ ret = pkvm_refill_memcache(state->vcpu, vcpu); - if (!ret) - ret = __pkvm_host_donate_guest(pfn, gfn, state->vcpu); + if (!ret) { + if (state->is_protected) + ret = __pkvm_host_donate_guest(pfn, gfn, state->vcpu); + else + ret = __pkvm_host_share_guest(pfn, gfn, state->vcpu); + } out: cpu_reg(host_ctxt, 1) = ret; }