Re: [PATCH v1 3/5] arm64/kvm: using ioctl to enable/disable the HDBSS feature

From: Marc Zyngier
Date: Tue Mar 11 2025 - 06:00:29 EST


+1 on everything Oliver said. Additionally:

On Tue, 11 Mar 2025 04:03:19 +0000,
Zhenyu Ye <yezhenyu2@xxxxxxxxxx> wrote:
>
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index 1f55b0c7b11d..9c11e2292b1e 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -1703,6 +1703,9 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
> if (writable)
> prot |= KVM_PGTABLE_PROT_W;
>
> + if (kvm->enable_hdbss && logging_active)
> + prot |= KVM_PGTABLE_PROT_DBM;
> +

This looks totally wrong. If the page is defined as R/O
(KVM_PGTABLE_PROT_W not being set), setting the DBM flag makes it
writable anyway (the W bit is the Dirty bit). Hello, memory
corruption?

overall, this patch is a total mess, and needs to be split to have the
runtime logic on one side, and the userspace API on the other. Don't
mix the two.

Thanks,

M.

--
Without deviation from the norm, progress is not possible.