Commit ab1e435c authored by Catalin Marinas's avatar Catalin Marinas Committed by Will Deacon

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: default avatarCatalin Marinas <catalin.marinas@arm.com>
Acked-by: default avatarLuis Machado <luis.machado@linaro.org>
Link: https://lore.kernel.org/r/20220131165456.2160675-4-catalin.marinas@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
parent 761b9b36
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#define MTE_TAG_SHIFT 56 #define MTE_TAG_SHIFT 56
#define MTE_TAG_SIZE 4 #define MTE_TAG_SIZE 4
#define MTE_TAG_MASK GENMASK((MTE_TAG_SHIFT + (MTE_TAG_SIZE - 1)), MTE_TAG_SHIFT) #define MTE_TAG_MASK GENMASK((MTE_TAG_SHIFT + (MTE_TAG_SIZE - 1)), MTE_TAG_SHIFT)
#define MTE_PAGE_TAG_STORAGE (MTE_GRANULES_PER_PAGE * MTE_TAG_SIZE / 8)
#define __MTE_PREAMBLE ARM64_ASM_PREAMBLE ".arch_extension memtag\n" #define __MTE_PREAMBLE ARM64_ASM_PREAMBLE ".arch_extension memtag\n"
......
...@@ -134,7 +134,7 @@ SYM_FUNC_END(mte_copy_tags_to_user) ...@@ -134,7 +134,7 @@ SYM_FUNC_END(mte_copy_tags_to_user)
/* /*
* Save the tags in a page * Save the tags in a page
* x0 - page address * x0 - page address
* x1 - tag storage * x1 - tag storage, MTE_PAGE_TAG_STORAGE bytes
*/ */
SYM_FUNC_START(mte_save_page_tags) SYM_FUNC_START(mte_save_page_tags)
multitag_transfer_size x7, x5 multitag_transfer_size x7, x5
...@@ -158,7 +158,7 @@ SYM_FUNC_END(mte_save_page_tags) ...@@ -158,7 +158,7 @@ SYM_FUNC_END(mte_save_page_tags)
/* /*
* Restore the tags in a page * Restore the tags in a page
* x0 - page address * x0 - page address
* x1 - tag storage * x1 - tag storage, MTE_PAGE_TAG_STORAGE bytes
*/ */
SYM_FUNC_START(mte_restore_page_tags) SYM_FUNC_START(mte_restore_page_tags)
multitag_transfer_size x7, x5 multitag_transfer_size x7, x5
......
...@@ -12,7 +12,7 @@ static DEFINE_XARRAY(mte_pages); ...@@ -12,7 +12,7 @@ static DEFINE_XARRAY(mte_pages);
void *mte_allocate_tag_storage(void) void *mte_allocate_tag_storage(void)
{ {
/* tags granule is 16 bytes, 2 tags stored per byte */ /* tags granule is 16 bytes, 2 tags stored per byte */
return kmalloc(PAGE_SIZE / 16 / 2, GFP_KERNEL); return kmalloc(MTE_PAGE_TAG_STORAGE, GFP_KERNEL);
} }
void mte_free_tag_storage(char *storage) void mte_free_tag_storage(char *storage)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment