Skip to content

fix(sev-snp): support large-BAR GPU passthrough (host-phys-bits + 1 GiB OVMF page tables) - #1705

Open
PierreLeGuen wants to merge 2 commits into
Dstack-TEE:nextfrom
nearai:fix/sev-snp-large-bar-gpus
Open

PierreLeGuen wants to merge 2 commits into
Dstack-TEE:nextfrom
nearai:fix/sev-snp-large-bar-gpus

Conversation

@PierreLeGuen

Copy link
Copy Markdown
Contributor

Summary

Enables mapping >128 GiB PCIe BARs (such as a 256 GiB NVIDIA B200 BAR1) inside AMD SEV-SNP guests.

Changes

  • fix(vmm): give SEV-SNP guests the host's physical address width (dstack/vmm/src/app/qemu.rs): pass -cpu EPYC-v4,host-phys-bits=on instead of QEMU's 40-bit default so SEV-SNP 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 (os/mkosi/components/ovmf/ovmf-build.sh): build AmdSevX64.dsc with -D PcdUse1GPageTable=TRUE so OVMF opens an 8 TiB 64-bit PCI MMIO window instead of capping at 40-bit / 128 GiB. TDX ovmf.fd is unchanged (note: ovmf-sev.fd and the SEV-SNP launch measurement change).

Verification

  • cargo test --locked -p dstack-vmm amd_sev_snp: 8 passed.
  • cargo clippy --locked -p dstack-vmm -- -D warnings --allow unused_variables, cargo fmt --all -- --check, and bash -n os/mkosi/components/ovmf/ovmf-build.sh: pass.
  • End-to-end verified with 8x NVIDIA B200 (256 GiB BAR1, Blackwell Confidential Computing) passthrough in a reproducible mkosi SEV-SNP guest.

Split out from #1703.

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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T13:26:20.614166Z 180e298 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant