diff mbox series

kasan: fix mention for KASAN_HW_TAGS

Message ID 20230619101224.22978-1-chanho.min@lge.com (mailing list archive)
State New
Headers show
Series kasan: fix mention for KASAN_HW_TAGS | expand

Commit Message

Chanho Min June 19, 2023, 10:12 a.m. UTC
This patch removes description of the KASAN_HW_TAGS's memory consumption.
KASAN_HW_TAGS does not set 1/32nd shadow memory.

Signed-off-by: Chanho Min <chanho.min@lge.com>
---
 lib/Kconfig.kasan | 2 --
 1 file changed, 2 deletions(-)

Comments

Dmitry Vyukov June 19, 2023, 10:14 a.m. UTC | #1
On Mon, 19 Jun 2023 at 12:12, Chanho Min <chanho.min@lge.com> wrote:
>
> This patch removes description of the KASAN_HW_TAGS's memory consumption.
> KASAN_HW_TAGS does not set 1/32nd shadow memory.

The hardware still allocates/uses shadow in MTE.
Though, it may be 1/16-th, not sure.

> Signed-off-by: Chanho Min <chanho.min@lge.com>
> ---
>  lib/Kconfig.kasan | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
> index fdca89c05745..5be1740234b9 100644
> --- a/lib/Kconfig.kasan
> +++ b/lib/Kconfig.kasan
> @@ -124,8 +124,6 @@ config KASAN_HW_TAGS
>           Supported only on arm64 CPUs starting from ARMv8.5 and relies on
>           Memory Tagging Extension and Top Byte Ignore.
>
> -         Consumes about 1/32nd of available memory.
> -
>           May potentially introduce problems related to pointer casting and
>           comparison, as it embeds a tag into the top byte of each pointer.
>
> --
> 2.17.1
>
Marco Elver June 19, 2023, 11:36 a.m. UTC | #2
On Mon, 19 Jun 2023 at 12:15, Dmitry Vyukov <dvyukov@google.com> wrote:
> On Mon, 19 Jun 2023 at 12:12, Chanho Min <chanho.min@lge.com> wrote:
> >
> > This patch removes description of the KASAN_HW_TAGS's memory consumption.
> > KASAN_HW_TAGS does not set 1/32nd shadow memory.
>
> The hardware still allocates/uses shadow in MTE.
> Though, it may be 1/16-th, not sure.

I think the point is that it depends on the hardware implementation of
MTE. There are a range of possibilities, but enabling KASAN_HW_TAGS
doesn't consume any extra memory for tags itself if the hardware has
to enable MTE and provision tag space via firmware to begin with.

> > Signed-off-by: Chanho Min <chanho.min@lge.com>

I think you just have to be a bit clearer in the commit description,
just briefly mentioning how/where the tag space is allocated in
hardware that do support MTE. Then removing this line is probably
fair, if KASAN_HW_TAGS isn't the direct reason for tag memory being
allocated.
Andrey Konovalov June 20, 2023, 4:32 p.m. UTC | #3
On Mon, Jun 19, 2023 at 1:36 PM Marco Elver <elver@google.com> wrote:
>
> On Mon, 19 Jun 2023 at 12:15, Dmitry Vyukov <dvyukov@google.com> wrote:
> > On Mon, 19 Jun 2023 at 12:12, Chanho Min <chanho.min@lge.com> wrote:
> > >
> > > This patch removes description of the KASAN_HW_TAGS's memory consumption.
> > > KASAN_HW_TAGS does not set 1/32nd shadow memory.
> >
> > The hardware still allocates/uses shadow in MTE.
> > Though, it may be 1/16-th, not sure.

1/32 is correct: 4 bits for every 16 bytes.

> I think the point is that it depends on the hardware implementation of
> MTE. There are a range of possibilities, but enabling KASAN_HW_TAGS
> doesn't consume any extra memory for tags itself if the hardware has
> to enable MTE and provision tag space via firmware to begin with.

Yeah, saying that HW_TAGS consumes memory is wrong.

But it might reasonable to spell out what happens with memory in the
config options description. Something like:

"Does not consume memory by itself but relies on the 1/32nd of
available memory being reserved by the firmware when MTE is enabled."
diff mbox series

Patch

diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
index fdca89c05745..5be1740234b9 100644
--- a/lib/Kconfig.kasan
+++ b/lib/Kconfig.kasan
@@ -124,8 +124,6 @@  config KASAN_HW_TAGS
 	  Supported only on arm64 CPUs starting from ARMv8.5 and relies on
 	  Memory Tagging Extension and Top Byte Ignore.
 
-	  Consumes about 1/32nd of available memory.
-
 	  May potentially introduce problems related to pointer casting and
 	  comparison, as it embeds a tag into the top byte of each pointer.