[bug report] KVM: arm64: Add a range to __pkvm_host_unshare_guest()
Quentin Perret
qperret at google.com
Mon Jul 28 08:38:39 PDT 2025
Hi Ben,
On Tuesday 22 Jul 2025 at 13:59:06 (+0100), Ben Horgan wrote:
> Hi,
>
> On trying to boot a pkvm guest when using transparent huge pages I see the
> crash below. I'm using v6.6-rc7.
>
> kvm [141]: nVHE hyp BUG at: arch/arm64/kvm/hyp/nvhe/mem_protect.c:1088!
>
> It looks pkvm_pgtable_stage_relax_perms() can be called with a block mapping
> but in __pkvm_host_relax_perms_guest() it assumes page size for the
> assert_host_shared_guest() check. With the following patch, I no longer see
> the crash:
>
> diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c
> b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
> index 8957734d6183..52c802da4172 100644
> --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c
> +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
> @@ -1010,9 +1010,12 @@ static int __check_host_shared_guest(struct
> pkvm_hyp_vm *vm, u64 *__phys, u64 ip
> return ret;
> if (!kvm_pte_valid(pte))
> return -ENOENT;
> - if (kvm_granule_size(level) != size)
> + if (size && kvm_granule_size(level) != size)
> return -E2BIG;
>
> + if (!size)
> + size = kvm_granule_size(level);
> +
> state = guest_get_page_state(pte, ipa);
> if (state != PKVM_PAGE_SHARED_BORROWED)
> return -EPERM;
> @@ -1100,7 +1103,7 @@ int __pkvm_host_relax_perms_guest(u64 gfn, struct
> pkvm_hyp_vcpu *vcpu, enum kvm_
> if (prot & ~KVM_PGTABLE_PROT_RWX)
> return -EINVAL;
>
> - assert_host_shared_guest(vm, ipa, PAGE_SIZE);
> + assert_host_shared_guest(vm, ipa, 0);
> guest_lock_component(vm);
> ret = kvm_pgtable_stage2_relax_perms(&vm->pgt, ipa, prot, 0);
> guest_unlock_component(vm);
Aha, indeed, that looks broken with CONFIG_NVHE_EL2_DEBUG=y...
Your patch has the correct approach, but we have the same issue in
__pkvm_host_mkyoung_guest() which needs s/PAGE_SIZE/0 too I think.
Thanks for the report!
Quentin
More information about the linux-arm-kernel
mailing list