From a16bc84560efdbfcd242e6c708992624a76ec7cd Mon Sep 17 00:00:00 2001 From: Manish Pandey Date: Fri, 6 Mar 2020 14:36:25 +0000 Subject: TSP: corrected log information In CPU resume function, CPU suspend count was printed instead of CPU resume count. Signed-off-by: Manish Pandey Change-Id: I0c081dc03a4ccfb2129687f690667c5ceed00a5f --- bl32/tsp/tsp_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bl32/tsp/tsp_main.c') diff --git a/bl32/tsp/tsp_main.c b/bl32/tsp/tsp_main.c index e1d961cc6..9da2f9af9 100644 --- a/bl32/tsp/tsp_main.c +++ b/bl32/tsp/tsp_main.c @@ -273,11 +273,11 @@ tsp_args_t *tsp_cpu_resume_main(uint64_t max_off_pwrlvl, spin_lock(&console_lock); INFO("TSP: cpu 0x%lx resumed. maximum off power level %lld\n", read_mpidr(), max_off_pwrlvl); - INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu suspend requests\n", + INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu resume requests\n", read_mpidr(), tsp_stats[linear_id].smc_count, tsp_stats[linear_id].eret_count, - tsp_stats[linear_id].cpu_suspend_count); + tsp_stats[linear_id].cpu_resume_count); spin_unlock(&console_lock); #endif /* Indicate to the SPD that we have completed this request */ -- cgit v1.2.3 From ae7b922d87597ecde226be632633f11a17ccba20 Mon Sep 17 00:00:00 2001 From: Madhukar Pappireddy Date: Fri, 20 Mar 2020 01:46:21 -0500 Subject: Bug fix: Protect TSP prints with lock CPUs use console to print debug/info messages. This critical section must be guarded by locks to avoid overlaps in messages from multiple CPUs. Change-Id: I786bf90072c1ed73c4f53d8c950979d95255e67e Signed-off-by: Madhukar Pappireddy --- bl32/tsp/tsp_main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'bl32/tsp/tsp_main.c') diff --git a/bl32/tsp/tsp_main.c b/bl32/tsp/tsp_main.c index 9da2f9af9..e9478380c 100644 --- a/bl32/tsp/tsp_main.c +++ b/bl32/tsp/tsp_main.c @@ -371,12 +371,16 @@ tsp_args_t *tsp_smc_handler(uint64_t func, tsp_stats[linear_id].smc_count++; tsp_stats[linear_id].eret_count++; +#if LOG_LEVEL >= LOG_LEVEL_INFO + spin_lock(&console_lock); INFO("TSP: cpu 0x%lx received %s smc 0x%llx\n", read_mpidr(), ((func >> 31) & 1) == 1 ? "fast" : "yielding", func); INFO("TSP: cpu 0x%lx: %d smcs, %d erets\n", read_mpidr(), tsp_stats[linear_id].smc_count, tsp_stats[linear_id].eret_count); + spin_unlock(&console_lock); +#endif /* Render secure services and obtain results here */ results[0] = arg1; -- cgit v1.2.3 From caff3c87245cab1c95c4f2958144d8f78f42685e Mon Sep 17 00:00:00 2001 From: Alexei Fedorov Date: Fri, 13 Nov 2020 12:36:49 +0000 Subject: TSP: Fix GCC 11.0.0 compilation error. This patch fixes the following compilation error reported by aarch64-none-elf-gcc 11.0.0: bl32/tsp/tsp_main.c: In function 'tsp_smc_handler': bl32/tsp/tsp_main.c:393:9: error: 'tsp_get_magic' accessing 32 bytes in a region of size 16 [-Werror=stringop-overflow=] 393 | tsp_get_magic(service_args); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ bl32/tsp/tsp_main.c:393:9: note: referencing argument 1 of type 'uint64_t *' {aka 'long long unsigned int *'} In file included from bl32/tsp/tsp_main.c:19: bl32/tsp/tsp_private.h:64:6: note: in a call to function 'tsp_get_magic' 64 | void tsp_get_magic(uint64_t args[4]); | ^~~~~~~~~~~~~ by changing declaration of tsp_get_magic function from void tsp_get_magic(uint64_t args[4]); to uint128_t tsp_get_magic(void); which returns arguments directly in x0 and x1 registers. In bl32\tsp\tsp_main.c the current tsp_smc_handler() implementation calls tsp_get_magic(service_args); , where service_args array is declared as uint64_t service_args[2]; and tsp_get_magic() in bl32\tsp\aarch64\tsp_request.S copies only 2 registers in output buffer: /* Store returned arguments to the array */ stp x0, x1, [x4, #0] Change-Id: Ib34759fc5d7bb803e6c734540d91ea278270b330 Signed-off-by: Alexei Fedorov --- bl32/tsp/tsp_main.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'bl32/tsp/tsp_main.c') diff --git a/bl32/tsp/tsp_main.c b/bl32/tsp/tsp_main.c index e9478380c..01c9ec58f 100644 --- a/bl32/tsp/tsp_main.c +++ b/bl32/tsp/tsp_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -363,8 +363,10 @@ tsp_args_t *tsp_smc_handler(uint64_t func, uint64_t arg6, uint64_t arg7) { + uint128_t service_args; + uint64_t service_arg0; + uint64_t service_arg1; uint64_t results[2]; - uint64_t service_args[2]; uint32_t linear_id = plat_my_core_pos(); /* Update this cpu's statistics */ @@ -387,10 +389,12 @@ tsp_args_t *tsp_smc_handler(uint64_t func, results[1] = arg2; /* - * Request a service back from dispatcher/secure monitor. This call - * return and thereafter resume execution + * Request a service back from dispatcher/secure monitor. + * This call returns and thereafter resumes execution. */ - tsp_get_magic(service_args); + service_args = tsp_get_magic(); + service_arg0 = (uint64_t)service_args; + service_arg1 = (uint64_t)(service_args >> 64U); #if CTX_INCLUDE_MTE_REGS /* @@ -403,20 +407,20 @@ tsp_args_t *tsp_smc_handler(uint64_t func, /* Determine the function to perform based on the function ID */ switch (TSP_BARE_FID(func)) { case TSP_ADD: - results[0] += service_args[0]; - results[1] += service_args[1]; + results[0] += service_arg0; + results[1] += service_arg1; break; case TSP_SUB: - results[0] -= service_args[0]; - results[1] -= service_args[1]; + results[0] -= service_arg0; + results[1] -= service_arg1; break; case TSP_MUL: - results[0] *= service_args[0]; - results[1] *= service_args[1]; + results[0] *= service_arg0; + results[1] *= service_arg1; break; case TSP_DIV: - results[0] /= service_args[0] ? service_args[0] : 1; - results[1] /= service_args[1] ? service_args[1] : 1; + results[0] /= service_arg0 ? service_arg0 : 1; + results[1] /= service_arg1 ? service_arg1 : 1; break; default: break; -- cgit v1.2.3