On Thu, Jun 25, 2020 at 12:37:40PM +0100, Steven Price wrote: > On 24/06/2020 18:52, Catalin Marinas wrote: > > diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c > > index 3e08aea56e7a..1712c504df15 100644 > > --- a/arch/arm64/kernel/mte.c > > +++ b/arch/arm64/kernel/mte.c > > @@ -10,6 +10,8 @@ > > #include <linux/sched.h> > > #include <linux/sched/mm.h> > > #include <linux/string.h> > > +#include <linux/swap.h> > > +#include <linux/swapops.h> > > #include <linux/thread_info.h> > > #include <linux/uio.h> > > @@ -18,15 +20,30 @@ > > #include <asm/ptrace.h> > > #include <asm/sysreg.h> > > +static void mte_sync_page_tags(struct page *page, pte_t *ptep, bool check_swap) > > +{ > > + pte_t old_pte = READ_ONCE(*ptep); > > + > > + if (check_swap && is_swap_pte(old_pte)) { > > + swp_entry_t entry = pte_to_swp_entry(old_pte); > > + > > + if (!non_swap_entry(entry) && mte_restore_tags(entry, page)) > > + return; > > + } > > + > > + mte_clear_page_tags(page_address(page)); > > +} > > + > > void mte_sync_tags(pte_t *ptep, pte_t pte) > > { > > struct page *page = pte_page(pte); > > long i, nr_pages = compound_nr(page); > > + bool check_swap = nr_pages == 0; > > /* if PG_mte_tagged is set, tags have already been initialised */ > > for (i = 0; i < nr_pages; i++, page++) { > > This is broken - for check_swap to be true, nr_pages==0, which means we > never enter the loop and nothing happens... > > Except I don't believe compound_nr() will return 0 - it's defined as: > > static inline unsigned long compound_nr(struct page *page) > { > return 1UL << compound_order(page); > } > > Changing it to nr_pages==1 works for me. Ah, I had it as compound_order() and changes to compound_nr() but left the 0 check. Fixed locally. Thanks. -- Catalin