From 55ff5f6bc99d57f4b10bbbfa45b626de7117f676 Mon Sep 17 00:00:00 2001 From: Quentin Perret Date: Thu, 28 Nov 2024 17:09:02 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Always check state from host_ack_unshare() Similar to how we failed to cross-check the state from the completer's PoV on the hyp_ack_unshare() path, we fail to do so from host_ack_unshare(). This shouldn't cause problems in practice as this can only be called on the guest_unshare_host() path, and guest currently don't have the ability to share their pages with anybody other than the host. But this again is rather fragile, so let's simply do the proper check -- it isn't very costly thanks to the hyp_vmemmap optimisation. Bug: 381409114 Change-Id: I3770b7db55c579758863e41f50ab30f6a8bb4a0c Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c index bd9ae1bc37f1..01c43037447a 100644 --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c @@ -1076,7 +1076,9 @@ static int host_ack_donation(u64 addr, const struct pkvm_mem_transition *tx) static int host_ack_unshare(u64 addr, const struct pkvm_mem_transition *tx) { - return __host_ack_transition(addr, tx, PKVM_PAGE_SHARED_BORROWED); + u64 size = tx->nr_pages * PAGE_SIZE; + + return __host_check_page_state_range(addr, size, PKVM_PAGE_SHARED_BORROWED); } static int host_complete_share(u64 addr, const struct pkvm_mem_transition *tx,