Repository navigation
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
Open
PierreLeGuen wants to merge 2 commits into
PierreLeGuen wants to merge 2 commits into
Conversation
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>
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. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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=oninstead 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): buildAmdSevX64.dscwith-D PcdUse1GPageTable=TRUEso OVMF opens an 8 TiB 64-bit PCI MMIO window instead of capping at 40-bit / 128 GiB. TDXovmf.fdis unchanged (note:ovmf-sev.fdand 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, andbash -n os/mkosi/components/ovmf/ovmf-build.sh: pass.mkosiSEV-SNP guest.Split out from #1703.