@@ -296,6 +296,24 @@ static int __init mte_tag_storage_activate_regions(void)
}
}
+ /*
+ * MTE disabled, tag storage pages can be used like any other pages. The
+ * only restriction is that the pages cannot be used by kexec because
+ * the memory is marked as reserved in the memblock allocator.
+ */
+ if (!system_supports_mte()) {
+ for (i = 0; i< num_tag_regions; i++) {
+ tag_range = &tag_regions[i].tag_range;
+ for (pfn = tag_range->start;
+ pfn <= tag_range->end;
+ pfn += pageblock_nr_pages) {
+ init_reserved_pageblock(pfn_to_page(pfn), MIGRATE_MOVABLE);
+ }
+ }
+
+ return 0;
+ }
+
for (i = 0; i < num_tag_regions; i++) {
tag_range = &tag_regions[i].tag_range;
for (pfn = tag_range->start; pfn <= tag_range->end; pfn += pageblock_nr_pages) {
@@ -354,6 +354,8 @@ extern struct page *alloc_contig_pages(unsigned long nr_pages, gfp_t gfp_mask,
#endif
void free_contig_range(unsigned long pfn, unsigned long nr_pages);
+extern void init_reserved_pageblock(struct page *page, enum migratetype migratetype);
+
#ifdef CONFIG_MEMORY_METADATA
extern void init_metadata_reserved_pageblock(struct page *page);
#else
@@ -2330,8 +2330,7 @@ bool __init deferred_grow_zone(struct zone *zone, unsigned int order)
#endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */
#if defined(CONFIG_CMA) || defined(CONFIG_MEMORY_METADATA)
-static void __init init_reserved_pageblock(struct page *page,
- enum migratetype migratetype)
+void __init init_reserved_pageblock(struct page *page, enum migratetype migratetype)
{
unsigned i = pageblock_nr_pages;
struct page *p = page;
If MTE is disabled (for example, from the kernel command line with the arm64.nomte option), the tag storage pages behave just like normal pages, because they will never be used to store tags. If that's the case, expose them to the page allocator as MIGRATE_MOVABLE pages. MIGRATE_MOVABLE has been chosen because the bulk of memory allocations comes from userspace, and the migratetype for those allocations is MIGRATE_MOVABLE. MIGRATE_RECLAIMABLE and MIGRATE_UNMOVABLE requests can still use the pages as a fallback. Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> --- arch/arm64/kernel/mte_tag_storage.c | 18 ++++++++++++++++++ include/linux/gfp.h | 2 ++ mm/mm_init.c | 3 +-- 3 files changed, 21 insertions(+), 2 deletions(-)