Commit 2e1dba44 authored by Konstantin Porotchkin's avatar Konstantin Porotchkin Committed by Manish Pandey
Browse files

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: default avatarKonstantin Porotchkin <kostap@marvell.com>
Change-Id: Ib8756cd3c0808b78c359f90c6f6913f7d16ac360
Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/boot/atf/+/33280

Tested-by: default avatarsa_ip-sw-jenkins <sa_ip-sw-jenkins@marvell.com>
Reviewed-by: default avatarNadav Haklai <nadavh@marvell.com>
parent 550a06df
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment