From aaacde46826df1dd4a119b2a31ff626adbce5653 Mon Sep 17 00:00:00 2001 From: Varun Wadekar Date: Thu, 27 Feb 2025 17:03:56 +0000 Subject: [PATCH] fix(xlat_tables_v2): zeromem to clear all tables This patch replaces the for loops to sero individual tables or entries in the translation table context with zeromem to improve the boot time. On Tegra platforms, this patch has proved to save 10ms during boot. Signed-off-by: Bhavesh Parekh Signed-off-by: Varun Wadekar Change-Id: Iea9fb2c18ae7a1aef4fe42c4151a321fb3f8660e --- lib/xlat_tables_v2/xlat_tables_core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/xlat_tables_v2/xlat_tables_core.c b/lib/xlat_tables_v2/xlat_tables_core.c index 971dba484..bd7f01701 100644 --- a/lib/xlat_tables_v2/xlat_tables_core.c +++ b/lib/xlat_tables_v2/xlat_tables_core.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1204,16 +1205,13 @@ void __init init_xlat_tables_ctx(xlat_ctx_t *ctx) xlat_mmap_print(mm); /* All tables must be zeroed before mapping any region. */ + zeromem(ctx->base_table, ctx->base_table_entries * sizeof(uint64_t)); - for (unsigned int i = 0U; i < ctx->base_table_entries; i++) - ctx->base_table[i] = INVALID_DESC; - - for (int j = 0; j < ctx->tables_num; j++) { #if PLAT_XLAT_TABLES_DYNAMIC - ctx->tables_mapped_regions[j] = 0; + zeromem(ctx->tables_mapped_regions, ctx->tables_num * sizeof(uint32_t)); #endif - for (unsigned int i = 0U; i < XLAT_TABLE_ENTRIES; i++) - ctx->tables[j][i] = INVALID_DESC; + for (int i = 0; i < ctx->tables_num; i++) { + zeromem(ctx->tables[i], XLAT_TABLE_ENTRIES * sizeof(uint64_t)); } while (mm->size != 0U) {