]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: arm64: Extend pKVM page ownership selftests to cover forced reclaim
authorWill Deacon <will@kernel.org>
Mon, 30 Mar 2026 14:48:36 +0000 (15:48 +0100)
committerMarc Zyngier <maz@kernel.org>
Mon, 30 Mar 2026 15:58:09 +0000 (16:58 +0100)
Extend the pKVM page ownership selftests to forcefully reclaim a donated
page and check that it cannot be re-donated at the same IPA.

Tested-by: Fuad Tabba <tabba@google.com>
Tested-by: Mostafa Saleh <smostafa@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Link: https://patch.msgid.link/20260330144841.26181-36-will@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/hyp/nvhe/mem_protect.c

index d8f8ebe59129c95dc7f0ff4cd0b7b6659e005eee..0775a82ee4fe53036a92e293fb6534292b8d3ecb 100644 (file)
@@ -1815,8 +1815,20 @@ void pkvm_ownership_selftest(void *base)
        assert_transition_res(-EPERM,   __pkvm_hyp_donate_host, pfn, 1);
 
        selftest_state.host = PKVM_PAGE_OWNED;
-       selftest_state.guest[0] = PKVM_NOPAGE;
-       assert_transition_res(0,        __pkvm_host_reclaim_page_guest, gfn, vm);
+       selftest_state.guest[0] = PKVM_POISON;
+       assert_transition_res(0,        __pkvm_host_force_reclaim_page_guest, phys);
+       assert_transition_res(-EPERM,   __pkvm_host_donate_guest, pfn, gfn, vcpu);
+       assert_transition_res(-EPERM,   __pkvm_host_share_guest, pfn, gfn, 1, vcpu, prot);
+
+       selftest_state.host = PKVM_NOPAGE;
+       selftest_state.guest[1] = PKVM_PAGE_OWNED;
+       assert_transition_res(0,        __pkvm_host_donate_guest, pfn, gfn + 1, vcpu);
+
+       selftest_state.host = PKVM_PAGE_OWNED;
+       selftest_state.guest[1] = PKVM_NOPAGE;
+       assert_transition_res(0,        __pkvm_host_reclaim_page_guest, gfn + 1, vm);
+       assert_transition_res(-EPERM,   __pkvm_host_donate_guest, pfn, gfn, vcpu);
+       assert_transition_res(-EPERM,   __pkvm_host_share_guest, pfn, gfn, 1, vcpu, prot);
 
        selftest_state.host = PKVM_NOPAGE;
        selftest_state.hyp = PKVM_PAGE_OWNED;