Skip to content

QEMUv8: RPMB device support#851

Closed
jforissier wants to merge 2 commits intoOP-TEE:masterfrom
jforissier:qemu-rpmb
Closed

QEMUv8: RPMB device support#851
jforissier wants to merge 2 commits intoOP-TEE:masterfrom
jforissier:qemu-rpmb

Conversation

@jforissier
Copy link
Copy Markdown
Contributor

This adds support for RPMB device emulation in QEMUv8.

Depends on OP-TEE/manifest#335.

QEMU has recently added RPMB support to its eMMC emulation [1]. In
order to use this feature, enable CONFIG_MMC_SDHCI_PCI in the kernel.
Also enable CONFIG_RPMB so that the in-kernel TEE RPMB routing can be
used and tested. The legacy support of RPMB via tee-supplicant remains
available to OP-TEE via CFG_RPMB_ANNOUNCE_PROBE_CAP=n.

[1] https://github.com/qemu/qemu/commits/45423e247076/

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Update the QEMUv8 command line as well as the kernel config so that an
emulated RPMB device is exposed to the Linux kernel and user space. This
allows testing CFG_RPMB_FS=y without RPMB support in tee-supplicant.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Comment thread qemu-check.exp
# Toolchain libraries might be here or there
send -- "export LD_LIBRARY_PATH=/lib:/lib/arm-linux-gnueabihf\r"
expect "# "
send -- {if [ -e /dev/mmcblk0rpmb ]; then echo "Programming RPMB key"; printf "\\xD3\\xEB\\x3E\\xC3\\x6E\\x33\\x4C\\x9F\\x98\\x8C\\xE2\\xC0\\xB8\\x59\\x54\\x61\\x0D\\x2B\\xCF\\x86\\x64\\x84\\x4D\\xF2\\xAB\\x56\\xE6\\xC6\\x1B\\xB7\\x01\\xE4" >rpmb_key.bin && mmc rpmb write-key /dev/mmcblk0rpmb rpmb_key.bin; fi}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this will not work for fTPM

Copy link
Copy Markdown
Contributor Author

@jforissier jforissier Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the key would need to be programmed earlier I suppose. For this use case I believe we could boot the machine, program the RPMB key, then save the eMMC device persistent state (where the RPMB key/write counter etc. are stored) via some QEMU command. Then boot the system again from that state snapshot. @philmd did I get this right?

We could keep this for a later PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, or we could even use a pre-fabricated binary image.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is, the key is not stored in the eMMC image file (the emmc0.img passed to QEMU on the command line). That image only contains the data blocks. But perhaps the key can be supplied via a state file that we could generate from scratch without having to save it from a running VM, I don't know.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might use the test key, which is well-known.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string inside the printf is the test key 😉

@github-actions
Copy link
Copy Markdown

This pull request has been marked as stale because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 5 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions Bot added the Stale label Dec 13, 2025
@github-actions github-actions Bot closed this Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants