32 Commits

Author SHA1 Message Date
c777e5cc67 feat(display): standalone Stage 2 desktop video (nvidia_rs_modeset + nvidia_rs_drm) (#608)
* feat(desktop-video): Stage 2 standalone nvidia_rs_modeset + nvidia_rs_drm cutover

Complete Stage 2 standalone clean-room desktop video implementation
matching exact NVIDIA 580.178.04 DRM and NVKMS UAPI layouts (rebased
onto #587 GEM_EXPORT_DMABUF_MEMORY):

- DRM (24/24 PORTED):
  - Harden atomic KMS compositor paths in nvidia_rs_drm.c:
    atomic_disable vblank event delivery (prevents Wayland hangs /
    WARN_ON), crtc_atomic_check, cursor plane <=256x256 validation,
    and async_page_flip capability advertisement.
  - Add KAPI kms_grant_permissions / kms_revoke_permissions backing
    and end-to-end QEMU smoke coverage for GEM_EXPORT_DMABUF_MEMORY,
    atomic modeset + vblank flips, CRTC disable, and DRM permissions.
- NVKMS (62/66 PORTED, 4 Quadro Sync framelock honestly PARTIAL):
  - Connect /dev/nvidia-rs-modeset (/dev/nvidia-modeset) chardev to
    refcounted shared nv_rs_kms_device instances (real heads, disps,
    connectors, EDID, hardware commit & CRC32).
  - Add #![no_std] low-stack EDID 1.4 / CEA-861 mode enumerator and
    validator (src/nvidia/src/nvkms/modes.rs) and stateful NVKMS
    backends for permissions, deferred request FIFOs, swap groups,
    DPY/DISP attributes, vblank sync/sem controls, fliplock, mux,
    and 580 cmd 63/64 (src/nvidia/src/nvkms/state.rs).
  - Add per-file event ring buffer + wait_queue_head_t poll() wakeups
    and exact 580 grant/unicast-event fd roles.
- Verification (offline + disposable QEMU/KVM Linux 7.0 guest only):
  - make modules + check_kernel_module.py: PASS (0 GOT, 0 SIMD,
    0 memcpy/memset/memmove, largest_stack=1016).
  - cargo fmt --check, cargo clippy -D warnings, cargo test nvkms (76/76),
    NV_RS_KERNEL_IBT=1 kernel-module-gate (37/37): ALL PASS.
  - tools/vm/run_desktop_drm_guest.py: 19/19 checks PASS with clean unload.

* nvkms/drm: address CodeRabbit review findings for Stage 2 desktop video

- EDID/mode parsing (modes.rs): use exact 64-bit FNV-1a timing dedup key
  (preserving nearby refresh rates like 1080p60 vs 1080p62 with zero memset),
  decode CTA-861 Video Data Block Short Video Descriptors (VICs), normalize
  interlaced DTD vertical field counts to full frame lines, and reject
  htotal/vtotal > 0x7fff.
- Permissions & swap-group transactional safety (state.rs, mod.rs,
  modeset_ffi.rs, nvidia_rs_modeset.c, nvidia_rs_drm.c): align permission
  type enum to exact 580 values (1=FLIPPING, 2=MODESET, 3=SUB_OWNER),
  validate modeset fd role and share grant fd publication between DRM KAPI
  and NVKMS chardev, scope DRM grants to per-drm_file issuer_id with
  postclose cleanup, support explicit NvKmsPermissions revocation
  (typeMask==0), scope release_device() permission/swap-group cleanup to
  the released device handle, and roll back ACQUIRE_PERMISSIONS /
  ACQUIRE_SWAP_GROUP on copy_to_user -EFAULT.
- Concurrency, refcounting & vblank delivery (nvidia_rs_modeset.c,
  nvidia_rs_drm.c): serialize first-open per GPU with nv_rs_kms_open_lock,
  refcount direct kms_dev lookups via kms_dev_get(), deliver NOTIFY_VBLANK
  asynchronously on real vblank ticks (with fd >= 0 support and release
  cleanup), only consume atomic_disable page-flip events when !active, and
  remove unlatched async_page_flip shortcut.
- Honest -EOPNOTSUPP & parity ledger (nvidia_rs_modeset.c, nvidia_rs_drm.c,
  build_parity_ledger.py, desktop_drm_smoke.c): enforce connector membership
  and connector-specific DigitalSignal on DPY attributes, tighten CRC32 head
  check (< 4) and return -EOPNOTSUPP/supported=0 until HW CRC32 is wired,
  return -EOPNOTSUPP after validation/ownership checks on unimplemented
  chardev hardware-programming ioctls, and update parity ledger & 19/19
  QEMU desktop DRM smoke tests.

* nvkms/drm: resolve round-2 CodeRabbit findings and rebase onto master

- Preserve the full 128-byte 580 NvKmsPermissions union payload verbatim
  across GRANT_PERMISSIONS, ACQUIRE_PERMISSIONS, and explicit
  REVOKE_PERMISSIONS (using black_box copy to keep 0 memcpy/memset).
- Enforce issuer authority (owner or SUB_OWNER) under owner lock before
  publishing chardev permission grants; reject explicit SUB_OWNER
  revocation without mutating state; subtract explicit revocation bits
  rather than deleting partially matching rows; ignore explicit payload
  bytes on non-zero typeMask revocations.
- Reserve consumed permission and swap-group grant slots (pending_commit)
  across copy_to_user and release via commit_acquire / un-reserve via
  rollback_acquire (without resurrecting grants for freed swap groups).
- In NOTIFY_VBLANK, write the reply before mutating ev_f->fd_role or
  linking the waiter, revalidate the device handle under f->lock ->
  nv_rs_kms_lock, wake physical-display waiters from real HW vblank IRQs
  only (keeping synthetic timer as virtual-display fallback).
- Return honest -EOPNOTSUPP for IDLE_BASE_CHANNEL and SET_MODE (both
  commit=0 and commit=1) until full decode/HW wait is implemented; move
  disable completion event delivery back to atomic_flush so disable does
  not signal before scanout stops.

* nvkms/drm: fix stock 580 ABI layouts, transactional grants, vblank sync, and EOPNOTSUPP stubs

* desktop/nvkms: address remaining minor CodeRabbit findings on Stage 2

* desktop/nvkms: resolve round-4 CodeRabbit review findings on Stage 2

* desktop/nvkms: fix irq-safe vblank disable lock and connector probe init

* fix(nvkms): address CodeRabbit review on probe errors, vblank, CursorImm auth, pclk, and attrs

* fix(nvkms,drm): track connector probe validity, add vblank barriers, keep 64-bit refresh checks

---------

Co-authored-by: morebrackets <19673572+morebrackets@users.noreply.github.com>
2026-12-05 13:25:22 -08:00
1ed77198c8 feat(blackwell): adapt desktop video Stage 1 & Stage 2 for RTX 50 (GB202-GB207) (#621)
* feat(blackwell): adapt desktop video Stage 1 & Stage 2 for RTX 50 (GB202-GB207)

* fix(blackwell): address CodeRabbit review on DP 2.1 UHBR training and GB10 preflight

---------

Co-authored-by: morebrackets <19673572+morebrackets@users.noreply.github.com>
2026-12-05 13:05:22 -08:00
b95d30a698 ada/desktop: adapt Stage 1 & Stage 2 desktop video for RTX 40 series (AD102-AD107) (#620)
* ada/desktop: adapt Stage 1 & Stage 2 desktop video for RTX 40 series (AD102-AD107)

Stage 1 & Core Ada GSP-RM / RM fixes (verified against stock 580.196.07):
- ga10x_gsp.rs: stop downgrading Ada's configured 580.x release string when
  no bundled 580.178.04 Ada booter exists, add 580.196.07 -> 580.178.04
  gsprm_load fallback, read NV_FUSE_STATUS_OPT_DISPLAY at 0x820c04 on
  Ampere/Ada+ (_nv030373rm) and propagate display_fused_off into hw facts,
  and fail explicitly (instead of silently skipping) when cold-boot Ada
  scrubber-580.bin is missing.
- display.rs, display_channels.rs, gsp_boot.rs, ga10x.rs: fix Ada
  DispSfUser BAR0 offset (0x6f0000 for all NvDisplay v03_00+ per
  _nv005909rm/_nv040109rm), fix Ada copy_engine class (0xc7b5
  AMPERE_DMA_COPY_B), enable ce_class_db filtering for ArchFamily::Ada,
  and pass real boot0 to configure_live_display().
- gsp_route.rs, rmapi_node.rs, modeset_ffi.rs, modeset_bridge.c: intercept
  NV_ESC_RM_BIND_CONTEXT_DMA (0x59) in pre() for host-side 0x0002 ->
  NvDisplay channel binds, keep modeset_gsp_alloc_ctxdma 100% host-side
  with Node RM video memory lookup via nv_rs_modeset_query_rm_mem, prevent
  double GSP memory registration, purge MODESET_MEMS/MODESET_CTXS on
  NVOS00 free, validate Stage 1 nv_rs_modeset_get_rm_ops against the
  configured 580.x driver_version, and fix NVOS64 debug status trace.

Stage 2 Ada NvDisplay v4.1 (0xc77d/0xc67e) & DRM pipeline fixes:
- nvidia_rs_modeset.c:
  - Separate full Core modeset/link-training from fast Window-only page
    flips and cursor-only Core updates; program Core FIRST on full modeset.
  - Resolve imported compositor/Vulkan/EGL VRAM handles via
    nv_rs_modeset_query_rm_mem and bind host-side NV01_CONTEXT_DMA to Core
    and Window channels for scanout.
  - Enforce BAR1 window bounds on 0x0040 allocations (falling back to
    BAR1-constrained nv_rs_modeset_vram_alloc on non-ReBAR 256 MiB GPUs)
    and propagate block-linear pte_kind.
  - Query NV0073_CTRL_CMD_SPECIFIC_OR_GET_INFO (0x0073028b) for SOR
    sublink A/B (DP_A/DP_B, SINGLE_TMDS_A/B, DUAL_TMDS), promote HDMI
    >600 MHz to SOR_PROTOCOL_HDMI_FRL (0xc), bracket DP link training with
    NV5070_CTRL_CMD_SET_SOR_FLUSH_MODE (0x50700457), support DP 1.4a HBR3
    (0x1e) via DP_GET_CAPS (0x00731369), and retry with FALLBACK_CONFIG.
  - Honor HSYNC/VSYNC polarity and 10 bpc depth in HEAD_SET_CONTROL_OR,
    emit HEAD_SET_CONTROL / PCLK_CFG / USAGE_BOUNDS / STORAGE_CURSOR,
    fix WIN_SET_PLANAR_STRG0 13-bit mask (& 0x1fff), add XBGR16161616F,
    and back off synthetic vblank timer when real HW vblank IRQs arrive
    (removing the 4 ms floor for 240/360 Hz displays).
- nvidia_rs_drm.c: fix VRAM BAR1 mmap vma->vm_pgoff bounds/offset,
  validate explicit FB modifiers and reject compressible modifiers, add
  XBGR16161616F, remove unimplemented NV12, set preferred_depth=24 and
  <6.13 allow_fb_modifiers=true, and pair drm_kms_helper_poll_init/fini.
- install_desktop_boot.sh, reload_stage1.sh: add Ada (ad102) GSP boot &
  scrubber firmware preflight check with extract_gsp_boot_ucode.py hint.
- Add unit tests in display.rs, gsp_boot.rs, nvdisp_pushbuf.rs, and
  gpu_tests.rs covering Ada classes, fuse register, and pushbuffer encode.

* ada/desktop: resolve all CodeRabbit review findings for RTX 40 desktop video

* ada/desktop: address round-2 CodeRabbit review findings

* ada/desktop: address final CodeRabbit review findings

* ada/desktop: track explicit fb modifiers, order disable before vblank_off, reserve Window room up front

---------

Co-authored-by: morebrackets <19673572+morebrackets@users.noreply.github.com>
2026-12-05 12:26:38 -08:00
f3862b6300 drm: implement GEM_EXPORT_DMABUF_MEMORY (24/24 DRM ioctls ported) (#587)
* drm: implement GEM_EXPORT_DMABUF_MEMORY via RM 0x71 external sgt bridge (24/24 DRM)

* rmapi: enforce external_gpu_id on DMA lookups and mirror forwarded GSP devices

* rmapi: keep locally registered memory RM_FREE on native execute_full path

* rmapi: scope local RM_FREE bypass to local UserPages (0x0071) backings only

* rmapi: mirror forwarded GSP peer device on import_slot and clean up local entries on forwarded FREE

* rmapi: recursively free native subtrees on GSP object free and keep UserPages MAP_MEMORY_DMA native

* rmapi: return NOT_SUPPORTED for UserPages MAP_MEMORY_DMA on legacy gsp_bringup sessions

* rmapi: verify client ownership before returning NOT_SUPPORTED on legacy GSP UserPages MAP_MEMORY_DMA

---------

Co-authored-by: Eric Hartford <eric@quixi.ai>
2026-12-05 04:20:19 -08:00
bbf609abf5 fix(kernel-open): shorten exported framelock symbol for CONFIG_MODVERSIONS and fix C90 warning (#572)
Co-authored-by: Eric Hartford <eric@quixi.ai>
2026-12-04 20:34:59 -08:00
6435d65112 fix(rmapi/modeset): rmmod refcnt leak (#491), modeset RM ops (#466), runtime logs/fw warning (#501) (#513)
* fix(ga10x/rmapi/modeset): R620 control translation, rmmod refcnt, modeset RM ops (#504, #491, #466, #501)

* chore(pr513): drop gsp_route R620 hunk in favor of live-verified #514

* fix(gpu_owner): balance get_task_struct with put_task_struct after kthread_stop

* fix(gpu_owner/irq): wait for runtime worker join & pin/teardown failed runtime IRQ close

Addresses CodeRabbit review findings on PR #513 (and #491/#528):
- gpu_owner.c: Wait for runtime_stopped in a 10s warning loop and always join
  via kthread_stop() + put_task_struct() so an unpinned runtime worker can
  never outlive module text during PCI removal / rmmod.
- irq_adapter.c: When nv_rs_irq_close() fails to quiesce an unpinned
  runtime-kthread IRQ owner, acquire THIS_MODULE before returning the error
  (or force-disable/synchronize/free handlers if the module is already
  unloading so no callback can outlive module text).
- ga10x_events.rs: Check nv_rs_irq_close() status in stop() and restore e.irq
  on failure instead of discarding the handle.
- tests/irq-mock: Cover both live-pin and unloading-force-teardown paths.

* fix(pci,irq): disable PCI INTx on forced IRQ close and bound AER/shutdown runtime stop

Address follow-up review findings on #513:
- In nv_rs_irq_close() forced teardown (unpinned runtime worker after mask
  failure), call pci_intx(owner->pdev, 0) for legacy INTx mode so the
  device stops asserting its level-triggered line without disabling a
  shared IRQ line for other devices, and add an irq-mock regression test.
- Add nv_rs_gpu_owner_runtime_stop_bounded(owner, timeout_ms) preserving
  runtime_task and runtime_stopping on timeout (preventing restart races
  and allowing a later nv_rs_remove() stop to complete the join).
- In nv_rs_shutdown() and nv_rs_aer_error_detected(), call pci_clear_master()
  first for immediate DMA containment, then use a bounded runtime stop so
  shutdown and PCIe AER callbacks never wedge indefinitely.

* fix(pci,pm): bound runtime_lock wait, reclaim retired worker on start/AER, and reassert BME clear

Address follow-up review findings on #513:
- Include runtime_lock acquisition inside nv_rs_gpu_owner_runtime_stop_bounded()'s
  deadline via bounded mutex_trylock() polling so shutdown/AER cannot hang when
  startup holds runtime_lock waiting for runtime_ready.
- Reclaim a retired worker in nv_rs_gpu_owner_runtime_start() via
  nv_rs_gpu_owner_runtime_reclaim_locked() and in nv_rs_aer_resume() so a
  timed-out bounded stop never strands runtime engines unavailable after recovery.
- Reassert pci_clear_master(pdev) after the serialized stop attempt in
  nv_rs_shutdown() and nv_rs_aer_error_detected() so in-flight GPU bring-up
  cannot leave Bus Master enabled.
- Use nv_rs_gpu_owner_runtime_stop_bounded() in PM suspend/runtime_suspend with
  full state rollback on timeout so suspend cannot wedge indefinitely while
  nv_rs_remove() keeps the unconditional join required before module unload.

* fix(pci): keep Bus Master enabled during bounded GSP unload on shutdown

Address final review comment on #513:
- In nv_rs_shutdown(), invoke nv_rs_gpu_owner_runtime_stop_bounded(owner, 10000)
  before pci_clear_master(pdev) so an active GSP session can complete its
  DMA unload RPC during clean shutdown, then clear Bus Master Enable once
  the stop finishes or hits its bounded deadline.

* fix(pci,pm): return DISCONNECT on AER stop timeout and keep full PM suspend stop

Address review findings on #513:
- In nv_rs_aer_error_detected(), return PCI_ERS_RESULT_DISCONNECT rather than
  PCI_ERS_RESULT_NEED_RESET if nv_rs_gpu_owner_runtime_stop_bounded() times
  out, preventing a PCIe slot reset while a live runtime worker could still
  issue MMIO or re-enable Bus Master.
- In nv_rs_pm_do_suspend() and nv_rs_pmops_runtime_suspend(), wait for worker
  retirement via nv_rs_gpu_owner_runtime_stop() before entering D3hot rather
  than half-aborting after modeset suspend and USERD VMA revocation.

---------

Co-authored-by: morebrackets <19673572+morebrackets@users.noreply.github.com>
2026-12-04 19:48:23 -08:00
ff0c7edbc0 feat(nvkms): add exact 580 ABI decoders, handle validation, and honest ledger audit (#517)
- Add exact 580.178.04 ABI Rust decoders/validators and unit tests (69/69)
  in src/nvidia/src/nvkms/mod.rs + kernel FFI exports in modeset_ffi.rs,
  modeset_iface_exports.c, and src/nvidia/Makefile for all remaining NVKMS
  ioctl commands.
- Wire per-command exact 580 ABI + handle validation in
  kernel-open/nvidia-modeset/nvidia_rs_modeset.c, returning honest -EINVAL
  (missing disp/head/framelock/swap-group) or -EOPNOTSUPP for unbacked
  display, framelock, permissions, deferred FIFO, swap-group join/leave/clip,
  and unicast-event handlers rather than fake success.
- Update tools/build_parity_ledger.py to inspect C handler function bodies
  and exclude -EOPNOTSUPP handlers from PORTED (keeping nvkms_ioctls honestly
  at 14 PORTED / 52 PARTIAL).

Co-authored-by: morebrackets <19673572+morebrackets@users.noreply.github.com>
2026-12-04 19:39:58 -08:00
9f70f56020 chore: update repository references from QuixiAI/nvdriver to nvdriver/nvdriver (#520)
Co-authored-by: Eric Hartford <eric@quixi.ai>
2026-12-03 21:34:14 -08:00
b52978f2a5 Address round-3 CodeRabbit PR #383 findings (all 12 remaining items) 2026-12-03 16:33:41 -08:00
c5a9dd147d Address round-2 CodeRabbit PR #383 findings across RMAPI, kernel glue, KMS/DRM, and tools 2026-12-03 16:13:36 -08:00
5a1b9a659e Merge origin/master (ca3d44e3, NVKMS surface FFI #471 + DRM PAGE_SIZE #458) into feat/ga102-desktop-master 2026-12-03 13:10:52 -08:00
fe16cf34e2 feat(nvkms): implement surface lifecycle registry and FFI (14/66 NVKMS PORTED) (#471)
* feat(nvkms): implement surface lifecycle registry and FFI (REGISTER/UNREGISTER/GRANT/ACQUIRE/RELEASE)

* fix(nvkms): validate format, reject userspace skipSync, check plane extent, avoid ID/handle wraparound collisions, and preserve idempotent unregister/release

* fix(nvkms): retain backing dma-buf/RM fd ref until unregister, reject multi-plane formats, and validate format Bpp row pitch

* fix(nvkms): tie backing dma-buf/RM ref lifetime to SurfaceRegistry reap across orphan lifetimes

---------

Co-authored-by: Eric Hartford <eric@quixi.ai>
2026-12-03 12:06:55 -08:00
0f8299f438 feat(display,nvkms): VBIOS DCB 4.x board output enumeration (#189) + NVKMS QUERY_DISP/QUERY_FRAMELOCK FFI (11/66 PORTED) (#446)
* feat(display,nvkms): add VBIOS DCB 4.x board output enumeration (#189) + NVKMS QUERY_DISP/QUERY_FRAMELOCK FFI

- Add src/nvidia/src/gpu/display_outputs.rs (BoardOutputs::enumerate,
  validate_heads, connector-table pairing) using existing 580-parity
  rom_dcb decoders, with unit tests for 4-connector consumer boards,
  headless datacenter SKUs, bounds/signature errors, and excess heads
- Wire NVKMS_IOCTL_QUERY_DISP (cmd=2, 172 B) and NVKMS_IOCTL_QUERY_FRAMELOCK
  (cmd=28, 20 B) through live Rust FFI (nv_rs_nvkms_validate_query_disp,
  nv_rs_nvkms_validate_query_framelock) with dedicated per-command unit tests
- Update tools/build_parity_ledger.py and docs/PARITY_LEDGER.md:
  nvkms_ioctls 9 -> 11 PORTED (total 2,551 PORTED / 65 PARTIAL / 0 MISSING)

* fix(display): reject DCB overflow, ignore version-0 connectors, keep zero-count NVKMS queries PARTIAL

* fix(dcb): distinguish 0xe EOL from 0xf skip and match DCB 4.x connector bit layout

---------

Co-authored-by: Eric Hartford <eric@quixi.ai>
2026-12-03 09:33:23 -08:00
2e86387188 Address CodeRabbit PR #383 review findings across RMAPI, kernel glue, KMS/DRM, and tools 2026-12-03 08:58:32 -08:00
b60c3dd220 Merge origin/master into feat/ga102-desktop-master 2026-12-03 07:55:02 -08:00
d792fac841 feat(nvkms): move ownership table & lifecycle validators into Rust FFI (9/66 PORTED)
- Export nv_rs_nvkms_ownership_{grab,release,is_owner,release_device,release_file}
  and nv_rs_nvkms_validate_{free_device,get_next_event,free_swap_group} from
  nvidia_rs.ko backed by nv_rs_core::nvkms
- Remove duplicated C nv_rs_modeset_owners[] table from nvidia_rs_modeset.c
  and route GRAB_OWNERSHIP, RELEASE_OWNERSHIP, FREE_DEVICE, GET_NEXT_EVENT,
  and FREE_SWAP_GROUP through the live Rust FFI entry points
- Add dedicated per-command unit tests (test_free_device, test_get_next_event,
  test_grab_ownership, test_release_ownership, test_free_swap_group) and
  update tools/build_parity_ledger.py + docs/PARITY_LEDGER.md
  (nvkms_ioctls 4 -> 9 PORTED, total 2,549 PORTED / 67 PARTIAL / 0 MISSING)
2026-12-03 12:57:21 +00:00
5f517ae5d3 fix(nvkms,ledger): require per-command live FFI + dedicated unit test for PORTED
- Export nv_rs_nvkms_validate_fbcon_disabled_userspace from nvidia_rs.ko
  and call it directly from nvidia_rs_modeset.c
- Split nvkms unit tests into dedicated per-command tests (test_alloc_device,
  test_declare_event_interest, test_alloc_swap_group, test_fbcon_disabled_userspace)
- Update audit_nvkms() in tools/build_parity_ledger.py to check an explicit
  per-command (ffi_symbol, test_fn_name) map and record each command's exact
  test in verification (4 PORTED, 62 PARTIAL, 0 MISSING)
2026-12-03 12:48:07 +00:00
b5ee3eadee feat(nvkms): move 580.178.04 NVKMS param table & validators into Rust core with FFI + unit tests
- Add clean-room #![no_std] nv_rs_core::nvkms (src/nvidia/src/nvkms/mod.rs)
  holding the single-source-of-truth 66-entry 580.178.04 NVKMS_PARAM_SIZES_580
  table (verified against target/stock-580-kmods/nvidia-modeset.ko:.rodata+0x25ee0),
  device/event-interest/swap-group/fbcon validators, OwnershipTable, and
  unit tests (cargo test nvkms::tests::*)
- Export nv_rs_nvkms_param_size_580, nv_rs_nvkms_validate_alloc_device,
  nv_rs_nvkms_validate_event_interest, and nv_rs_nvkms_validate_alloc_swap_group
  from nvidia_rs.ko and call them directly from nvidia_rs_modeset.c (removing
  the duplicated C size table)
- Update tools/build_parity_ledger.py and docs/PARITY_LEDGER.md:
  nvkms_ioctls 0 -> 9 PORTED (with Rust FFI + cargo test verification),
  total 2,549 PORTED, 67 PARTIAL, 0 MISSING, 19 EXCL
2026-12-03 12:39:44 +00:00
7fafb9c321 fix(modeset): address final 2 Minor CodeRabbit findings
- Clear global owner entry and swap groups under owner_lock -> f->lock
  when ALLOC_DEVICE rolls back on kzalloc or copy_to_user failure
- Return -EOPNOTSUPP in CLEAR_UNICAST_EVENT for non-unicast-event
  modeset descriptors until NvKmsPerOpenTypeUnicastEvent is implemented
2026-12-03 11:07:14 +00:00
fcc4b12bc3 fix(modeset,mmio,ledger): address all 10 second-round CodeRabbit findings
- Add nv_rs_modeset_poll() callback (report EPOLLIN only when pending) and
  reject non-zero DECLARE_EVENT_INTEREST subscriptions with -EOPNOTSUPP
- Reject userspace NVKMS_IOCTL_FRAMEBUFFER_CONSOLE_DISABLED with -EPERM
  (kernel-only in stock 580.178.04 _nv000413kms)
- Validate rm_device_id < 32 (NV_MAX_DEVICES) and mig_device == 0 on
  ALLOC_DEVICE and index exclusive ownership directly by rm_device_id
- Reject non-owner RELEASE_OWNERSHIP with -EPERM before any cleanup
- Copy and validate full 36-byte NvKmsAllocSwapGroupRequest headMask[8]
  (reject nonzero masks on headless numDisps==0 devices) and enforce
  modeset-owner check on ALLOC/FREE_SWAP_GROUP
- Publish bar1_ext_bytes in extend_bar1_identity_map() only after BAR1
  TLB invalidation readiness + ack polls succeed
- Reject both bus-loss (u32::MAX) and Poll32 timeout in Maxwell/Pascal
  flush_tlb() branches
- Include read_pascal_register() loops (wait_pascal_bar1_bind,
  flush_pascal_bar1, wait_pascal_mmu) in audit_mmio_bus_loss_guards()
  (32/32 verified) and emit honest PARTIAL for NVKMS until behavioral
  parity tests exist
2026-12-03 10:53:15 +00:00
f78f383a77 fix(modeset,mmio,ledger): address all 9 CodeRabbit review findings on PR #395
- Restore exact 580.178.04 66-entry NVKMS command numbering (retaining
  CHECK_LUT_NOTIFIER at 13, REGISTER_SURFACE at 17, GET_NEXT_EVENT at 32,
  ALLOC_SWAP_GROUP at 46, FRAMEBUFFER_CONSOLE_DISABLED at 65) and exact
  paramsSize table dumped directly from stock nvidia-modeset.ko (.rodata+0x25ee0)
- Use exact 40-byte NvKmsAllocSwapGroupParams layout (reply at offset 36)
  separately from 12-byte NvKmsFreeSwapGroupParams (reply at offset 8)
- Track display ownership per underlying (rm_device_id, mig_device) across
  opens with consistent lock ordering (owner_lock -> f->lock), reject competing
  owners with -EBUSY, and clear swap groups on ownership release and file close
- Give CLEAR_UNICAST_EVENT a dedicated unicastEventFd handler (fget/fput +
  f_op validation)
- Return -EOPNOTSUPP for REGISTER_SURFACE until fd surface import is implemented
  (never fabricate an unbacked handle)
- Propagate flush_tlb() bus-loss/timeout failures (bool #[must_use]) through
  uvm_map_range, uvm_map_pages, map_rm_default_sysmem, map_rm_default_vram,
  and scrub-CE/WFI paths with PTE rollback on failure
- Harden audit_mmio_bus_loss_guards() to parse comment-stripped balanced-brace
  loop bodies for an explicit u32::MAX/0xffff_ffff condition + break/return exit
  and populate stock_evidence/rust_location/verification fields; audit all 66
  NVKMS entries directly against stock 580.178.04 nvidia-modeset.ko
2026-12-03 10:29:11 +00:00
23479cafaa feat(modeset): port ALLOC/FREE_SWAP_GROUP and complete 580.178.04 NVKMS param-size table
- Port NVKMS_IOCTL_ALLOC_SWAP_GROUP (45) and FREE_SWAP_GROUP (46) with
  per-file tracking and device-free cleanup in nvidia_rs_modeset.c.
- Add exact gcc-verified 580.178.04 nv_rs_kms_param_sizes[65] table and
  deviceHandle validation for all remaining display-dependent NVKMS ioctls.
- Update docs/PARITY_LEDGER.md: 2,548 PORTED, 62 PARTIAL (display/GEM
  backends), 0 MISSING, 21 INTENTIONALLY_EXCLUDED across all 8 domains.
2026-12-03 10:05:34 +00:00
eb3c43c4b7 feat(modeset): port 8 core NVKMS device/surface/event/ownership ioctls
- Port NVKMS_IOCTL_REGISTER_SURFACE (16), UNREGISTER_SURFACE (17),
  GET_NEXT_EVENT (31), DECLARE_EVENT_INTEREST (32), CLEAR_UNICAST_EVENT (33),
  GRAB_OWNERSHIP (37), RELEASE_OWNERSHIP (38), and
  FRAMEBUFFER_CONSOLE_DISABLED (62) with exact 580.178.04 nvkms-api.h
  struct sizes/offsets and per-file surface/ownership tracking.
- Exclude removed 3DVision ioctls (34, 35, proc == NULL in stock 580 nvkms.c)
  and require explicit switch-case dispatch in audit_nvkms.
2026-12-03 10:02:08 +00:00
53f5e39858 rmapi/ga10x/modeset: address all 13 CodeRabbit review findings 2026-12-02 15:18:18 -08:00
a2707a4c99 ga102: Stage 1 desktop bring-up, 0x00da/0x0002 parity, 2M/64K MMU, BAR1 WC PT pool & lockless GSP queues 2026-12-02 13:52:08 -08:00
cd0bb9df8d fix(ga10x,drm,rmapi,vk): address all 15 CodeRabbit review findings on PR #266
- Enforce scope.caller.admin on 0x3f (NV01_MEMORY_LOCAL_PRIVILEGED) in gpu.rs
- Return -EOPNOTSUPP for unimplemented fence/dmabuf capability queries in nvidia_rs_drm.c
- Add per-open mutex-protected NVKMS device handle table in nvidia_rs_modeset.c validating NvKmsAllocDeviceRequest and FREE_DEVICE handles
- Require explicit VA-space handle in vas_root() and real Backing::Virtual in post_map_dma/post_unmap_dma
- Isolate per-TSG GR context-buffer VAs in a dedicated 40-bit reserved range [0x00f0_0000_0000, 0x00ff_ffff_ffff], exclude it from user VA allocations/DMA maps, and unmap + TLB-invalidate GR ctx PTEs before freeing PA on failure and tsg_release
- Guard post_map_dma/post_unmap_dma against arithmetic overflow and clamp nonzero req_size against range/mem lengths
- Share space_id across dup_space() so original and duplicated VA-space handles share a single non-overlapping virtual extent set
- Pass real KernelOs into gsp_route::post so drop_failed_alloc() frees System backing pages instead of leaking
- Harden tools/vm/vulkan_smoke.c: discover nvidia-drm node cleanly, require Vulkan 1.4, bind physical device via VK_EXT_physical_device_drm, and add TRANSFER->HOST readback barriers

Verified offline (967/967 unit tests, clippy, fmt, check_kernel_module passed with largest_stack=1000, 11/11 IBT gate) and live on RTX 3050 Mobile (GA107M) VFIO guest (2x consecutive VK_SMOKE_PASS + CUDA_COEXIST_OK, 10/10 GR0 interrupts, 0 MMU faults, clean rmmod).
2026-12-02 03:49:47 -08:00
915ed42ac0 feat(ga10x,drm,rmapi): live Vulkan 1.4 compute/transfer + DRM/NVKMS UAPI parity (#148, #172)
Brings up end-to-end Vulkan 1.4 device creation, VRAM DMA transfer, and hardware
SPIR-V compute shader execution on live GA107M (RTX 3050 Mobile) silicon alongside
stock 580.126.09 DRM/NVKMS UAPI parity and CUDA coexistence.

Key changes:
- nvidia_rs_drm: exact 580.126.09 DRM_IOCTL_NVIDIA_* command numbers/structs
  (GET_DEV_INFO 0x03, FENCE_SUPPORTED 0x04, GET_CLIENT_CAPABILITY 0x08,
  GEM_MAP_OFFSET 0x0a, DMABUF_SUPPORTED 0x0f, GET_DRM_FILE_UNIQUE_ID 0x18),
  multi-GPU display/3D PCI discovery skipping HDA audio, .name = "nvidia-drm",
  and race-free per-drm_file unique IDs.
- nvidia_rs_modeset: register /dev/nvidia-modeset compat node and handle
  NVKMS_IOCTL_IOWR ALLOC_DEVICE / FREE_DEVICE.
- RM API escapes & controls: implement NV_ESC_RM_VID_HEAP_CONTROL (0x4a),
  NV_ESC_RM_ALLOC_CONTEXT_DMA2 (0x54), NV_ESC_RM_BIND_CONTEXT_DMA (0x59),
  0x27 ALLOC_NONE (0x3f/0x70/0x40), V1 embedded-pointer nested_plan translations,
  0x102/0x204/0x301 root controls, NV_SEMAPHORE_SURFACE BIND/UNBIND_CHANNEL
  (0x00da_0002 / 0x00da_0006), NV_MEMORY_MAPPER (0x00fe), and DUP_OBJECT
  VA-space/GSP-RM mirroring.
- VOLTA_USERMODE_A (0xc361): map BAR0+0xbb_0000 on Turing-Blackwell GSP-RM
  GPUs (per 580.126.09 gpuGetRegBaseOffset_TU102) while keeping 0x81_0000 on Volta.
- GSP-RM / GA10x kernel-managed VAS & GR path: map/unmap 4 KiB GPU PTEs on
  RM_MAP/UNMAP_MEMORY_DMA (0x57/0x58), promote full GR context buffers with
  GPU VAs for kernel-managed VA spaces, support standalone CE channels under
  NV01_DEVICE_0, handle 0xc36f_010a / 0x2080_2a03 / 0x902d / 0xa140 / 0x9072 /
  0x9096 / 0x05 events.
- Add host unit tests and zero-dependency tools/vm/vulkan_smoke.c.
2026-12-02 03:14:46 -08:00
857a6044b9 kernel-open/kms: fix multi-head scanout, SOR/cursor/C9+ commits, and NVKMS/SEMSURF ABI 2026-12-01 19:59:50 -08:00
230f8f02dd rmapi/modeset: complete all 14 rm_kernel_rmapi_op opcodes and 0x78/0x7e/0x3d callbacks 2026-12-01 19:52:21 -08:00
fc49ee5f23 kernel-open: implement standalone nvidia_rs_modeset and nvidia_rs_drm KMS/DRM modules 2026-12-01 19:20:50 -08:00
33ff608a88 Add MIT LICENSE and unify repository SPDX/Cargo/module licensing
- Add root LICENSE (MIT License, Copyright (c) 2026 QuixiAI / Eric Hartford).
- Set license = "MIT" in workspace Cargo.toml and member crates (zero non-MIT dependencies).
- Update all kernel-open/ and tests/vm/ SPDX headers to MIT and EXPORT_SYMBOL_GPL -> EXPORT_SYMBOL.
- Use MODULE_LICENSE("Dual MIT/GPL") in Linux .ko modules so Linux modpost permits linking against the kernel's own EXPORT_SYMBOL_GPL symbols while keeping the repository source 100% MIT.

Closes #12.
2026-12-01 00:20:02 +00:00
0d6d2520eb Implement Round 6 580.178.04 ports (DP AUX/DPCD, GSP CrashCat decoder, ACPI NBCI mux/power, standalone nvidia_rs_modeset.ko) 2026-11-30 16:04:52 +00:00