Merge tag 'hw-misc-20251104' of https://github.com/philmd/qemu into staging

Misc HW patches

- Add RPMB emulation to eMMC model
- Use generic MachineState::fdt field in microvm machine
- Remove dead code in ac97_realize()

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmkLEUMACgkQ4+MsLN6t
# wN4yURAAuiQPYC6rcPbjCI1RZ5iPyrajH1iKW6HSV6nMWHap1vjL8hUnrfDu1GRH
# uCyf8ExMkPWemNJW1WcxMN19Gie/J42PfKv7ggHTVoEQwg70DLmKBUcFBbsPfLy7
# 7NJ9qNnyZANNgBlvywZRPxs3v+3WEgqa6NEjpWqS5ivIEQjW4bxGa6yJ6LmJq1UY
# YpdSuK/9tsdPcDnc0b95cEBOZa7y8tjr8gtxCAraPwY+elaM9EYDwB8Mrg84RWiN
# zeeiCt1PL/Hc9qRiZral2MsWGtfefeOPGCir0jawaYl7UfbLi/0EXvpHJbMTl626
# MjilMlUi23aUbn1cuxygA1NV3sy+yRpZtxrpfJTOhoo7WZUBnn0atcH6GKMH2AM0
# S/thR6c1ArUck8d8ABUBESskmZpZQFPGXLcW+XCi8SOP/HwmtT/0L+OlexQPLAep
# nqu/T/yXer2C4sUHB2iwK7DrF7Dl2bzhdRZhyTEtIYuT4dC0FDVv9bwdgna/xWj3
# Re0HPT5J9o0tzQ2QaGMwPkjepf+LH1z3ntXhgJstr0D5G2wJ8+g1ZlPFKgrvBsCj
# C/YWZ3og31THAIb12exxaF4mHUF4fBrerQHg4E93MPhz1403D+sqJDxOUaC/PRJB
# OWwBCkWsWE8tjLie+1igNWKKB0N4ZTNKTGu0yxXFbcocu9LO6r0=
# =X6wb
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 05 Nov 2025 09:56:35 AM CET
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20251104' of https://github.com/philmd/qemu:
  hw/audio: Remove dead code from ac97_realize
  hw/i386/microvm: Use fdt field from MachineState
  docs: Add eMMC device model description
  scripts: Add helper script to generate eMMC block device images
  hw/sd/sdcard: Handle RPMB MAC field
  hw/sd/sdcard: Add basic support for RPMB partition
  hw/sd/sdcard: Allow user creation of eMMCs
  hw/sd/sdcard: Fix size check for backing block image

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson
2025-11-05 13:42:24 +01:00
9 changed files with 686 additions and 95 deletions
+1
View File
@@ -88,6 +88,7 @@ Emulated Devices
devices/canokey.rst
devices/ccid.rst
devices/cxl.rst
devices/emmc.rst
devices/igb.rst
devices/ivshmem-flat.rst
devices/ivshmem.rst
+55
View File
@@ -0,0 +1,55 @@
.. SPDX-License-Identifier: GPL-2.0-or-later
==============
eMMC Emulation
==============
Besides SD card emulation, QEMU also offers an eMMC model as found on many
embedded boards. An eMMC, just like an SD card, is connected to the machine
via an SDHCI controller.
Create eMMC Images
==================
A recent eMMC consists of 4 partitions: 2 boot partitions, 1 Replay protected
Memory Block (RPMB), and the user data area. QEMU expects backing images for
the eMMC to contain those partitions concatenated in exactly that order.
However, the boot partitions as well as the RPMB might be absent if their sizes
are configured to zero.
The eMMC specification defines alignment constraints for the partitions. The
two boot partitions must be of the same size. Furthermore, boot and RPMB
partitions must be multiples of 128 KB with a maximum of 32640 KB for each
boot partition and 16384K for the RPMB partition.
The alignment constrain of the user data area depends on its size. Up to 2
GByte, the size must be a power of 2. From 2 GByte onward, the size has to be
multiples of 512 byte.
QEMU is enforcing those alignment rules before instantiating the device.
Therefore, the provided image has to strictly follow them as well. The helper
script ``scripts/mkemmc.sh`` can be used to create compliant images, with or
without pre-filled partitions. E.g., to create an eMMC image from a firmware
image and an OS image with an empty 2 MByte RPMB, use the following command:
.. code-block:: console
scripts/mkemmc.sh -b firmware.img -r /dev/zero:2M os.img emmc.img
This will take care of rounding up the partition sizes to the next valid value
and will leave the RPMB and the second boot partition empty (zeroed).
Adding eMMC Devices
===================
An eMMC is either automatically created by a machine model (e.g. Aspeed boards)
or can be user-created when using a PCI-attached SDHCI controller. To
instantiate the eMMC image from the example above in a machine without other
SDHCI controllers while assuming that the firmware needs a boot partitions of
1 MB, use the following options:
.. code-block:: console
-drive file=emmc.img,if=none,format=raw,id=emmc-img
-device sdhci-pci
-device emmc,drive=emmc-img,boot-partition-size=1048576,rpmb-partition-size=2097152