From 9793931f36d585878305ff0bf907b32138673b95 Mon Sep 17 00:00:00 2001 From: Pranav Tilak Date: Thu, 7 May 2026 17:03:59 +0530 Subject: [PATCH 1/2] fpga: versalpl: Fix unaligned buffer handling When fpga load is called with a misaligned buffer address, the versal_align_dma_buffer() function shifts the pointer forward to the next aligned boundary and uses memcpy() to copy the data. Since the destination is ahead of the source and the regions overlap, memcpy() produces undefined behavior; in practice U-Boot's generic memcpy() copies forward, repeating the first ARCH_DMA_MINALIGN-aligned chunk throughout the buffer. Replace memcpy() with memmove() which correctly handles overlapping regions by copying backwards when the destination is ahead of the source. Fixes: 26e054c943a7 ("arm64: versal: fpga: Add PL bit stream load support") Signed-off-by: Pranav Tilak Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/20260507113359.3665220-1-pranav.vinaytilak@amd.com --- drivers/fpga/versalpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/fpga/versalpl.c b/drivers/fpga/versalpl.c index 630d1ecfea3..3cb56cc0dc9 100644 --- a/drivers/fpga/versalpl.c +++ b/drivers/fpga/versalpl.c @@ -17,7 +17,7 @@ static ulong versal_align_dma_buffer(ulong *buf, u32 len) if ((ulong)buf != ALIGN((ulong)buf, ARCH_DMA_MINALIGN)) { new_buf = (ulong *)ALIGN((ulong)buf, ARCH_DMA_MINALIGN); - memcpy(new_buf, buf, len); + memmove(new_buf, buf, len); buf = new_buf; } From 8a5989acc6ff1430a2775178d2e6b0b5d4573247 Mon Sep 17 00:00:00 2001 From: Francois Berder Date: Thu, 21 May 2026 15:05:44 +0200 Subject: [PATCH 2/2] arm64: versal2: Fix buffer overflow in soc_name_decode The size of name buffer was not computed correctly. The suffix format is "--rel.-el" (9 chars instead of 6), and the longest platform name is "emu-mmd" (7 chars instead of 4). Fix comment and name size. Fixes: 40f5046c221a ("arm64: versal2: Add support for AMD Versal Gen 2") Signed-off-by: Francois Berder Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/BESP194MB280513B376D54A815F3FD507DA0E2@BESP194MB2805.EURP194.PROD.OUTLOOK.COM --- board/amd/versal2/board.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/board/amd/versal2/board.c b/board/amd/versal2/board.c index d94c1494d53..81daba1c5ef 100644 --- a/board/amd/versal2/board.c +++ b/board/amd/versal2/board.c @@ -81,12 +81,13 @@ char *soc_name_decode(void) } /* - * --rev. are 6 chars - * max platform name is qemu which is 4 chars + * --rev.-el are 9 chars + * max platform name is emu-mmd which is 7 chars * platform version number are 1+1 - * Plus 1 char for \n + * el is 1 char + * Plus 1 char for NULL byte */ - name = calloc(1, strlen(CONFIG_SYS_BOARD) + 13); + name = calloc(1, strlen(CONFIG_SYS_BOARD) + 20); if (!name) return NULL;