QEMU-Arm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jamin Lin <jamin_lin@aspeedtech.com>
To: "Cédric Le Goater" <clg@kaod.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Steven Lee" <steven_lee@aspeedtech.com>,
	"Troy Lee" <leetroy@gmail.com>,
	"Kane Chen" <kane_chen@aspeedtech.com>,
	"Andrew Jeffery" <andrew@codeconstruct.com.au>,
	"Joel Stanley" <joel@jms.id.au>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"open list:ASPEED BMCs" <qemu-arm@nongnu.org>,
	"open list:All patches CC here" <qemu-devel@nongnu.org>
Cc: Jamin Lin <jamin_lin@aspeedtech.com>, Troy Lee <troy_lee@aspeedtech.com>
Subject: [PATCH v1] tests/qtest/aspeed-acry: Allocate SRAM buffers on the heap
Date: Thu, 10 Sep 2026 01:24:24 +0000	[thread overview]
Message-ID: <20260910012422.4065857-1-jamin_lin@aspeedtech.com> (raw)

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>
---
 tests/qtest/aspeed-acry-test.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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);
 
-- 
2.43.0


                 reply	other threads:[~2026-09-10  1:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260910012422.4065857-1-jamin_lin@aspeedtech.com \
    --to=jamin_lin@aspeedtech.com \
    --cc=andrew@codeconstruct.com.au \
    --cc=clg@kaod.org \
    --cc=farosas@suse.de \
    --cc=joel@jms.id.au \
    --cc=kane_chen@aspeedtech.com \
    --cc=leetroy@gmail.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=steven_lee@aspeedtech.com \
    --cc=troy_lee@aspeedtech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox