mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
KVM: arm64: Reclaim faulting page from pKVM in spurious fault handler
Host kernel accesses to pages that are inaccessible at stage-2 result in the injection of a translation fault, which is fatal unless an exception table fixup is registered for the faulting PC (e.g. for user access routines). This is undesirable, since a get_user_pages() call could be used to obtain a reference to a donated page and then a subsequent access via a kernel mapping would lead to a panic(). Rework the spurious fault handler so that stage-2 faults injected back into the host result in the target page being forcefully reclaimed when no exception table fixup handler is registered. 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-27-will@kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org>
This commit is contained in:
committed by
Marc Zyngier
parent
56080f53a6
commit
281a38ad29
@@ -569,3 +569,15 @@ int pkvm_pgtable_stage2_split(struct kvm_pgtable *pgt, u64 addr, u64 size,
|
||||
WARN_ON_ONCE(1);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Forcefully reclaim a page from the guest, zeroing its contents and
|
||||
* poisoning the stage-2 pte so that pages can no longer be mapped at
|
||||
* the same IPA. The page remains pinned until the guest is destroyed.
|
||||
*/
|
||||
bool pkvm_force_reclaim_guest_page(phys_addr_t phys)
|
||||
{
|
||||
int ret = kvm_call_hyp_nvhe(__pkvm_force_reclaim_guest_page, phys);
|
||||
|
||||
return !ret || ret == -EAGAIN;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user