On 7/2/25 08:38, Ilias Apalodimas wrote:
Hi Michal
On Wed, 2 Jul 2025 at 09:34, Michal Simek <michal.si...@amd.com> wrote:
SOM has TPM with RNG in it that's why enable rng-seed generation.
Signed-off-by: Michal Simek <michal.si...@amd.com>
---
Changes in v2:
- Free alloc area in case of error
board/xilinx/common/board.c | 34 +++++++++++++++++++++++++++-
configs/xilinx_zynqmp_kria_defconfig | 1 +
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 8ffe74299016..f258675d7772 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2014 - 2022, Xilinx, Inc.
- * (C) Copyright 2022 - 2023, Advanced Micro Devices, Inc.
+ * (C) Copyright 2022 - 2025, Advanced Micro Devices, Inc.
*
* Michal Simek <michal.si...@amd.com>
*/
@@ -712,3 +712,35 @@ phys_addr_t board_get_usable_ram_top(phys_size_t
total_size)
}
#endif
+
+#if IS_ENABLED(CONFIG_BOARD_RNG_SEED)
+/* Use hardware rng to seed Linux random. */
+__weak int board_rng_seed(struct abuf *buf)
+{
+ struct udevice *dev;
+ ulong len = 64;
+ u64 *data;
+
+ data = malloc(len);
+ if (!data) {
+ printf("Out of memory\n");
+ return -ENOMEM;
+ }
Why don't you move the allocation just before abuf expects it?
You can get rid of the free() in case of failures
Good idea. Let me send v3.
M