Re: [PATCH 10/12] arm64: kasan: simplify and inline MTE functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 2, 2021 at 4:42 PM Catalin Marinas <catalin.marinas@xxxxxxx> wrote:
>
> On Mon, Feb 01, 2021 at 08:43:34PM +0100, Andrey Konovalov wrote:
> > +/*
> > + * Assign allocation tags for a region of memory based on the pointer tag.
> > + * Note: The address must be non-NULL and MTE_GRANULE_SIZE aligned and
> > + * size must be non-zero and MTE_GRANULE_SIZE aligned.
> > + */
>
> OK, so we rely on the caller to sanity-check the range. Fine by me but I
> can see (un)poison_range() only doing this for the size. Do we guarantee
> that the start address is aligned?

See the previous patch in the series. kasan_poison() checks and warns
on both unaligned addr and size. kasan_unpoison() checks addr and
rounds up size.

> > +static __always_inline void mte_set_mem_tag_range(void *addr, size_t size, u8 tag)
> > +{
> > +     u64 curr, end;
> > +
> > +     if (!size)
> > +             return;
> > +
> > +     curr = (u64)__tag_set(addr, tag);
> > +     end = curr + size;
> > +
> > +     do {
> > +             /*
> > +              * 'asm volatile' is required to prevent the compiler to move
> > +              * the statement outside of the loop.
> > +              */
> > +             asm volatile(__MTE_PREAMBLE "stg %0, [%0]"
> > +                          :
> > +                          : "r" (curr)
> > +                          : "memory");
> > +
> > +             curr += MTE_GRANULE_SIZE;
> > +     } while (curr != end);
> > +}
> >
> >  void mte_enable_kernel_sync(void);
> >  void mte_enable_kernel_async(void);
> > @@ -47,10 +95,12 @@ static inline u8 mte_get_mem_tag(void *addr)
> >  {
> >       return 0xFF;
> >  }
> > +
> >  static inline u8 mte_get_random_tag(void)
> >  {
> >       return 0xFF;
> >  }
> > +
> >  static inline void *mte_set_mem_tag_range(void *addr, size_t size, u8 tag)
>
> This function used to return a pointer and that's what the dummy static
> inline does here. However, the new mte_set_mem_tag_range() doesn't
> return anything. We should have consistency between the two (the new
> static void definition is fine by me).

Right, forgot to update the empty function definition. Will do in v2.

>
> Otherwise the patch looks fine.
>
> Reviewed-by: Catalin Marinas <catalin.marinas@xxxxxxx>

Thanks!




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux