Skip to content

Commit 82c9bff

Browse files
committed
dstack-mr: derive bootorder fw_cfg digest from the linuxboot ROM path
OVMF's `EV_PLATFORM_CONFIG_FLAGS` event for the `bootorder` fw_cfg key hashes the raw fw_cfg blob (verified in OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgCacheInit.c:208-228: TpmMeasureAndLogData hashes ItemData, the fw_cfg buffer). QEMU produces that blob in hw/i386/x86.c::x86_load_linux when `-kernel` is in use: it appends a single option ROM (`linuxboot.bin` or `linuxboot_dma.bin`, depending on whether fw_cfg DMA is enabled) with `bootindex = 0`. dstack-vmm always uses q35, which enables fw_cfg DMA, so the DMA variant ROM is used. No other dstack device gets an implicit bootindex. Confirmed by gdb-attaching the live dstack510 QEMU and calling get_boot_devices_list() — it returned exactly `/rom@genroms/linuxboot_dma.bin\0` (31 bytes), and sha384 of those bytes equals the digest we'd captured before. Replaces the previously-hardcoded `bootorder_fwcfg_hash` with that derivation and removes the "if you change host_share_mode you must recapture" warning — that condition isn't actually load-bearing for this measurement.
1 parent 5aac58f commit 82c9bff

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

dstack-mr/src/tdvf.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,19 @@ impl<'a> Tdvf<'a> {
346346
// menu=on`, so it defaults to 0x0000.
347347
let bootmenu_fwcfg_hash = measure_sha384(&[0x00, 0x00]);
348348

349-
// fw_cfg `bootorder` is QEMU's generated bootorder string for
350-
// the current device topology. dstack-vmm's QEMU command (9p +
351-
// virtio-blk + vhost-vsock, no `-boot order=` / `bootindex=`)
352-
// is fixed, so this is a constant. If the QEMU command line is
353-
// ever changed (different host_share_mode, GPU passthrough,
354-
// extra bootable devices) this digest will need re-capturing.
355-
let bootorder_fwcfg_hash =
356-
hex!("53D3DBC00691328371E74C1B1C77BDF1BF4FF79DD1B55222B694FE8341CD8B0ADB3A9AB9286552C681272883B9B0FC1D");
349+
// fw_cfg `bootorder` is the NUL-separated list of QEMU device
350+
// paths whose backing devices have `bootindex` set. For
351+
// `-kernel` boot, QEMU (hw/i386/x86.c::x86_load_linux) injects
352+
// a single option ROM with `bootindex = 0`:
353+
// * `linuxboot_dma.bin` if fw_cfg DMA is enabled (q35 default)
354+
// * `linuxboot.bin` otherwise
355+
// dstack-vmm always uses q35 → DMA is on → the bootorder file
356+
// contains just the single path below (31 bytes, trailing
357+
// NUL). No other dstack device gets an implicit bootindex.
358+
//
359+
// Verified end-to-end: gdb-attached the live QEMU and called
360+
// get_boot_devices_list() — returned exactly these 31 bytes.
361+
let bootorder_fwcfg_hash = measure_sha384(b"/rom@genroms/linuxboot_dma.bin\0");
357362

358363
// EV_EFI_VARIABLE_AUTHORITY: OVMF emits this once during BDS
359364
// even when Secure Boot is disabled. The 32-byte event blob in

0 commit comments

Comments
 (0)