From 3d5135fdd070d9121e2914c4f9d2d82a1f9033e6 Mon Sep 17 00:00:00 2001 From: Yidi Lin Date: Thu, 11 Dec 2025 12:03:46 +0800 Subject: [PATCH] lib/bootmem: Add memory type for Armv9 MTE tag storage The Armv9-A architecture introduces the Memory Tagging Extension (MTE), which uses a dedicated memory region for tag storage. This patch adds a new memory type, BM_MEM_TAG, to allow for the proper accounting and reservation of this memory region. This ensures that the payload, e.g. depthcharge, can correctly identify and utilize the tag storage area. BUG=b:438666196 Change-Id: I2f6d2b3c2c1a8e1f0e9b2c3d4e5f6a7b8c9d0e1f Signed-off-by: Yidi Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/90470 Tested-by: build bot (Jenkins) Reviewed-by: Yu-Ping Wu --- src/commonlib/include/commonlib/coreboot_tables.h | 1 + src/include/bootmem.h | 1 + src/lib/bootmem.c | 3 +++ 3 files changed, 5 insertions(+) diff --git a/src/commonlib/include/commonlib/coreboot_tables.h b/src/commonlib/include/commonlib/coreboot_tables.h index fa966b5fef..251e2c4491 100644 --- a/src/commonlib/include/commonlib/coreboot_tables.h +++ b/src/commonlib/include/commonlib/coreboot_tables.h @@ -143,6 +143,7 @@ struct lb_memory_range { #define LB_MEM_NVS 4 /* ACPI NVS Memory */ #define LB_MEM_UNUSABLE 5 /* Unusable address space */ #define LB_MEM_VENDOR_RSVD 6 /* Vendor Reserved */ +#define LB_MEM_TAG 7 /* Armv9 tag storage for MTE */ #define LB_MEM_TABLE 16 /* Ram configuration tables are kept in */ #define LB_MEM_SOFT_RESERVED 0xefffffff /* Specific purpose memory */ }; diff --git a/src/include/bootmem.h b/src/include/bootmem.h index b1352e395b..6bd2aab9eb 100644 --- a/src/include/bootmem.h +++ b/src/include/bootmem.h @@ -29,6 +29,7 @@ enum bootmem_type { BM_MEM_VENDOR_RSVD, /* Vendor Reserved */ BM_MEM_OPENSBI, /* Risc-V OpenSBI */ BM_MEM_BL31, /* Arm64 BL31 executable */ + BM_MEM_TAG, /* Armv9-A tag storage for MTE */ BM_MEM_TABLE, /* Ram configuration tables are kept in */ /* Tags below this point are ignored for the OS table. */ BM_MEM_OS_CUTOFF = BM_MEM_TABLE, diff --git a/src/lib/bootmem.c b/src/lib/bootmem.c index f8963f3299..dbd8450f06 100644 --- a/src/lib/bootmem.c +++ b/src/lib/bootmem.c @@ -55,6 +55,8 @@ static uint32_t bootmem_to_lb_tag(const enum bootmem_type tag) return LB_MEM_TABLE; case BM_MEM_SOFT_RESERVED: return LB_MEM_SOFT_RESERVED; + case BM_MEM_TAG: + return LB_MEM_TAG; default: printk(BIOS_ERR, "Unsupported tag %u\n", tag); return LB_MEM_RESERVED; @@ -166,6 +168,7 @@ static const struct range_strings type_strings[] = { { BM_MEM_SOFT_RESERVED, "SOFT RESERVED" }, { BM_MEM_RAMSTAGE, "RAMSTAGE" }, { BM_MEM_PAYLOAD, "PAYLOAD" }, + { BM_MEM_TAG, "TAG STORAGE" }, }; static const char *bootmem_range_string(const enum bootmem_type tag)