KVM: arm64: Return -EPERM from __pkvm_host_share_hyp()
authorQuentin Perret <qperret@google.com>
Wed, 11 Aug 2021 17:36:25 +0000 (18:36 +0100)
committerMarc Zyngier <maz@kernel.org>
Wed, 11 Aug 2021 18:40:53 +0000 (19:40 +0100)
Fix the error code returned by __pkvm_host_share_hyp() when the
host attempts to share with EL2 a page that has already been shared with
another entity.

Reported-by: Will Deacon <will@kernel.org>
Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210811173630.2536721-1-qperret@google.com
arch/arm64/kvm/hyp/nvhe/mem_protect.c

index 8165390d3ec997f4bb546abf8ca092987e90a91d..6ec69531149867f5640728e0d9b8247db886d95d 100644 (file)
@@ -404,7 +404,7 @@ int __pkvm_host_share_hyp(u64 pfn)
        cur = kvm_pgtable_hyp_pte_prot(pte);
        prot = pkvm_mkstate(PAGE_HYP, PKVM_PAGE_SHARED_BORROWED);
        if (!check_prot(cur, prot, ~prot))
-               ret = EPERM;
+               ret = -EPERM;
        goto unlock;
 
 map_shared: