Commit f254d83dee for qemu.org

commit f254d83dee9cae475f3d19437ab1a3dd84c64299
Author: Jamin Lin <jamin_lin@aspeedtech.com>
Date:   Thu Sep 10 01:24:24 2026 +0000

    tests/qtest/aspeed-acry: Allocate SRAM buffers on the heap

    The ACRY RSA qtest allocates two ACRY_SRAM_SIZE buffers on the
    stack. Since each buffer is nearly 9 KiB, this unnecessarily increases
    the stack usage of test_modexp_rsa() and may cause unexpected failures
    on environments with a limited stack size.

    This reduces the stack usage while preserving the existing test
    behavior.

    Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
    Reviewed-by: Cédric Le Goater <clg@kaod.org>
    Link: https://lore.kernel.org/qemu-devel/20260910012422.4065857-1-jamin_lin@aspeedtech.com
    Signed-off-by: Cédric Le Goater <clg@redhat.com>

diff --git a/tests/qtest/aspeed-acry-test.c b/tests/qtest/aspeed-acry-test.c
index ec348c2206..51048d697c 100644
--- a/tests/qtest/aspeed-acry-test.c
+++ b/tests/qtest/aspeed-acry-test.c
@@ -327,8 +327,8 @@ static void test_modexp_rsa(const void *opaque)
         .alg = QCRYPTO_AK_CIPHER_ALGO_RSA,
         .u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW,
     };
-    uint8_t dram_buf[ACRY_SRAM_SIZE] = { 0 };
-    uint8_t sram_buf[ACRY_SRAM_SIZE] = { 0 };
+    g_autofree uint8_t *dram_buf = g_malloc0(ACRY_SRAM_SIZE);
+    g_autofree uint8_t *sram_buf = g_malloc0(ACRY_SRAM_SIZE);
     uint8_t result[ACRY_MAX_BYTES] = { 0 };
     QTestState *qts;

@@ -345,7 +345,7 @@ static void test_modexp_rsa(const void *opaque)
     put_bignum_be_bytes(dram_buf, ACRY_MOD_OFFSET, t->n, t->n_len);
     put_bignum_be_bytes(dram_buf, ACRY_DATA_OFFSET, t->m, t->m_len);

-    qtest_memwrite(qts, c->dram_addr, dram_buf, sizeof(dram_buf));
+    qtest_memwrite(qts, c->dram_addr, dram_buf, ACRY_SRAM_SIZE);

     qtest_writel(qts, c->acry_addr + ACRY_DMA_CMD, ACRY_DMA_CMD_DMEM_AHB);
     qtest_writel(qts, c->acry_addr + ACRY_DMA_SRC, c->dram_addr);
@@ -362,7 +362,7 @@ static void test_modexp_rsa(const void *opaque)
     g_assert_cmphex(qtest_readl(qts, c->acry_addr + ACRY_STATUS), ==,
                     ACRY_STATUS_RSA_DONE);

-    qtest_memread(qts, c->sram_addr, sram_buf, sizeof(sram_buf));
+    qtest_memread(qts, c->sram_addr, sram_buf, ACRY_SRAM_SIZE);
     get_bignum_be_bytes(sram_buf, ACRY_DATA_OFFSET, result, t->c_len);
     g_assert_cmpmem(result, t->c_len, t->c, t->c_len);