Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c8a86c8 authored by Olav Haugan's avatar Olav Haugan
Browse files

drivers: soc: qcom: Use number of bytes returned from PRNG for entropy



Use the number of bytes returned from the PRNG to specify the amount of
entropy that we are contributing to the random pool instead of assuming
we receive the amount requested.

Change-Id: I5d49206146fd5f18f69516e4ba31dd3a38a81d62
[ohaugan@codeaurora.org: Fixed trivial merge conflicts]
Signed-off-by: default avatarOlav Haugan <ohaugan@codeaurora.org>
parent b156b913
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -48,9 +48,18 @@ void __init init_random_pool(void)
	ret = scm_call2(SCM_SIP_FNID(TZ_SVC_CRYPTO, PRNG_CMD_ID), &desc);

	if (!ret) {
		u64 bytes_received = desc.ret[0];

		if (bytes_received != SZ_512)
			pr_warn("Did not receive the expected number of bytes from PRNG: %llu\n",
				bytes_received);

		dmac_inv_range(random_buffer, random_buffer +
						RANDOM_BUFFER_SIZE);
		add_hwgenerator_randomness(random_buffer, SZ_512, SZ_512 << 3);
		bytes_received = (bytes_received <= RANDOM_BUFFER_SIZE) ?
					bytes_received : RANDOM_BUFFER_SIZE;
		add_hwgenerator_randomness(random_buffer, bytes_received,
					   bytes_received << 3);
	}
}