diff options
author | Konstantin Porotchkin <kostap@marvell.com> | 2020-08-02 20:27:56 +0300 |
---|---|---|
committer | Manish Pandey <manish.pandey2@arm.com> | 2021-04-20 13:00:07 +0200 |
commit | 2e1dba44fded455a38b3870998286ab16bc4237e (patch) | |
tree | 95ea68d452b749d166a286ed55f9db0b51fd4664 | |
parent | 550a06dfd144f6b8275a2c27eebe271e6ef36d83 (diff) | |
download | arm-trusted-firmware-2e1dba44fded455a38b3870998286ab16bc4237e.tar.gz |
plat/marvell/armada: fix TRNG return SMC handling
Use single 64b register for the return value instead of two 32b.
Report an error if caller requested larger than than 64b random
number in a single SMC call.
Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
Change-Id: Ib8756cd3c0808b78c359f90c6f6913f7d16ac360
Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/boot/atf/+/33280
Tested-by: sa_ip-sw-jenkins <sa_ip-sw-jenkins@marvell.com>
Reviewed-by: Nadav Haklai <nadavh@marvell.com>
-rw-r--r-- | plat/marvell/armada/common/mrvl_sip_svc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/plat/marvell/armada/common/mrvl_sip_svc.c b/plat/marvell/armada/common/mrvl_sip_svc.c index 4e17390ce..c4c5c0eea 100644 --- a/plat/marvell/armada/common/mrvl_sip_svc.c +++ b/plat/marvell/armada/common/mrvl_sip_svc.c @@ -80,7 +80,6 @@ uintptr_t mrvl_sip_smc_handler(uint32_t smc_fid, u_register_t flags) { u_register_t ret, read, x5 = x1; - uint32_t w2[2] = {0, 0}; int i; debug("%s: got SMC (0x%x) x1 0x%lx, x2 0x%lx, x3 0x%lx\n", @@ -165,8 +164,13 @@ uintptr_t mrvl_sip_smc_handler(uint32_t smc_fid, ret = mvebu_ddr_phy_read(x1, (uint16_t *)&read); SMC_RET2(handle, ret, read); case MV_SIP_RNG_64: - ret = eip76_rng_get_random((uint8_t *)&w2, 4 * (x1 % 2 + 1)); - SMC_RET3(handle, ret, w2[0], w2[1]); + if ((x1 % 2 + 1) > sizeof(read)/4) { + ERROR("%s: Maximum %ld random bytes per SMC call\n", + __func__, sizeof(read)); + SMC_RET1(handle, SMC_UNK); + } + ret = eip76_rng_get_random((uint8_t *)&read, 4 * (x1 % 2 + 1)); + SMC_RET2(handle, ret, read); default: ERROR("%s: unhandled SMC (0x%x)\n", __func__, smc_fid); SMC_RET1(handle, SMC_UNK); |