Repository navigation
fix(sev-snp): support firmware 1.58+ v5 reports, large-BAR GPUs, and single-node dstackup - #1703
PierreLeGuen wants to merge 12 commits into
Conversation
SEV-SNP firmware 1.58 and later returns version 5 attestation reports, which
put LAUNCH_MIT_VECTOR and CURRENT_MIT_VECTOR in bytes that sev 6.0.0 parses
as reserved and requires to be zero. On such hosts every report fails to
parse ("Skipped bytes were expected to be zeroed"), so an SNP guest stops at
boot when it reads its HOST_DATA, and the KMS cannot verify SNP guests.
Bump sev to 6.3.0, which parses and re-serializes version 5 reports, and let
sev-snp-qvl verify versions 3 to 5: it rejected anything newer than 3, and
the fields it reads are laid out the same in version 5.
Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com>
systemd does not unquote `WorkingDirectory=`, so the quoted value dstackup
wrote is read as a relative path. systemd 259 rejects it ("path is not
absolute"), and `dstackup install` then fails to start dstack-auth. Write
the path bare, escaping only `%`.
Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com>
The VMM host API binds vsock CID 2, which needs the vhost_vsock transport.
/dev/vhost-vsock is a static device node that loads the module only on
first open, so on a fresh host the bind fails with EADDRNOTAVAIL and the
VMM exits ("Failed to bind host API"). Load the module in ExecStartPre.
Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com>
Guest-OS releases are tagged `mkosi-os-v<version>` by the mkosi release workflow, but `dstackup image pull` only looked for `guest-os-v`, so both a pinned `--version` and the latest-release lookup found nothing for 0.6.x. Look up `mkosi-os-v` first and keep `guest-os-v` as a fallback. These releases also publish `dstack-<version>-kernel-devel.tar.gz`, which the asset picker accepted as a host image; skip it like the `-uki` archive. Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com>
`free_local_port()` bound port 0, which returns a kernel ephemeral port (32768 and up). The vmm.toml that `dstackup install` writes only allows tcp 1-20000, so the VMM refused every auto-picked port: the KMS CVM deploy in `dstackup install` failed with "Port mapping is not allowed", and so did `dstack deploy --port <vm>` without a host port. Pick a free loopback port from 10000-19999 instead, and test that the rendered port-mapping range covers it. Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com>
dstackup wrote kms.toml with the listener settings at their pre-0.6
locations ([rpc], [core.admin], core.onboard.address/port), had no
core.keyring_dir, and deployed KMS 0.5.11 by default. The 0.6 KMS refuses
that config at startup ("the config sets listener settings at their old
locations", and keyring_dir has no default), and 0.5.11 has no SEV-SNP
support, so a dstackup install on an SNP host never gets a working KMS.
Render [listeners.default.tls], [listeners.guest], [listeners.admin] and
[listeners.onboard], put the keyring on the persistent KMS volume
(/kms/keyring), and default to the 0.6.7 KMS image, which reads that layout.
Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com>
SEV-SNP guests run with `-cpu EPYC-v4`. A named CPU model gets QEMU's default of 40 physical address bits, so the guest has 1 TiB of address space and OVMF sizes its 64-bit PCI MMIO window from that. GPUs with large BARs (a B200 BAR1 is 256 GiB) then cannot be mapped. TDX guests use `-cpu host`, which already takes the host's width. Pass host-phys-bits=on with the SEV-SNP CPU model. The CPUID page is measured as zeros, so the launch measurement does not change. Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com>
PcdUse1GPageTable defaults to FALSE and AmdSevX64.dsc does not set it, so OVMF caps the guest physical address width at 40 bits even when the vCPU reports more. Its dynamic 64-bit PCI MMIO window is then at most 128 GiB, smaller than a single B200 BAR1 (256 GiB), and an SEV-SNP guest cannot map the GPU. Build the AmdSev firmware with PcdUse1GPageTable=TRUE. With 46 physical address bits OVMF then opens an 8 TiB window. This changes ovmf-sev.fd and so the SEV-SNP launch measurement; the TDX firmware is unchanged. Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com>
Building a volume copied the filesystem image twice: into a scratch file, then into the GPT image through a 1 MiB userspace buffer. For a large image that doubles the disk space and the time. Clone instead with FICLONE / FICLONERANGE: the partitions are 1 MiB aligned and the data and hash images are padded to whole blocks, so XFS and Btrfs share the extents. Fall back to a copy where cloning is not supported. copy_file_range is not used because it does not reliably clone (it did not on Linux 7.0 with XFS). Tested: packing a 1.1 TB squashfs on XFS no longer needs a second 1.1 TB, and the scratch copy completes immediately. Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com>
On SEV-SNP launches with a 0.6.7+ guest image (app_epoch_pin: true), the VMM queries the KMS from the host to resolve the current app epoch before starting QEMU. Under single-node user-mode networking (as configured by dstackup), cvm.kms_urls holds the guest-only 10.0.2.2 alias, which is not routable from the host. When the VM manifest does not override kms_urls, try the host-side top-level kms_url first and fall back to cvm.kms_urls (deduplicated). Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com>
dstackup install writes cvm.kms_urls with the QEMU user-mode guest alias (https://10.0.2.2:<port>), which is not routable from the host, and left the top-level host kms_url empty. Set kms_url = https://127.0.0.1:<port> when KMS is enabled so host-side VMM RPCs (app-epoch resolution on 0.6.7 SEV-SNP launches and env-key lookups) can reach the local KMS. Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com>
create_vm rejected --env-file when --kms-url was omitted even if --kms-encrypt-url was given (unlike update_vm, which already allowed it). Allowing --kms-encrypt-url without --kms-url lets single-node hosts encrypt envs against the host-side KMS without overriding cvm.kms_urls on the VM. Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e908f978e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /// compose hash. | ||
| pub const DEFAULT_KMS_IMAGE: &str = "dstacktee/dstack-kms:0.5.11@sha256:84b793feed825a5b5e70d04386e931e0e110461492793f17ab2128e39808d989"; | ||
| /// compose hash. It has to read the `[listeners.*]` layout `kms_toml` renders. | ||
| pub const DEFAULT_KMS_IMAGE: &str = "ghcr.io/dstack-tee/dstack-kms:0.6.7@sha256:693b7c80bad6f759a17f3cc62503eb1ef768852527d448dcfbbb9edb3e8f99f3"; |
There was a problem hiding this comment.
Register root epochs before selecting the epoch-aware KMS
On a fresh default dstackup install, auth_allowlist_json() still writes neither rootEpochs nor kmsContractAddr, and cmd_install() never populates them after bootstrap. Unlike the previous 0.5.11 default, KMS 0.6.7 authorizes application key release through /authorizeApp; dstack/crates/dstack-auth/src/main.rs:435-455 rejects non-bootstrap operations without registered roots and also requires the KMS app ID. Consequently, installation can report success, but even a subsequently allowlisted application cannot obtain its boot keys without an additional manual migration. Populate the verified epoch-zero roots and KMS app ID during installation before making this image the default.
Useful? React with 👍 / 👎.
|
Split this PR into six focused PRs by purpose against
Closing this combined PR in favor of the split PRs above. |
Summary
A set of 12 focused fixes required to bring up AMD SEV-SNP hosts (EPYC Turin, firmware 1.58+) with large-BAR GPUs (e.g. 8x NVIDIA B200 with 256 GiB BAR1 in Confidential Computing mode) and single-node
dstackupdeployments cleanly on0.6.7/next:SEV-SNP firmware 1.58+ & large-BAR GPU passthrough
fix(sev-snp): accept version 5 attestation reports— bumpsevfrom6.0.0to6.3.0(parsesLAUNCH_MIT_VECTOR/CURRENT_MIT_VECTORinstead of failing withSkipped bytes were expected to be zeroed), allow report versions3..=5insev-snp-qvl, and populateversion/sig_algo/chip_idbeforeAttestationReport::write_bytesinmock-attestation.fix(vmm): give SEV-SNP guests the host's physical address width— pass-cpu EPYC-v4,host-phys-bits=on(instead of QEMU's 40-bit default) so guests can map multi-TiB 64-bit PCI MMIO windows; does not alter the SNP launch measurement.fix(os): build the SEV-SNP OVMF with 1 GiB page tables— buildAmdSevX64.dscwithPcdUse1GPageTable=TRUEso OVMF opens an 8 TiB 64-bit PCI MMIO window instead of capping at 40-bit / 128 GiB (too small for a single 256 GiB B200 BAR1). TDXovmf.fdis unchanged.Large verity volumes
fix(volume): share extents when packing a volume— useFICLONERANGEon Linux when packing dm-verity GPT volumes (with copy fallback), avoiding a 2x disk and I/O copy for TB-scale model weight volumes on XFS/Btrfs.dstackup,dstack-cli, and0.6.7single-node SEV-SNP KMS /app_epoch_pinfix(dstackup): write WorkingDirectory as a bare path in unit files— systemd 259 rejects quotedWorkingDirectory=.fix(dstackup): load vhost_vsock before starting the VMM— addExecStartPre=/sbin/modprobe vhost_vsockso CID 2 host-API bind works on fresh hosts.fix(dstackup): find mkosi-os-v guest-OS releases— look upmkosi-os-v*release tags first (keepingguest-os-v*fallback) and exclude*-kernel-devel.tar.gz.fix(dstack-cli): pick auto host ports inside the VMM port-mapping range— pick from10000..=19999instead of kernel ephemeral ports rejected byvmm.toml.fix(dstackup): render the KMS 0.6 listener layout— render[listeners.*]andcore.keyring_dirand updateDEFAULT_KMS_IMAGEto digest-pinned0.6.7.fix(vmm): prefer host kms_url when querying SEV-SNP app epoch— on0.6.7+images (app_epoch_pin: true), try host-reachable top-levelkms_urlbefore guest-onlycvm.kms_urls(10.0.2.2) whenmanifest.kms_urlsis unset.fix(dstackup): set host kms_url in vmm.toml— renderkms_url = "https://127.0.0.1:<port>"alongside guestcvm.kms_urls.fix(vmm-cli): allow --env-file with --kms-encrypt-url alone— matchupdate_vmsocreate_vmcan encrypt envs against a host-reachable KMS without overriding guestkms_urls.Verification
cargo test --workspace --locked: all 1,861 tests across 134 suites pass (including new unit tests for report v5,EPYC-v4,host-phys-bits=on,app_epoch_kms_urls,dstackupconfig/systemd/image/port rendering, andtest_vmm_cli.py23/23 passing).cargo clippy --locked(-D warnings --allow unused_variables) andcargo fmt --all -- --checkpass cleanly.mkosiprod guest image (0.6.7),dstack-kmsbootstrap + LUKS unseal across VMM restart, and an 8-GPU SEV-SNP CVM withapp_epoch_pin, two dm-verity volumes (1.1 TB + 66 MiB), and full SEV-SNP + 8-GPU attestation.Happy to split into separate PRs (e.g. SEV-SNP/OVMF/volume vs.
dstackup/CLI) if preferred.