Skip to content

Land immediately verifiable P2P safety fixes - #33

Open
ducphuc wants to merge 7 commits into
aikitoria:610.43.03-p2pfrom
ducphuc:fix/610-p2p-safety-prerequisite
Open

Land immediately verifiable P2P safety fixes#33
ducphuc wants to merge 7 commits into
aikitoria:610.43.03-p2pfrom
ducphuc:fix/610-p2p-safety-prerequisite

Conversation

@ducphuc

@ducphuc ducphuc commented Aug 4, 2026

Copy link
Copy Markdown

Summary

  • remove dead BAR1 P2P address plumbing while preserving the live DMA encoder
  • leave P2P atomics at the platform default with the global BAR1 protocol policy and all HAL/device coverage unchanged
  • reject unsafe hugetlb fast-path ranges and fall back to the existing per-page path
  • restore IOVA lifetime diagnostics and 64K dynamic-granularity accounting
  • synchronize the inactive Resizable BAR registry mirror
  • document the current hugetlb, IOMMU, and ACS safety constraints

The retained global pcieP2PType = BAR1 default also selects BAR1 on qualifying PCIe-only datacenter GPUs; the existing static-BAR1 support checks still gate use of that protocol.

Validation

  • git diff --check upstream/610.43.03-p2p..HEAD
  • complete make modules -j64 build on Linux 7.0.0-28-generic
  • inspected that generated HAL routing and install.sh are unchanged
  • inspected that ineligible hugetlb layouts enter the unchanged per-page path
  • loaded an enrolled-MOK-signed integration build on two GB206 GPUs with PR Display-aware BAR1 P2P on GB206 and transactional mailbox P2P setup #31 behavioral commits applied
  • nvidia-smi topo -p2p: read, write, and PCIe are OK; atomics are NS, not DR, confirming this branch regkey no longer disables atomics
  • simpleP2P: bidirectional correctness passed at about 13.09 GB/s
  • p2pBandwidthLatencyTest: 14.09 GB/s per direction and about 27.8 GB/s aggregate bidirectional
  • no Xids, assertions, BAR1 failures, IOMMU faults, or P2PDMA conflicts in the final test log

The GB206 copy validation includes PR #31 because that PR contains the display-aware BAR1 and transactional mailbox fixes and is intended to rebase immediately after this prerequisite merges.

ducphuc added 7 commits August 4, 2026 11:27
BAR1 mappings already select SYS_COH or SYS_NONCOH before PTE construction, so the PEER-aperture rewrites and bar1BusAddr base assignment were unreachable. Keep the live BAR1 DMA address encoder unchanged.
Keep BAR1 reads and writes enabled, but encode the atomics field as DEFAULT instead of implicitly disabling it with 0x11. Preserve the branch-wide BAR1 protocol policy, including qualifying PCIe-only datacenter GPUs, and retain registry-key precedence.
Use the reduced page-array path only for non-empty, overflow-safe ranges that are hugepage aligned, exactly sized in hugepages, and contained in one hugetlb VMA. Fall back to the existing base-page path for every other layout.
Report leftover mappings and mappings that outlive their I/O VA space without triggering a debug breakpoint. Use the portable NvU64 format for mappingCount and retain null-safe teardown.
Dynamic-granularity page arrays already use the OS page size, so pass PageCount directly when unregistering them. The RM-to-OS conversion is only correct for ordinary RM-granularity arrays on 64K-page systems.
Match the inactive nv-reg.h mirror to the kernel-open definition. Only os-registry.c instantiates the active table, so this is source hygiene and does not change runtime behavior.
Keep IOMMU passthrough required while translated-IOMMU scatterlist merging remains unsafe, document the hugetlb eligibility fallback, and replace the broad ACS override recommendation with scoped upstream controls and an isolation warning.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens and clarifies P2P safety behavior in the kernel driver branch by removing unused BAR1 peer-address plumbing, hardening the hugetlb registration fast-path eligibility checks, restoring/adding diagnostics around IOVA/IOVA-lifetime issues, and aligning registry defaults/documentation with the intended safe operating constraints.

Changes:

  • Remove dead BAR1 P2P address-plumbing from external alloc PTE/physaddr builders while keeping the live DMA encoder path intact.
  • Add stricter hugetlb fast-path eligibility validation (alignment, single-VMA containment, overflow bounds) and fall back to the existing per-page pinning path when ineligible.
  • Re-enable IOVA lifetime/mapping diagnostics, sync Resizable BAR global defaults, and update README documentation on current IOMMU/ACS/hugetlb constraints.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/nvidia/src/kernel/rmapi/nv_gpu_ops.c Removes unused BAR1 bus-address threading and redundant aperture overrides in external mapping builders.
src/nvidia/src/kernel/mem_mgr/io_vaspace.c Restores/widens diagnostics for leftover mappings and dangling mapping lifetimes.
src/nvidia/src/kernel/gpu/bif/kernel_bif.c Adjusts default P2P registry override to enable reads/writes while leaving atomics at platform default.
src/nvidia/arch/nvalloc/unix/src/osmemdesc.c Fixes page-count accounting selection for dynamic granularity paths during page-array teardown.
src/nvidia/arch/nvalloc/unix/include/nv-reg.h Changes global default for resizable BAR enablement to match the mirrored registry header.
README.md Documents current safety constraints (IOMMU translated mode limitations for hugetlb path; safer ACS guidance).
kernel-open/nvidia/os-mlock.c Adds hugetlb fast-path eligibility helper with stronger validation and safe fallback behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants