From: Andrey Konovalov <andreyknvl@google.com>
To: Marco Elver <elver@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>,
Alexander Potapenko <glider@google.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Evgenii Stepanov <eugenis@google.com>,
Andrey Ryabinin <aryabinin@virtuozzo.com>,
Branislav Rankov <Branislav.Rankov@arm.com>,
Kevin Brodsky <kevin.brodsky@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
kasan-dev <kasan-dev@googlegroups.com>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
Linux Memory Management List <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 08/20] kasan: inline random_tag for HW_TAGS
Date: Thu, 12 Nov 2020 01:21:21 +0100 [thread overview]
Message-ID: <CAAeHK+w4mXJxrerZc0YLXPV0sx6-uadocRHhkrq-4UYRkuXs8g@mail.gmail.com> (raw)
In-Reply-To: <20201111170213.GJ517454@elver.google.com>
On Wed, Nov 11, 2020 at 6:02 PM Marco Elver <elver@google.com> wrote:
>
> On Tue, Nov 10, 2020 at 11:20PM +0100, Andrey Konovalov wrote:
> > Using random_tag() currently results in a function call. Move its
> > definition to mm/kasan/kasan.h and turn it into a static inline function
> > for hardware tag-based mode to avoid uneeded function calls.
> >
> > Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> > Link: https://linux-review.googlesource.com/id/Iac5b2faf9a912900e16cca6834d621f5d4abf427
> > ---
> > mm/kasan/hw_tags.c | 5 -----
> > mm/kasan/kasan.h | 34 +++++++++++++++++-----------------
> > 2 files changed, 17 insertions(+), 22 deletions(-)
>
> Reviewed-by: Marco Elver <elver@google.com>
>
> But see style comments below.
>
> > diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c
> > index 49ea5f5c5643..1476ac07666e 100644
> > --- a/mm/kasan/hw_tags.c
> > +++ b/mm/kasan/hw_tags.c
> > @@ -42,11 +42,6 @@ void kasan_unpoison_memory(const void *address, size_t size)
> > round_up(size, KASAN_GRANULE_SIZE), get_tag(address));
> > }
> >
> > -u8 random_tag(void)
> > -{
> > - return hw_get_random_tag();
> > -}
> > -
> > bool check_invalid_free(void *addr)
> > {
> > u8 ptr_tag = get_tag(addr);
> > diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
> > index 8a5501ef2339..7498839a15d3 100644
> > --- a/mm/kasan/kasan.h
> > +++ b/mm/kasan/kasan.h
> > @@ -188,6 +188,12 @@ static inline bool addr_has_metadata(const void *addr)
> >
> > #endif /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS */
> >
> > +#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS)
> > +void print_tags(u8 addr_tag, const void *addr);
> > +#else
> > +static inline void print_tags(u8 addr_tag, const void *addr) { }
> > +#endif
> > +
> > bool check_invalid_free(void *addr);
> >
> > void *find_first_bad_addr(void *addr, size_t size);
> > @@ -223,23 +229,6 @@ static inline void quarantine_reduce(void) { }
> > static inline void quarantine_remove_cache(struct kmem_cache *cache) { }
> > #endif
> >
> > -#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS)
> > -
> > -void print_tags(u8 addr_tag, const void *addr);
> > -
> > -u8 random_tag(void);
> > -
> > -#else
> > -
> > -static inline void print_tags(u8 addr_tag, const void *addr) { }
> > -
> > -static inline u8 random_tag(void)
> > -{
> > - return 0;
> > -}
> > -
> > -#endif
> > -
> > #ifndef arch_kasan_set_tag
> > static inline const void *arch_kasan_set_tag(const void *addr, u8 tag)
> > {
> > @@ -279,6 +268,17 @@ static inline const void *arch_kasan_set_tag(const void *addr, u8 tag)
> >
> > #endif /* CONFIG_KASAN_HW_TAGS */
> >
> > +#ifdef CONFIG_KASAN_SW_TAGS
> > +u8 random_tag(void);
> > +#elif defined(CONFIG_KASAN_HW_TAGS)
> > +#define random_tag() hw_get_random_tag()
>
> Shouldn't this also be a function?
>
> +static inline u8 random_tag(void) { return hw_get_random_tag(); }
>
> Or is there a reason why this was made a macro?
No reason, will turn into a function in v10.
>
> > +#else
> > +static inline u8 random_tag(void)
> > +{
> > + return 0;
> > +}
>
> Could just be on 1 line:
>
> +static inline u8 random_tag(void) { return 0; }
Will do in v10.
Thanks!
>
> > +#endif
> > +
> > /*
> > * Exported functions for interfaces called from assembly or from generated
> > * code. Declarations here to avoid warning about missing declarations.
> > --
> > 2.29.2.222.g5d2a92d10f8-goog
> >
next prev parent reply other threads:[~2020-11-12 0:21 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 22:20 [PATCH v2 00/20] kasan: boot parameters for hardware tag-based mode Andrey Konovalov
2020-11-10 22:20 ` [PATCH v2 01/20] kasan: simplify quarantine_put call site Andrey Konovalov
2020-11-11 16:08 ` Marco Elver
2020-11-10 22:20 ` [PATCH v2 02/20] kasan: rename get_alloc/free_info Andrey Konovalov
2020-11-11 16:09 ` Marco Elver
2020-11-10 22:20 ` [PATCH v2 03/20] kasan: introduce set_alloc_info Andrey Konovalov
2020-11-11 16:10 ` Marco Elver
2020-11-10 22:20 ` [PATCH v2 04/20] kasan, arm64: unpoison stack only with CONFIG_KASAN_STACK Andrey Konovalov
2020-11-11 16:13 ` Marco Elver
2020-11-12 9:51 ` Catalin Marinas
2020-11-12 19:38 ` Andrey Konovalov
2020-11-10 22:20 ` [PATCH v2 05/20] kasan: allow VMAP_STACK for HW_TAGS mode Andrey Konovalov
2020-11-11 16:20 ` Marco Elver
2020-11-12 0:24 ` Andrey Konovalov
2020-11-12 10:31 ` Catalin Marinas
2020-11-10 22:20 ` [PATCH v2 06/20] kasan: remove __kasan_unpoison_stack Andrey Konovalov
2020-11-11 16:42 ` Marco Elver
2020-11-10 22:20 ` [PATCH v2 07/20] kasan: inline kasan_reset_tag for tag-based modes Andrey Konovalov
2020-11-11 16:54 ` Marco Elver
2020-11-10 22:20 ` [PATCH v2 08/20] kasan: inline random_tag for HW_TAGS Andrey Konovalov
2020-11-11 17:02 ` Marco Elver
2020-11-12 0:21 ` Andrey Konovalov [this message]
2020-11-10 22:20 ` [PATCH v2 09/20] kasan: inline kasan_poison_memory and check_invalid_free Andrey Konovalov
2020-11-11 17:50 ` Marco Elver
2020-11-10 22:20 ` [PATCH v2 10/20] kasan: inline and rename kasan_unpoison_memory Andrey Konovalov
2020-11-11 17:49 ` Marco Elver
2020-11-12 19:45 ` Andrey Konovalov
2020-11-12 19:52 ` Marco Elver
2020-11-12 20:54 ` Andrey Konovalov
2020-11-12 22:20 ` Marco Elver
2020-11-10 22:20 ` [PATCH v2 11/20] kasan: add and integrate kasan boot parameters Andrey Konovalov
2020-11-11 18:29 ` Marco Elver
2020-11-12 19:51 ` Andrey Konovalov
2020-11-12 11:35 ` Catalin Marinas
2020-11-12 11:53 ` Marco Elver
2020-11-12 12:54 ` Catalin Marinas
2020-11-12 19:52 ` Andrey Konovalov
2020-11-13 17:52 ` Marco Elver
2020-11-13 17:55 ` Marco Elver
2020-11-10 22:20 ` [PATCH v2 12/20] kasan, mm: check kasan_enabled in annotations Andrey Konovalov
2020-11-11 14:48 ` Marco Elver
2020-11-12 0:36 ` Andrey Konovalov
2020-11-10 22:20 ` [PATCH v2 13/20] kasan: simplify kasan_poison_kfree Andrey Konovalov
2020-11-11 18:42 ` Marco Elver
2020-11-10 22:20 ` [PATCH v2 14/20] kasan, mm: rename kasan_poison_kfree Andrey Konovalov
2020-11-11 18:53 ` Marco Elver
2020-11-12 1:05 ` Andrey Konovalov
2020-11-10 22:20 ` [PATCH v2 15/20] kasan: don't round_up too much Andrey Konovalov
2020-11-11 19:08 ` Marco Elver
2020-11-10 22:20 ` [PATCH v2 16/20] kasan: simplify assign_tag and set_tag calls Andrey Konovalov
2020-11-11 19:17 ` Marco Elver
2020-11-10 22:20 ` [PATCH v2 17/20] kasan: clarify comment in __kasan_kfree_large Andrey Konovalov
2020-11-11 19:18 ` Marco Elver
2020-11-10 22:20 ` [PATCH v2 18/20] kasan: clean up metadata allocation and usage Andrey Konovalov
2020-11-11 23:06 ` Marco Elver
2020-11-12 20:11 ` Andrey Konovalov
2020-11-10 22:20 ` [PATCH v2 19/20] kasan, mm: allow cache merging with no metadata Andrey Konovalov
2020-11-11 15:13 ` Marco Elver
2020-11-12 23:00 ` Andrey Konovalov
2020-11-11 23:27 ` Marco Elver
2020-11-10 22:20 ` [PATCH v2 20/20] kasan: update documentation Andrey Konovalov
2020-11-11 16:03 ` Marco Elver
2020-11-12 0:51 ` Andrey Konovalov
2020-11-10 22:24 ` [PATCH v2 00/20] kasan: boot parameters for hardware tag-based mode Andrey Konovalov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAeHK+w4mXJxrerZc0YLXPV0sx6-uadocRHhkrq-4UYRkuXs8g@mail.gmail.com \
--to=andreyknvl@google.com \
--cc=Branislav.Rankov@arm.com \
--cc=akpm@linux-foundation.org \
--cc=aryabinin@virtuozzo.com \
--cc=catalin.marinas@arm.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=eugenis@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=kevin.brodsky@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vincenzo.frascino@arm.com \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).