Skip to content

Add ASPEED ACRY RSA model for the AST2600

Jamin Lin qemu-arm qemu-devel 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 2 repliesIn review
  2. v34 patches 3 repliesSuperseded
  3. v24 patches 2 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v15 patches7 repliesSuperseded

Changes in v4 from the cover letter

1. Remove unused macros.
2. Dynamically allocate data and src_buf to reduce stack usage in aspeed_acry_do_rsa().
3. Add a helper function to clear the result when aspeed_acry_do_rsa() fails.
4. Add bounds checking to aspeed_acry_operand_offset() and replace magic numbers with compile-time constants.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4hw/misc/aspeed_acry: Add ASPEED ACRY modelhw/misc/aspeed_acry.c hw/misc/meson.build hw/misc/trace-events +1 more+527 -00 replies
2/4hw/arm/aspeed_ast2600: Introduce the ACRY SRAMhw/arm/aspeed_ast2600.c include/hw/arm/aspeed_soc.h+18 -00 replies
3/4hw/arm/aspeed_ast2600: Wire up the ACRY modelhw/arm/aspeed_ast2600.c include/hw/arm/aspeed_soc.h+20 -00 replies
4/4tests/qtest/aspeed-acry-test: Add RSA ModExp teststests/qtest/aspeed-acry-test.c tests/qtest/meson.build+410 -10 replies

Reviews trailers per patch

2 of 4 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchCédric Le GoaterPhilippe Mathieu-Daudé
SeriesR-b
1/4
2/4R-b
3/4R-b R-b
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/4] Add ASPEED ACRY RSA model for the AST2600

This series adds a model of the ASPEED ACRY engine found on the AST2600 SoC, wires it into the SoC, and adds a qtest.

The ACRY engine performs RSA modular exponentiation (c = m^e mod n). It DMAs the operands (data, exponent, and modulus) from guest DRAM and writes the result to a dedicated 64 KiB SRAM region.

Guest firmware uses the engine for RSA signature verification during boot. Without a model, the guest starts the engine and waits indefinitely for a completion interrupt, causing the boot to hang.

The model uses QEMU's generic akcipher API to perform raw (unpadded) RSA. Raw RSA is currently supported only by the libgcrypt backend, which can be enabled alongside gnutls with -Dgcrypt=enabled, so a build does not have to choose between the two. When raw RSA is unavailable, the engine still completes and raises its interrupt, but returns an all-zero result. This allows the guest's signature verification to fail cleanly instead of hanging. The qtest is skipped when the selected crypto backend does not support raw RSA.

Although the hardware documentation describes both RSA and ECDSA support, ECDSA is known to be broken on this hardware and is therefore not modeled.

v1:
1. Add ASPEED ACRY RSA model for the AST2600
2. Add qtest for AST2600 ASPEED ACRY RSA model

v2:
1. squash "Add the ACRY model to AspeedSoCState" into "Wire up the ACRY model"
2. wrap the ACRY SRAM in a container mapped at offset 0 so the device addresses it by relative offset (drop the "sram-base" property)
3. build the scattered SRAM byte offsets on the fly instead of caching them in per-instance lookup tables
4. write the result with address_space_stl_le() and check the MemTxResult

v3:
1. Return early when the DMA read of the operand buffer fails
2. Replace g_printerr with g_test_skip

v4:
1. Remove unused macros.
2. Dynamically allocate data and src_buf to reduce stack usage in aspeed_acry_do_rsa().
3. Add a helper function to clear the result when aspeed_acry_do_rsa() fails.
4. Add bounds checking to aspeed_acry_operand_offset() and replace magic numbers with compile-time constants.

Jamin Lin (4):
hw/misc/aspeed_acry: Add ASPEED ACRY model hw/arm/aspeed_ast2600: Introduce the ACRY SRAM hw/arm/aspeed_ast2600: Wire up the ACRY model tests/qtest/aspeed-acry-test: Add RSA ModExp tests

 include/hw/arm/aspeed_soc.h    |   4 +
 include/hw/misc/aspeed_acry.h  |  39 +++
 hw/arm/aspeed_ast2600.c        |  34 +++
 hw/misc/aspeed_acry.c          | 481 +++++++++++++++++++++++++++++++++
 tests/qtest/aspeed-acry-test.c | 406 ++++++++++++++++++++++++++++
 hw/misc/meson.build            |   1 +
 hw/misc/trace-events           |   6 +
 tests/qtest/meson.build        |   5 +-
 8 files changed, 975 insertions(+), 1 deletion(-)
 create mode 100644 include/hw/misc/aspeed_acry.h
 create mode 100644 hw/misc/aspeed_acry.c
 create mode 100644 tests/qtest/aspeed-acry-test.c
Signature · 1 line
2.53.0