aboutsummaryrefslogtreecommitdiff
path: root/bl32
diff options
context:
space:
mode:
authorAchin Gupta <achin.gupta@arm.com>2014-02-09 23:11:46 +0000
committerDan Handley <dan.handley@arm.com>2014-02-20 19:06:34 +0000
commit916a2c1ec16eed4199f27a24b8e2985275cda423 (patch)
treee324c9fffa85fda4e2394bc98d3adc47f84cb2e2 /bl32
parent607084ee4c2a7c20832beb8cd1d5cebf02b2cb26 (diff)
downloadarm-trusted-firmware-916a2c1ec16eed4199f27a24b8e2985275cda423.tar.gz
Rework arithmetic operations in Test Secure Payload
This patch reworks the service provided by the TSP to perform common arithmetic operations on a set of arguments provided by the non-secure world. For a addition, division, subtraction & multiplication operation requested on two arguments in x0 and x1 the steps are: 1. TSPD saves the non-secure context and passes the operation and its arguments to the TSP. 2. TSP asks the TSPD to return the same arguments once again. This exercises an additional SMC path. 3. TSP now has two copies of both x0 and x1. It performs the operation on the corresponding copies i.e. in case of addition it returns x0+x0 and x1+x1. 4. TSPD receives the result, saves the secure context, restores the non-secure context and passes the result back to the non-secure client. Change-Id: I6eebfa2ae0a6f28b1d2e11a31f575c7a4b96724b Co-authored-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
Diffstat (limited to 'bl32')
-rw-r--r--bl32/tsp/aarch64/tsp_request.S1
-rw-r--r--bl32/tsp/tsp_main.c33
2 files changed, 15 insertions, 19 deletions
diff --git a/bl32/tsp/aarch64/tsp_request.S b/bl32/tsp/aarch64/tsp_request.S
index 763e8fc..13e5931 100644
--- a/bl32/tsp/aarch64/tsp_request.S
+++ b/bl32/tsp/aarch64/tsp_request.S
@@ -55,7 +55,6 @@ tsp_get_magic:
/* Store returned arguments to the array */
stp x0, x1, [x4, #0]
- stp x2, x3, [x4, #16]
ret
diff --git a/bl32/tsp/tsp_main.c b/bl32/tsp/tsp_main.c
index f6640ed..05907f5 100644
--- a/bl32/tsp/tsp_main.c
+++ b/bl32/tsp/tsp_main.c
@@ -288,17 +288,24 @@ tsp_args *tsp_fast_smc_handler(uint64_t func,
uint64_t arg6,
uint64_t arg7)
{
- uint64_t results[4];
- uint64_t service_args[4];
+ uint64_t results[2];
+ uint64_t service_args[2];
+ uint64_t mpidr = read_mpidr();
+ uint32_t linear_id = platform_get_core_pos(mpidr);
- INFO("Received fast smc 0x%x on cpu 0x%x\n", func, read_mpidr());
+ /* Update this cpu's statistics */
+ tsp_stats[linear_id].smc_count++;
+ tsp_stats[linear_id].eret_count++;
+
+ printf("SP: cpu 0x%x received fast smc 0x%x\n", read_mpidr(), func);
+ INFO("cpu 0x%x: %d smcs, %d erets\n", mpidr,
+ tsp_stats[linear_id].smc_count,
+ tsp_stats[linear_id].eret_count);
- /* Render sercure services and obtain results here */
+ /* Render secure services and obtain results here */
results[0] = arg1;
results[1] = arg2;
- results[2] = arg3;
- results[3] = arg4;
/*
* Request a service back from dispatcher/secure monitor. This call
@@ -311,36 +318,26 @@ tsp_args *tsp_fast_smc_handler(uint64_t func,
case TSP_FID_ADD:
results[0] += service_args[0];
results[1] += service_args[1];
- results[2] += service_args[2];
- results[3] += service_args[3];
break;
case TSP_FID_SUB:
results[0] -= service_args[0];
results[1] -= service_args[1];
- results[2] -= service_args[2];
- results[3] -= service_args[3];
break;
case TSP_FID_MUL:
results[0] *= service_args[0];
results[1] *= service_args[1];
- results[2] *= service_args[2];
- results[3] *= service_args[3];
break;
case TSP_FID_DIV:
results[0] /= service_args[0] ? service_args[0] : 1;
results[1] /= service_args[1] ? service_args[1] : 1;
- results[2] /= service_args[2] ? service_args[2] : 1;
- results[3] /= service_args[3] ? service_args[3] : 1;
break;
default:
break;
}
- return set_smc_args(TSP_WORK_DONE,
+ return set_smc_args(func,
results[0],
results[1],
- results[2],
- results[3],
- 0, 0, 0);
+ 0, 0, 0, 0, 0);
}