diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 2ccdb64..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,36 +0,0 @@ -# Keep GitHub Actions pinned by commit SHA and Go modules current. -# -# Workflows pin actions to commit SHAs (see the trailing `# vN` comments); -# this keeps those pins from silently ageing out, and tracks the five Go -# modules under windows/tools/. - -version: 2 -updates: - - package-ecosystem: github-actions - directory: / - schedule: - interval: weekly - commit-message: - prefix: "ci" - groups: - actions: - patterns: ["*"] - - # All five modules form one dependency chain: the four tools resolve - # `40hxcore` through `replace ../40hxcore` and share its go.sum entries. - # Bumping one module alone leaves the others with a stale go.sum and breaks - # `go build` ("updates to go.mod needed"), so they are updated together. - - package-ecosystem: gomod - directories: - - /windows/tools/40hxcore - - /windows/tools/check40x - - /windows/tools/inst40hx - - /windows/tools/uninstall40x - - /windows/tools/winres_gen - schedule: - interval: weekly - commit-message: - prefix: "deps" - groups: - go-modules: - patterns: ["*"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2233054..f415943 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ # CI for the CMP 40HX unlock project. # -# Independent Windows/UEFI and Linux CPU-RM gates: +# Independent Windows/UEFI and Linux pre-driver gates: # # 1. go-tools — builds every Go module, vets it, and runs the unit tests # that can only execute on Windows (40hxcore imports @@ -10,31 +10,32 @@ # cross-build is also the cheapest proof that the tree is complete: # inst40hx fails to compile if any //go:embed input went missing. # -# 2. efi — rebuilds unlock40x_v70.c from source inside the pinned toolchain -# container and compares the SHA-256 against the committed -# embed/40HXUNLK.EFI. The build is byte-for-byte reproducible, so a -# mismatch means the committed payload and its source have drifted. +# 2. rust-efi-core — checks the Rust EFI against its C reference, +# compares the installer image with a fresh FULL build, and runs QEMU. # -# The CPU-RM job builds without loading a module and exercises the firmware +# The Linux pre-driver job builds without loading a module and exercises the firmware # parsers/layout offline. The open-module patch series has its separate CI. name: CI on: push: - branches: [main] + branches: [main, port/rust] paths: - 'windows/**' - - 'linux/cpu-rm/**' + - 'linux/preboot/**' - 'tools/gen2/**' - '.github/workflows/ci.yml' + - '.github/workflows/release.yml' pull_request: paths: - 'windows/**' - - 'linux/cpu-rm/**' + - 'linux/preboot/**' - 'tools/gen2/**' - '.github/workflows/ci.yml' + - '.github/workflows/release.yml' workflow_dispatch: + workflow_call: permissions: contents: read @@ -44,8 +45,70 @@ concurrency: cancel-in-progress: true jobs: - linux-cpu-rm: - name: Linux CPU-RM module and offline firmware checks + rust-efi-core: + name: Rust EFI core, carrier and QEMU boot checks + runs-on: ubuntu-latest + env: + RUST_TOOLCHAIN: '1.100.0' + defaults: + run: + working-directory: windows/efi-rust + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Install the Rust toolchain + run: rustup toolchain install "$RUST_TOOLCHAIN" --profile minimal --component rustfmt --component clippy --target x86_64-pc-windows-gnu --target x86_64-unknown-uefi + - name: Fetch locked EFI dependencies + run: cargo +"$RUST_TOOLCHAIN" fetch --locked --target x86_64-unknown-uefi + - name: Check formatting and lints + run: | + set -euo pipefail + cargo +"$RUST_TOOLCHAIN" fmt --all -- --check + cargo +"$RUST_TOOLCHAIN" clippy --locked --offline -p cmp40-efi-core --all-targets -- -D warnings + cargo +"$RUST_TOOLCHAIN" clippy --locked --offline --target x86_64-unknown-uefi -p cmp40-efi -p cmp40-efi-boot-fixture -- -D warnings + cargo +"$RUST_TOOLCHAIN" clippy --locked --offline --target x86_64-unknown-uefi -p cmp40-efi --features unlock -- -D warnings + cargo +"$RUST_TOOLCHAIN" clippy --locked --offline --target x86_64-unknown-uefi -p cmp40-efi-boot-fixture --features adapters -- -D warnings + cargo +"$RUST_TOOLCHAIN" clippy --locked --offline --target x86_64-unknown-uefi -p cmp40-efi -p cmp40-efi-boot-fixture --features gen2-experiment,adapters -- -D warnings + - name: Compare Rust boot data and firmware operations with the actual C EFI functions + run: | + set -euo pipefail + cargo +"$RUST_TOOLCHAIN" test --locked --offline -p cmp40-efi-core + python3 tests/test_assets.py + python3 -m unittest discover -s tests -p 'test_trace_log.py' -v + - name: Check the core for the Windows target + run: cargo +"$RUST_TOOLCHAIN" check --locked --offline -p cmp40-efi-core --lib --target x86_64-pc-windows-gnu + - name: Build the standard EFI and test boot targets + run: cargo +"$RUST_TOOLCHAIN" build --locked --offline --release --target x86_64-unknown-uefi -p cmp40-efi -p cmp40-efi-boot-fixture --features unlock,adapters + - name: Install QEMU and OVMF + run: sudo apt-get update && sudo apt-get install -y qemu-system-x86 ovmf + - name: Compare the embedded EFI with the Rust FULL build + env: + RUSTUP_TOOLCHAIN: ${{ env.RUST_TOOLCHAIN }} + run: | + set -euo pipefail + bash build_installer_efi.sh + python3 tests/compare_installer_efi.py target/x86_64-unknown-uefi/release/cmp40-unlock-full.efi ../tools/inst40hx/embed/40HXUNLK.EFI + - name: Boot the installer EFI and verify persisted logs and parked failure in QEMU + run: python3 tests/qemu_smoke.py --unlock --adapters --raw --rebar + - name: Check early logs and unstarted candidate images + run: python3 tests/qemu_smoke.py --case entrycheck --case entrycheck-invalid + - name: Build the Gen2 experiment and test fixtures + run: cargo +"$RUST_TOOLCHAIN" build --locked --offline --release --target x86_64-unknown-uefi --target-dir target/gen2 -p cmp40-efi -p cmp40-efi-boot-fixture --features gen2-experiment,adapters + - name: Boot the Gen2 experiment in QEMU + run: python3 tests/qemu_smoke.py --image-dir target/gen2/x86_64-unknown-uefi/release --gen2 + - name: Preserve the QEMU boot evidence + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: rust-efi-qemu-logs + path: | + windows/efi-rust/target/qemu-smoke/**/serial.log + windows/efi-rust/target/qemu-smoke/**/report.json + windows/efi-rust/target/qemu-smoke/**/summary.json + windows/efi-rust/target/qemu-smoke/**/R*.LOG + if-no-files-found: ignore + + linux-unlock: + name: Linux pre-driver module and offline firmware checks runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -56,14 +119,14 @@ jobs: set -euo pipefail kdir=$(find /lib/modules -maxdepth 2 -name build | sort | tail -n1) test -n "$kdir" - make -C linux/cpu-rm/kernel KDIR="$kdir" W=1 -j2 + make -C linux/preboot/kernel KDIR="$kdir" W=1 -j2 - name: Verify firmware preparation and parsers run: | set -euo pipefail - python3 -m unittest discover -s linux/cpu-rm/firmware -p 'test_*.py' -v - python3 linux/cpu-rm/firmware/prepare.py - make -C linux/cpu-rm offline-test - bash -n linux/cpu-rm/unlock.sh linux/cpu-rm/gen2.sh linux/cpu-rm/common.sh linux/cpu-rm/mkinitcpio/cmp40-unlock + python3 -m unittest discover -s linux/preboot/firmware -p 'test_*.py' -v + python3 linux/preboot/firmware/prepare.py + make -C linux/preboot offline-test + bash -n linux/preboot/unlock.sh linux/preboot/gen2.sh linux/preboot/common.sh linux/preboot/mkinitcpio/cmp40-unlock go-tools: name: Go tools (${{ matrix.name }}) @@ -90,6 +153,18 @@ jobs: go-version-file: windows/tools/inst40hx/go.mod cache-dependency-path: windows/tools/*/go.sum + - name: Check Go formatting + if: matrix.cross == '1' + shell: bash + working-directory: windows/tools + run: | + set -euo pipefail + unformatted=$(gofmt -l .) + if [[ -n "$unformatted" ]]; then + printf '::error::gofmt found unformatted files:\n%s\n' "$unformatted" + exit 1 + fi + - name: Build every module shell: bash working-directory: windows/tools @@ -157,94 +232,25 @@ jobs: shell: powershell run: windows/tools/test_efi_copy.ps1 + - name: Test the release package verifier + if: matrix.cross == '0' + shell: powershell + run: windows/tools/test_package_verification.ps1 + # winres_gen produces a PE resource object, so it cross-generates fine # on Linux. Kept on the Linux leg because the byte comparison uses # `cmp`, which every Linux runner has. - - name: Regenerate the Windows resource object and compare + - name: Compare Windows version resources for each Go tool if: matrix.cross == '1' shell: bash working-directory: windows/tools/winres_gen run: | set -euo pipefail - go run . "$RUNNER_TEMP/rsrc_windows_amd64.syso" - if ! cmp -s "$RUNNER_TEMP/rsrc_windows_amd64.syso" \ - ../inst40hx/rsrc_windows_amd64.syso; then - echo "::error::windows/tools/inst40hx/rsrc_windows_amd64.syso is stale — regenerate it with 'go run . ' in windows/tools/winres_gen and commit the result" - exit 1 - fi - echo "resource object matches the committed copy" - - efi: - name: EFI payload reproducibility - runs-on: ubuntu-latest - env: - # Pinned by digest. The EFI link is sensitive to the exact toolchain: - # the committed payload needs gcc 16 / binutils 2.47 / gnu-efi 4.0.4 - # and does not even build under Ubuntu's older binutils (the .rodata - # section disappears and build_v70.sh rejects the output). Pinning the - # image keeps the hash comparison meaningful; Arch is a rolling - # distribution, so when the digest is refreshed the hash below is - # expected to change too. - EFI_IMAGE: archlinux:base@sha256:f3691b4dde62ba4c4b6f0ae2c1fbf28e8c0c8c4b9a35c7e06dc1f70e21aa29f6 - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Rebuild inside the pinned toolchain container - run: | - set -euo pipefail - mkdir -p "$RUNNER_TEMP/efi-out" - docker run --rm \ - -v "$GITHUB_WORKSPACE/windows/tools:/src:ro" \ - -v "$RUNNER_TEMP/efi-out:/out" \ - -w /src \ - "$EFI_IMAGE" \ - bash -lc ' - set -euo pipefail - pacman -Sy --noconfirm --quiet gcc binutils make gnu-efi python - - # The image digest fixes the package database, not the packages: - # Arch is a rolling distribution, so `pacman -Sy` resolves to - # whatever is current. The EFI link is byte-sensitive to the - # exact gcc/binutils. Fail here, with a precise message, when - # the versions drift — otherwise the payload comparison below - # reports a misleading "source and payload have drifted". - check_pkg() { # - local actual - actual="$(pacman -Q "$1" | awk "{print \$2}")" - case "$actual" in - "$2"*|"$2") ;; - *) echo "::error::package $1 is $actual, expected $2*; re-pin EFI_EXPECTED_${1^^}_VERSION in ci.yml and regenerate windows/tools/inst40hx/embed/40HXUNLK.EFI" >&2; exit 1 ;; - esac - } - check_pkg gcc 16.2.1 - check_pkg binutils 2.47 - check_pkg make 4.4.1 - check_pkg gnu-efi 4.0.4 - - cp -r /src /build - cd /build/unlock40x - CPU_RM_CONTROL=zero EFI_OUT=/out/40HXZERO.EFI ./build_v70.sh - CPU_RM_CONTROL=full VBIOS_DUMP=0 DIRECT_WRITE_PROBE=0 PRELOAD_PROBE=0 ./build_v70.sh - cp unlock40x_v70.efi /out/ - ' - - - name: Compare with the committed embedded EFI - run: | - set -euo pipefail - built=$(sha256sum "$RUNNER_TEMP/efi-out/unlock40x_v70.efi" | cut -d' ' -f1) - committed=$(sha256sum windows/tools/inst40hx/embed/40HXUNLK.EFI | cut -d' ' -f1) - echo "rebuilt from source : $built" - echo "committed payload : $committed" - if [ "$built" != "$committed" ]; then - echo "::error::embed/40HXUNLK.EFI does not match a fresh build of tools/unlock40x/unlock40x_v70.c. Either the source changed and the payload needs re-embedding, or the pinned toolchain digest was updated and the payload needs regenerating." - exit 1 - fi - echo "EFI payload reproduces byte-for-byte" - - - name: Upload the rebuilt EFI - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: unlock40x_v70.efi - path: ${{ runner.temp }}/efi-out/unlock40x_v70.efi - if-no-files-found: error - retention-days: 14 + for module in inst40hx check40x uninstall40x winres_gen; do + generated="$RUNNER_TEMP/$module.syso" + go run . -tool "$module" "$generated" + if ! cmp -s "$generated" "../$module/rsrc_windows_amd64.syso"; then + echo "::error::$module has a stale Windows resource object" + exit 1 + fi + done diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 8d3511d..70309f7 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -13,8 +13,6 @@ # variants (normal and diagnostic where it exists), then assert # the unlock markers are present. # lint — shellcheck every shell script in the repository. -# gofmt — formatting gate for the Windows Go tree (Linux runners already -# have gofmt; the Go modules themselves are built in ci.yml). # # The kernel-module build itself is deliberately not attempted here: it needs # the target kernel's headers and is verified by install.sh on the target. @@ -26,7 +24,7 @@ on: branches: [main] paths: - 'patches/**' - - 'linux/cpu-rm/kernel/gen2_core.h' + - 'linux/preboot/kernel/gen2_core.h' - 'install.sh' - 'tools/**' - 'cmp_glcore_patch/**' @@ -34,7 +32,7 @@ on: pull_request: paths: - 'patches/**' - - 'linux/cpu-rm/kernel/gen2_core.h' + - 'linux/preboot/kernel/gen2_core.h' - 'install.sh' - 'tools/**' - 'cmp_glcore_patch/**' @@ -137,25 +135,3 @@ jobs: ) printf 'linting %d script(s)\n' "${#scripts[@]}" shellcheck -x -S warning "${scripts[@]}" - - gofmt: - name: gofmt - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 - with: - go-version-file: windows/tools/inst40hx/go.mod - - - name: Fail on unformatted Go files - working-directory: windows/tools - run: | - set -euo pipefail - unformatted="$(gofmt -l .)" - if [ -n "$unformatted" ]; then - printf '::error::gofmt found unformatted files:\n%s\n' "$unformatted" - gofmt -d . | head -200 - exit 1 - fi - echo "all Go files are gofmt-clean" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f853dd..9e421e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,15 +19,22 @@ on: - 'v*' permissions: - contents: write + contents: read concurrency: group: release-${{ github.ref }} cancel-in-progress: false jobs: + verify: + name: Verify tagged commit + uses: ./.github/workflows/ci.yml + build: name: Build release assets + needs: verify + permissions: + contents: write runs-on: windows-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -64,26 +71,21 @@ jobs: cp windows/tools/inst40hx/embed/ThrottleStop.sys "$OUT/gen2/drivers/ThrottleStop.sys" cp windows/tools/inst40hx/embed/WinRing0x64.sys "$OUT/gen2/drivers/WinRing0x64.sys" cp windows/tools/inst40hx/embed/WinRing0x64.sys "$OUT/files/WinRing0x64.sys" + cp windows/40HX_Gen2_Windows/source/WinRing0-master/LICENSE "$OUT/WinRing0-LICENSE.txt" cp windows/FORK_CHANGES.md "$OUT/FORK_CHANGES.md" cp windows/release-files/README.md "$OUT/README.md" cp windows/release-files/EFI应急修复指南.md "$OUT/" - cp windows/release-files/AI辅助安装提示词.txt "$OUT/" cp windows/release-files/make_usb_efi.bat "$OUT/" cp windows/release-files/copy_efi_verified.ps1 "$OUT/" cp windows/tools/verify_source.ps1 "$OUT/" - name: Write SHA256SUMS.txt - shell: bash - env: - OUT: ${{ github.workspace }}/windows/release - run: | - set -euo pipefail - cd "$OUT" - find . -type f ! -name SHA256SUMS.txt -print0 \ - | sort -z \ - | xargs -0 sha256sum \ - | sed 's|\./||' > SHA256SUMS.txt - cat SHA256SUMS.txt + shell: powershell + run: '& ./windows/tools/write_package_manifest.ps1 -Directory ./windows/release' + + - name: Check the package with its bundled verifier + shell: powershell + run: '& ./windows/release/verify_source.ps1' - name: Create the Windows ZIP and archive checksum shell: python @@ -122,6 +124,13 @@ jobs: Download CMP40HX-Windows-${GITHUB_REF_NAME}.zip and verify it against the attached SHA256SUMS.txt. Extract the entire ZIP before running the installer; its SHA256SUMS.txt verifies the individual package files. See FORK_CHANGES.md inside the ZIP for the changes in this fork. EOF + # An old run can be retried after a tag is moved. Check its peeled commit. + tagged_commit=$(git ls-remote --exit-code origin "$GITHUB_REF" "${GITHUB_REF}^{}" | + awk -v ref="$GITHUB_REF" '$2 == ref {direct=$1} $2 == ref "^{}" {peeled=$1} END {print (peeled ? peeled : direct)}') + if [[ "$tagged_commit" != "$(git rev-parse HEAD)" ]]; then + echo "::error::The release tag no longer points to the commit verified by CI." + exit 1 + fi gh release create "${GITHUB_REF_NAME}" \ --verify-tag \ --draft \ diff --git a/.gitignore b/.gitignore index e99ec57..21e3724 100644 --- a/.gitignore +++ b/.gitignore @@ -7,14 +7,20 @@ NVIDIA-*.tar.xz NVIDIA-kernel-module-source-*/ NVIDIA-kernel-module-source-*.tar.* artifacts/ -linux/cpu-rm/build/ -linux/cpu-rm/kernel/*.o -linux/cpu-rm/kernel/*.ko -linux/cpu-rm/kernel/*.mod -linux/cpu-rm/kernel/*.mod.c -linux/cpu-rm/kernel/.*.cmd -linux/cpu-rm/kernel/Module.symvers -linux/cpu-rm/kernel/modules.order + +# Local agent configuration and cloud credentials. +.agents/ +.codex/ +.aws/ + +linux/preboot/build/ +linux/preboot/kernel/*.o +linux/preboot/kernel/*.ko +linux/preboot/kernel/*.mod +linux/preboot/kernel/*.mod.c +linux/preboot/kernel/.*.cmd +linux/preboot/kernel/Module.symvers +linux/preboot/kernel/modules.order # Python helper bytecode. __pycache__/ @@ -43,3 +49,6 @@ windows/tools/unlock40x/*.signed.efi # proprietary libnvidia-glcore.so and is generated locally, never committed. cmp_glcore_patch/patch_glcore cmp_glcore_patch/libnvidia-glcore.so* + +# Rust EFI port build outputs. +windows/efi-rust/target/ diff --git a/LICENSE b/LICENSE index 5f79cc3..94ecc5c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2026 Cyridd +Copyright (c) 2026 CMP unlock project Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 3cb2814..0014604 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,10 @@ Hardware-research project for the NVIDIA CMP 40HX (TU106, PCI device ID `10de:1f0b`), covering both Linux and Windows. -- **Linux** — open-kernel-module patches for NVIDIA `580.173.02`, `610.57.04`, `615.71.09`, `615.78.08` and `620.70.06` (default), installed by `install.sh`; a separate [proprietary CPU-RM unlock](linux/cpu-rm/README.md) validated on `610.43.03`, `615.78.08` and `620.70.06` with GSP OFF; and an optional proprietary-userspace pipeline patch. The 620 runtime tests cover manual driver switching; startup before the first NVIDIA initialization still needs validation. +- **Linux** — open-kernel-module patches for NVIDIA `580.173.02`, `610.57.04`, `615.71.09`, `615.78.08` and `620.70.06` (default), installed by `install.sh`; a separate [pre-driver compute unlock](linux/preboot/README.md) validated on `610.43.03`, `615.78.08` and `620.70.06` with GSP OFF; and an optional proprietary-userspace pipeline patch. The 620 runtime tests cover manual driver switching; startup before the first NVIDIA initialization still needs validation. - **Windows / UEFI** ([`windows/`](windows/)) — a UEFI unlock application and Go installer/checker/uninstaller tools. See [`windows/README.md`](windows/README.md). -Choose the path matching your driver and OS. The proprietary Linux and Windows -CPU-RM paths share the published CMP40HX selector payload and small-WPR strategy. +Choose the path matching your driver and OS. The Linux pre-driver module and Windows EFI share the published CMP40HX selector payload and small-WPR strategy. ## What it unlocks @@ -16,7 +15,7 @@ CPU-RM paths share the published CMP40HX selector payload and small-WPR strategy - **Pipeline bind / MME throttle unlock** (Linux, optional) — removes the artificial delay executed on classic `vkCmdBindPipeline` paths by patching the NVIDIA userspace `libnvidia-glcore.so` emitter. None of these modifications flashes the VBIOS. Compute can be unlocked by -patched open modules, the Linux pre-driver CPU-RM module, or the Windows EFI. +patched open modules, the Linux pre-driver module, or the Windows EFI. The proprietary Linux path covers compute and an optional runtime Gen2 helper. ReBAR and the profiling patch require the open-module path on Linux. The pipeline unlock patches a local copy @@ -25,12 +24,15 @@ reapplied after a full GPU reset or power cycle. ## Results -**GSP OFF is now supported.** Proprietary Linux 615.78.08 at a verified 150 W +I tested the proprietary Linux driver and the Windows Rust EFI with GSP enabled. +Both retained compute unlock. [GSP test results](docs/results.md#gsp-enabled-on-linux-and-windows). + +With GSP disabled, proprietary Linux 615.78.08 at a verified 150 W reached FP16 WMMA `1.0440 → 66.1629 TFLOPS` and INT8 WMMA `2.0724 → 131.0379 TOPS`; a numerical WMMA check matched 163,840 outputs -with zero error. I confirmed successful Windows ZERO/FULL initialization, -FULL unlock, and the installer's GSP-OFF upgrade. See -[CPU-RM results](docs/research/CPU_RM_SMALL_WPR.md). +with zero error. Successful Windows ZERO/FULL initialization, FULL unlock, +and the installer's GSP-OFF upgrade are confirmed. See +[Small-WPR results](docs/research/CPU_RM_SMALL_WPR.md). The screenshots below describe the earlier Windows GSP-ON setup. Measured with the independent [clpeak](https://github.com/krrishnarraj/clpeak) (CUDA backend) on one Windows system, NVIDIA driver `617.14`: @@ -61,9 +63,9 @@ The full tables (including OpenCL and Vulkan), PCIe Gen2, ReBAR and pipeline mea ### Linux -For the **proprietary driver with GSP OFF**, follow -[`linux/cpu-rm/README.md`](linux/cpu-rm/README.md). Compute unlock runs before -NVIDIA loads; the optional [CPU-RM Gen2 helper](linux/cpu-rm/gen2.sh) runs after +For the **proprietary driver**, follow +[`linux/preboot/README.md`](linux/preboot/README.md). Compute unlock runs before +NVIDIA loads; the optional [runtime Gen2 helper](linux/preboot/gen2.sh) runs after native initialization and was validated with 615.78.08 and 620.70.06. The commands below are for the **open kernel modules**. @@ -90,12 +92,14 @@ other metrics and Nsight Compute still need validation. See Download the Windows ZIP from the [Releases page](https://github.com/Cyridd/cmpunlocker/releases), verify its checksum against the attached `SHA256SUMS.txt`, and extract the entire archive. Then follow [`windows/README.md`](windows/README.md) for firmware prerequisites, installation, verification and recovery. The EFI application is unsigned, so Secure Boot must be off or you must sign it yourself. +Hosting links use the `Cyridd/cmpunlocker` repository. + ## Compatibility at a glance - **Linux:** open-gpu-kernel-modules `580.173.02`, `610.57.04`, `615.71.09` (Ubuntu `nvidia-*-615-server-open`), `615.78.08` and `620.70.06` (default); 620 compute, ReBAR and CUPTI counters passed runtime tests. Other versions need porting and revalidation. Secure Boot must be disabled or the modules signed. Rebuild after a kernel update. -- **Proprietary Linux CPU-RM:** `610.43.03`, `615.78.08` and `620.70.06`, GSP OFF, 8 GiB TU106. The 620 tests confirmed compute, numerical WMMA and runtime Gen2 after driver unload. +- **Proprietary Linux, earlier GSP-OFF tests:** `610.43.03`, `615.78.08` and `620.70.06`, GSP OFF, 8 GiB TU106. The 620 tests confirmed compute, numerical WMMA and runtime Gen2 after driver unload. - **Windows:** UEFI/GPT, Above 4G Decoding on, Secure Boot and CSM off. -- **Windows GSP OFF:** the installer now recommends `EnableGpuFirmware=0`; upgrade both the EFI and installer. Gen2 no longer changes GSP. +- **Windows GSP setting:** installation preserves the driver setting by default. The GUI offers an explicit GSP-OFF option. - **PCIe Gen2 x16 is verified; Gen3 and RT-core unlocks are not implemented.** - The CMP 40HX has no display outputs; graphics use needs a headless, secondary-GPU or remote-display setup. @@ -106,7 +110,7 @@ Full list: [`docs/compatibility.md`](docs/compatibility.md). | Document | Contents | |---|---| | [`docs/linux-install.md`](docs/linux-install.md) | Linux prerequisites, installer options, verification, removal | -| [`linux/cpu-rm/README.md`](linux/cpu-rm/README.md) | Proprietary Linux driver, GSP OFF: firmware, pre-driver module, guarded handoff | +| [`linux/preboot/README.md`](linux/preboot/README.md) | Proprietary Linux driver: firmware, pre-driver module, guarded handoff | | [`windows/README.md`](windows/README.md) | Windows/UEFI guide: prerequisites, installation, Secure Boot, recovery | | [`docs/how-it-works.md`](docs/how-it-works.md) | Technical description of the four unlocks | | [`docs/results.md`](docs/results.md) | Benchmark screenshots and measured results | diff --git a/ROADMAP.md b/ROADMAP.md index fd93379..61150d0 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,11 +1,14 @@ # Roadmap -The former items 1 and 2 are completed for the tested CMP40HX CPU-RM paths: +The former items 1 and 2 are completed for the tested proprietary Linux and Windows paths. | Completed direction | Result | | --- | --- | -| 1. Proprietary Linux driver | Pre-driver compute unlock with GSP OFF; native 610.43.03 and 615.78.08 initialization and CUDA workloads pass. [Guide](linux/cpu-rm/README.md). Resolves the proprietary-driver feature requested in [issue #8](https://github.com/Cyridd/cmpunlocker/issues/8). | -| 2. Windows without GSP | ZERO/FULL 960 KiB EFI initialization and FULL unlock tested by me. Installer installation and GSP-OFF upgrade also pass; Gen2 leaves GSP OFF. [Report](docs/research/CPU_RM_SMALL_WPR.md). | +| 1. Proprietary Linux driver | Pre-driver compute unlock with GSP OFF; native 610.43.03 and 615.78.08 initialization and CUDA workloads pass. [Guide](linux/preboot/README.md). Resolves the proprietary-driver feature requested in [issue #8](https://github.com/Cyridd/cmpunlocker/issues/8). | +| 2. Windows without GSP | ZERO/FULL 960 KiB EFI initialization and FULL unlock tested on hardware. Installer installation and GSP-OFF upgrade also pass; Gen2 preserves the configured GSP setting. [Report](docs/research/CPU_RM_SMALL_WPR.md). | + +Later [GSP-enabled tests](docs/results.md#gsp-enabled-on-linux-and-windows) +also confirmed compute unlock with the Linux module and the Windows Rust EFI. GRID/vGPU was part of the original Linux request but has not been independently validated. [A community report on GRID 19.6 / 580.178.05](docs/research/GRID_CPU_RM_REPORT.md) diff --git a/docs/compatibility.md b/docs/compatibility.md index 04e9164..675955e 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -2,14 +2,14 @@ ## Linux -The Gen2 engine updated on 2026-11-08 is shared by CPU-RM 0.17.0 and all four +The Gen2 engine updated on 2026-11-08 is shared by pre-driver module 0.17.0 and all four open patch sets. Hardware validation passed. The Gen2 measurements below were taken with the earlier implementation. See [the Gen2 report](research/CPU_RM_PCIE_GEN2.md#shared-gen2-engine-0170). -- **Proprietary CPU-RM compute unlock:** native initialization and CUDA +- **Proprietary pre-driver compute unlock:** native initialization and CUDA throughput validated on `610.43.03`, `615.78.08` and `620.70.06` with GSP OFF, on an - 8 GiB CMP40HX/TU106. Use [the separate guide](../linux/cpu-rm/README.md). + 8 GiB CMP40HX/TU106. A subsequent [GSP-enabled test](results.md#gsp-enabled-on-linux-and-windows) also retained compute unlock. Use [the separate guide](../linux/preboot/README.md). For `620.70.06`, the module build/offline checks and manual native initialization, numerical WMMA and runtime Gen2 tests passed on `7.3.3-1-cachyos`. A separate @@ -85,10 +85,8 @@ sudo ./install.sh --no-download **Secure Boot** and **CSM** disabled — the EFI application is unsigned. - The unlock is volatile and is reapplied at every boot by the EFI entry. POST, FLR, a driver reset, or a power cycle clears it. -- The current small-WPR EFI supports **GSP OFF / CPU-RM**. The installer - explicitly writes `EnableGpuFirmware=0`, replaces old login-task targets, - and recommends upgrading the EFI first. I tested ZERO/FULL initialization, - FULL unlock, and the installer's GSP-OFF upgrade; results are recorded in +- The Windows Rust EFI also passed the [GSP-enabled test](results.md#gsp-enabled-on-linux-and-windows). The Go installer preserves the GSP setting by default. Its optional **Disable GSP** action writes `EnableGpuFirmware=0` after checking the deployed EFI. ZERO/FULL initialization, FULL + unlock, and the installer's GSP-OFF upgrade were tested; results are recorded in [the report](research/CPU_RM_SMALL_WPR.md); the exact final Windows driver version was not recorded. - Earlier GSP-ON measurements reported about 8024 MB CUDA VRAM instead of diff --git a/docs/file-structure.md b/docs/file-structure.md index 10c775f..e5d18df 100644 --- a/docs/file-structure.md +++ b/docs/file-structure.md @@ -28,9 +28,9 @@ ## Windows / UEFI (`windows/`) -The separate proprietary Linux path is [`linux/cpu-rm/`](../linux/cpu-rm/README.md): +The separate proprietary Linux path is [`linux/preboot/`](../linux/preboot/README.md): `kernel/` contains the pre-driver module, `firmware/` prepares pinned assets, -`unlock.sh` checks completion before loading CPU-RM, and `test_offline.c` +`unlock.sh` checks completion before loading NVIDIA, and `test_offline.c` checks the firmware parsers and WPR layout. `build/` and compiled modules are local outputs and are not committed. @@ -38,13 +38,15 @@ local outputs and are not committed. |---|---| | `windows/README.md` | Windows user guide: prerequisites, installation, verification, recovery | | `windows/FORK_CHANGES.md` | Fork-specific changes, the boot-manager handoff, and research boundaries | -| `windows/tools/unlock40x/` | UEFI unlock application source, firmware blobs, and `build_v70.sh` | +| `windows/tools/unlock40x/` | Old C EFI implementation, its build script, and the firmware blobs used by Rust | +| `windows/efi-rust/` | Current EFI implementation, including the installer’s Rust FULL image, the ZERO control and QEMU tests | +| `docs/research/RUST_EFI_PORT.md` | Rust port baseline, completed stage and remaining validation | | `windows/tools/inst40hx/` | Installer GUI/CLI (`40HXInstaller.exe`) and its embedded EFI/drivers | | `windows/tools/check40x/` | Status and diagnostic utility (`40HXCheck.exe`) | | `windows/tools/uninstall40x/` | Component-level uninstaller (`40HXUninstaller.exe`) | | `windows/tools/40hxcore/` | Shared Windows operations and Gen2 link logic | | `windows/tools/build_release.bat` | Packages a release with a SHA-256 manifest | -| `windows/tools/verify_source.ps1` | Verifies expected source inputs and prints EFI hashes | +| `windows/tools/verify_source.ps1` | Checks source inputs in a checkout or verifies the SHA-256 manifest in a package | | `windows/release-files/` | Recovery guide, FAT32 USB helper, and other packaged documents | | `windows/40HX_Gen2_Windows/` | Legacy standalone Gen2 scripts, helper drivers, and WinRing0 source | diff --git a/docs/how-it-works.md b/docs/how-it-works.md index 9dc2255..66400ea 100644 --- a/docs/how-it-works.md +++ b/docs/how-it-works.md @@ -46,17 +46,16 @@ Expected driver log: `CMP40_COMPUTE_UNLOCK_V525: ... SS0=0x88888888 SS1=0x00000008 FECS_PLM=0xffffff8f` -### Proprietary CPU-RM with GSP OFF +### Pre-driver compute unlock -The independent [`linux/cpu-rm/`](../linux/cpu-rm/README.md) module runs the +The independent [`linux/preboot/`](../linux/preboot/README.md) module runs the signed 610.43.03 Booter and the same published stock-relock selector payload before the proprietary driver probes the GPU. A 1 MiB temporary WPR heap moves WPR start to `0x1fe000000`, above the observed native CPU-RM ACR code PA `0x1fdf97000`. After firmware completion, it verifies the selectors, stock FECS permissions and WPR teardown, clears stopped SEC2 DMEM and restores -staging state. The native proprietary driver then initializes with -`NVreg_EnableGpuFirmware=0`. This transaction does not run GSP-RM or patch -the installed proprietary driver. Firmware hashes and the exact 8 GiB layout +staging state. The proprietary driver then initializes with its configured GSP policy. The +pre-driver transaction finishes before the driver chooses its runtime mode. Firmware hashes and the exact 8 GiB layout are checked before the privileged load. The Windows EFI uses the same placement strategy with a **960 KiB** heap: @@ -92,7 +91,7 @@ LnkCtl2: Target Link Speed: 5GT/s This is a genuine PCIe Gen2 x16 link, not just a spoofed capability value. -The normal sequence is verified on the maintainer's AMD root port. On Intel +The normal sequence is verified on the tested AMD root port. On Intel Alder Lake, a manual Link Disable experiment can train the physical link to Gen2 x16 but can also leave `nvidia-smi` unable to access the GPU; that platform-specific experiment is intentionally excluded from the kernel patch. diff --git a/docs/licensing.md b/docs/licensing.md index 4df4b65..9807c14 100644 --- a/docs/licensing.md +++ b/docs/licensing.md @@ -6,11 +6,11 @@ their original terms. ## Linux -- Proprietary CPU-RM pre-driver module and firmware tooling in `linux/cpu-rm/` +- Linux pre-driver module and firmware tooling in `linux/preboot/` — derived from [nlzy/turing-unlock](https://github.com/nlzy/turing-unlock) commit `417f333263ff169e8f449c931b70db9dfd7b8ef4`, GPL-2.0-only, with CMP40HX-specific changes. License copies are in - [`linux/cpu-rm/licenses/`](../linux/cpu-rm/licenses/). + [`linux/preboot/licenses/`](../linux/preboot/licenses/). The shared published selector payload is MIT. Extracted NVIDIA generated source assets retain NVIDIA's MIT terms; the binary GSP firmware retains its own license notice, extracted into the prepared assets directory. @@ -28,6 +28,12 @@ their original terms. ## Windows / UEFI (`windows/`) +- The independently implemented Rust sources under `windows/efi-rust/` are MIT, + under this repository's `LICENSE`. It contains no NVIDIA firmware and no + imported code from `nv-uefi-unlocker`. The EFI carrier depends on uefi-rs + (MIT OR Apache-2.0) and the dependencies pinned in its Cargo.lock. Host tests + compile selected functions from the existing C EFI as a reference; this does not relicense + the inherited C code or third-party inputs listed below. - The tree is a fork of [`PZH1gdmu/CMP40HX-Unlock`](https://github.com/PZH1gdmu/CMP40HX-Unlock), which builds on [`WildFlash1st/cmp90hx-unlock-for-windows`](https://github.com/WildFlash1st/cmp90hx-unlock-for-windows). Upstream terms apply to the inherited code; see [`windows/FORK_CHANGES.md`](../windows/FORK_CHANGES.md) diff --git a/docs/linux-install.md b/docs/linux-install.md index ea7b4c2..f9b0618 100644 --- a/docs/linux-install.md +++ b/docs/linux-install.md @@ -9,15 +9,15 @@ The earlier 620.70.06 patch series passed build/offline checks and manual runtime tests for compute, Gen2 x16, 8 GiB BAR1 and a CUPTI hardware counter. The Gen2 engine updated on 2026-11-08 passed hardware validation. Its [shared implementation](research/CPU_RM_PCIE_GEN2.md#shared-gen2-engine-0170) -is used by all four open patch sets and CPU-RM. +is used by all four open patch sets and the pre-driver module. The first normal Gen2 pass failed in that session; subsequent initializations passed. Automatic cold-boot startup remains unverified. See [the Booter report](research/615_BOOTER_COMPATIBILITY.md). For the Windows/UEFI procedure, see [`windows/README.md`](../windows/README.md) instead. -For the **proprietary Linux driver with GSP disabled**, use the separate -[`linux/cpu-rm/README.md`](../linux/cpu-rm/README.md). That pre-driver module +For the **proprietary Linux driver**, use the separate +[`linux/preboot/README.md`](../linux/preboot/README.md). That pre-driver module is validated with 610.43.03, 615.78.08 and 620.70.06 and does not patch NVIDIA's driver. The 620 tests confirmed native initialization, compute and runtime Gen2 after driver unload. A later cold-boot control confirmed the mkinitcpio @@ -39,8 +39,7 @@ On Ubuntu, the `nvidia-*-615-server-open` packages ship `615.71.09`. The distribution's NVIDIA installation must provide a compatible open kernel module stack; this project does not install the NVIDIA driver or firmware. -The open modules require GSP ON. When switching from the CPU-RM path, remove -the `NVreg_EnableGpuFirmware=0` override from modprobe configuration or the +The open modules require GSP ON. When switching from the pre-driver module, remove any `NVreg_EnableGpuFirmware=0` override from modprobe configuration or the kernel command line and disable the `cmp40-unlock` initramfs hook before installation. `install.sh` rebuilds the initramfs but does not change those settings. Confirm GSP firmware 620.70.06 after boot when selecting that release. diff --git a/docs/research/CMP40_NVIDIA_PATCHER_PIPELINE_CORRELATION.md b/docs/research/CMP40_NVIDIA_PATCHER_PIPELINE_CORRELATION.md index 685e478..2c8c924 100644 --- a/docs/research/CMP40_NVIDIA_PATCHER_PIPELINE_CORRELATION.md +++ b/docs/research/CMP40_NVIDIA_PATCHER_PIPELINE_CORRELATION.md @@ -343,9 +343,9 @@ remained loaded at that point. ### Stock/restored kernel comparison -Verified on 2026-11-14: I ran the temporary kernel comparison from KDE on the -integrated GPU. I closed the application using NVIDIA and stopped -`nvidia-persistenced`; KDE remained running. A TTY and display-manager stop +Verified on 2026-11-14: the temporary kernel comparison ran from KDE on the +integrated GPU. The application using NVIDIA was closed and +`nvidia-persistenced` was stopped; KDE remained running. A TTY and display-manager stop were unnecessary in this setup. Normal module unloading succeeded after the NVIDIA clients released their device handles. @@ -482,8 +482,8 @@ python3 tools/devid/probe_selector.py "$pci_selector_device" ### Measured alternate identity -Verified on 2026-11-14: I unloaded NVIDIA, held runtime PM active, ran both -selector cases and restored the original `auto` policy after the experiment. +Verified on 2026-11-14: NVIDIA was unloaded, runtime PM was held active, both +selector cases ran and the original `auto` policy was restored afterward. The commands were run from the repository root; the external device-directory value is redacted: @@ -554,7 +554,7 @@ Vulkan. Reset/resume remains untested. ### Native initialization and policy under 1f4b -Verified on 2026-11-14: I followed the two-terminal protocol with the +Verified on 2026-11-14: the two-terminal protocol was followed with the prepared stock `nvidia.ko`, GSP OFF, and the selector held at value one. Inspection of the six saved outputs confirmed: @@ -602,8 +602,8 @@ Before manual recovery, a read-only inspection found NVIDIA bound again with selector one still enabled and physical identity `1f4b`. The failed hold record was preserved. Separate recovery successfully reasserted runtime PM, restored CYA3 `0987e0ed` and all three identities to -`1f0b10de`, and preserved unrelated fields. I restored the `auto` power -policy, reloaded NVIDIA with GSP OFF and checked the original ID in +`1f0b10de`, and preserved unrelated fields. The `auto` power policy was +restored, NVIDIA was reloaded with GSP OFF and the original ID was checked in `nvidia-smi -q`. The post-reload result was reported directly; no saved NVML output was supplied for that check. @@ -701,7 +701,7 @@ when the selector or identity cannot be restored and confirmed. ### Stock Linux A1/B/A2 results -Verified on 2026-11-14: I completed the sequence with stock proprietary +Verified on 2026-11-14: the sequence completed with stock proprietary 620.70.06 and stock glcore, GSP OFF. A1 and A2 used physical `1f0b`; B used physical `1f4b` while the Linux PCI cache stayed `1f0b`. Inspection of the saved runs confirmed identical recorded sources, executables, workload diff --git a/docs/research/CPU_RM_PCIE_GEN2.md b/docs/research/CPU_RM_PCIE_GEN2.md index 4093bb0..68b6f16 100644 --- a/docs/research/CPU_RM_PCIE_GEN2.md +++ b/docs/research/CPU_RM_PCIE_GEN2.md @@ -1,6 +1,6 @@ # CMP40HX PCIe Gen2 with proprietary Linux CPU-RM -On 2026-11-01 I tested a pre-driver Gen2 setup followed by the unmodified +On 2026-11-01, a pre-driver Gen2 setup was tested with the unmodified proprietary NVIDIA 615.78.08 driver with GSP disabled. Preparing and training the link before NVIDIA worked, but native initialization changed the GPU-side policy and returned the link to Gen1. A normal post-driver retrain alone failed. @@ -14,11 +14,11 @@ and the post-driver helper alone exposed and trained Gen2 x16. ## Shared Gen2 engine (0.17.0) **Verified by source inspection:** the Gen2 update on 2026-11-08 uses one implementation in -[`gen2_core.h`](../../linux/cpu-rm/kernel/gen2_core.h) for CPU-RM and all four +[`gen2_core.h`](../../linux/preboot/kernel/gen2_core.h) for the pre-driver module and all four open-driver patch sets. The hardware measurements elsewhere in this report used the previous implementation. -**Verified:** I tested 0.17.0 on hardware and confirmed successful operation. +**Verified:** 0.17.0 was tested on hardware; successful operation is confirmed. The policy follows the current [CMP50HX source](https://github.com/xrip/cmp50hx-unlock/tree/b630a493b7877fbd4472113dcb960a93749c0a78) @@ -44,7 +44,7 @@ OVR 0x8872c = 6 # last, only if live Gen2 capability is absent BOOT0, full compute selectors and every register to be written must be readable before the first policy write. XP3G registers are written only when their PLM is `ffffffff` and their values are valid. Other PLM values retain -the previous CMP40 subset. The optional CPU-RM `windows` policy still uses +the previous CMP40 subset. The optional pre-driver `windows` policy still uses full MISC/CYA constants. A failed write/readback stops the sequence before retraining; partial policy remains visible for diagnosis. @@ -59,7 +59,7 @@ A retained Gen2 capability no longer skips policy restoration. Actual speed is checked separately. Retraining uses only the upstream port's RL bit; CCC, ASPM, HASD/HAWD, CFG bit 22 and the other unmasked fields are preserved. The update does not write `0x88610`, XP3G VAL3/OVR3, PL bits 16/20, or the -endpoint's RL bit. My repeated `0x88610` tests on CMP40HX, including `0x1001`, +endpoint's RL bit. Repeated `0x88610` tests on CMP40HX, including `0x1001`, produced no Gen2 improvement. This register is a Gen3 control. The open adapter calls the engine after the successful stock-Booter guard, @@ -73,9 +73,9 @@ A healthy early Gen1 timeout preserves TLS=2 for the later stages. It does not mean the early retrain succeeded. GSP-ready performs policy restoration only; the post-init stage performs ordinary retraining. -CPU-RM retains `gen2=off` by default. Its pre-driver `prepare`, `targets` and -`retrain` controls run after compute cleanup. The explicit runtime helper -still requires an idle native proprietary driver with GSP halted. The late +The pre-driver module retains `gen2=off` by default. Its pre-driver `prepare`, `targets` and +`retrain` controls run after compute cleanup. The runtime helper checks that the proprietary driver is responding. The +module checks the GSP halt register before retraining. The late engine allows two retrain requests, each with a two-second observation window. It retries only on a healthy Gen1 link with unchanged width and live Gen2 capability, restoring policy without another `0x8872c` write first. @@ -103,11 +103,11 @@ both declarations, along with compute, ReBAR and optional profiling patches. with Python 3.14.9 and Clang/LLD 23.1.4: ```bash -make -C linux/cpu-rm offline-test -python3 -m unittest discover -s linux/cpu-rm/firmware -p 'test_*.py' -make -C linux/cpu-rm/kernel KDIR=/usr/lib/modules/7.3.3-1-cachyos/build LLVM=1 -bash -n linux/cpu-rm/unlock.sh tools/check-linux-patches.sh -shellcheck -x -S warning linux/cpu-rm/unlock.sh tools/check-linux-patches.sh +make -C linux/preboot offline-test +python3 -m unittest discover -s linux/preboot/firmware -p 'test_*.py' +make -C linux/preboot/kernel KDIR=/usr/lib/modules/7.3.3-1-cachyos/build LLVM=1 +bash -n linux/preboot/unlock.sh tools/check-linux-patches.sh +shellcheck -x -S warning linux/preboot/unlock.sh tools/check-linux-patches.sh ``` All exited 0. The offline suite passed 44 production-code PCI/MMIO fault @@ -152,7 +152,7 @@ that each embedded core and adapter matched the canonical files. The recorded build inputs matched the final `gen2_core.h`. `git diff --check` also passed. -**Verified limitation:** a full CPU-RM LTS build exited 2 at the existing +**Verified limitation:** a full pre-driver module LTS build exited 2 at the existing `timeline.c:35` sysfs callback: these headers require `struct bin_attribute *`, while the current callback takes `const struct bin_attribute *`. The separate final `gen2.o` build passed with: @@ -259,7 +259,7 @@ actual transfers for acceptance, without modifying Linux's PCI cache. ## Cold control with runtime-only Gen2 -I repeated the test after a full cold power-off with `gen2=off` during compute +The test was repeated after a full cold power-off with `gen2=off` during compute unlock. Both the post-unlock and post-NVIDIA PCI snapshots still reported `CAP2=00000002`, Gen1 x16, GPU TLS=1. Before the runtime helper, the GPU-side state was: @@ -269,7 +269,7 @@ OVR=00000000 CFG=800c5800 PL=00120036 MISC=e0b40500 CYA=068731b3 CAP=00453d01 CAP2=00000002 CTL2=00000001 ``` -The public `linux/cpu-rm/gen2.sh` helper, using module 0.16.0, applied the masked +The public `linux/preboot/gen2.sh` helper, using module 0.16.0, applied the masked policy after native initialization. Its register writes were all logged under the NVIDIA-owned device; no Gen2 writes preceded native initialization. The result was: @@ -305,8 +305,8 @@ Gen2 writes preceded native initialization. NVIDIA DRM and modeset were unloaded and `fuser` found no clients before running: ```bash -sudo bash linux/cpu-rm/gen2.sh --gpu \ - --module linux/cpu-rm/kernel/cmp40_preboot.ko +sudo bash linux/preboot/gen2.sh --gpu \ + --module linux/preboot/kernel/cmp40_preboot.ko ``` The helper exited 0 with `GEN2_RUNTIME_RESULT error=0 device_ok=1 @@ -358,9 +358,9 @@ to it. The public helper ran once, with its existing client checks and NVML monitor, using this command from the repository root: ```bash -bash linux/cpu-rm/gen2.sh \ +bash linux/preboot/gen2.sh \ --gpu \ - --module linux/cpu-rm/kernel/cmp40_preboot.ko + --module linux/preboot/kernel/cmp40_preboot.ko ``` It ran as root and exited 0 with `GEN2_RUNTIME_RESULT error=0 device_ok=1 @@ -418,8 +418,8 @@ The explicit runtime mode is `mode=gen2_runtime gen2=retrain`. It does not execute firmware, allocate firmware DMA, detach NVIDIA, change PCI enable counts or perform a reset. In addition to exact CMP40HX identity and an active link, it requires the NVIDIA driver, full selectors and halted GSP. -The [CPU-RM helper](../../linux/cpu-rm/gen2.sh) verifies proprietary GSP OFF, -native health and absence of open GPU clients, then temporarily holds an +The [runtime helper](../../linux/preboot/gen2.sh) checks driver health and +the absence of open GPU clients before retraining, then temporarily holds an NVML client while the module reapplies the masked policy and retrains. The existing driver-reprobe helper remains specific to the patched open @@ -470,9 +470,9 @@ cold boots with the same driver and workload: Collect OVR, CFG, PL, MISC, CYA and live endpoint/upstream capabilities before and after each boundary, then verify native health, full selectors and DMA bandwidth. Keep Link Disable out of these comparisons. The two community -reports use open/GSP drivers; switching them to proprietary CPU-RM is itself +reports use open/GSP drivers; switching them to the proprietary driver is itself a driver-path change and cannot isolate the effect of earlier preparation -in the open driver. The CPU-RM runtime helper requires GSP OFF. +in the open driver. ## VFIO passthrough: host retrain in issue #20 diff --git a/docs/research/CPU_RM_SMALL_WPR.md b/docs/research/CPU_RM_SMALL_WPR.md index fb4e849..6670ba9 100644 --- a/docs/research/CPU_RM_SMALL_WPR.md +++ b/docs/research/CPU_RM_SMALL_WPR.md @@ -1,27 +1,29 @@ -# CMP 40HX CPU-RM unlock with a small Booter WPR heap +# CMP 40HX compute unlock with a small Booter WPR heap On 2026-10-31, proprietary Linux **610.43.03 and 615.78.08** initialized and -completed CUDA workloads with the full unlock and GSP disabled. I then -confirmed that the Windows **ZERO and FULL 960 KiB EFI variants both +completed CUDA workloads with the full unlock and GSP disabled. Subsequent +tests confirmed that the Windows **ZERO and FULL 960 KiB EFI variants both initialize successfully**, and that FULL retains the unlock in multiple tests. The exact Windows driver version for those tests was not recorded. Earlier Windows failures on 617.14 are historical controls, not a claim that the new build was tested on every Windows release. -The repository now ships the FULL Windows path and a separate Linux -[pre-driver CPU-RM module](../../linux/cpu-rm/README.md). Windows keeps the +The repository now ships the FULL Windows path and a separate +[Linux pre-driver module](../../linux/preboot/README.md). Windows keeps the current repository's ReBAR, signed-image installation and return-to-bootloader -features. I also tested the integrated installer and reproduced an upgrade: -after I deliberately set `EnableGpuFirmware=1`, **Disable GSP** changed it +features. Integrated installer tests also reproduced an upgrade: +after deliberately setting `EnableGpuFirmware=1`, **Disable GSP** changed it to `0`, and the Gen2 task left it at `0`. +A later [GSP-enabled test](../results.md#gsp-enabled-on-linux-and-windows) covered the Linux pre-driver module and the Windows Rust EFI. + ## NVIDIA 620.70.06 follow-up Verified on 2026-11-08: the same 610.43.03 firmware and 1 MiB heap worked with proprietary NVIDIA 620.70.06, GSP OFF, on `7.3.3-1-cachyos`. The module was -built with `make -C linux/cpu-rm/kernel LLVM=1 W=1 -j8` using Clang/LLD +built with `make -C linux/preboot/kernel LLVM=1 W=1 -j8` using Clang/LLD `23.1.4`. Firmware preparation with `--offline`, the firmware unit tests and -`make -C linux/cpu-rm offline-test ROM=` +`make -C linux/preboot offline-test ROM=` passed. The offline run included 24 Gen2 fault cases and six helper cases. The ROM path and PCI address in these commands are redacted. The hardware @@ -29,7 +31,7 @@ sequence was stock native initialization and a locked benchmark, driver unload, then: ```bash -sudo insmod linux/cpu-rm/kernel/cmp40_preboot.ko \ +sudo insmod linux/preboot/kernel/cmp40_preboot.ko \ target= mode=unlock cpu_rm_handoff=1 stock_handoff=1 \ small_wpr_heap=1 gen2=off ``` @@ -45,7 +47,7 @@ clpeak 2.0.19 used CUDA toolkit 13.2 and reported driver API 13.5. Both runs held an NVML client open, verified 150 W before and after the workload, and restored the previous 184 W limit: -| Measurement | Stock | CPU-RM unlock | +| Measurement | Stock | Unlocked (GSP OFF) | |---|---:|---:| | FP16 WMMA, TFLOPS | 1.05 | 66.77 | | INT8 WMMA, TOPS | 2.08 | 132.08 | @@ -140,8 +142,8 @@ establish successful initialization. ## Reproduction and provenance - Linux firmware hashes and sizes are pinned in - [`artifacts-610.43.03.json`](../../linux/cpu-rm/firmware/artifacts-610.43.03.json) - and [`asset_hashes.h`](../../linux/cpu-rm/kernel/asset_hashes.h). + [`artifacts-610.43.03.json`](../../linux/preboot/firmware/artifacts-610.43.03.json) + and [`asset_hashes.h`](../../linux/preboot/kernel/asset_hashes.h). - FULL payload SHA-256: `de7288bcfb80c2d4b259a59e823c926ba0a9adcab594219cc6802c94257ce271`. - ZERO payload SHA-256: @@ -149,7 +151,7 @@ establish successful initialization. - Earlier Windows controls are curated in [WINDOWS_CPU_RM_HISTORY.md](WINDOWS_CPU_RM_HISTORY.md). -Use the [Linux guide](../../linux/cpu-rm/README.md) or +Use the [Linux guide](../../linux/preboot/README.md) or [Windows guide](../../windows/README.md). The small heap is for this pre-driver transaction; running GSP-RM with it is not validated. Other boards/models, long-duration stability, reset recovery and suspend/resume @@ -175,4 +177,4 @@ The Linux module builds with LLVM and `W=1` against `7.2.9-2-cachyos` headers. Firmware preparation from cached pinned archives, selector-control tests, offline Booter/GSP/layout/malformed-input tests and the saved board-ROM FWSEC parser checks pass. These build/offline checks complement the native Linux -workloads and my Windows installation and upgrade tests described above. +workloads and the Windows installation and upgrade tests described above. diff --git a/docs/research/GRID_CPU_RM_REPORT.md b/docs/research/GRID_CPU_RM_REPORT.md index 0082cd2..7ede2b4 100644 --- a/docs/research/GRID_CPU_RM_REPORT.md +++ b/docs/research/GRID_CPU_RM_REPORT.md @@ -95,11 +95,10 @@ Two issues were independent of the unlock payload: GSP OFF are verified. 2. This GRID build has no `/sys/module/nvidia/parameters` directory. Its actual setting is `EnableGpuFirmware: 0` in `/proc/driver/nvidia/params`, - with `GSP Firmware Version: N/A` in NVIDIA-SMI. Both CPU-RM helpers now - accept the sysfs or /proc representation. An explicitly enabled setting - is still rejected. + with `GSP Firmware Version: N/A` in NVIDIA-SMI. The runtime Gen2 helper now checks whether the driver responds to + `nvidia-smi`, regardless of where GRID exposes its firmware setting. -The [CPU-RM guide](../../linux/cpu-rm/README.md) includes this ordering. +The [pre-driver guide](../../linux/preboot/README.md) includes this ordering. ## Gen2 observations @@ -249,7 +248,7 @@ capability or CFG differences. A successful native test would still leave ### First cold boot: pre-driver power check **Verified:** the first cold boot reached the test console on 2026-11-08. -I reported a cold start and a refusal from the native-test guard. Inspection +A cold start and a refusal from the native-test guard were reported. Inspection of the snapshot's persistent journal found: ```text @@ -306,9 +305,9 @@ failed, without removing the guard, retrying unlock or loading a GPU module. ### Second cold boot: native GRID initialization **Verified:** the second cold boot passed the revised pre-driver check, -compute-unlock completion and native GRID initialization. I confirmed that -the PSU was disconnected for about 30 seconds before this boot and ran the -native-test harness. The recorded commands +compute-unlock completion and native GRID initialization. PSU disconnection +for about 30 seconds before this boot and a native-test harness run are +confirmed. The recorded commands `modprobe --ignore-install nvidia NVreg_EnableGpuFirmware=0` and `/usr/bin/nvidia-smi -q` both exited `0`. @@ -374,21 +373,21 @@ before workloads or vGPU startup and refused a second attempt in the same boot. **Verified:** local tests passed seven native-record cases, ten link-result cases and rejection outside the test boot. -`bash -n linux/cpu-rm/gen2.sh linux/cpu-rm/common.sh` exited `0`. Installed +`bash -n linux/preboot/gen2.sh linux/preboot/common.sh` exited `0`. Installed file hashes matched; the helper scripts, test initramfs and ordinary boot images were unchanged. The third boot exercised the hardware sequence. ### Third cold boot: native GRID Gen2 **Verified, 2026-11-08:** the third cold boot reached Gen2 x16 with the same -GRID 580.178.05 and LTS kernel. I confirmed disconnecting the PSU for about -30 seconds before this boot and ran the Gen2 harness. It completed native +GRID 580.178.05 and LTS kernel. PSU disconnection for about 30 seconds before +this boot and a Gen2 harness run are confirmed. It completed native initialization, removed the completed unlock module and invoked the public helper once. The installed helper/module paths and PCI address are redacted below; the helper path is shown relative to the repository: ```bash -bash linux/cpu-rm/gen2.sh --gpu \ +bash linux/preboot/gen2.sh --gpu \ --module ``` @@ -456,9 +455,9 @@ version, so the Linux v1 accessor boundary does not apply there. There is a separate register difference in `src/core_40hx.c:write_full_set()`: the compute stage writes BAR0 `0x88610 = 0x1001` before SBR. Its source -comment describes matching an RTX 2070 value. **Verified by my prior tests:** -I repeatedly tested this Gen3-enabling register, including `0x1001`, without -an effect on CMP40HX. I confirmed these prior results on 2026-11-08; their +comment describes matching an RTX 2070 value. **Verified by prior tests:** +Repeated tests of this Gen3-enabling register, including `0x1001`, had no +effect on CMP40HX. These prior results were confirmed on 2026-11-08; their raw logs were not reviewed in this session. The current collector does sample `0x88610` under the name `HIER`: it was `00000001` before and after the successful GRID Gen2 run. This corrects the @@ -470,7 +469,7 @@ HASD on both ends, clears ASPM, and first clears CCC on both ends. It sets upstream HAWD and Retrain Link, clears bandwidth-status flags, and polls both link speeds. On failure, its second round uses the upstream's original CCC bit on both ends. If that bit was already zero, both rounds use zero. -The current CPU-RM helper waits 50 ms after policy and preserves CCC, ASPM, +The current runtime Gen2 helper waits 50 ms after policy and preserves CCC, ASPM, HASD and HAWD while setting TLS and requesting ordinary Retrain Link. The external repository reports an Intel Xeon E7 v4 IIO / C224 platform, @@ -545,7 +544,7 @@ The late policy restoration has a local precedent: the 615.78.08 CPU-RM test retained Gen2 capability through native initialization, but lost the working MISC/CFG/PL settings and actual Gen2 speed. Restoring the policy then retraining succeeded; see [the ordered result](CPU_RM_PCIE_GEN2.md#ordered-hardware-result). -The current CPU-RM helper already reapplies policy when the link is Gen1, +The current runtime Gen2 helper already reapplies policy when the link is Gen1, even if CAP2 or TLS advertises Gen2. ### Issue #51: hybrid code and a second initialization @@ -653,11 +652,11 @@ hypotheses concern the affected CMP40HX host. - Independently reproduce the guest measurements with paired stock/FULL and numerical controls, then exercise guest/manager lifecycle transitions. -CPU-RM 0.17.0 and the refreshed open patches now use a +Pre-driver module 0.17.0 and the refreshed open patches now use a [shared Gen2 engine](CPU_RM_PCIE_GEN2.md#shared-gen2-engine-0170). It reads live capability independently of Linux's cached version, permits policy application from live v1, and requires live v2 before TLS writes. It adds -`gen2=targets` for the early TLS comparison. I tested the new engine on -hardware and confirmed successful operation. +`gen2=targets` for the early TLS comparison. The new engine was tested on +hardware; successful operation is confirmed. Kernel PCI caches, CFG bit 22 and Link Disable remain unchanged. See [the B550 Gen2 report](CPU_RM_PCIE_GEN2.md) and [Link Disable audit](PCIE_LINK_DISABLE_AUDIT.md) for the tested boundaries. diff --git a/docs/research/PCIE_LINK_DISABLE_AUDIT.md b/docs/research/PCIE_LINK_DISABLE_AUDIT.md index f4da185..60ae029 100644 --- a/docs/research/PCIE_LINK_DISABLE_AUDIT.md +++ b/docs/research/PCIE_LINK_DISABLE_AUDIT.md @@ -13,7 +13,7 @@ it is not a safe operation after NVIDIA RM/GSP has initialized the GPU. ## Observed results -### CMP 40HX on my system (Ryzen 5 5600G + MSI MPG B550 Gaming Plus) +### CMP 40HX on the tested system (Ryzen 5 5600G + MSI MPG B550 Gaming Plus) The compute and GSP PCIe policy parts completed successfully. The integrated Link Disable variant then left the card with POST-like maximum fan speed and diff --git a/docs/research/README.md b/docs/research/README.md index 212e19d..2c0bf0a 100644 --- a/docs/research/README.md +++ b/docs/research/README.md @@ -6,6 +6,7 @@ install or use the project; start from the [main README](../../README.md) and th | Note | Contents | |---|---| +| [`RUST_EFI_PORT.md`](RUST_EFI_PORT.md) | Rust EFI port, read-only hardware report, compute unlock core, C comparisons and remaining EFI integration | | [`CMP40_NVIDIA_PATCHER_PIPELINE_CORRELATION.md`](CMP40_NVIDIA_PATCHER_PIPELINE_CORRELATION.md) | RM/glcore throttle control in 610/615/620, stock Linux A/B/A results under `1f4b`, CUDA discovery failure, selector recovery and reproduction protocol | | [`CMP40_CPU_RM_VULKAN_PIPELINE_THROTTLE.md`](CMP40_CPU_RM_VULKAN_PIPELINE_THROTTLE.md) | Vulkan pipeline-bind delay with proprietary GSP OFF and argument-0 measurements using command buffers and glcore | | [`WINDOWS_DISK_PCI_AUDIT.md`](WINDOWS_DISK_PCI_AUDIT.md) | Disk I/O boundaries, Gen2 guards, experimental ReBAR policy and requirements for a conservative standalone EFI | diff --git a/docs/research/RUST_EFI_PORT.md b/docs/research/RUST_EFI_PORT.md new file mode 100644 index 0000000..7a0c7bd --- /dev/null +++ b/docs/research/RUST_EFI_PORT.md @@ -0,0 +1,425 @@ +# Rust EFI port: carrier, compute unlock core and experimental FULL/ZERO + +The port starts on branch `port/rust` from commit `1c94f8e`. Stage 1 adds +[`windows/efi-rust/`](../../windows/efi-rust/README.md), a pure Rust core and +differential tests against the existing C EFI. The shipped EFI, its embedded +copy, installer, NVIDIA assets and payload are not changed by this stage. + +## Runtime contract to preserve + +The reference is the Windows build selected by `build_v70.sh`: +`CPU_RM_HANDOFF`, `HANDOFF_PRELOAD_DEFAULT`, and `STAGE_CONTROL=9` (FULL) or +`10` (ZERO). Porting preserves: + +- CMP40HX TU106, PCI identity `10de:1f0b`, 8 GiB framebuffer. +- The existing signed Booter and board-specific FWSEC inputs. +- The existing FULL/ZERO payload bytes and their verified SHA-256 values. +- A `0x1bfadc8`-byte dummy image, `0x6000`-byte boot image, code offset `0x1800`, + data offset `0x800`, and manifest offset zero. +- Heap size `0xf0000` (960 KiB), WPR start `0x1fe000000`, heap start + `0x1fe100000`, image start `0x1fe1f0000`, and WPR end `0x1fff00000`. +- Native Booter completion, including HALT, mailbox 0, exact selectors, + WPR2 teardown, and stock FEAT PLM `0xffffff8f`. +- No final FLR or extra SEC2/GSP cleanup. The current delays, sparse reads, + and absence of a retry in the production controls are part of the baseline. +- Early Windows image preparation, parent-bootloader return options, and + explicit experimental ReBAR opt-in with `norebar` taking precedence. +- Existing RootBridgeIo address encodings and CF8 fallback when the hardware + access layer is ported; a PciIo-only replacement needs separate validation. + +The independent implementation uses the current project's wire formats and +observable behavior. No code is imported from `nv-uefi-unlocker`. + +## Stage 1 implementation and acceptance + +The `cmp40-efi-core` library serializes bytes explicitly, builds radix tables +in caller-owned memory, parses existing boot policy, and checks recorded +register snapshots. It uses `no_std`, no heap, no dependencies and no unsafe +code. The host comparison compiles actual C functions instead of a manually +rewritten C reference. + +The acceptance checks cover: + +- All 256 metadata bytes with three sets of low/high DMA addresses, for both + payload and stock signature sizes; fixed assertions also pin the measured + compute unlock geometry independently of changes to the C reference. +- Radix output at partial-page boundaries, across leaf 511/512, and at the + actual dummy-image size. Last-leaf padding and the caller's buffer tail are + checked separately. +- Existing boot options, aliases, conflicting handoff modes, case sensitivity, + whitespace, NUL termination, odd trailing bytes, binary OptionalData, and + missing/invalid/disabled/enabled ReBAR policy. +- Entry and FULL/ZERO Booter statuses under selector, WPR2, CPU, mailbox, + and PLM changes, including unreadable register values. +- Invalid DMA ranges and unsupported radix sizes refusing before stores. +- Formatting, Clippy with warnings denied, and Windows-target library checks. + +The Rust API adds numeric DMA range/alignment validation and rejects images +that would exceed the existing layout's one L1 page. These rejection cases +are not executed through the C reference, whose corresponding input bounds +are not checked. An accepted numeric address does not establish actual DMA +mapping or GPU accessibility. + +## Stage 2: EFI carrier and emulated boot validation + +The `cmp40-efi` application now builds for `x86_64-unknown-uefi`, using uefi-rs +0.41 for standard EFI services. Its PCI adapter exposes only config reads and +GetLocation, with static x86-64 protocol-layout assertions. It inventories +devices, counts `10de:1f0b` targets and performs no application GPU writes. + +Windows image preparation uses complete volume device paths. The application +tries its own volume first; otherwise it accepts one other Windows candidate, +refuses multiple candidates, and stops on corrupt or security-rejected images. +It preserves the parent's return aliases. It skips its own Windows-loader path +to avoid recursive launches and cleans up rejected/unstarted image handles. +EFI applications are unloaded by firmware on exit; returned child handles are +not reused. A raw LoadImage call retains the error-path out-handle that the +uefi-rs 0.41 wrapper otherwise discards. + +Seven QEMU/OVMF cases verify actual EFI entry, PCI reads, LoadImage/StartImage, +parent resumption and failure paths with no NVIDIA device. The private FAT +volumes contain small test EFI images instead of real Windows. The smoke +runner verifies the PE32+ image, EFI subsystem, entry point and base relocations, +and records serial logs and image hashes. CI builds and runs the same cases. +The [stage-2 evidence](../../windows/efi-rust/tests/evidence/stage2/README.md) +records the seven passing boot cases and identifies the tested EFI images. + +Physical CMP40HX discovery was subsequently confirmed (`0000:10:00.0`, +`10de:1f0b`, 34 PCI handles, one target, zero read errors) and successful +Windows boot from another disk. The [physical report](../../windows/efi-rust/tests/evidence/stage2/hardware-report.md) +records the reported partition layout and evidence limits. This accepts the +read-only hardware milestone for that machine. RootBridgeIo/CF8 fallbacks, +the C loader's raw BlockIo/FAT path and file logging remain pending. + +## Stage 3a: compute unlock firmware operations against a host backend + +The independent `no_std` core now implements: + +- The existing reserved-page placement policy: 12 dynamic high slots, the + three static high fallbacks, then AllocateMaxAddress below 4 GiB. Dynamic + success advances by allocation size plus 16 MiB; static/low success does + not advance the cursor. No automatic release is introduced. +- PTIMER seed arithmetic and the original high-word/low-word write order. + The C arithmetic omits the day of the month and timezone; the port keeps + that behavior. Invalid calendar fields additionally use the existing + fallback instead of risking out-of-bounds month-table access. +- GFW stop, reset propagation reads and the conditional SEC2 Falcon switch; + the board's FWSEC WITH_LOADER descriptor and FRTS command patch; IMEM/DMEM + port loading, tags and checked readbacks; the direct Booter launch with + full 64-bit metadata address and sparse completion reads. +- Native FULL/ZERO completion: exact selectors, WPR2 down, stock FEAT PLM, + Booter HALT/mailbox 0 and idle/halted GSP checks. The final path performs + no reset, mailbox clear, FLR or DMA release. + +`Transaction::run` retains the attempt state on error and refuses reuse before +any backend call. Its deferred callbacks keep FWSEC allocation/copy after +GFW stop, and the Booter recopy/signature patch immediately after SEC2 health. +These callbacks must flush the copied buffers before the firmware routines. +`run_prepared` is a host convenience for synthetic, already prepared buffers. +The EFI adapter must retain one transaction object for the boot attempt and +must not replace it to retry after failure. + +The tests compile the actual corresponding C functions and the pre-FWSEC +main-entry segment, retaining diagnostic register reads and replacing WBINVD +with recorded barriers. Synthetic buffers exercise 147 firmware-operation +comparisons, 896 reserved-allocation comparisons and 180 PTIMER seeds. Writes, +delays and barriers retain exact order. Consecutive read groups are sorted +to accommodate C's unspecified diagnostic argument evaluation order; every +read and returned value is still compared. Additional tests run the whole +prepared firmware sequence, verify deferred preparation ordering, reject +malformed inputs, and confirm that failure never retries or adds cleanup. +GCC and Clang both pass the new comparisons. See [stage-3 evidence](../../windows/efi-rust/tests/evidence/stage3/README.md). + +The core includes no firmware or payload bytes and no `unsafe` code. The host +execution milestone supplies no EFI adapters; those belong to stage 3b below. + +## Stage 3b: experimental EFI compute unlock integration + +The opt-in `unlock` feature builds separate FULL/ZERO EFI applications. The +default application remains the read-only carrier. The adapters implement the +existing RootBridgeIo encodings/CF8 route, verified BAR enable, volatile MMIO, +PTIMER seeding and retained reserved memory. High-slot placement and payload, +Booter, boot image, dummy image, radix, metadata and deferred FWSEC allocation +follow the C order. Booter recopy/signature patch remains in the deferred callback. + +Source assets are verified by full length and SHA-256 before output publication. +The original 128 KiB GSP boot input produces the exact 24 KiB C runtime prefix, +with an independent hash; FULL/ZERO and the signature match the existing inputs. +No generated asset is committed. The unlock uses its 960 KiB heap and native +completion with no reset/cleanup/FLR/retry tail. Windows is prepared before PCI +mutation, or the existing parent return option is honored after completion. + +Numbered logs preserve earlier runs and record identity/route, asset hashes, +allocated addresses, metadata and a bounded, preallocated transaction trace. +The trace captures existing observations rather than adding diagnostic MMIO. +Firmware data ports are omitted and counted; repeated events are compressed. +No disk/console operation occurs inside `Transaction::run`. The trace is dumped +after return, and logs close before terminal handoff. Hard stalls leave only +the checkpoint written before transaction entry. This differs from C's in-flight +printing and must be considered when comparing physical behavior. + +The [stage-3b evidence](../../windows/efi-rust/tests/evidence/stage3b/README.md) +records checks and image hashes. Four PCI policy tests cover scan encodings, +bus bounds/multifunction discovery and BAR refusal/readback. Asset checks include +corruption outside the runtime prefix and refusal without changing prior output. +QEMU exercises both no-NVIDIA paths in addition to the seven carrier cases. +The [hardware guide](../../windows/efi-rust/tests/UNLOCK_HARDWARE.md) defines the +remaining ZERO/FULL comparison; physical GPU transactions are not yet accepted. + +## Stage 3c: first ZERO failure and diagnostic recovery + +The first reported ZERO hardware run used Limine `protocol: efi`, empty +`cmdline`, and a cold boot. It reached Booter, returned `DEVICE_ERROR`, then +Windows started with a long black screen and NVIDIA Code 43. The initial report +said no log was found on the Linux EFI volume; the log was later located and +the missing-log claim was withdrawn. That first report was transcribed from video; +the subsequent raw ZERO trace is documented in stage 3d below. + +Returning an EFI error did not prevent Limine/firmware from selecting another +boot target. Failed attempts after possible GPU mutation now park without +returning to the parent, resetting the GPU or releasing DMA pages. A QEMU +parent/child test verifies that the shared terminal failure path does not resume +the parent after the failure marker. Pre-mutation errors can still return safely. + +The logger uses short numbered `RZ`/`RF` names, detects short successful writes +through file-position checks, and flushes/closes/reopens/verifies content at each +checkpoint. LOGCHECK uses the same logger without PCI/MMIO access and creates +an `RL` log for a physical visibility check before another GPU attempt. QEMU +checks multi-chunk persistence, append positions, preservation of two logs and +the production LOGCHECK image on local FAT images. These remain verification +hardening; no original firmware logging failure is established. + +Eight Booter gate diagnostics report the values already read; host comparisons +with C preserve the original register traffic and delays. No payload, firmware, +heap geometry or retry policy is changed. The [stage-3c record](../../windows/efi-rust/tests/evidence/stage3c/README.md) +contains the manual report and validation. Next: confirm LOGCHECK's visible file, +then obtain the corrected ZERO's exact failure detail before changing execution. + +## Stage 3d: physical mailbox 0x91 and FWSEC completion barrier + +The raw `RZ000001.LOG` identifies Booter `MailboxStatus=0x91`, halted SEC2, +`DEBUGINFO=0xdeadb00d`, unchanged ZERO selectors/stock FEAT PLM, and WPR2 still +up. The input code/signature and metadata mailbox readbacks passed. All 256 +logged metadata bytes match the actual C builder for the physical addresses. +The trace contains no dropped records and all DMA buffers are above 4 GiB. +This does not prove SEC2 DMA read the same bytes or identify a unique cause. + +FWSEC produced WPR2 after three explicit 1 ms waits, but the immediately +following SEC2 health snapshot still read GSP `CPUCTL=0`. Both C and the initial +Rust entry returned on WPR2 appearance without waiting for FWSEC HALT; C's +in-flight output adds incidental timing. The [Linux implementation](../../linux/preboot/kernel/unlock.c) +waits for HALT and checks scratch0e/FRTS. The reference TU10x analyses associate +`0x91` with WPR validation, but timing/geometry/DMA alternatives remain open. + +`Transaction::run` now has `FwsecCompletion` between WPR2 appearance and SEC2 +health. It performs a bounded 5-second HALT wait, checks scratch0e's high-half +FRTS error code, and rechecks the WPR2 window before preparing Booter. It reports +`FWSEC_COMPLETION` with the observed registers and wait. Timeout or invalid +results stop before Booter preparation/start. Firmware writes, source assets, +payloads, allocation order and no-retry/no-cleanup behavior remain unchanged. +This added read-only barrier intentionally differs from the early-return C +orchestration; low-level C comparisons are retained separately. + +The [stage-3d evidence](../../windows/efi-rust/tests/evidence/stage3d/README.md) +archives the raw trace and physical metadata comparison. Model tests exercise +WPR2 appearing before HALT, delayed completion, timeout, FRTS error, window +drift and unreadable results, all without premature Booter preparation or retry. +Physical success of the new completion barrier is not yet established. + +## Stage 3e: accepted FULL/ZERO hardware milestone + +Supplied `RF000001.LOG` and `RZ000002.LOG` confirm both modes work, with FULL +compute unlock reported to survive OS handoff. Both logs observe 99 ms +of extra FWSEC completion waiting, then GSP HALT, zero FRTS error, native +Booter mailbox0 zero, exact FULL/ZERO selectors, stock FEAT PLM and WPR2 +teardown. DMA placement and all metadata bytes are identical to the earlier +failed ZERO trace; the control traces of FULL/ZERO match apart from PTIMER +and selector observations. `DEBUGINFO=deadb00d` also appears on success. + +The [stage-3e evidence](../../windows/efi-rust/tests/evidence/stage3e/README.md) +accepts the Rust compute unlock execution milestone on this tested configuration. +EFI hashes were not separately reconfirmed; numeric benchmark, driver-version, +repeated-boot and suspend/resume records were not supplied. Physical parent-return +is not covered by these `parent=false` runs. The accepted provided binaries +remain frozen while subsequent changes are evaluated separately. + +## Stage 3f: accepted memory optimization + +The memory-r1 runtime (`e1422c1`) constructs the zero-filled image directly in +the radix leaves, removing the duplicate 29,339,648-byte reserved allocation +(27.98 MiB of system RAM). Validation precedes stores; padding and unused +entries remain zero, with no change to GPU heap/WPR geometry, pinned firmware, +payloads, cache barriers or failure policy. Host comparisons cover the real +image and leaf boundaries; Clang's host C reference now uses the EFI build's +`-fno-builtin` to avoid an incompatible host `wcslen` substitution. + +Successful cold FULL and ZERO runs with FULL compute unlock in the OS are +confirmed. `RF000002.LOG` verifies the expected shifted DMA addresses, all 256 +metadata bytes against C, 99 ms of FWSEC completion waiting, native FULL state +and zero trace drops. Exactly five retained records differ from the earlier +successful FULL: two PTIMER writes, one FWSEC address event and two metadata +mailbox address observations. Every other retained record is identical. +ZERO's raw log was not copied, so its success is recorded as a reported observation. + +The [stage-3f record](../../windows/efi-rust/tests/evidence/stage3f/README.md) +accepts memory-r1 on this tested configuration and freezes the provided pair in +`target/baseline-memory-e1422c1/`, preserving the earlier accepted pair. +Executable hashes were not separately reconfirmed; physical parent/Linux +handoff and other boards remain outside this acceptance. + +## Stage 4a: raw loading, file policy and read-only discovery + +The carrier now uses a dependency-free read-only FAT16/FAT32 parser over +aligned BlockIo reads for Windows preload and its own ReBAR policy file. +It checks BPB/partition bounds, active FAT selection, LFN sequence/checksum, +directory cycles and complete size-consistent file chains. Primary MBR FAT +partitions and GPT ESPs preserve their native logical block size; GPT header +and entry-table CRCs are verified. Exact volume paths deduplicate firmware +partition handles and whole-disk views. Extended MBR chains, FAT12, backup-GPT +recovery and raw filesystem writing are outside this implementation. + +Windows image bytes reach LoadImage as SourceBuffer with the complete source +volume + filename path. Its loaded device must resolve to that volume; rejected +images are unloaded. Own-volume preference, ambiguous-candidate refusal and +self-Windows recursion checks remain. Unsupported raw formats can retain +firmware loading, while supported-format corruption and security/image failures +stop instead of bypassing verification. Logging still uses SimpleFileSystem +outside the GPU transaction, so raw preload alone is not an SFS-free logger. + +`EFI/40HX/REBAR.CFG` reads preserve the C policy and `norebar` precedence. +The read-only carrier reports effective opt-in without resizing; FULL/ZERO +refuse it until ReBAR allocation is implemented. The read-only carrier also +exercises shared RootBridgeIo Standard/Compact and CF8 discovery without BAR +enable or GPU MMIO. The accepted compute unlock preparation/transaction and reserved +DMA code are preserved; this changed OS preparation still needs hardware checks. + +Eleven new host disk tests cover FAT, fragmentation, LFN boundaries, cycles, +geometry, I/O errors, MBR and native-block GPT/CRC. All 39 core tests pass, along +with GCC/Clang comparisons, both EFI feature configurations and Windows checks. +All 25 QEMU scenarios pass; a failing filesystem shim forces raw preload/policy, +and GPT/FAT32 disks exercise actual 512/4096-byte BlockIo. Four further default +build cases verify the read-only carrier. The +[stage-4a record](../../windows/efi-rust/tests/evidence/stage4a/README.md) +archives evidence and identifies the isolated preflight image. + +The [physical report](../../windows/efi-rust/tests/evidence/stage4a/hardware-report.md) +now accepts the default read-only carrier on the tested configuration: +Windows/NVIDIA preload works, return to Limine works, and Linux subsequently +starts. This is reported console/OS behavior without a raw capture or separately +reconfirmed image checksum. The supplied read-only archive is frozen unchanged +under `target/baseline-carrier-fe02bf7/`. + +The previously QEMU-tested carrier-r1 ZERO/FULL images (`fe02bf7`) are packaged +without rebuilding, preserving the recorded EFI hashes. Follow the standalone +[GPU comparison guide](../../windows/efi-rust/tests/CARRIER_GPU_HARDWARE.md) +for cold ZERO/FULL Windows preload, then FULL return/Linux compute checks. +Their combined Windows GPU/carrier acceptance is now recorded in stage 4c +below; memory-r1 stays frozen as the earlier baseline. + +The first reported combined ZERO/FULL attempts appeared to skip into Windows +without visible messages or logs, using existing working Limine entries and +matching image checksums. The [stage-4b record](../../windows/efi-rust/tests/evidence/stage4b/README.md) +provides separate ENTRYCHK diagnostics: early verified logs, policy/read-only +PCI checks, candidate LoadImage/unload and Windows preparation without any +StartImage or GPU transaction. A subsequently supplied successful `RE000001.LOG` followed removal of +`REBAR.CFG`, which was confirmed to have enabled ReBAR with value 1. This identifies the early unsupported-ReBAR gate before +RF/RZ log creation. The physical diagnostic is accepted; reuse the original +GPU pair with explicit `cmdline: norebar` for GPU comparison. That comparison +subsequently passed, as recorded below. + +## Stage 4c: accepted carrier-r1 FULL/ZERO Windows path + +Supplied `RZ000003.LOG` and `RF000004.LOG` accompany confirmation that +Windows/NVIDIA work in both controls and FULL compute unlock is present in +Windows. Both +logs identify RawBuffer handoff, 99 ms of FWSEC completion waiting, successful +native Booter status, expected FULL/ZERO selectors, stock FEAT PLM and WPR2 +teardown, with 20,499 retained records and zero drops. All 256 metadata bytes +match the actual C builder using GCC and Clang and the earlier memory-r1 FULL. +FULL's retained trace differs from memory-r1 only at two PTIMER seed writes. + +The [stage-4c record](../../windows/efi-rust/tests/evidence/stage4c/README.md) +accepts carrier-r1 Windows GPU/handoff behavior on this configuration. Original +provided images and archives are frozen unchanged under +`target/baseline-carrier-gpu-fe02bf7/`, preserving earlier GPU/carrier baselines. +Both logs use `parent=false`; FULL-to-Limine/Linux compute handoff is recorded +in the subsequent stage below. No runtime source or firmware input changed +for this evidence update. + +## Stage 4d: accepted FULL parent/Linux handoff + +`RF000007.LOG` records `HANDOFF_PREPARED parent=true source=None` followed by +successful native FULL completion. Return to Limine, Linux boot, working +NVIDIA and compute unlock are confirmed with **620.70.06 proprietary, GSP OFF**, +without another unlocker. Metadata and asset manifests match Windows FULL; +the retained trace differs only at two PTIMER seed writes, with 20,499 records +and zero drops. FWSEC completion waits the same additional 99 ms. + +The [stage-4d record](../../windows/efi-rust/tests/evidence/stage4d/README.md) +accepts the GPU parent/Linux path on this configuration and closes outstanding +carrier/handoff acceptance. EFI-native completion is verified by the raw log; +post-return menu/driver/compute behavior is a reported observation. This does +not extend acceptance to GSP ON, other drivers/boards, repeated-boot statistics +or suspend/resume. Original carrier-r1 GPU images remain frozen unchanged. + +## Stage 5: accepted ReBAR-r1 FULL/ZERO + +I tested both controls with the enabled policy file, first with `norebar` +and then with an empty command line, and noticed no errors. Compute unlock +survived OS handoff in both FULL runs. In both ReBAR-enabled controls, +`nvidia-smi -q` and GPU-Z showed 8192 MB BAR1. I observed about 10% higher +game FPS than with the stock 64 MB BAR1. These are reported observations; +no game names, raw FPS samples, driver version or OS version were supplied. + +Verified: inspection of all four complete logs confirms native FULL/ZERO, +`RawBuffer` Windows preload with `parent=false`, 99 ms of extra FWSEC waiting, +and zero trace drops. All 256 metadata bytes per run match the actual C +builder; input manifests match the pinned sources and derived runtime bytes. +Same-control compute unlock traces differ only at two PTIMER writes. The enabled +ZERO/FULL ReBAR traces are identical across all 111 records: 8 GiB BAR1, +32 MiB BAR3, placement at attempt 0, matching readback and two zero VRAM +samples. Both `norebar` logs skip ReBAR despite the reported enabled file. + +The [stage-5 record](../../windows/efi-rust/tests/evidence/stage5/README.md) +contains redacted checkpoint excerpts and a report separating inspected EFI +results from my OS observations. This accepts ReBAR-r1 on the tested +configuration. The delivered archive and pair were preserved locally with +their original hashes, without rebuilding or changing runtime code. Physical +rollback and ReBAR parent/Linux handoff are outside these four runs; the FPS +observation does not establish a general performance gain. + +## Remaining work and validation + +1. **Experimental ReBAR:** the [ReBAR-r1 C allocator port](../../windows/efi-rust/README.md#experimental-rebar) + has FULL/ZERO OS acceptance with explicit opt-in/`norebar`. Physical + rollback and parent/Linux handoff with ReBAR still need validation. + A resource planner and EFI backend with real routing, GCD reservation, + decode-off extended configuration and consistent firmware/OS resource + descriptions remain later work. Preserve the accepted carrier-r1 and memory-r1 pairs. +2. **Production logging:** replace unbounded per-boot diagnostic files with + compact success summaries, failure/opt-in traces and a bounded retention + budget. The [proposal](../../windows/efi-rust/LOGGING_POLICY.md) targets 8 MiB + and at most four full traces, subject to the byte limit; existing logs remain + intact during these milestones. This is a release gate for default Rust + distribution on small Windows ESPs, with checker/uninstaller format support. +3. **Go distribution integration:** update the embedded Rust image, deployment + checks and log support in the existing Go tools after carrier/ReBAR parity + and bounded logging. C remains the installer default until those requirements + are complete; a Go rewrite is not required. + +Mapped DMA, map-based placement and explicit releases remain separate later +changes; none is required to accept the completed memory optimization. + +The host tests do not model firmware scheduling, DMA coherency/reachability, +PCI routing, device reset propagation or driver initialization. QEMU without +GPU passthrough checks the EFI carrier and negative path; it does not validate +the NVIDIA transaction. The accepted Rust pair now provides a physical baseline +on this board; C remains the shipped image until carrier/distribution parity. + +The Windows Go applications remain in place during EFI porting. They already +share `40hxcore` for diagnostics, configuration and uninstall operations. Rust +EFI integration should update their embedded image, deployment checks and log +support after carrier parity. A full Go rewrite is not a prerequisite and has +no established unlock/Gen2 performance benefit. Reassess a shared Rust library +or GUI replacement only when a concrete maintenance or product need warrants +the Windows API, localization, installation and recovery regression work. diff --git a/docs/research/WINDOWS_CPU_RM_HISTORY.md b/docs/research/WINDOWS_CPU_RM_HISTORY.md index dc77f82..83f34bc 100644 --- a/docs/research/WINDOWS_CPU_RM_HISTORY.md +++ b/docs/research/WINDOWS_CPU_RM_HISTORY.md @@ -2,7 +2,7 @@ These October 2026 experiments explain how the search narrowed before the successful [small-WPR handoff](CPU_RM_SMALL_WPR.md). Code 43 remained -unresolved on 2026-10-07; I later confirmed successful ZERO/FULL 960 KiB +unresolved on 2026-10-07; later tests confirmed successful ZERO/FULL 960 KiB initialization and FULL unlock. The earlier stand was CMP 40HX / TU106 on MSI MPG B550 Gaming Plus. Older @@ -27,8 +27,8 @@ so their zeros are not snapshots of the initial fault. The PMU timeout with ACR disabled was a distinct control and must not be conflated with the primary SEC2 failure under normal ACR. -I corrected some initial observations about stock/GSP OFF, compute retention -and ReBAR through repeat testing. Code 43 alone does not +Repeat testing corrected some initial observations about stock/GSP OFF, +compute retention and ReBAR. Code 43 alone does not identify signature rejection, BROM failure or a particular MMIO register. The successful Ampere CMP90HX CPU-RM implementation was useful as a control flow reference; its registers and firmware layout were not assumed to apply diff --git a/docs/research/WINDOWS_DISK_PCI_AUDIT.md b/docs/research/WINDOWS_DISK_PCI_AUDIT.md index 03f1072..0c7e0fd 100644 --- a/docs/research/WINDOWS_DISK_PCI_AUDIT.md +++ b/docs/research/WINDOWS_DISK_PCI_AUDIT.md @@ -17,7 +17,7 @@ on the affected system, so its cause remains unresolved. | Gen2 and checker | Deploy helper drivers; write status and diagnostic logs | Windows driver directory and project log directories | | Uninstaller and USB helper | Remove project files or restore a verified fallback backup | System ESP or the explicitly selected USB drive | -Verified: the shipped CPU-RM entry does not call the historical FAT32, +Verified: the shipped C EFI entry does not call the historical FAT32, BlockIo or GA102 disk-preload helpers. EFI logging uses firmware file services and flushes each line. It has no fixed 8 KiB length and is not a raw-sector write. A firmware filesystem error, failing storage or interrupted FAT diff --git a/docs/results.md b/docs/results.md index a5ef984..6117cf9 100644 --- a/docs/results.md +++ b/docs/results.md @@ -3,7 +3,7 @@ Unless stated otherwise, the measurements below come from the Windows/UEFI unlock path on one system: CMP 40HX, AMD Ryzen 5 5600G host, NVIDIA driver `617.14`, CUDA Toolkit `13.4`. The Windows-side summary is in -[`windows/README.md`](../windows/README.md#results). My Linux measurements +[`windows/README.md`](../windows/README.md#results). Linux measurements and a separately attributed community GRID/vGPU report follow below. ## clpeak (CUDA backend) @@ -84,7 +84,7 @@ mechanism behind the CUDA loops has not been investigated here. ### Setup notes - This earlier "after" state has GSP enabled (`EnableGpuFirmware=1`). The - current small-WPR EFI supports GSP OFF; see the CPU-RM results below. + small-WPR tests below cover both GSP modes. With GSP on, the driver reserves some video memory, so the reported VRAM drops from `8191 MB` to `8024 MB` (CUDA) and from `8016 MB` to `7857 MB` (Vulkan). These figures describe the earlier GSP-ON comparison. @@ -144,9 +144,9 @@ sbccc1888's own benchmarks. They are replaced by the clpeak measurements above: | FP16 cuBLAS, `~0.39 -> 11.42 TFLOPS` | Replaced. cuBLASLt GEMM fp16 measures 1.12 TFLOPS before and 56.5 TFLOPS after. | | FP16 Tensor Core MMA, *unavailable -> 63.8 TFLOPS* | Replaced. The Tensor path runs on the stock card at about 1.1 TFLOPS (WMMA fp16) and reaches 72.0 TFLOPS after. | -## My measurements (Linux, own benchmarks) +## Local measurements (Linux benchmarks) -The sections below are single-system observations by me. The benchmark +The sections below are single-system observations. The benchmark sources are not published in this repository, so treat them as reported observations, not reproducible results. @@ -209,18 +209,26 @@ Before the userspace pipeline fix, the affected game configurations showed a ver large slowdown, reported as up to roughly 10-15x. The application figures above are observations from one system, not universal performance guarantees. +## GSP enabled on Linux and Windows + +On 2026-11-26 I tested compute unlock with the proprietary NVIDIA driver on +Linux (`NVreg_EnableGpuFirmware=1`) and with the Rust EFI on Windows +(`EnableGpuFirmware=1`). In both systems, `nvidia-smi -q` reported a GSP +firmware version, compute unlock persisted, and the driver ran stably. +Gen2 also worked in these tests. The performance differences I observed +were within measurement error. + ## Proprietary Linux and Windows with GSP OFF -The current small-WPR CPU-RM path passed native proprietary Linux 610.43.03 +The small-WPR handoff passed native proprietary Linux 610.43.03 and 615.78.08 initialization. At a verified 150 W on 615, FP16 WMMA increased from 1.0440 to 66.1629 TFLOPS, INT8 WMMA from 2.0724 to 131.0379 TOPS, and cuBLASLt FP16 from 1.0335 to 52.1347 TFLOPS. A separate numerical WMMA test matched 163,840 outputs with maximum error 0 and passed again after a fresh FULL unlock. The earlier 610 pair used the recorded 184 W default limit. -I confirmed successful Windows ZERO/FULL initialization and FULL unlock with -the 960 KiB EFI. I also tested the integrated installer and reproduced an -upgrade: Disable GSP changed `EnableGpuFirmware=1` to `0`, and the Gen2 task +Successful Windows ZERO/FULL initialization and FULL unlock are confirmed +with the 960 KiB EFI. Integrated installer tests reproduced an upgrade: Disable GSP changed `EnableGpuFirmware=1` to `0`, and the Gen2 task left it at `0`. GRID/vGPU support has not been independently validated. The exact geometry, controls, full table, provenance and limitations are in [CPU_RM_SMALL_WPR.md](research/CPU_RM_SMALL_WPR.md). diff --git a/linux/cpu-rm/tests/run_helpers.py b/linux/cpu-rm/tests/run_helpers.py deleted file mode 100644 index 4417860..0000000 --- a/linux/cpu-rm/tests/run_helpers.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-License-Identifier: GPL-2.0-only -"""Check stock and GRID representations of the actual driver's GSP setting.""" -from pathlib import Path -import subprocess -import tempfile - -source = Path(__file__).resolve().parents[1] / "common.sh" -with tempfile.TemporaryDirectory(prefix="cmp40-gsp-test-") as directory: - root = Path(directory) - sys_file, proc_file = root / "sys-param", root / "proc-params" - for sys_value, proc_value, expected in ( - ("0\n", "EnableGpuFirmware: 1\n", "0"), - ("1\n", "EnableGpuFirmware: 0\n", "1"), - (None, "OtherParam: 1\nEnableGpuFirmware: 0\n", "0"), - (None, "EnableGpuFirmware: 1\n", "1"), - (None, "OtherParam: 0\n", None), - (None, None, None), - ): - for path, value in ((sys_file, sys_value), (proc_file, proc_value)): - if value is None: - path.unlink(missing_ok=True) - else: - path.write_text(value) - result = subprocess.run( - ["bash", "-c", 'source "$1"; cmp40_gsp_setting "$2" "$3"', - "test", str(source), str(sys_file), str(proc_file)], - capture_output=True, text=True, check=False, - ) - if expected is None: - assert result.returncode != 0, result - else: - assert result.returncode == 0 and result.stdout.strip() == expected, result -print("CPU-RM helpers: 6 stock/GRID GSP cases passed") diff --git a/linux/cpu-rm/Makefile b/linux/preboot/Makefile similarity index 100% rename from linux/cpu-rm/Makefile rename to linux/preboot/Makefile diff --git a/linux/cpu-rm/README.md b/linux/preboot/README.md similarity index 87% rename from linux/cpu-rm/README.md rename to linux/preboot/README.md index 34c579f..0cf63ba 100644 --- a/linux/cpu-rm/README.md +++ b/linux/preboot/README.md @@ -1,7 +1,8 @@ -# CMP 40HX proprietary Linux driver / CPU-RM unlock +# CMP 40HX pre-driver compute unlock This path unlocks compute on an **8 GiB CMP 40HX / TU106 (`10de:1f0b`)** -before the proprietary NVIDIA driver loads, with **GSP disabled**. It does not +before the proprietary NVIDIA driver loads. Compute unlock works with GSP +enabled or disabled on the tested card. See the [GSP-enabled results](../../docs/results.md#gsp-enabled-on-linux-and-windows). It does not modify or install NVIDIA's proprietary driver. Native initialization and CUDA throughput were validated with **610.43.03, 615.78.08 and 620.70.06**; see [the research report](../../docs/research/CPU_RM_SMALL_WPR.md). @@ -41,14 +42,14 @@ Ubuntu's distribution headers. Rebuild and reinstall after kernel updates. From the repository root, as a normal user: ```bash -python3 linux/cpu-rm/firmware/prepare.py -make -C linux/cpu-rm/kernel -make -C linux/cpu-rm offline-test -python3 -m unittest discover -s linux/cpu-rm/firmware -p 'test_*.py' +python3 linux/preboot/firmware/prepare.py +make -C linux/preboot/kernel +make -C linux/preboot offline-test +python3 -m unittest discover -s linux/preboot/firmware -p 'test_*.py' ``` For a kernel built with Clang/LTO, such as CachyOS, use -`make -C linux/cpu-rm/kernel LLVM=1`. For a different kernel, specify +`make -C linux/preboot/kernel LLVM=1`. For a different kernel, specify `KDIR=/lib/modules//build`. Firmware preparation downloads the pinned NVIDIA 610.43.03 source archive and @@ -78,9 +79,9 @@ Install only the pre-driver module and its firmware: ```bash sudo install -d /lib/firmware/cmp40-preboot/610.43.03 -sudo cp linux/cpu-rm/build/assets/* /lib/firmware/cmp40-preboot/610.43.03/ +sudo cp linux/preboot/build/assets/* /lib/firmware/cmp40-preboot/610.43.03/ sudo install -d /lib/modules/"$(uname -r)"/extra -sudo install -m 0644 linux/cpu-rm/kernel/cmp40_preboot.ko /lib/modules/"$(uname -r)"/extra/ +sudo install -m 0644 linux/preboot/kernel/cmp40_preboot.ko /lib/modules/"$(uname -r)"/extra/ sudo depmod -a ``` @@ -101,19 +102,17 @@ for the example below: ```bash readlink /sys/bus/pci/devices/0000:01:00.0/driver # must have no driver link -sudo bash linux/cpu-rm/unlock.sh --gpu 0000:01:00.0 --load-nvidia +sudo bash linux/preboot/unlock.sh --gpu 0000:01:00.0 --load-nvidia nvidia-smi -sudo dmesg | rg 'cmp40_preboot|NVRM' +sudo dmesg | rg 'CMPUNLOCKER|cmp40_preboot|NVRM' ``` The helper does not detach/reset an initialized GPU. It loads `cmp40_preboot` in `mode=unlock`, explicitly selects the tested stock handoff and 1 MiB WPR heap, checks `unlock_error=0` and `resources_retained=N`, then loads the -proprietary `nvidia` module with `NVreg_EnableGpuFirmware=0`. Omit +proprietary `nvidia` module using the system modprobe configuration. Omit `--load-nvidia` to stop after the pre-driver unlock. If `cmp40_preboot` is already loaded, inspect its parameters and logs before another operation. -The GSP check accepts `/sys/module/nvidia/parameters/NVreg_EnableGpuFirmware` -or `/proc/driver/nvidia/params`; some GRID builds expose only the latter. For a GRID host, keep the vGPU manager and guests stopped through this sequence. After native health and GSP OFF are confirmed, explicitly load the separate @@ -130,12 +129,12 @@ benchmarks is recorded in [the GRID report](../../docs/research/GRID_CPU_RM_REPO Expected pre-driver markers: ```text -CPU-RM handoff verified: FECS_PLM=0xffffff8f ... DMEM=zero WPR2=0:0x1ffffe00 +CMPUNLOCKER: handoff verified: FECS_PLM=0xffffff8f ... DMEM=zero WPR2=0:0x1ffffe00 PRE_DRIVER_UNLOCK_PASS ``` These markers establish firmware completion. Confirm native driver operation -with `nvidia-smi`, GSP Firmware `N/A`, and an independent CUDA benchmark such +with `nvidia-smi -q` and an independent CUDA benchmark such as clpeak (WMMA FP16/INT8). Successful `insmod` alone is insufficient: if firmware still owns DMA buffers, the module deliberately stays resident while reporting a nonzero `unlock_error` and `resources_retained=Y`. @@ -146,7 +145,7 @@ For a read-only inspection on an active GPU, with no existing preboot module: ```bash sudo modprobe cmp40_preboot target=0000:01:00.0 mode=inspect -sudo dmesg | rg 'cmp40_preboot' +sudo dmesg | rg 'CMPUNLOCKER|cmp40_preboot' sudo modprobe -r cmp40_preboot ``` @@ -161,7 +160,7 @@ unlock inside a systemd-based initramfs, before module loading and udev. It selects exactly one unbound `10de:1f0b`, uses the stock handoff and 1 MiB WPR heap, and leaves `gen2=off`. NVIDIA loads later through the normal boot path. -I tested this hook on my CachyOS system with proprietary NVIDIA 615.78.08 +This hook was tested on CachyOS with proprietary NVIDIA 615.78.08 and GSP OFF. Automatic compute unlock worked after boot. Install the module and prepared firmware as described above for every kernel @@ -170,17 +169,14 @@ you boot. Keep `base`, `systemd` and `modconf` in `HOOKS`, and place Do not put `cmp40_preboot` in `MODULES`: the service must load it with explicit unlock parameters. Keep NVIDIA modules out of this initramfs as well. -Persist GSP OFF before enabling automatic unlock. For example, create -`/etc/modprobe.d/cmp40-cpu-rm.conf` with: - -```text -options nvidia NVreg_EnableGpuFirmware=0 -``` +The hook leaves the NVIDIA GSP policy to the system configuration. +Existing initramfs images can still pass the legacy module parameter +`cpu_rm_handoff`. New hooks use `driver_handoff` for the same setting. From the repository root: ```bash -sudo install -Dm644 linux/cpu-rm/mkinitcpio/cmp40-unlock /etc/initcpio/install/cmp40-unlock +sudo install -Dm644 linux/preboot/mkinitcpio/cmp40-unlock /etc/initcpio/install/cmp40-unlock echo 'HOOKS=(${HOOKS[@]/modconf/modconf cmp40-unlock})' | sudo tee /etc/mkinitcpio.conf.d/20-cmp40-unlock.conf sudo mkinitcpio -P ``` @@ -211,7 +207,7 @@ adding it to the automatic module-load list. After a cold boot: ```bash -journalctl -k -b | rg 'cmp40|NVRM' +journalctl -k -b | rg 'CMPUNLOCKER|cmp40|NVRM' cat /sys/module/cmp40_preboot/parameters/{unlock_error,resources_retained} nvidia-smi ``` @@ -219,7 +215,7 @@ nvidia-smi The log should show `PRE_DRIVER_UNLOCK_PASS` and `pre-driver unlock completed on ; verify with nvidia-smi after boot` before NVIDIA's module-load message. The two parameter files must print `0` -and `N`. Confirm GSP Firmware `N/A` with `nvidia-smi -q` and run a CUDA workload +and `N`. Check the GSP firmware version with `nvidia-smi -q` and run a CUDA workload to check native operation; the firmware completion markers alone do not prove workload stability. @@ -241,9 +237,9 @@ remove the guard or force a GPU driver to load during that boot. For a one-boot bypass, add `cmp40.skip` to the kernel command line. To remove the integration, remove the `cmp40-unlock` HOOKS entry or its `20-cmp40-unlock.conf` drop-in and `/etc/initcpio/install/cmp40-unlock`, then -regenerate the initramfs. Keep GSP OFF if you still use the manual CPU-RM path. +regenerate the initramfs. -## PCIe Gen2 with CPU-RM +## PCIe Gen2 with the proprietary driver Module **0.17.0** updates the Gen2 policy and training logic from the current CMP50HX approach. It shares its C implementation with the open-driver patches. @@ -253,7 +249,7 @@ passed hardware validation; see Gen2 can be applied entirely **after native NVIDIA initialization**. An isolated 615.78.08 cold-boot control with no preliminary Gen2 writes reached Gen2 x16 -using the CPU-RM helper. The helper also passed the manual 620.70.06 tests +using the runtime Gen2 helper. The helper also passed the manual 620.70.06 tests after driver unload. Both used CMP40HX VBIOS `90.06.67.00.06` and MSI B550; see [the hardware report](../../docs/research/CPU_RM_PCIE_GEN2.md). @@ -261,9 +257,9 @@ After installing the rebuilt module and firmware, start from an unbound cold boot and run this order, replacing the example PCI address: ```bash -sudo bash linux/cpu-rm/unlock.sh --gpu 0000:01:00.0 --load-nvidia +sudo bash linux/preboot/unlock.sh --gpu 0000:01:00.0 --load-nvidia sudo modprobe -r cmp40_preboot -sudo bash linux/cpu-rm/gen2.sh --gpu 0000:01:00.0 +sudo bash linux/preboot/gen2.sh --gpu 0000:01:00.0 ``` After a successful mkinitcpio unlock, verify `unlock_error=0` and @@ -271,13 +267,14 @@ After a successful mkinitcpio unlock, verify `unlock_error=0` and sequence. The compute unlock has already run; do not invoke `unlock.sh` again. The first helper verifies compute unlock and firmware/DMA cleanup. Unload its -completed one-shot module before using it again for runtime Gen2. The Gen2 -helper verifies proprietary GSP OFF, native health and absence of open NVIDIA +completed one-shot module before using it again for runtime Gen2. The Gen2 helper checks that the proprietary driver responds to `nvidia-smi` +and reads the link speed. If retraining is needed, it checks for open GPU clients, then holds a temporary NVML client while the module sets the GPU-side policy and requests ordinary upstream retraining. It allows one further attempt only if the link remains healthy at Gen1 with its original width; before that attempt it restores policy without another adoption write. -It requires full compute selectors, halted GSP and an active PCIe link. Its runtime mode +Before retraining, the kernel module checks the compute selectors, GSP halt +register and link state. Its runtime mode uses existing PCI decoding and leaves the native driver's PCI enable count unchanged. @@ -322,7 +319,7 @@ policy setup could affect native initialization or capability sampling; neither report has yet been fixed by this experiment. The [hardware report](../../docs/research/CPU_RM_PCIE_GEN2.md#early-preparation-on-other-platforms) describes the cold-boot controls. The reported open/GSP path is a separate -comparison from this proprietary GSP-OFF helper. +comparison with the proprietary driver. Gen2 outcomes are recorded separately in `gen2_error`, `gen2_device_ok` and `gen2_link_status`; compute unlock has its own `unlock_error`. A Gen2 timeout @@ -335,11 +332,11 @@ the code never changes Linux's PCI cache. CCC, ASPM, HASD/HAWD and `0x88610` are preserved. All Gen2 modes use the actual upstream port and ordinary Retrain Link, without Link Disable or driver reprobe. The existing `tools/cmp40hx-driver-reprobe-gen2.sh` depends on the patched open driver's -Gen2 setup running again at probe time, so use the CPU-RM helper for this path. +Gen2 setup running again at probe time, so use the runtime Gen2 helper for this path. ## Boot ordering and removal -Persist CPU-RM selection in a modprobe configuration if desired: +To reproduce the earlier GSP-OFF tests, select the driver mode in modprobe configuration: ```text options nvidia NVreg_EnableGpuFirmware=0 diff --git a/linux/cpu-rm/common.sh b/linux/preboot/common.sh similarity index 100% rename from linux/cpu-rm/common.sh rename to linux/preboot/common.sh diff --git a/linux/cpu-rm/firmware/artifacts-610.43.03.json b/linux/preboot/firmware/artifacts-610.43.03.json similarity index 88% rename from linux/cpu-rm/firmware/artifacts-610.43.03.json rename to linux/preboot/firmware/artifacts-610.43.03.json index d551b36..473aea7 100644 --- a/linux/cpu-rm/firmware/artifacts-610.43.03.json +++ b/linux/preboot/firmware/artifacts-610.43.03.json @@ -1,6 +1,6 @@ { "version": 1, - "target": "CMP40HX TU106 CPU-RM pre-driver unlock / signed TU102 Booter 610.43.03", + "target": "CMP40HX TU106 pre-driver unlock / signed TU102 Booter 610.43.03", "source_artifacts": [ { "name": "NVIDIA open kernel modules source archive", @@ -65,7 +65,7 @@ "gsp_boot_desc_tu102.bin": "9e7cca2cfdc5ce601b0adba39967850046108df6c2d23fff95578ca3f0ccbe01", "sec2_bl_tu102.bin": "f21f1cfbb8fffa8067685314367fc4c50f3f84dd99eda7c19db4292d9269b9d9" }, - "limitation": "Pinned 610 firmware is used only by the pre-driver transaction. Native proprietary CPU-RM 610.43.03, 615.78.08 and 620.70.06 validated on one 8-GiB CMP40HX. The 620.70.06 tests on kernel 7.3.3 confirmed compute, numerical WMMA and runtime Gen2 after driver unload following power-on; the initramfs hook before the first NVIDIA initialization was not tested. GRID/vGPU and GSP-RM with small heap unvalidated.", + "limitation": "Pinned 610 firmware is used only by the pre-driver transaction. Native proprietary drivers 610.43.03, 615.78.08 and 620.70.06 validated on one 8-GiB CMP40HX. The 620.70.06 tests on kernel 7.3.3 confirmed compute, numerical WMMA and runtime Gen2 after driver unload following power-on; the initramfs hook before the first NVIDIA initialization was not tested. Those version-specific runs used GSP OFF. A later proprietary Linux hardware test with GSP enabled also retained compute unlock.", "cmp40hx_payloads": { "v67-tu106-stock-handoff-610.43.03.bin": "de7288bcfb80c2d4b259a59e823c926ba0a9adcab594219cc6802c94257ce271", "v67-tu106-locked-control-610.43.03.bin": "6e1f97567bc75b7389782226c73d52c07ae51d04c00fc7df975e5ec325463262" diff --git a/linux/cpu-rm/firmware/extract_boot_assets.py b/linux/preboot/firmware/extract_boot_assets.py similarity index 100% rename from linux/cpu-rm/firmware/extract_boot_assets.py rename to linux/preboot/firmware/extract_boot_assets.py diff --git a/linux/cpu-rm/firmware/fetch_artifacts.py b/linux/preboot/firmware/fetch_artifacts.py similarity index 100% rename from linux/cpu-rm/firmware/fetch_artifacts.py rename to linux/preboot/firmware/fetch_artifacts.py diff --git a/linux/cpu-rm/firmware/generate_v67.py b/linux/preboot/firmware/generate_v67.py similarity index 100% rename from linux/cpu-rm/firmware/generate_v67.py rename to linux/preboot/firmware/generate_v67.py diff --git a/linux/cpu-rm/firmware/prepare.py b/linux/preboot/firmware/prepare.py similarity index 98% rename from linux/cpu-rm/firmware/prepare.py rename to linux/preboot/firmware/prepare.py index 8c560ee..906256c 100644 --- a/linux/cpu-rm/firmware/prepare.py +++ b/linux/preboot/firmware/prepare.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0-only -"""Prepare hash-pinned CMP40HX CPU-RM firmware without installing a driver.""" +"""Prepare hash-pinned CMP40HX pre-driver firmware without installing a driver.""" from __future__ import annotations import argparse diff --git a/linux/cpu-rm/firmware/test_prepare.py b/linux/preboot/firmware/test_prepare.py similarity index 100% rename from linux/cpu-rm/firmware/test_prepare.py rename to linux/preboot/firmware/test_prepare.py diff --git a/linux/cpu-rm/gen2.sh b/linux/preboot/gen2.sh similarity index 88% rename from linux/cpu-rm/gen2.sh rename to linux/preboot/gen2.sh index 366caac..273c07e 100644 --- a/linux/cpu-rm/gen2.sh +++ b/linux/preboot/gen2.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash # SPDX-License-Identifier: GPL-2.0-only -# Explicit one-shot Gen2 policy reapplication on idle proprietary CPU-RM. +# Explicit one-shot Gen2 policy reapplication on an idle proprietary driver. set -euo pipefail -source "$(dirname -- "${BASH_SOURCE[0]}")/common.sh" usage() { echo "Usage: sudo $0 --gpu 0000:01:00.0 [--module /path/cmp40_preboot.ko]"; } -die() { printf 'cmp40 CPU-RM Gen2: %s\n' "$*" >&2; exit 1; } +die() { printf 'CMPUNLOCKER Gen2: %s\n' "$*" >&2; exit 1; } gpu='' module='' while (($#)); do case "$1" in @@ -25,10 +24,7 @@ device=/sys/bus/pci/devices/$gpu [[ -r /proc/driver/nvidia/version ]] && ! grep -q 'Open Kernel Module' /proc/driver/nvidia/version || die "requires the proprietary NVIDIA module" [[ ! -d /sys/module/nvidia_drm && ! -d /sys/module/nvidia_modeset ]] || die "stop NVIDIA display users (nvidia_drm, nvidia_modeset) before the Gen2 experiment" [[ ! -d /sys/module/cmp40_preboot ]] || die "cmp40_preboot is already loaded; inspect its result before another operation" -firmware=$(cmp40_gsp_setting) || die "cannot read NVIDIA's GSP setting from sysfs or /proc" -[[ $firmware == 0 ]] || die "requires GSP OFF" -report=$(nvidia-smi -i "$gpu" -q) || die "NVIDIA is not responding" -grep -q 'GSP Firmware Version[[:space:]]*:[[:space:]]*N/A' <<< "$report" || die "NVIDIA-SMI did not confirm GSP OFF" +nvidia-smi -i "$gpu" -q >/dev/null || die "NVIDIA is not responding" status=$(setpci -s "$gpu" CAP_EXP+12.W) [[ $status =~ ^[[:xdigit:]]{4}$ && $status != ffff ]] || die "cannot read live Link Status" # An already trained link needs only reads, even with active GPU clients. diff --git a/linux/cpu-rm/kernel/Kbuild b/linux/preboot/kernel/Kbuild similarity index 100% rename from linux/cpu-rm/kernel/Kbuild rename to linux/preboot/kernel/Kbuild diff --git a/linux/cpu-rm/kernel/Makefile b/linux/preboot/kernel/Makefile similarity index 100% rename from linux/cpu-rm/kernel/Makefile rename to linux/preboot/kernel/Makefile diff --git a/linux/cpu-rm/kernel/asset_hashes.h b/linux/preboot/kernel/asset_hashes.h similarity index 100% rename from linux/cpu-rm/kernel/asset_hashes.h rename to linux/preboot/kernel/asset_hashes.h diff --git a/linux/cpu-rm/kernel/boot.c b/linux/preboot/kernel/boot.c similarity index 100% rename from linux/cpu-rm/kernel/boot.c rename to linux/preboot/kernel/boot.c diff --git a/linux/cpu-rm/kernel/boot.h b/linux/preboot/kernel/boot.h similarity index 100% rename from linux/cpu-rm/kernel/boot.h rename to linux/preboot/kernel/boot.h diff --git a/linux/cpu-rm/kernel/diagnostic.h b/linux/preboot/kernel/diagnostic.h similarity index 69% rename from linux/cpu-rm/kernel/diagnostic.h rename to linux/preboot/kernel/diagnostic.h index 1776256..ee24efe 100644 --- a/linux/cpu-rm/kernel/diagnostic.h +++ b/linux/preboot/kernel/diagnostic.h @@ -3,12 +3,12 @@ #define TURING_UNLOCK_DIAGNOSTIC_H #ifdef __KERNEL__ #include -#define GU_NOTE(fmt, ...) pr_info("cmp40_preboot: " fmt, ##__VA_ARGS__) -#define GU_ERROR(fmt, ...) pr_err("cmp40_preboot: " fmt, ##__VA_ARGS__) +#define GU_NOTE(fmt, ...) pr_info("CMPUNLOCKER: " fmt, ##__VA_ARGS__) +#define GU_ERROR(fmt, ...) pr_err("CMPUNLOCKER: " fmt, ##__VA_ARGS__) #else #include -#define GU_NOTE(fmt, ...) fprintf(stderr, "cmp40_preboot: " fmt, ##__VA_ARGS__) -#define GU_ERROR(fmt, ...) fprintf(stderr, "cmp40_preboot: " fmt, ##__VA_ARGS__) +#define GU_NOTE(fmt, ...) fprintf(stderr, "CMPUNLOCKER: " fmt, ##__VA_ARGS__) +#define GU_ERROR(fmt, ...) fprintf(stderr, "CMPUNLOCKER: " fmt, ##__VA_ARGS__) #endif /* No extra device reads. Preserve the errno and identify the exact guard in diff --git a/linux/cpu-rm/kernel/firmware.h b/linux/preboot/kernel/firmware.h similarity index 100% rename from linux/cpu-rm/kernel/firmware.h rename to linux/preboot/kernel/firmware.h diff --git a/linux/cpu-rm/kernel/gen2.c b/linux/preboot/kernel/gen2.c similarity index 100% rename from linux/cpu-rm/kernel/gen2.c rename to linux/preboot/kernel/gen2.c diff --git a/linux/cpu-rm/kernel/gen2.h b/linux/preboot/kernel/gen2.h similarity index 88% rename from linux/cpu-rm/kernel/gen2.h rename to linux/preboot/kernel/gen2.h index 5b56e8b..fe72dcc 100644 --- a/linux/cpu-rm/kernel/gen2.h +++ b/linux/preboot/kernel/gen2.h @@ -16,7 +16,7 @@ void cmp40_gen2_snapshot(struct pci_dev *pdev, const char *phase); /* action: 0=prepare, 1=targets, 2=retrain. */ int cmp40_gen2_prepare(struct pci_dev *pdev, unsigned int action, bool windows_policy, struct cmp40_gen2_result *result); -/* Explicit diagnostic only: helper must verify idle proprietary CPU-RM first. */ +/* Explicit diagnostic only: helper must verify an idle proprietary driver first. */ int cmp40_gen2_runtime(struct pci_dev *pdev, bool windows_policy, struct cmp40_gen2_result *result); diff --git a/linux/cpu-rm/kernel/gen2_core.h b/linux/preboot/kernel/gen2_core.h similarity index 98% rename from linux/cpu-rm/kernel/gen2_core.h rename to linux/preboot/kernel/gen2_core.h index 978d7da..3197893 100644 --- a/linux/cpu-rm/kernel/gen2_core.h +++ b/linux/preboot/kernel/gen2_core.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* Shared by CPU-RM and the generated open-driver patches. No ownership changes. +/* Shared by the pre-driver module and the generated open-driver patches. No ownership changes. * Policy reference: xrip/cmp50hx-unlock b630a493b7877fbd4472113dcb960a93749c0a78. * The caller serializes access and supplies a decoded, unlocked TU106 BAR0. */ @@ -10,7 +10,7 @@ #include #ifndef CMP40_GEN2_LOG -#define CMP40_GEN2_LOG "cmp40_preboot: GEN2" +#define CMP40_GEN2_LOG "CMPUNLOCKER: GEN2" #endif #define GEN2_BAR_SIZE 0x90000 #define REG_OVR 0x8872c diff --git a/linux/cpu-rm/kernel/gfw_eval.c b/linux/preboot/kernel/gfw_eval.c similarity index 100% rename from linux/cpu-rm/kernel/gfw_eval.c rename to linux/preboot/kernel/gfw_eval.c diff --git a/linux/cpu-rm/kernel/gfw_eval.h b/linux/preboot/kernel/gfw_eval.h similarity index 100% rename from linux/cpu-rm/kernel/gfw_eval.h rename to linux/preboot/kernel/gfw_eval.h diff --git a/linux/cpu-rm/kernel/inspect.c b/linux/preboot/kernel/inspect.c similarity index 79% rename from linux/cpu-rm/kernel/inspect.c rename to linux/preboot/kernel/inspect.c index 1ed2e27..4502c43 100644 --- a/linux/cpu-rm/kernel/inspect.c +++ b/linux/preboot/kernel/inspect.c @@ -23,23 +23,23 @@ static void mmu_fault_snapshot(struct pci_dev *pdev, void __iomem *bar) addr_hi = readl(bar + base + 0x3084); inst_lo = readl(bar + base + 0x3088); inst_hi = readl(bar + base + 0x308c); - pci_info(pdev, "cmp40_preboot: SEC2_MMUFAULT status=%08x info=%08x addr=%08x:%08x inst=%08x:%08x stable=%u\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_MMUFAULT status=%08x info=%08x addr=%08x:%08x inst=%08x:%08x stable=%u\n", status, info, addr_hi, addr_lo, inst_hi, inst_lo, status == readl(bar + base + 0x3094) && info == readl(bar + base + 0x3090)); for (i = 0; i < 2; i++) { u32 offset = base + 0x3000 + i * 32; - pci_info(pdev, "cmp40_preboot: SEC2_MMUFAULT_BUFFER index=%u lo=%08x hi=%08x get=%08x put=%08x size=%08x\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_MMUFAULT_BUFFER index=%u lo=%08x hi=%08x get=%08x put=%08x size=%08x\n", i, readl(bar + offset), readl(bar + offset + 4), readl(bar + offset + 8), readl(bar + offset + 12), readl(bar + offset + 16)); } /* Adjacent security/region fields are deliberately raw: published * TU102 headers omit their semantics. Readback only, no field changes. */ - pci_info(pdev, "cmp40_preboot: SEC2_REGION_RAW 630=%08x 634=%08x 638=%08x 63c=%08x 640=%08x 644=%08x 648=%08x 64c=%08x\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_REGION_RAW 630=%08x 634=%08x 638=%08x 63c=%08x 640=%08x 644=%08x 648=%08x 64c=%08x\n", readl(bar + 0x840630), readl(bar + 0x840634), readl(bar + 0x840638), readl(bar + 0x84063c), readl(bar + 0x840640), readl(bar + 0x840644), readl(bar + 0x840648), readl(bar + 0x84064c)); - pci_info(pdev, "cmp40_preboot: MMU_REGION_RAW 81c=%08x 820=%08x 824=%08x 828=%08x 830=%08x 834=%08x 838=%08x 83c=%08x\n", + pci_info(pdev, "CMPUNLOCKER: MMU_REGION_RAW 81c=%08x 820=%08x 824=%08x 828=%08x 830=%08x 834=%08x 838=%08x 83c=%08x\n", readl(bar + 0x1fa81c), readl(bar + 0x1fa820), readl(bar + 0x1fa824), readl(bar + 0x1fa828), readl(bar + 0x1fa830), readl(bar + 0x1fa834), readl(bar + 0x1fa838), readl(bar + 0x1fa83c)); } @@ -67,32 +67,32 @@ int cmp40_inspect(struct pci_dev *pdev) ret = -EIO; goto out; } - pci_info(pdev, "cmp40_preboot: SNAPSHOT driver=%s command=%04x boot0=%08x\n", + pci_info(pdev, "CMPUNLOCKER: SNAPSHOT driver=%s command=%04x boot0=%08x\n", pdev->driver ? pdev->driver->name : "none", command, boot0); { u32 gfw_plm = readl(bar + 0x118128); u32 gfw_boot = (gfw_plm & 1) ? readl(bar + 0x118234) : ~0u; - pci_info(pdev, "cmp40_preboot: SNAPSHOT GFW_PLM=%08x GFW_BOOT=%08x\n", + pci_info(pdev, "CMPUNLOCKER: SNAPSHOT GFW_PLM=%08x GFW_BOOT=%08x\n", gfw_plm, gfw_boot); } - pci_info(pdev, "cmp40_preboot: SNAPSHOT PLM=%08x SS0=%08x READOUT=%08x SS1=%08x\n", + pci_info(pdev, "CMPUNLOCKER: SNAPSHOT PLM=%08x SS0=%08x READOUT=%08x SS1=%08x\n", readl(bar + 0x409650), readl(bar + 0x409664), readl(bar + 0x409668), readl(bar + 0x40966c)); - pci_info(pdev, "cmp40_preboot: SNAPSHOT WPR2=%08x:%08x GSP_CPUCTL=%08x SEC2_CPUCTL=%08x MB0=%08x MB1=%08x\n", + pci_info(pdev, "CMPUNLOCKER: SNAPSHOT WPR2=%08x:%08x GSP_CPUCTL=%08x SEC2_CPUCTL=%08x MB0=%08x MB1=%08x\n", readl(bar + 0x1fa828), readl(bar + 0x1fa824), readl(bar + 0x110100), readl(bar + 0x840100), readl(bar + 0x840040), readl(bar + 0x840044)); - pci_info(pdev, "cmp40_preboot: SNAPSHOT SEC2_RESET_PLM=%08x SEC2_ENGINE=%08x\n", + pci_info(pdev, "CMPUNLOCKER: SNAPSHOT SEC2_RESET_PLM=%08x SEC2_ENGINE=%08x\n", readl(bar + 0x8403c4), readl(bar + 0x8403c0)); - pci_info(pdev, "cmp40_preboot: SNAPSHOT SEC2_SCTL=%08x DEBUGINFO=%08x BOOTVEC=%08x HWCFG=%08x EXCI=%08x IMEMC=%08x DMEMC=%08x FALCON2_388=%08x\n", + pci_info(pdev, "CMPUNLOCKER: SNAPSHOT SEC2_SCTL=%08x DEBUGINFO=%08x BOOTVEC=%08x HWCFG=%08x EXCI=%08x IMEMC=%08x DMEMC=%08x FALCON2_388=%08x\n", readl(bar + 0x840240), readl(bar + 0x840094), readl(bar + 0x840104), readl(bar + 0x840108), readl(bar + 0x8400d0), readl(bar + 0x840180), readl(bar + 0x8401c0), readl(bar + 0x841388)); - pci_info(pdev, "cmp40_preboot: SNAPSHOT SEC2_FBIF_CTL=%08x TRANS0=%08x TRANS4=%08x DMACTL=%08x DMACMD=%08x IRQSTAT=%08x IRQMASK=%08x\n", + pci_info(pdev, "CMPUNLOCKER: SNAPSHOT SEC2_FBIF_CTL=%08x TRANS0=%08x TRANS4=%08x DMACTL=%08x DMACMD=%08x IRQSTAT=%08x IRQMASK=%08x\n", readl(bar + 0x840624), readl(bar + 0x840600), readl(bar + 0x840610), readl(bar + 0x84010c), readl(bar + 0x840118), readl(bar + 0x840008), readl(bar + 0x840018)); - pci_info(pdev, "cmp40_preboot: SNAPSHOT GSP_FBIF_CTL=%08x TRANS4=%08x DMACTL=%08x\n", + pci_info(pdev, "CMPUNLOCKER: SNAPSHOT GSP_FBIF_CTL=%08x TRANS4=%08x DMACTL=%08x\n", readl(bar + 0x110624), readl(bar + 0x110610), readl(bar + 0x11010c)); mmu_fault_snapshot(pdev, bar); out: @@ -119,7 +119,7 @@ int cmp40_sec2_ports(struct pci_dev *pdev) bar = ioremap(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); if (!bar) return -ENOMEM; - /* Require the exact primary wait state captured on native CPU-RM 610. */ + /* Require the exact primary wait state captured with the proprietary 610 driver and GSP disabled. */ if (readl(bar + 0x840100) != 0 || readl(bar + 0x840040) != 0xfe || readl(bar + 0x840104) != 0xfd00) { ret = -EAGAIN; @@ -133,17 +133,17 @@ int cmp40_sec2_ports(struct pci_dev *pdev) goto out_ports; } dst = ((hwcfg & 0x1ffu) - 3) << 8; - pci_info(pdev, "cmp40_preboot: SEC2_PORTS_BEGIN IMEMC=%08x DMEMC=%08x loader_dst=%08x\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_PORTS_BEGIN IMEMC=%08x DMEMC=%08x loader_dst=%08x\n", imemc, dmemc, dst); mmu_fault_snapshot(pdev, bar); - pci_info(pdev, "cmp40_preboot: SEC2_CONTEXT TRANS1=%08x INSTBLK=%08x CTL=%08x DMACTL=%08x DMACMD=%08x ACHK0=%08x:%08x ACHK1=%08x:%08x\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_CONTEXT TRANS1=%08x INSTBLK=%08x CTL=%08x DMACTL=%08x DMACMD=%08x ACHK0=%08x:%08x ACHK1=%08x:%08x\n", readl(bar + 0x840604), readl(bar + 0x840620), readl(bar + 0x840624), readl(bar + 0x84010c), readl(bar + 0x840118), readl(bar + 0x840630), readl(bar + 0x840634), readl(bar + 0x840638), readl(bar + 0x84063c)); for (i = 0; i < 3; i++) { writel(dst + i * 256, bar + 0x840180); - pci_info(pdev, "cmp40_preboot: SEC2_IMEM_TAG %04x: %08x\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_IMEM_TAG %04x: %08x\n", dst + i * 256, readl(bar + 0x840188)); } writel(1u << 25, bar + 0x8401c0); /* DMEMC AINCR at offset zero */ @@ -152,7 +152,7 @@ int cmp40_sec2_ports(struct pci_dev *pdev) for (j = 0; j < 4; j++) words[j] = readl(bar + 0x8401c4); - pci_info(pdev, "cmp40_preboot: SEC2_DMEM %04x: %08x %08x %08x %08x\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_DMEM %04x: %08x %08x %08x %08x\n", i, words[0], words[1], words[2], words[3]); } for (i = 0; i < 768; i += 16) { @@ -163,7 +163,7 @@ int cmp40_sec2_ports(struct pci_dev *pdev) writel(dst + i + j * 4, bar + 0x840180); words[j] = readl(bar + 0x840184); } - pci_info(pdev, "cmp40_preboot: SEC2_IMEM %04x: %08x %08x %08x %08x\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_IMEM %04x: %08x %08x %08x %08x\n", dst + i, words[0], words[1], words[2], words[3]); } /* The native descriptor's NS destination is IMEM 0, and the signed @@ -177,7 +177,7 @@ int cmp40_sec2_ports(struct pci_dev *pdev) writel(i + j * 4, bar + 0x840180); words[j] = readl(bar + 0x840184); } - pci_info(pdev, "cmp40_preboot: SEC2_ACR_NS %04x: %08x %08x %08x %08x\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_ACR_NS %04x: %08x %08x %08x %08x\n", i, words[0], words[1], words[2], words[3]); } writel((1u << 25) | 0x2200u, bar + 0x8401c0); @@ -186,14 +186,14 @@ int cmp40_sec2_ports(struct pci_dev *pdev) for (j = 0; j < 4; j++) words[j] = readl(bar + 0x8401c4); - pci_info(pdev, "cmp40_preboot: SEC2_ACR_DMEM %04x: %08x %08x %08x %08x\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_ACR_DMEM %04x: %08x %08x %08x %08x\n", i, words[0], words[1], words[2], words[3]); } writel(imemc, bar + 0x840180); writel(dmemc, bar + 0x8401c0); ret = (readl(bar + 0x840180) == imemc && readl(bar + 0x8401c0) == dmemc && readl(bar + 0x840100) == 0 && readl(bar + 0x840040) == 0xfe) ? 0 : -EAGAIN; - pci_info(pdev, "cmp40_preboot: SEC2_PORTS_END restored=%u CPUCTL=%08x MB0=%08x status=%d\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_PORTS_END restored=%u CPUCTL=%08x MB0=%08x status=%d\n", readl(bar + 0x840180) == imemc && readl(bar + 0x8401c0) == dmemc, readl(bar + 0x840100), readl(bar + 0x840040), ret); out_ports: @@ -235,7 +235,7 @@ int cmp40_direct_selectors(struct pci_dev *pdev) ss0 = readl(bar + 0x409664); ss1 = readl(bar + 0x40966c); readout = readl(bar + 0x409668); - pci_info(pdev, "cmp40_preboot: DIRECT_RESULT PLM=%08x SS0=%08x SS1=%08x READOUT=%08x\n", + pci_info(pdev, "CMPUNLOCKER: DIRECT_RESULT PLM=%08x SS0=%08x SS1=%08x READOUT=%08x\n", readl(bar + 0x409650), ss0, ss1, readout); if (readl(bar + 0x409650) == plm && ss0 == 0x88888888 && ss1 == 8 && !readout) { ret = 0; diff --git a/linux/cpu-rm/kernel/inspect.h b/linux/preboot/kernel/inspect.h similarity index 100% rename from linux/cpu-rm/kernel/inspect.h rename to linux/preboot/kernel/inspect.h diff --git a/linux/cpu-rm/kernel/layout.c b/linux/preboot/kernel/layout.c similarity index 100% rename from linux/cpu-rm/kernel/layout.c rename to linux/preboot/kernel/layout.c diff --git a/linux/cpu-rm/kernel/layout.h b/linux/preboot/kernel/layout.h similarity index 100% rename from linux/cpu-rm/kernel/layout.h rename to linux/preboot/kernel/layout.h diff --git a/linux/cpu-rm/kernel/main.c b/linux/preboot/kernel/main.c similarity index 85% rename from linux/cpu-rm/kernel/main.c rename to linux/preboot/kernel/main.c index ebc6b5b..ec2cb26 100644 --- a/linux/cpu-rm/kernel/main.c +++ b/linux/preboot/kernel/main.c @@ -16,7 +16,7 @@ MODULE_PARM_DESC(target, "Exact PCI address of one CMP40HX in domain:bus:slot.fu static char *mode = "inspect"; module_param(mode, charp, 0444); -MODULE_PARM_DESC(mode, "inspect/sec2_timeline: read only; sec2_ports/sec2_vm: diagnostic reads with restored ports/window; direct: SS0/SS1; unlock: Booter; gen2_runtime: explicit idle CPU-RM PCIe experiment"); +MODULE_PARM_DESC(mode, "inspect/sec2_timeline: read only; sec2_ports/sec2_vm: diagnostic reads with restored ports/window; direct: SS0/SS1; unlock: Booter; gen2_runtime: idle-driver PCIe experiment"); static bool timeline_armed; module_param(timeline_armed, bool, 0444); MODULE_PARM_DESC(timeline_armed, "Read-only SEC2 timeline is sampling; start the first native query now"); @@ -27,9 +27,12 @@ MODULE_PARM_DESC(unlock_error, "Operation errno; always check before loading NVI static bool resources_retained; module_param(resources_retained, bool, 0444); MODULE_PARM_DESC(resources_retained, "Firmware could not stop; keep module resident and power off"); -static bool cpu_rm_handoff = true; -module_param(cpu_rm_handoff, bool, 0444); -MODULE_PARM_DESC(cpu_rm_handoff, "Reset stopped SEC2, clear DMEM, restore stock FECS protection before CPU-RM"); +static bool driver_handoff = true; +module_param(driver_handoff, bool, 0444); +/* Keep existing modprobe configurations and initramfs images working. */ +module_param_named(cpu_rm_handoff, driver_handoff, bool, 0444); +MODULE_PARM_DESC(cpu_rm_handoff, "Legacy name for driver_handoff"); +MODULE_PARM_DESC(driver_handoff, "Reset stopped SEC2, clear DMEM, restore stock FECS protection before NVIDIA initialization"); static bool stock_handoff = true; module_param(stock_handoff, bool, 0444); MODULE_PARM_DESC(stock_handoff, "Use published CMP40HX GPU-side selector and stock-FECS-relock payload"); @@ -38,7 +41,7 @@ module_param(locked_control, bool, 0444); MODULE_PARM_DESC(locked_control, "Diagnostic stock-handoff control with SS0/SS1 kept zero"); static bool signed_unload; module_param(signed_unload, bool, 0444); -MODULE_PARM_DESC(signed_unload, "Diagnostic: force production Booter Unload after WPR2 teardown, before CPU-RM"); +MODULE_PARM_DESC(signed_unload, "Diagnostic: force production Booter Unload after WPR2 teardown, before NVIDIA initialization"); static bool unload_before_down; module_param(unload_before_down, bool, 0444); MODULE_PARM_DESC(unload_before_down, "Diagnostic: preserve the measured FWSEC WPR2 range in the payload, then run signed Unload before teardown"); @@ -47,7 +50,7 @@ module_param(unload_full_wpr, bool, 0444); MODULE_PARM_DESC(unload_full_wpr, "Diagnostic: substitute complete planned Booter WPR bounds, rather than FRTS-only, before signed Unload"); static bool small_wpr_heap = true; module_param(small_wpr_heap, bool, 0444); -MODULE_PARM_DESC(small_wpr_heap, "CPU-RM handoff: 1-MiB Booter WPR heap instead of 88 MiB; required for the tested proprietary path"); +MODULE_PARM_DESC(small_wpr_heap, "Driver handoff: 1-MiB Booter WPR heap instead of 88 MiB; required for the tested proprietary path"); static bool loader_control; module_param(loader_control, bool, 0444); MODULE_PARM_DESC(loader_control, "Diagnostic: run an internal DMEM marker/EXIT NS probe through the native generic SEC2 loader"); @@ -71,11 +74,11 @@ module_param(loader_boundary, uint, 0444); MODULE_PARM_DESC(loader_boundary, "Diagnostic physical NS probe: 1 last page before former WPR, 2 first WPR page, 3 first heap page"); static bool mmu_invalidate; module_param(mmu_invalidate, bool, 0444); -MODULE_PARM_DESC(mmu_invalidate, "Diagnostic: invalidate all MMU PDB/VA mappings with global ACK after quiesced CPU-RM handoff"); +MODULE_PARM_DESC(mmu_invalidate, "Diagnostic: invalidate all MMU PDB/VA mappings with global ACK after quiesced driver handoff"); static char *gen2 = "off"; module_param(gen2, charp, 0444); -MODULE_PARM_DESC(gen2, "Opt-in pre-driver Gen2 experiment: off/prepare/targets/retrain (normal CPU-RM unlock only)"); +MODULE_PARM_DESC(gen2, "Opt-in pre-driver Gen2 experiment: off/prepare/targets/retrain (pre-driver unlock only)"); static char *gen2_policy = "rmw"; module_param(gen2_policy, charp, 0444); MODULE_PARM_DESC(gen2_policy, "Gen2 register policy: rmw preserves unrelated bits; windows uses the Windows full MISC/CYA constants"); @@ -108,23 +111,23 @@ static int __init cmp40_preboot_init(void) do_gen2 = strcmp(gen2, "off") != 0; if (runtime_gen2 && strcmp(gen2, "retrain")) return -EINVAL; - if (do_gen2 && ((!runtime_gen2 && strcmp(mode, "unlock")) || !stock_handoff || !cpu_rm_handoff || + if (do_gen2 && ((!runtime_gen2 && strcmp(mode, "unlock")) || !stock_handoff || !driver_handoff || !small_wpr_heap || locked_control || signed_unload || loader_control || mmu_invalidate || unload_before_down || unload_full_wpr || loader_fb_control || loader_virtual_control || loader_native_fbif || loader_native_addresses || loader_native_physical || loader_boundary)) return -EINVAL; - if (locked_control && (strcmp(mode, "unlock") || !stock_handoff || !cpu_rm_handoff)) + if (locked_control && (strcmp(mode, "unlock") || !stock_handoff || !driver_handoff)) return -EINVAL; - if (signed_unload && (strcmp(mode, "unlock") || !stock_handoff || !cpu_rm_handoff)) + if (signed_unload && (strcmp(mode, "unlock") || !stock_handoff || !driver_handoff)) return -EINVAL; if (unload_before_down && (!signed_unload || !locked_control || loader_control)) return -EINVAL; if (unload_full_wpr && !unload_before_down) return -EINVAL; - if (!strcmp(mode, "unlock") && small_wpr_heap && (!stock_handoff || !cpu_rm_handoff || signed_unload || loader_boundary)) + if (!strcmp(mode, "unlock") && small_wpr_heap && (!stock_handoff || !driver_handoff || signed_unload || loader_boundary)) return -EINVAL; - if (loader_control && (signed_unload || strcmp(mode, "unlock") || !stock_handoff || !cpu_rm_handoff)) + if (loader_control && (signed_unload || strcmp(mode, "unlock") || !stock_handoff || !driver_handoff)) return -EINVAL; if (loader_fb_control && (!loader_control || !locked_control || signed_unload)) return -EINVAL; @@ -138,7 +141,7 @@ static int __init cmp40_preboot_init(void) return -EINVAL; if (loader_boundary > 3 || (loader_boundary && (!loader_fb_control || loader_virtual_control || loader_native_addresses || loader_native_physical))) return -EINVAL; - if (mmu_invalidate && (strcmp(mode, "unlock") || !stock_handoff || !cpu_rm_handoff)) + if (mmu_invalidate && (strcmp(mode, "unlock") || !stock_handoff || !driver_handoff)) return -EINVAL; while ((pdev = pci_get_device(PCI_VENDOR_ID_NVIDIA, 0x1f0b, pdev))) if (!strcmp(pci_name(pdev), target)) @@ -166,7 +169,7 @@ static int __init cmp40_preboot_init(void) goto out; } if (unlock && pdev->driver) { - pci_err(pdev, "cmp40_preboot: refusing unlock while driver %s owns the card\n", + pci_err(pdev, "CMPUNLOCKER: refusing unlock while driver %s owns the card\n", pdev->driver->name); ret = -EBUSY; goto out; @@ -175,13 +178,13 @@ static int __init cmp40_preboot_init(void) struct cmp40_gen2_result result; /* No firmware runs, DMA allocation, detach, PCI enable or FLR here. - * The external diagnostic helper checks idle proprietary GSP OFF; + * The external diagnostic helper checks the proprietary driver and its clients; * gen2.c additionally requires halted GSP and full selectors. */ gen2_error = cmp40_gen2_runtime(pdev, !strcmp(gen2_policy, "windows"), &result); gen2_device_ok = result.device_ok; gen2_link_status = result.link_status; - pci_info(pdev, "cmp40_preboot: GEN2_RUNTIME_RESULT error=%d device_ok=%u status=%04x\n", + pci_info(pdev, "CMPUNLOCKER: GEN2_RUNTIME_RESULT error=%d device_ok=%u status=%04x\n", gen2_error, gen2_device_ok, gen2_link_status); ret = 0; } else if (!strcmp(mode, "sec2_timeline")) { @@ -195,28 +198,28 @@ static int __init cmp40_preboot_init(void) } else if (!strcmp(mode, "sec2_vm")) { ret = cmp40_sec2_vm(pdev); if (!ret) - pci_info(pdev, "cmp40_preboot: SEC2_VM_CAPTURE (window restored; see walk_status)\n"); + pci_info(pdev, "CMPUNLOCKER: SEC2_VM_CAPTURE (window restored; see walk_status)\n"); } else if (!strcmp(mode, "sec2_ports")) { ret = cmp40_sec2_ports(pdev); if (!ret) - pci_info(pdev, "cmp40_preboot: SEC2_PORTS_PASS (index ports restored; memory unchanged)\n"); + pci_info(pdev, "CMPUNLOCKER: SEC2_PORTS_PASS (index ports restored; memory unchanged)\n"); } else if (!unlock) { ret = cmp40_inspect(pdev); if (!ret) cmp40_gen2_snapshot(pdev, "inspect"); if (!ret) - pci_info(pdev, "cmp40_preboot: INSPECT_PASS (no writes)\n"); + pci_info(pdev, "CMPUNLOCKER: INSPECT_PASS (no writes)\n"); } else if (!strcmp(mode, "direct")) { ret = cmp40_direct_selectors(pdev); if (!ret) - pci_info(pdev, "cmp40_preboot: PRE_DRIVER_DIRECT_PASS (driver compatibility untested)\n"); + pci_info(pdev, "CMPUNLOCKER: PRE_DRIVER_DIRECT_PASS (driver compatibility untested)\n"); } else { if (do_gen2) cmp40_gen2_snapshot(pdev, "before_compute"); - ret = turing_unlock_card(pdev, &resources_retained, cpu_rm_handoff, + ret = turing_unlock_card(pdev, &resources_retained, driver_handoff, stock_handoff, locked_control, signed_unload, loader_control, mmu_invalidate, unload_before_down, loader_fb_control, loader_virtual_control, loader_native_fbif, loader_native_addresses, loader_native_physical, loader_boundary, unload_full_wpr, small_wpr_heap); if (!ret) - pci_info(pdev, "cmp40_preboot: PRE_DRIVER_%s_PASS (verify native driver and workload next)\n", + pci_info(pdev, "CMPUNLOCKER: PRE_DRIVER_%s_PASS (verify native driver and workload next)\n", locked_control ? "CONTROL" : "UNLOCK"); /* turing_unlock_card has already freed DMA and restored device state. * Keep link errors out of its FLR cleanup and unlock_error entirely. @@ -229,7 +232,7 @@ static int __init cmp40_preboot_init(void) !strcmp(gen2_policy, "windows"), &result); gen2_device_ok = result.device_ok; gen2_link_status = result.link_status; - pci_info(pdev, "cmp40_preboot: GEN2_RESULT error=%d device_ok=%u status=%04x\n", + pci_info(pdev, "CMPUNLOCKER: GEN2_RESULT error=%d device_ok=%u status=%04x\n", gen2_error, gen2_device_ok, gen2_link_status); } } @@ -247,7 +250,7 @@ static int __init cmp40_preboot_init(void) * Keep this pinned module alive while firmware still owns DMA buffers. * This is a recorded failure, never a successful unlock. */ - pr_err("cmp40_preboot: RETAINED_ERROR errno=%d; power off before loading a GPU driver\n", ret); + pr_err("CMPUNLOCKER: RETAINED_ERROR errno=%d; power off before loading a GPU driver\n", ret); return 0; } return ret; @@ -261,5 +264,5 @@ static void __exit cmp40_preboot_exit(void) module_init(cmp40_preboot_init); module_exit(cmp40_preboot_exit); MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("CMP40HX CPU-RM pre-driver unlock and inspection"); +MODULE_DESCRIPTION("CMP40HX pre-driver unlock and inspection"); MODULE_VERSION("0.17.0"); diff --git a/linux/cpu-rm/kernel/prep.c b/linux/preboot/kernel/prep.c similarity index 100% rename from linux/cpu-rm/kernel/prep.c rename to linux/preboot/kernel/prep.c diff --git a/linux/cpu-rm/kernel/prep.h b/linux/preboot/kernel/prep.h similarity index 100% rename from linux/cpu-rm/kernel/prep.h rename to linux/preboot/kernel/prep.h diff --git a/linux/cpu-rm/kernel/timeline.c b/linux/preboot/kernel/timeline.c similarity index 83% rename from linux/cpu-rm/kernel/timeline.c rename to linux/preboot/kernel/timeline.c index a0835c3..9bb912b 100644 --- a/linux/cpu-rm/kernel/timeline.c +++ b/linux/preboot/kernel/timeline.c @@ -84,7 +84,7 @@ static void dump(const char *kind, u32 index, const struct tl_record *r) { /* One line per record keeps a parseable bounded log. Values are raw. */ - timeline_length += scnprintf(timeline_log + timeline_length, TL_LOG_SIZE - timeline_length, "cmp40_preboot: SEC2_TIMELINE_%s index=%u begin_ns=%llu end_ns=%llu ctl=%08x fault=%08x cpu=%08x mb0=%08x mb1=%08x trans1=%08x dma=%08x irq=%08x wpr_lo=%08x wpr_hi=%08x current=%08x next=%08x pause=%08x inst=%08x sctl=%08x gsp_cpu=%08x bootvec=%08x engine=%08x reset_plm=%08x r630=%08x r634=%08x r638=%08x r63c=%08x r640=%08x r644=%08x r648=%08x r64c=%08x ctl_again=%08x fault_again=%08x\n", + timeline_length += scnprintf(timeline_log + timeline_length, TL_LOG_SIZE - timeline_length, "CMPUNLOCKER: SEC2_TIMELINE_%s index=%u begin_ns=%llu end_ns=%llu ctl=%08x fault=%08x cpu=%08x mb0=%08x mb1=%08x trans1=%08x dma=%08x irq=%08x wpr_lo=%08x wpr_hi=%08x current=%08x next=%08x pause=%08x inst=%08x sctl=%08x gsp_cpu=%08x bootvec=%08x engine=%08x reset_plm=%08x r630=%08x r634=%08x r638=%08x r63c=%08x r640=%08x r644=%08x r648=%08x r64c=%08x ctl_again=%08x fault_again=%08x\n", kind, index, r->begin_ns, r->end_ns, r->values[0], r->values[1], r->values[2], r->values[3], r->values[4], r->values[5], r->values[6], r->values[7], @@ -130,9 +130,9 @@ int cmp40_sec2_timeline(struct pci_dev *pdev, bool *armed) goto unmap; } start_ns = ktime_get_ns(); - timeline_length += scnprintf(timeline_log + timeline_length, TL_LOG_SIZE - timeline_length, "cmp40_preboot: SEC2_TIMELINE_BEGIN start_ns=%llu duration_ns=%llu capacity=%u sleep_min_us=100 sleep_max_us=200 gpu_writes=0\n", + timeline_length += scnprintf(timeline_log + timeline_length, TL_LOG_SIZE - timeline_length, "CMPUNLOCKER: SEC2_TIMELINE_BEGIN start_ns=%llu duration_ns=%llu capacity=%u sleep_min_us=100 sleep_max_us=200 gpu_writes=0\n", start_ns, TL_DURATION_NS, TL_CAPACITY); - pci_info(pdev, "cmp40_preboot: SEC2_TIMELINE_BEGIN start_ns=%llu duration_ns=%llu capacity=%u sleep_min_us=100 sleep_max_us=200 gpu_writes=0\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_TIMELINE_BEGIN start_ns=%llu duration_ns=%llu capacity=%u sleep_min_us=100 sleep_max_us=200 gpu_writes=0\n", start_ns, TL_DURATION_NS, TL_CAPACITY); /* Sysfs parameters exist during module_init. Publish only once all * guards/allocation/mapping have succeeded. The wrapper waits for Y. @@ -156,9 +156,9 @@ int cmp40_sec2_timeline(struct pci_dev *pdev, bool *armed) for (i = 0; i < count; i++) dump("CHANGE", i, &records[i]); dump("LAST", samples - 1, &latest); - timeline_length += scnprintf(timeline_log + timeline_length, TL_LOG_SIZE - timeline_length, "cmp40_preboot: SEC2_TIMELINE_END start_ns=%llu finish_ns=%llu samples=%u changes=%u stored=%u dropped=%u gpu_writes=0\n", + timeline_length += scnprintf(timeline_log + timeline_length, TL_LOG_SIZE - timeline_length, "CMPUNLOCKER: SEC2_TIMELINE_END start_ns=%llu finish_ns=%llu samples=%u changes=%u stored=%u dropped=%u gpu_writes=0\n", start_ns, finish_ns, samples, changes, count, dropped); - pci_info(pdev, "cmp40_preboot: SEC2_TIMELINE_END start_ns=%llu finish_ns=%llu samples=%u changes=%u stored=%u dropped=%u gpu_writes=0\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_TIMELINE_END start_ns=%llu finish_ns=%llu samples=%u changes=%u stored=%u dropped=%u gpu_writes=0\n", start_ns, finish_ns, samples, changes, count, dropped); timeline_attr.size = timeline_length; ret = sysfs_create_bin_file(&THIS_MODULE->mkobj.kobj, &timeline_attr); diff --git a/linux/cpu-rm/kernel/unlock.c b/linux/preboot/kernel/unlock.c similarity index 98% rename from linux/cpu-rm/kernel/unlock.c rename to linux/preboot/kernel/unlock.c index 3d3fd95..22aa591 100644 --- a/linux/cpu-rm/kernel/unlock.c +++ b/linux/preboot/kernel/unlock.c @@ -48,7 +48,7 @@ #define TU_V67_SIZE 0xfa00u #define TU_SEC2_BL_SIZE 768u -/* Transient coherent-sysmem staging must not leak into native CPU-RM. */ +/* Transient coherent-sysmem staging must not leak into the native driver. */ static const u32 tu_fbif_offsets[] = { GSP_FBIF + 0x24, GSP_FBIF + 4 * 4, SEC_FBIF + 0x24, SEC_FBIF, SEC_FBIF + 1 * 4, SEC_FBIF + 4 * 4, @@ -952,7 +952,7 @@ static int preserve_wpr_before_unload(struct tu_work *w) * Mirror the existing cmpunlocker handoff: a stopped fresh SEC2, empty DMEM, * a host-reset window, and stock FECS protection over the unlocked selectors. */ -static int prepare_cpu_rm_handoff(struct tu_work *w) +static int prepare_driver_handoff(struct tu_work *w) { u32 i, reset_plm; int ret; @@ -960,7 +960,7 @@ static int prepare_cpu_rm_handoff(struct tu_work *w) if (!(rd(w, SEC_BASE + 0x100) & (1u << 4))) return GU_DIAG(-EBUSY); reset_plm = rd(w, SEC_BASE + 0x3c4); - GU_NOTE("CPU-RM handoff before: reset_plm=%#x wpr2=%#x:%#x\n", + GU_NOTE("handoff before: reset_plm=%#x wpr2=%#x:%#x\n", reset_plm, rd(w, 0x1fa828), rd(w, 0x1fa824)); wr(w, SEC_BASE + 0x3c4, 0xff); if (rd(w, SEC_BASE + 0x3c4) != 0xff) @@ -983,7 +983,7 @@ static int prepare_cpu_rm_handoff(struct tu_work *w) /* Only privileged firmware can restore all stock permission bits. */ if (!w->stock_handoff) wr(w, TU_FEAT_PLM, TU_FEAT_PLM_STOCK); - GU_NOTE("CPU-RM handoff observed: FECS_PLM=%#x SS0=%#x SS1=%#x READOUT=%#x WPR2=%#x:%#x\n", + GU_NOTE("handoff observed: FECS_PLM=%#x SS0=%#x SS1=%#x READOUT=%#x WPR2=%#x:%#x\n", rd(w, TU_FEAT_PLM), rd(w, TU_FEAT_SS0), rd(w, TU_FEAT_SS1), rd(w, TU_FEAT_READOUT), rd(w, 0x1fa828), rd(w, 0x1fa824)); if (rd(w, TU_FEAT_PLM) != TU_FEAT_PLM_STOCK || @@ -992,7 +992,7 @@ static int prepare_cpu_rm_handoff(struct tu_work *w) rd(w, TU_FEAT_READOUT) != w->expected_readout || rd(w, 0x1fa828) || (w->stock_handoff && rd(w, 0x1fa824) != TU_WPR2_LO_DOWN)) return GU_DIAG(-EIO); - GU_NOTE("CPU-RM handoff verified: FECS_PLM=%#x RESET_PLM=%#x SEC2_CPUCTL=%#x DMEM=zero WPR2=%#x:%#x\n", + GU_NOTE("handoff verified: FECS_PLM=%#x RESET_PLM=%#x SEC2_CPUCTL=%#x DMEM=zero WPR2=%#x:%#x\n", rd(w, TU_FEAT_PLM), rd(w, SEC_BASE + 0x3c4), rd(w, SEC_BASE + 0x100), rd(w, 0x1fa828), rd(w, 0x1fa824)); return 0; @@ -1135,7 +1135,7 @@ static int tu_flr(struct tu_work *w) return 0; } -int turing_unlock_card(struct pci_dev *pdev, bool *retained, bool cpu_rm_handoff, +int turing_unlock_card(struct pci_dev *pdev, bool *retained, bool driver_handoff, bool stock_handoff, bool locked_control, bool signed_unload, bool loader_control, bool mmu_invalidate, bool unload_before_down, bool loader_fb_control, bool loader_virtual_control, @@ -1489,9 +1489,9 @@ int turing_unlock_card(struct pci_dev *pdev, bool *retained, bool cpu_rm_handoff ret = run_signed_unload(w); if (!ret && loader_control) ret = run_ns_loader_control(w); - if (!ret && cpu_rm_handoff) - ret = prepare_cpu_rm_handoff(w); - if (!ret && cpu_rm_handoff && stock_handoff) + if (!ret && driver_handoff) + ret = prepare_driver_handoff(w); + if (!ret && driver_handoff && stock_handoff) ret = restore_staging_fbif(w); if (!ret && mmu_invalidate) ret = invalidate_mmu_handoff(w); @@ -1504,7 +1504,7 @@ int turing_unlock_card(struct pci_dev *pdev, bool *retained, bool cpu_rm_handoff if (!firmware_quiesced(w)) { w->retained = true; *retained = true; - pci_err(pdev, "cmp40_preboot: firmware did not stop; retaining DMA resources until power off\n"); + pci_err(pdev, "CMPUNLOCKER: firmware did not stop; retaining DMA resources until power off\n"); __module_get(THIS_MODULE); if (!ret) ret = -EBUSY; diff --git a/linux/cpu-rm/kernel/unlock.h b/linux/preboot/kernel/unlock.h similarity index 97% rename from linux/cpu-rm/kernel/unlock.h rename to linux/preboot/kernel/unlock.h index a93de3a..7baf846 100644 --- a/linux/cpu-rm/kernel/unlock.h +++ b/linux/preboot/kernel/unlock.h @@ -6,7 +6,7 @@ struct pci_dev; -int turing_unlock_card(struct pci_dev *pdev, bool *retained, bool cpu_rm_handoff, +int turing_unlock_card(struct pci_dev *pdev, bool *retained, bool driver_handoff, bool stock_handoff, bool locked_control, bool signed_unload, bool loader_control, bool mmu_invalidate, bool unload_before_down, bool loader_fb_control, bool loader_virtual_control, diff --git a/linux/cpu-rm/kernel/vbios.c b/linux/preboot/kernel/vbios.c similarity index 100% rename from linux/cpu-rm/kernel/vbios.c rename to linux/preboot/kernel/vbios.c diff --git a/linux/cpu-rm/kernel/vbios.h b/linux/preboot/kernel/vbios.h similarity index 100% rename from linux/cpu-rm/kernel/vbios.h rename to linux/preboot/kernel/vbios.h diff --git a/linux/cpu-rm/kernel/vm_inspect.c b/linux/preboot/kernel/vm_inspect.c similarity index 91% rename from linux/cpu-rm/kernel/vm_inspect.c rename to linux/preboot/kernel/vm_inspect.c index 3eb68d3..6789053 100644 --- a/linux/cpu-rm/kernel/vm_inspect.c +++ b/linux/preboot/kernel/vm_inspect.c @@ -52,7 +52,7 @@ static int vm_dump_target(struct vm_view *v, const char *name, u64 addr, u32 at; int ret = vm_read_target(v, addr, out, size, target); - pci_info(v->pdev, "cmp40_preboot: SEC2_VM_BLOB %s addr=%#llx size=%#x status=%d\n", + pci_info(v->pdev, "CMPUNLOCKER: SEC2_VM_BLOB %s addr=%#llx size=%#x status=%d\n", name, (unsigned long long)addr, size, ret); if (ret) return ret; @@ -64,10 +64,10 @@ static int vm_dump_target(struct vm_view *v, const char *name, u64 addr, u8 *p = (u8 *)out + at; if (bytes > 64) - pci_info(v->pdev, "cmp40_preboot: SEC2_VM_HEX %s %04x: %*phN%*phN\n", + pci_info(v->pdev, "CMPUNLOCKER: SEC2_VM_HEX %s %04x: %*phN%*phN\n", name, at, 64, p, bytes - 64, p + 64); else - pci_info(v->pdev, "cmp40_preboot: SEC2_VM_HEX %s %04x: %*phN\n", + pci_info(v->pdev, "CMPUNLOCKER: SEC2_VM_HEX %s %04x: %*phN\n", name, at, bytes, p); } return 0; @@ -109,7 +109,7 @@ static int vm_range(struct vm_view *v, const char *name, u32 va, u32 size, bytes = min(bytes, page_size - (page_va & (page_size - 1))); addr = vm_entry_addr(entry) + (page_va & (page_size - 1)); snprintf(label, sizeof(label), "%s_%04x", name, at); - pci_info(v->pdev, "cmp40_preboot: SEC2_VM_MAP %s offset=%#x va=%#x pte=%08x:%08x phys=%#llx size=%#x\n", + pci_info(v->pdev, "CMPUNLOCKER: SEC2_VM_MAP %s offset=%#x va=%#x pte=%08x:%08x phys=%#llx size=%#x\n", name, at, page_va, (u32)(entry >> 32), (u32)entry, (unsigned long long)addr, bytes); ret = vm_dump(v, label, addr, buf, bytes); @@ -139,7 +139,7 @@ static int vm_walk(struct vm_view *v, u32 *buf) lo = buf[128]; hi = buf[129]; addr = ((u64)hi << 32) | (lo & 0xfffff000u); - pci_info(v->pdev, "cmp40_preboot: SEC2_VM_PDB record=%08x:%08x addr=%#llx new_pt=%u target=%u\n", + pci_info(v->pdev, "CMPUNLOCKER: SEC2_VM_PDB record=%08x:%08x addr=%#llx new_pt=%u target=%u\n", hi, lo, (unsigned long long)addr, !!(lo & (1u << 10)), lo & 3); if (!(lo & (1u << 10)) || (lo & 3) || !addr || addr >= VM_FB_SIZE) return -EOPNOTSUPP; @@ -203,7 +203,7 @@ static int vm_fault(struct vm_view *v, u32 *buf) get = readl(v->bar + base + 0x3008); put = readl(v->bar + base + 0x300c); size = readl(v->bar + base + 0x3010); - pci_info(v->pdev, "cmp40_preboot: SEC2_VM_FAULT_BEGIN bar2=%08x buffer=%08x:%08x get=%08x put=%08x size=%08x\n", + pci_info(v->pdev, "CMPUNLOCKER: SEC2_VM_FAULT_BEGIN bar2=%08x buffer=%08x:%08x get=%08x put=%08x size=%08x\n", bar2, hi, lo, get, put, size); /* Buffer bases are BAR2 virtual addresses, not physical FB addresses: * kgmmuEnableFaultBuffer_GV100 writes bar2FaultBufferAddr. Follow the @@ -257,7 +257,7 @@ static int vm_fault(struct vm_view *v, u32 *buf) return -EOPNOTSUPP; addr = target ? ((entry >> 8) & 0x3fffffffffffull) << 12 : vm_entry_addr(entry); addr += va & (small ? 0xfff : 0xffff); - pci_info(v->pdev, "cmp40_preboot: SEC2_VM_FAULT_MAP va=%#llx pte=%08x:%08x target=%u phys=%#llx\n", + pci_info(v->pdev, "CMPUNLOCKER: SEC2_VM_FAULT_MAP va=%#llx pte=%08x:%08x target=%u phys=%#llx\n", (unsigned long long)va, (u32)(entry >> 32), (u32)entry, target, (unsigned long long)addr); ret = vm_dump_target(v, "FAULT_RECORD", addr, buf, 32, target); @@ -300,17 +300,17 @@ int cmp40_sec2_vm(struct pci_dev *pdev) if (v.saved_window == ~0u || (v.saved_window & 0xffff0000u) == 0xbadf0000u) goto out; instance_before = readl(v.bar + 0x840620); - pci_info(pdev, "cmp40_preboot: SEC2_VM_BEGIN window=%08x INSTBLK=%08x CHANNEL_CUR=%08x CHANNEL_NEXT=%08x STATUS_PAUSE=%08x\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_VM_BEGIN window=%08x INSTBLK=%08x CHANNEL_CUR=%08x CHANNEL_NEXT=%08x STATUS_PAUSE=%08x\n", v.saved_window, instance_before, readl(v.bar + 0x840050), readl(v.bar + 0x840054), readl(v.bar + 0x84005c)); walk_status = vm_walk(&v, buf); fault_status = vm_fault(&v, buf); - pci_info(pdev, "cmp40_preboot: SEC2_VM_FAULT_END status=%d\n", fault_status); + pci_info(pdev, "CMPUNLOCKER: SEC2_VM_FAULT_END status=%d\n", fault_status); writel(v.saved_window, v.bar + VM_WINDOW); ret = (readl(v.bar + VM_WINDOW) == v.saved_window && readl(v.bar + 0x840620) == instance_before && readl(v.bar + 0x840100) == 0 && readl(v.bar + 0x840040) == 0xfe) ? 0 : -EAGAIN; - pci_info(pdev, "cmp40_preboot: SEC2_VM_END window_restored=%u stable=%u walk_status=%d\n", + pci_info(pdev, "CMPUNLOCKER: SEC2_VM_END window_restored=%u stable=%u walk_status=%d\n", readl(v.bar + VM_WINDOW) == v.saved_window, !ret, walk_status); out: iounmap(v.bar); diff --git a/linux/cpu-rm/licenses/CMPUNLOCKER-MIT.txt b/linux/preboot/licenses/CMPUNLOCKER-MIT.txt similarity index 96% rename from linux/cpu-rm/licenses/CMPUNLOCKER-MIT.txt rename to linux/preboot/licenses/CMPUNLOCKER-MIT.txt index 5f79cc3..94ecc5c 100644 --- a/linux/cpu-rm/licenses/CMPUNLOCKER-MIT.txt +++ b/linux/preboot/licenses/CMPUNLOCKER-MIT.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2026 Cyridd +Copyright (c) 2026 CMP unlock project Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linux/cpu-rm/licenses/GPL-2.0.txt b/linux/preboot/licenses/GPL-2.0.txt similarity index 100% rename from linux/cpu-rm/licenses/GPL-2.0.txt rename to linux/preboot/licenses/GPL-2.0.txt diff --git a/linux/cpu-rm/licenses/NVIDIA-MIT.txt b/linux/preboot/licenses/NVIDIA-MIT.txt similarity index 100% rename from linux/cpu-rm/licenses/NVIDIA-MIT.txt rename to linux/preboot/licenses/NVIDIA-MIT.txt diff --git a/linux/cpu-rm/mkinitcpio/cmp40-unlock b/linux/preboot/mkinitcpio/cmp40-unlock similarity index 95% rename from linux/cpu-rm/mkinitcpio/cmp40-unlock rename to linux/preboot/mkinitcpio/cmp40-unlock index 2de8595..d529e5a 100644 --- a/linux/cpu-rm/mkinitcpio/cmp40-unlock +++ b/linux/preboot/mkinitcpio/cmp40-unlock @@ -100,8 +100,8 @@ modprobe -n cmp40_preboot >/dev/null 2>&1 || skip "cmp40_preboot is not availabl # Leave the guard installed if modprobe, the wrapper or the service is interrupted. block_drivers || fail "could not install the driver block; unlock was not attempted" -msg 6 "unlocking $gpu (CPU-RM, stock handoff, small WPR heap)" -modprobe cmp40_preboot target="$gpu" mode=unlock cpu_rm_handoff=1 stock_handoff=1 small_wpr_heap=1 \ +msg 6 "unlocking $gpu (stock handoff, small WPR heap)" +modprobe cmp40_preboot target="$gpu" mode=unlock driver_handoff=1 stock_handoff=1 small_wpr_heap=1 \ gen2=off gen2_policy=rmw || fail "modprobe cmp40_preboot failed for $gpu" p=/sys/module/cmp40_preboot/parameters @@ -114,7 +114,7 @@ SCRIPT add_file - /usr/lib/systemd/system/cmp40-unlock.service 644 <<'UNIT' || return 1 [Unit] -Description=CMP 40HX CPU-RM pre-driver unlock +Description=CMP 40HX pre-driver unlock DefaultDependencies=no ConditionKernelCommandLine=!cmp40.skip Before=systemd-modules-load.service systemd-udevd.service systemd-udev-trigger.service sysinit.target @@ -133,7 +133,7 @@ UNIT help() { cat <<'HELPEOF' -Runs the CMP 40HX CPU-RM compute unlock before systemd loads modules or starts +Runs the CMP 40HX compute unlock before systemd loads modules or starts udev. Requires base and systemd; place it after modconf and after autodetect when autodetect is present. Do not list cmp40_preboot in MODULES. diff --git a/linux/cpu-rm/test_offline.c b/linux/preboot/test_offline.c similarity index 100% rename from linux/cpu-rm/test_offline.c rename to linux/preboot/test_offline.c diff --git a/linux/cpu-rm/tests/gen2_shim.h b/linux/preboot/tests/gen2_shim.h similarity index 100% rename from linux/cpu-rm/tests/gen2_shim.h rename to linux/preboot/tests/gen2_shim.h diff --git a/linux/cpu-rm/tests/run_gen2.py b/linux/preboot/tests/run_gen2.py similarity index 100% rename from linux/cpu-rm/tests/run_gen2.py rename to linux/preboot/tests/run_gen2.py diff --git a/linux/preboot/tests/run_helpers.py b/linux/preboot/tests/run_helpers.py new file mode 100644 index 0000000..552f954 --- /dev/null +++ b/linux/preboot/tests/run_helpers.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-only +"""Exercise the driver helpers with private sysfs and command fixtures.""" +from pathlib import Path +import subprocess +import tempfile + +source = Path(__file__).resolve().parents[1] / "common.sh" +with tempfile.TemporaryDirectory(prefix="cmp40-gsp-test-") as directory: + root = Path(directory) + sys_file, proc_file = root / "sys-param", root / "proc-params" + for sys_value, proc_value, expected in ( + ("0\n", "EnableGpuFirmware: 1\n", "0"), + ("1\n", "EnableGpuFirmware: 0\n", "1"), + (None, "OtherParam: 1\nEnableGpuFirmware: 0\n", "0"), + (None, "EnableGpuFirmware: 1\n", "1"), + (None, "OtherParam: 0\n", None), + (None, None, None), + ): + for path, value in ((sys_file, sys_value), (proc_file, proc_value)): + if value is None: + path.unlink(missing_ok=True) + else: + path.write_text(value) + result = subprocess.run( + ["bash", "-c", 'source "$1"; cmp40_gsp_setting "$2" "$3"', + "test", str(source), str(sys_file), str(proc_file)], + capture_output=True, text=True, check=False, + ) + if expected is None: + assert result.returncode != 0, result + else: + assert result.returncode == 0 and result.stdout.strip() == expected, result +print("GSP setting reader: 6 stock/GRID cases passed") + +# Run the manual helper against a private sysfs tree. Record all modprobe +# arguments so an explicit GSP override fails the test even if it is zero. +unlock = (source.parent / "unlock.sh").read_text() +unlock = unlock.replace("/sys/", "./sys/").replace("((EUID == 0))", "true") +mocks = """ +modinfo() { echo NVIDIA; } +modprobe() { + echo "$*" >> calls + if [[ $1 == cmp40_preboot ]]; then + mkdir -p sys/module/cmp40_preboot/parameters + echo 0 > sys/module/cmp40_preboot/parameters/unlock_error + echo N > sys/module/cmp40_preboot/parameters/resources_retained + fi +} +""" +for load_nvidia in (False, True): + with tempfile.TemporaryDirectory(prefix="cmp40-unlock-test-") as directory: + root = Path(directory) + gpu = "0000:01:00.0" + device = root / "sys/bus/pci/devices" / gpu + device.mkdir(parents=True) + (device / "vendor").write_text("0x10de\n") + (device / "device").write_text("0x1f0b\n") + args = ["--gpu", gpu] + if load_nvidia: + args.append("--load-nvidia") + subprocess.run(["bash", "-c", mocks + unlock, "unlock.sh", *args], + cwd=root, capture_output=True, text=True, check=True) + calls = (root / "calls").read_text().splitlines() + assert calls[0].startswith("cmp40_preboot ") + assert calls[1:] == (["nvidia"] if load_nvidia else []), calls +print("Manual unlock helper: optional NVIDIA load preserves modprobe policy") + +# Exercise the Gen2 shell preflight without a GPU or a loadable kernel module. +gen2 = (source.parent / "gen2.sh").read_text() +gen2 = gen2.replace("/sys/", "./sys/").replace("/proc/", "./proc/").replace("((EUID == 0))", "true") +gen2_mocks = """ +nvidia-smi() { [[ $1 == -i && $3 == -q && $driver_health == ok ]] || return 1; echo "$report"; } +setpci() { echo "$link"; } +modinfo() { echo fixture; } +modprobe() { return 1; } +insmod() { return 1; } +rmmod() { return 1; } +fuser() { return 1; } +""" +with tempfile.TemporaryDirectory(prefix="cmp40-gen2-helper-") as directory: + root = Path(directory) + gpu = "0000:01:00.0" + device = root / "sys/bus/pci/devices" / gpu + device.mkdir(parents=True) + (device / "vendor").write_text("0x10de\n") + (device / "device").write_text("0x1f0b\n") + (device / "driver").symlink_to("nvidia") + version = root / "proc/driver/nvidia/version" + version.parent.mkdir(parents=True) + version.write_text("NVIDIA proprietary driver\n") + for report in ("GSP Firmware Version : N/A", "GSP Firmware Version : 620.70.06", ""): + for health, link, expected in ( + ("ok", "0102", "already has an active Gen2 link"), + ("ok", "0101", "pre-driver module/kernel mismatch"), + ("failed", "0102", "NVIDIA is not responding"), + ): + wrapper = 'report=$1; driver_health=$2; link=$3; shift 3\n' + gen2_mocks + gen2 + result = subprocess.run(["bash", "-c", wrapper, "gen2.sh", report, health, link, "--gpu", gpu], + cwd=root, capture_output=True, text=True) + assert (result.returncode == 0) == (health == "ok" and link == "0102"), result + assert expected in result.stdout + result.stderr, result +print("Gen2 helper: 9 driver health and link cases passed without GSP settings") diff --git a/linux/cpu-rm/tests/run_mkinitcpio.py b/linux/preboot/tests/run_mkinitcpio.py similarity index 100% rename from linux/cpu-rm/tests/run_mkinitcpio.py rename to linux/preboot/tests/run_mkinitcpio.py diff --git a/linux/cpu-rm/tests/test_gen2.c b/linux/preboot/tests/test_gen2.c similarity index 100% rename from linux/cpu-rm/tests/test_gen2.c rename to linux/preboot/tests/test_gen2.c diff --git a/linux/cpu-rm/unlock.sh b/linux/preboot/unlock.sh similarity index 83% rename from linux/cpu-rm/unlock.sh rename to linux/preboot/unlock.sh index 12539bd..1404d0d 100644 --- a/linux/cpu-rm/unlock.sh +++ b/linux/preboot/unlock.sh @@ -2,12 +2,11 @@ # SPDX-License-Identifier: GPL-2.0-only # Explicit pre-driver unlock. No unbind, reset, PCI rescan or background task. set -euo pipefail -source "$(dirname -- "${BASH_SOURCE[0]}")/common.sh" usage() { echo "Usage: sudo $0 --gpu 0000:01:00.0 [--load-nvidia] [--gen2 prepare|targets|retrain] [--gen2-policy rmw|windows]" echo "The target must be an unbound 10de:1f0b; firmware/module must be installed." } -die() { echo "cmp40 CPU-RM: $*" >&2; exit 1; } +die() { echo "cmpunlocker: $*" >&2; exit 1; } gpu='' load_nvidia=0 gen2=off gen2_policy=rmw while (($#)); do case "$1" in @@ -26,14 +25,14 @@ done ((EUID == 0)) || die "run as root" device=/sys/bus/pci/devices/$gpu [[ -d $device ]] || die "PCI device $gpu does not exist" -[[ $(cat "$device/vendor") == 0x10de && $(cat "$device/device") == 0x1f0b ]] || die "target is not CMP40HX (10de:1f0b)" +[[ $(cat "$device/vendor") == 0x10de && $(cat "$device/device") == 0x1f0b ]] || die "target is not CMP 40HX (10de:1f0b)" [[ ! -L $device/driver ]] || die "a driver owns $gpu; boot with the GPU unbound before using this tool" [[ ! -d /sys/module/cmp40_preboot ]] || die "cmp40_preboot is already loaded; inspect its status before another operation" if ((load_nvidia)); then - [[ ! -d /sys/module/nvidia ]] || die "NVIDIA is already loaded; boot without NVIDIA to select CPU-RM" + [[ ! -d /sys/module/nvidia ]] || die "NVIDIA is already loaded; boot without NVIDIA to load the proprietary driver" [[ $(modinfo -F license nvidia) == NVIDIA ]] || die "--load-nvidia requires the proprietary kernel module" fi -modprobe cmp40_preboot target="$gpu" mode=unlock cpu_rm_handoff=1 stock_handoff=1 small_wpr_heap=1 \ +modprobe cmp40_preboot target="$gpu" mode=unlock driver_handoff=1 stock_handoff=1 small_wpr_heap=1 \ gen2="$gen2" gen2_policy="$gen2_policy" parameters=/sys/module/cmp40_preboot/parameters [[ $(cat "$parameters/unlock_error") == 0 && $(cat "$parameters/resources_retained") == N ]] || @@ -46,8 +45,6 @@ if [[ $gen2 != off ]]; then echo "Gen2 experiment: errno=$gen2_error Link Status=$(cat "$parameters/gen2_link_status") (decimal)." fi if ((load_nvidia)); then - modprobe nvidia NVreg_EnableGpuFirmware=0 - firmware=$(cmp40_gsp_setting) || die "cannot read NVIDIA's GSP setting from sysfs or /proc" - [[ $firmware == 0 ]] || die "NVIDIA did not select GSP OFF" - echo "Proprietary NVIDIA loaded with GSP OFF. Verify with nvidia-smi and a compute workload." + modprobe nvidia + echo "Proprietary NVIDIA loaded. Verify compute with a workload." fi diff --git a/patches/580.173.02/0002-cmp40hx-pcie2-unlock.patch b/patches/580.173.02/0002-cmp40hx-pcie2-unlock.patch index 0e87419..c1b7092 100644 --- a/patches/580.173.02/0002-cmp40hx-pcie2-unlock.patch +++ b/patches/580.173.02/0002-cmp40hx-pcie2-unlock.patch @@ -72,7 +72,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +++ b/kernel-open/nvidia/gen2_core.h @@ -0,0 +1,352 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ -+/* Shared by CPU-RM and the generated open-driver patches. No ownership changes. ++/* Shared by the pre-driver module and the generated open-driver patches. No ownership changes. + * Policy reference: xrip/cmp50hx-unlock b630a493b7877fbd4472113dcb960a93749c0a78. + * The caller serializes access and supplies a decoded, unlocked TU106 BAR0. + */ @@ -83,7 +83,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +#include + +#ifndef CMP40_GEN2_LOG -+#define CMP40_GEN2_LOG "cmp40_preboot: GEN2" ++#define CMP40_GEN2_LOG "CMPUNLOCKER: GEN2" +#endif +#define GEN2_BAR_SIZE 0x90000 +#define REG_OVR 0x8872c diff --git a/patches/610.57.04/0002-cmp40hx-pcie2-diagnostic.patch b/patches/610.57.04/0002-cmp40hx-pcie2-diagnostic.patch index 20efa1a..e4f62e0 100644 --- a/patches/610.57.04/0002-cmp40hx-pcie2-diagnostic.patch +++ b/patches/610.57.04/0002-cmp40hx-pcie2-diagnostic.patch @@ -73,7 +73,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +++ b/kernel-open/nvidia/gen2_core.h @@ -0,0 +1,352 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ -+/* Shared by CPU-RM and the generated open-driver patches. No ownership changes. ++/* Shared by the pre-driver module and the generated open-driver patches. No ownership changes. + * Policy reference: xrip/cmp50hx-unlock b630a493b7877fbd4472113dcb960a93749c0a78. + * The caller serializes access and supplies a decoded, unlocked TU106 BAR0. + */ @@ -84,7 +84,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +#include + +#ifndef CMP40_GEN2_LOG -+#define CMP40_GEN2_LOG "cmp40_preboot: GEN2" ++#define CMP40_GEN2_LOG "CMPUNLOCKER: GEN2" +#endif +#define GEN2_BAR_SIZE 0x90000 +#define REG_OVR 0x8872c diff --git a/patches/610.57.04/0002-cmp40hx-pcie2-unlock.patch b/patches/610.57.04/0002-cmp40hx-pcie2-unlock.patch index afce718..12fd6e5 100644 --- a/patches/610.57.04/0002-cmp40hx-pcie2-unlock.patch +++ b/patches/610.57.04/0002-cmp40hx-pcie2-unlock.patch @@ -72,7 +72,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +++ b/kernel-open/nvidia/gen2_core.h @@ -0,0 +1,352 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ -+/* Shared by CPU-RM and the generated open-driver patches. No ownership changes. ++/* Shared by the pre-driver module and the generated open-driver patches. No ownership changes. + * Policy reference: xrip/cmp50hx-unlock b630a493b7877fbd4472113dcb960a93749c0a78. + * The caller serializes access and supplies a decoded, unlocked TU106 BAR0. + */ @@ -83,7 +83,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +#include + +#ifndef CMP40_GEN2_LOG -+#define CMP40_GEN2_LOG "cmp40_preboot: GEN2" ++#define CMP40_GEN2_LOG "CMPUNLOCKER: GEN2" +#endif +#define GEN2_BAR_SIZE 0x90000 +#define REG_OVR 0x8872c diff --git a/patches/615.71.09/0002-cmp40hx-pcie2-diagnostic.patch b/patches/615.71.09/0002-cmp40hx-pcie2-diagnostic.patch index 16a620a..a419f88 100644 --- a/patches/615.71.09/0002-cmp40hx-pcie2-diagnostic.patch +++ b/patches/615.71.09/0002-cmp40hx-pcie2-diagnostic.patch @@ -73,7 +73,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +++ b/kernel-open/nvidia/gen2_core.h @@ -0,0 +1,352 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ -+/* Shared by CPU-RM and the generated open-driver patches. No ownership changes. ++/* Shared by the pre-driver module and the generated open-driver patches. No ownership changes. + * Policy reference: xrip/cmp50hx-unlock b630a493b7877fbd4472113dcb960a93749c0a78. + * The caller serializes access and supplies a decoded, unlocked TU106 BAR0. + */ @@ -84,7 +84,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +#include + +#ifndef CMP40_GEN2_LOG -+#define CMP40_GEN2_LOG "cmp40_preboot: GEN2" ++#define CMP40_GEN2_LOG "CMPUNLOCKER: GEN2" +#endif +#define GEN2_BAR_SIZE 0x90000 +#define REG_OVR 0x8872c diff --git a/patches/615.71.09/0002-cmp40hx-pcie2-unlock.patch b/patches/615.71.09/0002-cmp40hx-pcie2-unlock.patch index bba59bd..e3d89b8 100644 --- a/patches/615.71.09/0002-cmp40hx-pcie2-unlock.patch +++ b/patches/615.71.09/0002-cmp40hx-pcie2-unlock.patch @@ -72,7 +72,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +++ b/kernel-open/nvidia/gen2_core.h @@ -0,0 +1,352 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ -+/* Shared by CPU-RM and the generated open-driver patches. No ownership changes. ++/* Shared by the pre-driver module and the generated open-driver patches. No ownership changes. + * Policy reference: xrip/cmp50hx-unlock b630a493b7877fbd4472113dcb960a93749c0a78. + * The caller serializes access and supplies a decoded, unlocked TU106 BAR0. + */ @@ -83,7 +83,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +#include + +#ifndef CMP40_GEN2_LOG -+#define CMP40_GEN2_LOG "cmp40_preboot: GEN2" ++#define CMP40_GEN2_LOG "CMPUNLOCKER: GEN2" +#endif +#define GEN2_BAR_SIZE 0x90000 +#define REG_OVR 0x8872c diff --git a/patches/615.78.08/0002-cmp40hx-pcie2-diagnostic.patch b/patches/615.78.08/0002-cmp40hx-pcie2-diagnostic.patch index 16a620a..a419f88 100644 --- a/patches/615.78.08/0002-cmp40hx-pcie2-diagnostic.patch +++ b/patches/615.78.08/0002-cmp40hx-pcie2-diagnostic.patch @@ -73,7 +73,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +++ b/kernel-open/nvidia/gen2_core.h @@ -0,0 +1,352 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ -+/* Shared by CPU-RM and the generated open-driver patches. No ownership changes. ++/* Shared by the pre-driver module and the generated open-driver patches. No ownership changes. + * Policy reference: xrip/cmp50hx-unlock b630a493b7877fbd4472113dcb960a93749c0a78. + * The caller serializes access and supplies a decoded, unlocked TU106 BAR0. + */ @@ -84,7 +84,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +#include + +#ifndef CMP40_GEN2_LOG -+#define CMP40_GEN2_LOG "cmp40_preboot: GEN2" ++#define CMP40_GEN2_LOG "CMPUNLOCKER: GEN2" +#endif +#define GEN2_BAR_SIZE 0x90000 +#define REG_OVR 0x8872c diff --git a/patches/615.78.08/0002-cmp40hx-pcie2-unlock.patch b/patches/615.78.08/0002-cmp40hx-pcie2-unlock.patch index bba59bd..e3d89b8 100644 --- a/patches/615.78.08/0002-cmp40hx-pcie2-unlock.patch +++ b/patches/615.78.08/0002-cmp40hx-pcie2-unlock.patch @@ -72,7 +72,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +++ b/kernel-open/nvidia/gen2_core.h @@ -0,0 +1,352 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ -+/* Shared by CPU-RM and the generated open-driver patches. No ownership changes. ++/* Shared by the pre-driver module and the generated open-driver patches. No ownership changes. + * Policy reference: xrip/cmp50hx-unlock b630a493b7877fbd4472113dcb960a93749c0a78. + * The caller serializes access and supplies a decoded, unlocked TU106 BAR0. + */ @@ -83,7 +83,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +#include + +#ifndef CMP40_GEN2_LOG -+#define CMP40_GEN2_LOG "cmp40_preboot: GEN2" ++#define CMP40_GEN2_LOG "CMPUNLOCKER: GEN2" +#endif +#define GEN2_BAR_SIZE 0x90000 +#define REG_OVR 0x8872c diff --git a/patches/620.70.06/0002-cmp40hx-pcie2-diagnostic.patch b/patches/620.70.06/0002-cmp40hx-pcie2-diagnostic.patch index 8229ab1..77d1a8e 100644 --- a/patches/620.70.06/0002-cmp40hx-pcie2-diagnostic.patch +++ b/patches/620.70.06/0002-cmp40hx-pcie2-diagnostic.patch @@ -73,7 +73,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +++ b/kernel-open/nvidia/gen2_core.h @@ -0,0 +1,352 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ -+/* Shared by CPU-RM and the generated open-driver patches. No ownership changes. ++/* Shared by the pre-driver module and the generated open-driver patches. No ownership changes. + * Policy reference: xrip/cmp50hx-unlock b630a493b7877fbd4472113dcb960a93749c0a78. + * The caller serializes access and supplies a decoded, unlocked TU106 BAR0. + */ @@ -84,7 +84,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +#include + +#ifndef CMP40_GEN2_LOG -+#define CMP40_GEN2_LOG "cmp40_preboot: GEN2" ++#define CMP40_GEN2_LOG "CMPUNLOCKER: GEN2" +#endif +#define GEN2_BAR_SIZE 0x90000 +#define REG_OVR 0x8872c diff --git a/patches/620.70.06/0002-cmp40hx-pcie2-unlock.patch b/patches/620.70.06/0002-cmp40hx-pcie2-unlock.patch index b996573..6a5fc02 100644 --- a/patches/620.70.06/0002-cmp40hx-pcie2-unlock.patch +++ b/patches/620.70.06/0002-cmp40hx-pcie2-unlock.patch @@ -72,7 +72,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +++ b/kernel-open/nvidia/gen2_core.h @@ -0,0 +1,352 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ -+/* Shared by CPU-RM and the generated open-driver patches. No ownership changes. ++/* Shared by the pre-driver module and the generated open-driver patches. No ownership changes. + * Policy reference: xrip/cmp50hx-unlock b630a493b7877fbd4472113dcb960a93749c0a78. + * The caller serializes access and supplies a decoded, unlocked TU106 BAR0. + */ @@ -83,7 +83,7 @@ diff --git a/kernel-open/nvidia/gen2_core.h b/kernel-open/nvidia/gen2_core.h +#include + +#ifndef CMP40_GEN2_LOG -+#define CMP40_GEN2_LOG "cmp40_preboot: GEN2" ++#define CMP40_GEN2_LOG "CMPUNLOCKER: GEN2" +#endif +#define GEN2_BAR_SIZE 0x90000 +#define REG_OVR 0x8872c diff --git a/tools/check-linux-patches.sh b/tools/check-linux-patches.sh index cdac8b1..280c2dd 100755 --- a/tools/check-linux-patches.sh +++ b/tools/check-linux-patches.sh @@ -178,8 +178,8 @@ apply_and_check() { #