Skip to content

Commit c53fbdb

Browse files
Quentin PerretMarc Zyngier
authored andcommitted
KVM: arm64: Improve error handling from check_host_shared_guest()
The check_host_shared_guest() path expects to find a last-level valid PTE in the guest's stage-2 page-table. However, it checks the PTE's level before its validity, which makes it hard for callers to figure out what went wrong. To make error handling simpler, check the PTE's validity first. Signed-off-by: Quentin Perret <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 0e45981 commit c53fbdb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/arm64/kvm/hyp/nvhe/mem_protect.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,10 +943,10 @@ static int __check_host_shared_guest(struct pkvm_hyp_vm *vm, u64 *__phys, u64 ip
943943
ret = kvm_pgtable_get_leaf(&vm->pgt, ipa, &pte, &level);
944944
if (ret)
945945
return ret;
946-
if (level != KVM_PGTABLE_LAST_LEVEL)
947-
return -E2BIG;
948946
if (!kvm_pte_valid(pte))
949947
return -ENOENT;
948+
if (level != KVM_PGTABLE_LAST_LEVEL)
949+
return -E2BIG;
950950

951951
state = guest_get_page_state(pte, ipa);
952952
if (state != PKVM_PAGE_SHARED_BORROWED)

0 commit comments

Comments
 (0)