CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
CUDApp / native / gsp / README.md
| 1 | WARNING: This can and may permanently damage your system. No warranty of any kind. Do not use it unless you are a professional lab that is prepared to lose the hardware. |
| 2 | |
| 3 | # native/gsp: GSP firmware container parser (read-only) |
| 4 | |
| 5 | This directory holds read-only research into the GPU boot chain. `fwimage.om` reads one firmware file and |
| 6 | writes a text report. It never opens a device, maps a BAR, writes to a device or runs anything on one. |
| 7 | |
| 8 | On Drake's DGX Spark the signed boot chain is never modified: UEFI and platform firmware, NVIDIA-signed |
| 9 | GSP/booter/FMC firmware, VBIOS and fuses. A future first-party driver may only load NVIDIA's signed firmware |
| 10 | unmodified, as nouveau and nova do. Replacing the boot chain is future work, and only if a dedicated, |
| 11 | sponsored DGX Spark exists for it. |
| 12 | |
| 13 | ## Files |
| 14 | |
| 15 | | Path | Role | |
| 16 | |---|---| |
| 17 | | `native/gsp/fwimage.om` | Seeded Omega (OM-2) parser. It is compiled together with omega-mv `om/tls/sha2.om` (SHA-256). | |
| 18 | | `tests/gsp/run-fwimage-host.sh` | Host runner: pins, compile, oracle comparison, negative controls. | |
| 19 | | `tests/gsp/expected-580.173.02.txt` | Expected report, generated with `readelf -SW`, `dd` and `sha256sum` only. | |
| 20 | |
| 21 | Build and run, with the pinned omc from omega-mv `369dbc96daa1684db2d7c2c7085bbf16b3fd77ee` |
| 22 | (`seed/out/omc` sha256 `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`): |
| 23 | |
| 24 | ```sh |
| 25 | cat native/gsp/fwimage.om "$OMEGA_MV/om/tls/sha2.om" | "$OMEGA_MV/seed/out/omc" > /tmp/fwimage |
| 26 | chmod 700 /tmp/fwimage |
| 27 | /tmp/fwimage /lib/firmware/nvidia/580.173.02/gsp_ga10x.bin gb20y |
| 28 | tests/gsp/run-fwimage-host.sh "$OMEGA_MV/seed/out/omc" /lib/firmware/nvidia/580.173.02/gsp_ga10x.bin |
| 29 | ``` |
| 30 | |
| 31 | The runner refuses (exit 69) unless the omc, `sha2.om` (`5cf0f981…6fdb33`) and the firmware |
| 32 | (`32cb7cf3…d963`) match their pins. It prints `FWIMAGE PASS` only when every check below holds: |
| 33 | |
| 34 | 1. The committed expectation equals a fresh `readelf`/`dd`/`sha256sum` reference. |
| 35 | 2. The fwimage output equals that expectation, with no family, with gb20y and with gb10y. |
| 36 | 3. An expectation with one altered digest digit is rejected (a negative control on the checker itself). |
| 37 | 4. The C oracle `ck_gsp_fw_inspect.c` from lane L332 agrees on the lines both tools print. The runner |
| 38 | builds it into its temporary directory, and it is used only as a verification oracle. |
| 39 | 5. Six mutated inputs are refused, each with its documented code: truncated to 1000 bytes (12), ELF magic |
| 40 | byte changed (10), `.fwversion` sh_offset past end of file (14), `.fwversion` renamed (16), a duplicate |
| 41 | section name (18), and an unknown family (17). |
| 42 | |
| 43 | ## Report and exit codes |
| 44 | |
| 45 | ``` |
| 46 | SECTION <name> off=<hex> size=<hex> every section header after index 0, in table order |
| 47 | FWVERSION <text> |
| 48 | SHA256 <name> <hex> .fwimage and every .fwsignature_* section, in table order |
| 49 | SELECT family=<f> image_off=<hex> image_size=<hex> sig_section=.fwsignature_<f> sig_sha256=<hex> |
| 50 | ``` |
| 51 | |
| 52 | All checks run before any output, so a refusal prints only `FWIMAGE REFUSE <reason>` on stderr. |
| 53 | |
| 54 | | Exit | Meaning | |
| 55 | |---|---| |
| 56 | | 0 | report written | |
| 57 | | 2 | usage | |
| 58 | | 3 | I/O: open, seek, short read or stdout write failed | |
| 59 | | 10 | not ELF (magic) | |
| 60 | | 11 | not ELF64 / little-endian / version 1 / RISC-V (e_machine 243) | |
| 61 | | 12 | truncated: file shorter than 64 bytes, or the section header table passes end of file | |
| 62 | | 13 | malformed header: e_ehsize or e_shentsize not 64, e_shnum 0, e_shstrndx 0 or ≥ e_shnum, name table not SHT_STRTAB or empty | |
| 63 | | 14 | section or name out of bounds (offset + size > file size, overflow-checked; name outside the table; table not zero-terminated) | |
| 64 | | 15 | missing `.fwimage` | |
| 65 | | 16 | missing `.fwversion` | |
| 66 | | 17 | unknown family (only gb20y, gb10y) | |
| 67 | | 18 | duplicate section names | |
| 68 | | 19 | capacity: more than 1024 sections or a name table above 64 KiB | |
| 69 | | 20 | selected `.fwsignature_<family>` absent | |
| 70 | | 21 | `.fwimage` or a `.fwsignature_*` section is SHT_NOBITS or empty | |
| 71 | | 22 | `.fwversion` malformed: size 0 or above 63, no final zero byte, or a non-printable byte | |
| 72 | | 100+n | Omega runtime trap n (none expected) | |
| 73 | |
| 74 | ## Container format, as the 580.173.02 driver reads it |
| 75 | |
| 76 | Citations are paths under `open-gpu-kernel-modules` 580.173.02 |
| 77 | (git `20e4e6e19cc26ba47b5cbe23130a396be100c427`). |
| 78 | |
| 79 | - **File choice.** Families GB10Y=11 and GB20Y=12 (`kernel-open/common/inc/nv-firmware.h:52-53`) have the |
| 80 | names `gb10y` and `gb20y` (`:63-64`). Both, together with GB10X/GB20X/GH100/AD10X/GA10X, load `gsp_ga10x` |
| 81 | (`:94-102`). |
| 82 | - **Container.** The firmware is an ELF64 image. `_kgspFwContainerGetSection` |
| 83 | (`src/nvidia/src/kernel/gpu/gsp/kernel_gsp.c:5078`) checks: |
| 84 | - the magic (`:5116`), little-endian (`:5118`) and ELFCLASS64 (`:5120`); |
| 85 | - `shentsize == 64` (`:5123`) and an overflow-checked section header table inside the buffer (`:5124-5126`); |
| 86 | - `shstrndx <= shnum` (`:5127`). |
| 87 | |
| 88 | It then scans the headers backward from `shnum - 1` (`:5139`), bounds-checks each name offset (`:5145`) |
| 89 | and each section's offset + size (`:5158`). |
| 90 | - **Section names** (`src/nvidia/generated/g_kernel_gsp_nvoc.h:269-274`): `.fwversion`, `.fwimage`, |
| 91 | `.fwsignature_` (prefix), `.note.gnu.build-id`, `.fwsignature_cc_` (prefix for confidential compute). |
| 92 | - **Version.** `_kgspFwContainerVerifyVersion` (`kernel_gsp.c:4735`) requires: |
| 93 | - a size of 1..63 that ends in a zero byte (`:4763-4766`); |
| 94 | - text equal to the driver's `NV_VERSION_STRING`, with size = length + 1 (`:4768-4772`). |
| 95 | |
| 96 | In this file the value is `580.173.02` (11 bytes). |
| 97 | - **Image and signature.** `_kgspPrepareGspRmBinaryImage` (`kernel_gsp.c:4843`) verifies the version, takes |
| 98 | `.fwimage`, and takes the signature section named prefix + family. That name comes from |
| 99 | `_kgspGetSectionNameForPrefix` (`:4796`), into a 32-byte buffer (`:4850`). The function then builds the |
| 100 | radix3 descriptor over the image (`:4884`). |
| 101 | - **Signature prefix.** For Blackwell the prefix comes from `kgspGetSignatureSectionNamePrefix_GB100` |
| 102 | (`src/nvidia/generated/g_kernel_gsp_nvoc.c:1811`; `src/nvidia/src/kernel/gpu/gsp/arch/blackwell/kernel_gsp_gb100.c:95-108`). |
| 103 | It returns `.fwsignature_cc_` when confidential compute is enabled, otherwise `.fwsignature_`. |
| 104 | This file has no `.fwsignature_cc_gb10y` or `.fwsignature_cc_gb20y`, so on this chip the selection with |
| 105 | CC enabled would fail. That last point is an inference from the section list and is not run. |
| 106 | - **Boot.** SEC2 boots GSP-FMC for GB10B, GB20B and GB20C (`PDB_PROP_KSEC2_BOOT_GSPFMC`, |
| 107 | `src/nvidia/generated/g_kernel_sec2_nvoc.c:446-455`). |
| 108 | |
| 109 | Measured on `/lib/firmware/nvidia/580.173.02/gsp_ga10x.bin` (75,012,080 bytes) with `readelf -SW`: |
| 110 | |
| 111 | - 17 sections; e_shoff 0x47893b0; e_shstrndx 16. |
| 112 | - `.fwimage` at 0x40, size 0x477f000. |
| 113 | - Ten `.fwsignature_*` sections of 0x1000 bytes each. |
| 114 | - The full list is in `tests/gsp/expected-580.173.02.txt`. |
| 115 | |
| 116 | Where `fwimage.om` is stricter than the driver: |
| 117 | |
| 118 | | Check | Driver | fwimage.om | |
| 119 | |---|---|---| |
| 120 | | e_shstrndx bound | accepts `shstrndx == shnum` (`:5127`), which indexes one past the table | requires `0 < shstrndx < shnum` | |
| 121 | | duplicate section names | backward scan, so the last header with a name wins | refuses (18) | |
| 122 | | e_machine (243) and e_version | not checked | checked | |
| 123 | |
| 124 | ## Chip identity: gb20y or gb10y (unresolved) |
| 125 | |
| 126 | The family string picks the signature section, so a wrong family selects the wrong signature. |
| 127 | Family selection (`src/nvidia/arch/nvalloc/common/inc/nv-firmware-chip-family-select.h`): |
| 128 | |
| 129 | | Chip | Architecture | Implementation | Family | Source | |
| 130 | |---|---|---|---|---| |
| 131 | | GB10B | GB1XX = 0x1A0 (`src/common/inc/swref/published/nv_arch.h:51`) | 0x0B (`:111`) | gb10y | `nv-firmware-chip-family-select.h:58-62` | |
| 132 | | GB20B | GB2XX = 0x1B0 (`nv_arch.h:53`) | ≥ GB20B = 0x0B (`:127`) | gb20y | `nv-firmware-chip-family-select.h:64-68` | |
| 133 | |
| 134 | Lane L332 assumed GB10B (gb10y). Lead evidence points to GB20B (gb20y): |
| 135 | |
| 136 | - CUDApp measures sm_121. |
| 137 | - The UVM source pairs GB10B with T264 (Thor). |
| 138 | - `PDB_PROP_GPU_CLKS_IN_TEGRA_SOC` is set for GB10B only. |
| 139 | |
| 140 | Only a `PMC_BOOT_42` read during an authorized window settles it; that read is not run. Until then the |
| 141 | parser and runner treat both families and report both selections. |
| 142 | |
| 143 | The two signature digests differ: |
| 144 | |
| 145 | | Family | Signature digest | |
| 146 | |---|---| |
| 147 | | gb20y | `6d38023b…f9a1` | |
| 148 | | gb10y | `08541c3a…8f2d` | |