Re: [PATCH 2/3] KVM: arm64: Clear the whole hugetlb folio when storing MTE tags
From: Fuad Tabba
Date: Tue Oct 20 2026 - 09:23:06 EST
Hi Lorenzo,
On Tue, 20 Oct 2026 12:58:13 +0100, Lorenzo Stoakes (ARM)
<ljs@xxxxxxxxxx> 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).
Thanks,
/fuad