Re: [PATCH 3/3] KVM: arm64: Sanitise MTE tags when a permission fault installs a mapping

From: Fuad Tabba

Date: Tue Oct 20 2026 - 09:24:21 EST


Hi Lorenzo,

On Tue, 20 Oct 2026 13:14:01 +0100, Lorenzo Stoakes (ARM)
<ljs@xxxxxxxxxx> wrote:
[...]
> > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
[...]
> > @@ -2060,7 +2060,7 @@ static int kvm_s2_fault_map(const struct kvm_s2_fault_desc *s2fd,
> > }
> > }
> >
> > - if (!perm_fault_granule && !s2vi->map_non_cacheable && kvm_has_mte(kvm))
> > + if (mapping_size != perm_fault_granule && !s2vi->map_non_cacheable && kvm_has_mte(kvm))
>
> So 'translation fault or permission fault if this will install a mapping' rather
> than 'translation fault' alone right?

Right.

> Just after this code you have:
>
> if (mapping_size == perm_fault_granule) {
> ...
> } else {
> ...
> }
>
> So you could put
>
> if (!s2vi->map_non_cacheable && kvm_has_mte(kvm))
> sanitise_mte_tags(kvm, pfn, mapping_size);
>
> In the else branch? Seems neater and clearer.

Agree, I'll move it there in v2.

> Also I wonder if the !s2vi->map_non_cacheable && kvm_has_mte(kvm) check could be
> abstracted?
>
> E.g.:
>
> static bool is_mte_fault(const struct kvm *kvm,
> const struct kvm_s2_fault_vma_info *s2vi)
> {
> return !s2vi->map_non_cacheable && kvm_has_mte(kvm);
> }
>
> Then could be:
>
> if (is_mte_fault(kvm, s2vi))
> sanitise_mte_tags(kvm, pfn, mapping_size);

I'd rather leave that out: the fix doesn't change that part of the
condition, and it only appears twice.

Thanks,
/fuad