The mte-v4 linux arm kernel development branch requires these tags. It is still an open question as to whether they will be required for the final commit.
Signed-off-by: Richard Henderson <richard.hender...@linaro.org> --- v9: Split from patch creating the tag memory; sort to the end since it's not yet certain that it's a requirement. --- include/hw/arm/boot.h | 3 +++ hw/arm/boot.c | 12 +++++++++--- hw/arm/virt.c | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/hw/arm/boot.h b/include/hw/arm/boot.h index ce2b48b88b..605446afe7 100644 --- a/include/hw/arm/boot.h +++ b/include/hw/arm/boot.h @@ -116,6 +116,9 @@ struct arm_boot_info { */ bool secure_board_setup; + /* If set, all ram objects have tag memory objects. */ + bool tag_memory; + arm_endianness endianness; }; diff --git a/hw/arm/boot.c b/hw/arm/boot.c index fef4072db1..4f96ce42fe 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -427,7 +427,7 @@ static void set_kernel_args_old(const struct arm_boot_info *info, static int fdt_add_memory_node(void *fdt, uint32_t acells, hwaddr mem_base, uint32_t scells, hwaddr mem_len, - int numa_node_id) + int numa_node_id, bool tag_memory) { char *nodename; int ret; @@ -446,6 +446,10 @@ static int fdt_add_memory_node(void *fdt, uint32_t acells, hwaddr mem_base, ret = qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", numa_node_id); } + if (tag_memory) { + qemu_fdt_setprop(fdt, nodename, "arm,armv8.5-memtag", "", 0); + } + out: g_free(nodename); return ret; @@ -534,6 +538,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, hwaddr mem_base, mem_len; char **node_path; Error *err = NULL; + bool tag_memory; if (binfo->dtb_filename) { char *filename; @@ -599,12 +604,13 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, } g_strfreev(node_path); + tag_memory = binfo->tag_memory; if (ms->numa_state != NULL && ms->numa_state->num_nodes > 0) { mem_base = binfo->loader_start; for (i = 0; i < ms->numa_state->num_nodes; i++) { mem_len = ms->numa_state->nodes[i].node_mem; rc = fdt_add_memory_node(fdt, acells, mem_base, - scells, mem_len, i); + scells, mem_len, i, tag_memory); if (rc < 0) { fprintf(stderr, "couldn't add /memory@%"PRIx64" node\n", mem_base); @@ -615,7 +621,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, } } else { rc = fdt_add_memory_node(fdt, acells, binfo->loader_start, - scells, binfo->ram_size, -1); + scells, binfo->ram_size, -1, tag_memory); if (rc < 0) { fprintf(stderr, "couldn't add /memory@%"PRIx64" node\n", binfo->loader_start); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 22ce6d6199..8a4ddf13f7 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1422,6 +1422,7 @@ static void create_secure_ram(VirtMachineState *vms, if (secure_tag_sysmem) { create_tag_ram(secure_tag_sysmem, base, size, "mach-virt.secure-tag"); + qemu_fdt_setprop(vms->fdt, nodename, "arm,armv8.5-memtag", "", 0); } g_free(nodename); @@ -1842,6 +1843,7 @@ static void machvirt_init(MachineState *machine) */ if (object_property_find(cpuobj, "tag-memory", NULL)) { if (!tag_sysmem) { + vms->bootinfo.tag_memory = true; tag_sysmem = g_new(MemoryRegion, 1); memory_region_init(tag_sysmem, OBJECT(machine), "tag-memory", UINT64_MAX / 32); -- 2.25.1