Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: mte: Define the number of bytes for storing the tags in a page

Rather than explicitly calculating the number of bytes for a compact tag
storage format corresponding to a page, just add a MTE_PAGE_TAG_STORAGE
macro. With the current MTE implementation of 4 bits per tag, we store
2 tags in a byte.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Luis Machado <luis.machado@linaro.org>
Link: https://lore.kernel.org/r/20220131165456.2160675-4-catalin.marinas@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Catalin Marinas and committed by
Will Deacon
ab1e435c 761b9b36

+4 -3
+1
arch/arm64/include/asm/mte-def.h
··· 11 11 #define MTE_TAG_SHIFT 56 12 12 #define MTE_TAG_SIZE 4 13 13 #define MTE_TAG_MASK GENMASK((MTE_TAG_SHIFT + (MTE_TAG_SIZE - 1)), MTE_TAG_SHIFT) 14 + #define MTE_PAGE_TAG_STORAGE (MTE_GRANULES_PER_PAGE * MTE_TAG_SIZE / 8) 14 15 15 16 #define __MTE_PREAMBLE ARM64_ASM_PREAMBLE ".arch_extension memtag\n" 16 17
+2 -2
arch/arm64/lib/mte.S
··· 134 134 /* 135 135 * Save the tags in a page 136 136 * x0 - page address 137 - * x1 - tag storage 137 + * x1 - tag storage, MTE_PAGE_TAG_STORAGE bytes 138 138 */ 139 139 SYM_FUNC_START(mte_save_page_tags) 140 140 multitag_transfer_size x7, x5 ··· 158 158 /* 159 159 * Restore the tags in a page 160 160 * x0 - page address 161 - * x1 - tag storage 161 + * x1 - tag storage, MTE_PAGE_TAG_STORAGE bytes 162 162 */ 163 163 SYM_FUNC_START(mte_restore_page_tags) 164 164 multitag_transfer_size x7, x5
+1 -1
arch/arm64/mm/mteswap.c
··· 12 12 void *mte_allocate_tag_storage(void) 13 13 { 14 14 /* tags granule is 16 bytes, 2 tags stored per byte */ 15 - return kmalloc(PAGE_SIZE / 16 / 2, GFP_KERNEL); 15 + return kmalloc(MTE_PAGE_TAG_STORAGE, GFP_KERNEL); 16 16 } 17 17 18 18 void mte_free_tag_storage(char *storage)