All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Bin Meng" <bmeng.cn@gmail.com>,
	qemu-block@nongnu.org,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH v2 0/8] sd: Add RPMB emulation to eMMC model
Date: Mon,  1 Sep 2025 07:56:20 +0200	[thread overview]
Message-ID: <cover.1756706188.git.jan.kiszka@siemens.com> (raw)

Changes in v2 [1]:
 - handle write counter expiry
 - assert() availability of QCRYPTO_HASH_ALGO_SHA256
 - add missing SPDX-License-Identifier

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 [2]: 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://github.com/siemens/qemu/commits/queues/emmc/
[2] 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      | 186 ++++++++++++++++++++++++
 9 files changed, 532 insertions(+), 22 deletions(-)
 create mode 100755 scripts/mkemmc.sh

-- 
2.43.0



             reply	other threads:[~2025-09-01  6:08 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-01  5:56 Jan Kiszka [this message]
2025-09-01  5:56 ` [PATCH v2 1/8] hw/sd/sdcard: Fix size check for backing block image Jan Kiszka
2025-09-02 15:06   ` Philippe Mathieu-Daudé
2025-09-02 15:34     ` Jan Kiszka
2025-09-02 15:43       ` Philippe Mathieu-Daudé
2025-09-02 15:45         ` Philippe Mathieu-Daudé
2025-09-02 15:47           ` Cédric Le Goater
2025-09-02 15:55             ` Philippe Mathieu-Daudé
2025-09-02 16:00               ` Cédric Le Goater
2025-09-02 16:14                 ` Philippe Mathieu-Daudé
2025-09-02 16:19                   ` Cédric Le Goater
2025-09-02 16:20                   ` Philippe Mathieu-Daudé
2025-09-02 16:24                     ` Jan Kiszka
2025-09-02 16:39                       ` Jan Kiszka
2025-09-02 16:47                         ` Jan Lübbe
2025-09-02 16:52                           ` Jan Kiszka
2025-09-02 17:07                           ` Warner Losh
2025-09-02 17:18                             ` Jan Kiszka
2025-09-02 17:22                               ` Warner Losh
2025-09-02 17:30                                 ` Warner Losh
2025-09-02 17:37                                   ` Jan Kiszka
2025-09-02 17:48                                     ` Warner Losh
2025-09-02 17:53                                       ` Jan Kiszka
2025-09-02 17:55                                         ` Warner Losh
2025-09-02 17:59                                         ` Philippe Mathieu-Daudé
2025-09-02 18:07                                           ` Warner Losh
2025-09-02 17:20                         ` Warner Losh
2025-09-02 17:39                           ` Jan Kiszka
2025-09-02 17:53                             ` Warner Losh
2025-09-02 15:43       ` Cédric Le Goater
2025-09-02 15:47         ` Philippe Mathieu-Daudé
2025-09-02 15:59       ` Cédric Le Goater
2025-09-01  5:56 ` [PATCH v2 2/8] hw/sd/sdcard: Add validation for boot-partition-size Jan Kiszka
2025-09-01 17:19   ` Alex Bennée
2025-09-01  5:56 ` [PATCH v2 3/8] hw/sd/sdcard: Allow user-instantiated eMMC Jan Kiszka
2025-09-01  5:56 ` [PATCH v2 4/8] hw/sd/sdcard: Refactor sd_bootpart_offset Jan Kiszka
2025-09-01  5:56 ` [PATCH v2 5/8] hw/sd/sdcard: Add basic support for RPMB partition Jan Kiszka
2025-09-01  5:56 ` [PATCH v2 6/8] crypto/hmac: Allow to build hmac over multiple qcrypto_gnutls_hmac_bytes[v] calls Jan Kiszka
2025-09-01  8:55   ` Daniel P. Berrangé
2025-09-01  5:56 ` [PATCH v2 7/8] hw/sd/sdcard: Handle RPMB MAC field Jan Kiszka
2025-09-01  5:56 ` [PATCH v2 8/8] scripts: Add helper script to generate eMMC block device images Jan Kiszka
2025-09-01 17:24   ` Alex Bennée
2025-09-01 20:58 ` [PATCH v2 0/8] sd: Add RPMB emulation to eMMC model Philippe Mathieu-Daudé
2025-09-02 11:42   ` Jan Kiszka
2025-09-02 13:28     ` Philippe Mathieu-Daudé

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=cover.1756706188.git.jan.kiszka@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=berrange@redhat.com \
    --cc=bmeng.cn@gmail.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.