Skip to content

Commit

Permalink
plat-rcar: romapi: retry call to ROM_GetRndVector
Browse files Browse the repository at this point in the history
Sometimes ROM_GetRndVector() function returns an error, which causes
OP-TEE panic down the call path, as OP-TEE can't handle errors from
the hardware random number generator. As a workaround, we can try to
repeat call to the ROM_GetRndVector() because it succeeds on the next
try.

Anyways, this hardly can be considered as a normal behavior so it is
better to disable HW RNG by default, which will be done in a separate
patch.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
  • Loading branch information
lorc committed Jan 16, 2024
1 parent e53a3fe commit eb10b22
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/arch/arm/plat-rcar/romapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ uint32_t plat_rom_getrndvector(uint8_t rndbuff[PLAT_RND_VECTOR_SZ],
uint8_t *scratch, uint32_t scratch_sz)
{
uint32_t ret = -1;
int try = 0;
paddr_t func_addr = romapi_getrndvector[get_api_table_index()];
paddr_t rndbuff_pa = va2pa(rndbuff);
paddr_t scratch_pa = va2pa(scratch);
Expand All @@ -129,7 +130,15 @@ uint32_t plat_rom_getrndvector(uint8_t rndbuff[PLAT_RND_VECTOR_SZ],
assert(rndbuff_pa % RCAR_CACHE_LINE_SZ == 0);
assert(scratch_pa % RCAR_CACHE_LINE_SZ == 0);

ret = plat_call_romapi(func_addr, rndbuff_pa, scratch_pa, scratch_sz);
while (try++ < 3)
{
ret = plat_call_romapi(func_addr, rndbuff_pa, scratch_pa,
scratch_sz);
if (ret == 0)
break;
else
IMSG("ROM_GetRndVector() returned 0x%X", ret);
}

/*
* ROM code is called with MMU turned off, so any accesses to rndbuff
Expand Down

0 comments on commit eb10b22

Please sign in to comment.