Skip to content

Add NVMe BP read + firmware-update emulation to QEMU hw/nvme (part 1) #74

@kat-perez

Description

@kat-perez

Test-environment prerequisite (part 1 of 2): QEMU upstream hw/nvme does not emulate NVMe Boot Partitions, so the SRE boot and capsule-update flows cannot be exercised end-to-end in QEMU today. This issue tracks the read + firmware-update half on a local QEMU fork. The write-protection (BPWPS) half is tracked separately in the follow-up issue. Upstreaming both is deferred to a later issue.

Starting point: Gollu Appalanaidu's 2021 series "[PATCH v2 1/2] hw/nvme: add support for boot partitions" (https://lists.gnu.org/archive/html/qemu-devel/2021-06/msg00138.html), which stalled after review feedback.

Scope (Iter 5):

  1. Rebase the 2021 v2 patch against current QEMU master (hw/nvme/ctrl.c, hw/nvme/nvme.h, include/block/nvme.h, hw/nvme/trace-events).
  2. Replace the g_malloc BP buffer with a BlockBackend backed by the bootpart= device property so BP contents persist across VM restart.
  3. BP read path: BPINFO / BPRSEL / BPMBL MMIO handling, CAP.BPS = 1.
  4. Admin commands: Firmware Download (0x11) and Firmware Commit actions 0x6 (replace) / 0x7 (activate) targeting the boot partition.
  5. Fold in Stefan Hajnoczi's read-path review fixes from the 2021 thread:
    • Bound memory allocation in the DMA read path.
    • Check BPINFO.BRS on BPMBL writes; ignore writes while a read is active (NVMe Base Spec §8.13).
    • Save BP aiocb on the controller struct; cancel on reset / unplug.
  6. Smoke-test manually: qemu-img the BP backing file, boot a guest, dump BPRSEL contents.

Out of scope (tracked in follow-up):

  • Set Features FID 0x11 (BPWPS) — the write-protection / lock semantic.
  • VMState / live migration entries.
  • Formal qtest coverage in tests/qtest/nvme-test.c.
  • Doc update in docs/system/devices/nvme.rst.
  • Upstreaming.

Unblocks #51, #52 (read path for WIM-to-RAM boot, FW Commit for capsule apply).
Does NOT unblock #49, #53 — those need BPWPS, in the follow-up.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions