[PATCH 2/3] KVM: arm64: Clear the whole hugetlb folio when storing MTE tags

Lorenzo Stoakes (ARM) ljs at kernel.org
Tue Oct 20 06:17:32 PDT 2026


On Tue, Oct 20, 2026 at 02:11:11PM +0100, Fuad Tabba wrote:

> > > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
> > > @@ -1042,12 +1043,14 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,
> > > -                        if (folio_test_hugetlb(folio))
> > > -                                folio_try_hugetlb_mte_tagging(folio);
> > > -                        else
> > > +                        if (!folio_test_hugetlb(folio))
> > >                                  try_page_mte_tagging(page);
> > > +                        else if (folio_try_hugetlb_mte_tagging(folio))
> >
> > Slightly awkward logic, testing a negative then the negative of the negative
> > (i.e. else) plus folio_try_hugetlb_mte_tagging(), makes it a little harder to
> > understand.
> >
> > With mte_clear_folio_tags() you can make life simpler:
> >
> >         if (folio_test_hugetlb(folio)) {
> >                 if (folio_try_hugetlb_mte_tagging(folio))
> >                         mte_clear_folio_tags(folio);
> >         } else {
> >                 try_page_mte_tagging(page);
> >         }
>
> Without the helper, the extra level of nesting takes the loop body
> past 100 columns, so I'll switch to your version in the separate patch
> that adds mte_clear_folio_tags() (see 1/3).

Ack makes sense, thanks!

--
Cheers, Lorenzo



More information about the linux-arm-kernel mailing list