[PATCH v3 1/4] kasan, arm64: Add KASAN light mode
Mark Rutland
mark.rutland at arm.com
Mon Jan 18 05:24:26 EST 2021
On Sat, Jan 16, 2021 at 01:47:08PM +0000, Vincenzo Frascino wrote:
> On 1/15/21 3:08 PM, Mark Rutland wrote:
> > On Fri, Jan 15, 2021 at 12:00:40PM +0000, Vincenzo Frascino wrote:
> >> #ifdef CONFIG_KASAN_HW_TAGS
> >> -#define arch_enable_tagging() mte_enable_kernel()
> >> +#define arch_enable_tagging(mode) mte_enable_kernel(mode)
> >
> > Rather than passing a mode in, I think it'd be better to have:
> >
> > * arch_enable_tagging_prod()
> > * arch_enable_tagging_light()
> >
> > ... that we can map in the arch code to separate:
> >
> > * mte_enable_kernel_sync()
> > * mte_enable_kernel_async()
> >
> > ... as by construction that avoids calls with an unhandled mode, and we
> > wouldn't need the mode enum kasan_hw_tags_mode...
> >
> >> +static inline int hw_init_mode(enum kasan_arg_mode mode)
> >> +{
> >> + switch (mode) {
> >> + case KASAN_ARG_MODE_LIGHT:
> >> + return KASAN_HW_TAGS_ASYNC;
> >> + default:
> >> + return KASAN_HW_TAGS_SYNC;
> >> + }
> >> +}
> >
> > ... and we can just have a wrapper like this to call either of the two functions directly, i.e.
> >
> > static inline void hw_enable_tagging_mode(enum kasan_arg_mode mode)
> > {
> > if (mode == KASAN_ARG_MODE_LIGHT)
> > arch_enable_tagging_mode_light();
> > else
> > arch_enable_tagging_mode_prod();
> > }
> >
>
> Fine by me, this would remove the need of adding a new enumeration as well and
> reflect on the arch code. I would keep "arch_enable_tagging_mode_sync" and
> "arch_enable_tagging_mode_async" though to give a clear indication in the KASAN
> code of the mode we are setting. I will adapt my code accordingly for v4.
Thanks, that sounds great!
I completely agree on keeping the '_sync' and '_aync' suffixes in the
the core code.
Mark.
More information about the linux-arm-kernel
mailing list