qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] sd: Add RPMB emulation to eMMC model
@ 2025-08-24  7:18 Jan Kiszka
  2025-08-24  7:18 ` [PATCH 1/8] hw/sd/sdcard: Fix size check for backing block image Jan Kiszka
                   ` (7 more replies)
  0 siblings, 8 replies; 22+ messages in thread
From: Jan Kiszka @ 2025-08-24  7:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé, Bin Meng, qemu-block,
	Ilias Apalodimas, Daniel P. Berrangé

This closes an old gap in system integration testing for the very
complex ARM firmware stacks by adding fairly advanced Replay Protected
Memory Block (RPMB) emulation to the eMMC device model. Key programming
and message authentication are working, so is the write counter. Known
users are happy with the result. What is missing, but not only for RPMB-
related registers, is state persistence across QEMU restarts. This is OK
at this stage for most test scenarios, though, and could still be added
later on.

What can already be done with it is demonstrated in the WIP branch of
isar-cip-core at [1]: TF-A + OP-TEE + StandaloneMM TA + fTPM TA, used by
U-Boot and Linux for UEFI variable storage and TPM scenarios. If you
want to try: build qemu-arm64 target for trixie with 6.12-cip *head*
kernel, enable secure boot and disk encryption, then run

$ QEMU_PATH=/path/to/qemu-build/ ./start-qemu.sh

Deploy snakeoil keys into PK, KEK and db after first boot to enable
secure booting:

root@demo:~# cert-to-efi-sig-list PkKek-1-snakeoil.pem PK.esl
root@demo:~# sign-efi-sig-list -k PkKek-1-snakeoil.key -c PkKek-1-snakeoil.pem PK PK.esl PK.auth
root@demo:~# efi-updatevar -f PK.auth db
root@demo:~# efi-updatevar -f PK.auth KEK
root@demo:~# efi-updatevar -f PK.auth PK

Note that emulation is a bit slow in general, and specifically the
partition encryption on first boot is taking 20 min. - we should
probably reduce its size or understand if there is still something to
optimize.

Jan

[1] https://gitlab.com/cip-project/cip-core/isar-cip-core/-/commits/wip/qemu-rpmb

Cc: "Daniel P. Berrangé" <berrange@redhat.com>

Jan Kiszka (8):
  hw/sd/sdcard: Fix size check for backing block image
  hw/sd/sdcard: Add validation for boot-partition-size
  hw/sd/sdcard: Allow user-instantiated eMMC
  hw/sd/sdcard: Refactor sd_bootpart_offset
  hw/sd/sdcard: Add basic support for RPMB partition
  crypto/hmac: Allow to build hmac over multiple
    qcrypto_gnutls_hmac_bytes[v] calls
  hw/sd/sdcard: Handle RPMB MAC field
  scripts: Add helper script to generate eMMC block device images

 crypto/hmac-gcrypt.c   |   4 +-
 crypto/hmac-glib.c     |   4 +-
 crypto/hmac-gnutls.c   |   4 +-
 crypto/hmac-nettle.c   |   4 +-
 hw/sd/sd.c             | 314 ++++++++++++++++++++++++++++++++++++++---
 hw/sd/sdmmc-internal.h |  24 +++-
 hw/sd/trace-events     |   2 +
 include/crypto/hmac.h  |  12 ++
 scripts/mkemmc.sh      | 185 ++++++++++++++++++++++++
 9 files changed, 530 insertions(+), 23 deletions(-)
 create mode 100755 scripts/mkemmc.sh

-- 
2.43.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2025-09-14 12:26 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-24  7:18 [PATCH 0/8] sd: Add RPMB emulation to eMMC model Jan Kiszka
2025-08-24  7:18 ` [PATCH 1/8] hw/sd/sdcard: Fix size check for backing block image Jan Kiszka
2025-08-25  9:39   ` Philippe Mathieu-Daudé
2025-08-24  7:18 ` [PATCH 2/8] hw/sd/sdcard: Add validation for boot-partition-size Jan Kiszka
2025-08-24  7:18 ` [PATCH 3/8] hw/sd/sdcard: Allow user-instantiated eMMC Jan Kiszka
2025-08-24  7:18 ` [PATCH 4/8] hw/sd/sdcard: Refactor sd_bootpart_offset Jan Kiszka
2025-08-25  9:41   ` Philippe Mathieu-Daudé
2025-08-24  7:18 ` [PATCH 5/8] hw/sd/sdcard: Add basic support for RPMB partition Jan Kiszka
2025-08-24  7:18 ` [PATCH 6/8] crypto/hmac: Allow to build hmac over multiple qcrypto_gnutls_hmac_bytes[v] calls Jan Kiszka
2025-08-25  9:43   ` Philippe Mathieu-Daudé
2025-08-24  7:18 ` [PATCH 7/8] hw/sd/sdcard: Handle RPMB MAC field Jan Kiszka
2025-08-25  9:47   ` Philippe Mathieu-Daudé
2025-08-25 16:12     ` Jan Kiszka
2025-08-25 16:30       ` Philippe Mathieu-Daudé
2025-08-26 10:18         ` Daniel P. Berrangé
2025-08-27  5:53           ` Jan Kiszka
2025-08-27  9:53             ` Daniel P. Berrangé
2025-09-09 14:39   ` Jerome Forissier
2025-08-24  7:18 ` [PATCH 8/8] scripts: Add helper script to generate eMMC block device images Jan Kiszka
2025-08-25  9:51   ` Philippe Mathieu-Daudé
2025-09-09 14:25   ` Jerome Forissier
2025-09-14 12:23     ` Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).