Skip to contentSkip to conversation

kasan: fix mention for KASAN_HW_TAGS

PATCH Superseded Chanho Min 4 participants 6 messages Jun 19, 2023 – Jun 23, 2023

Subsystems (3)
lore
Share & tools
lore

Chanho Min

author
#0 lore raw

PATCH 1/1 kasan: fix mention for KASAN_HW_TAGS

This patch removes description of the KASAN_HW_TAGS's memory consumption. KASAN_HW_TAGS does not set 1/32nd shadow memory.

---
 lib/Kconfig.kasan | 2 --
 1 file changed, 2 deletions(-)
lib/Kconfig.kasan +0 -2
index fdca89c05745..5be1740234b9 100644
@@ -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.
 
Signature · 1 line
2.17.1
reviewer
#1 lore raw
Quoted 3 lines · Chanho Min

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.

Quoted 21 lines
---
 lib/Kconfig.kasan | 2 --
 1 file changed, 2 deletions(-)
lib/Kconfig.kasan +0 -3
index fdca89c05745..5be1740234b9 100644
@@ -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

#2 lore raw
Quoted 7 lines · Dmitry Vyukov
Quoted 3 lines · Chanho Min

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.

Quoted 1 line
Quoted 1 line

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.

#3 lore raw
Quoted 9 lines · Marco Elver
Quoted 7 lines · Dmitry Vyukov
Quoted 3 lines · Chanho Min

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.

Quoted 4 lines

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."

author
#4 lore raw

PATCH v2 1/1 kasan: fix mention for KASAN_HW_TAGS

This patch fixes description of the KASAN_HW_TAGS's memory consumption. KASAN_HW_TAGS are dependent on the HW implementation and are not reserved from system memory like shadow memory.

---
 lib/Kconfig.kasan | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/Kconfig.kasan +2 -1
index fdca89c05745..f8f9e12510b7 100644
@@ -124,7 +124,8 @@ 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.
+	  Does not consume memory by itself but relies on the 1/32nd of
+	  available memory being reserved by the firmware when MTE is enabled.
 
 	  May potentially introduce problems related to pointer casting and
 	  comparison, as it embeds a tag into the top byte of each pointer.
Signature · 1 line
2.17.1
reviewer Reviewed-by on v2 1/1
#5 lore raw
Quoted 26 lines · Chanho Min

This patch fixes description of the KASAN_HW_TAGS's memory consumption. KASAN_HW_TAGS are dependent on the HW implementation and are not reserved from system memory like shadow memory.

---
 lib/Kconfig.kasan | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/Kconfig.kasan +2 -2
index fdca89c05745..f8f9e12510b7 100644
@@ -124,7 +124,8 @@ 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.
+         Does not consume memory by itself but relies on the 1/32nd of
+         available memory being reserved by the firmware when MTE is enabled.
 
          May potentially introduce problems related to pointer casting and
          comparison, as it embeds a tag into the top byte of each pointer.
--
Quoted 2 lines

2.17.1

Thank you!