mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 06:28:39 +00:00
tools: run the GP106 oracle areas from validate_all.sh
The 19 areas of tools/gp106/check.sh, which hold all 26 GP106 opt-in (#[ignore]) comparisons against the 580.178.04 instructions, were run by nothing: not by validate_all.sh, not by the Makefile. They only ran when someone typed the loop from reports/gp106-core-validation.md, and that loop left out pte-policy. check.sh gains an `all` area that runs every area in order and stops at the first failure. validate_all.sh runs it as the optional step gp106_oracles, next to gsp_620_headers. Missing prerequisites follow the existing optional-step rule (exit 2 is SKIP, as in test_native_compute.sh and oracle_gsp_620.py): `all` exits 2 before running anything when the interpreter cannot import Unicorn and pyelftools, or when resolve_580_binary() finds no original object. A present object with the wrong digest, a generator error or a Rust mismatch is still FAIL. The interpreter default is the top-level Makefile's REA_PYTHON default. The report now documents `check.sh all` in place of the hand-written loop. The step count in AGENTS.md, CLAUDE.md and docs/GPU_BRINGUP_GUIDE.md is set to 36, the number of PASS/FAIL/SKIP lines validate_all.sh prints with this step; those files said 31, 30 and 31 while the script already printed 35. Tests: tests/gp106/test_check_all.py covers both exit-2 paths and the usage line with stand-in interpreters; tests/vm/test_validate_guest_steps.py covers PASS, SKIP and FAIL of the new step. All six fail on master. No driver logic changes. On this host `check.sh all` passes all 19 areas (90 Rust tests, 0 failed) in about 4 minutes cold, 3 minutes warm; BAR2 and the two framebuffer generators are most of it.
This commit is contained in:
@ -43,7 +43,7 @@ We are building a clean-room Rust driver that matches the **exact behavior** of
|
||||
- Keep evidence categories strictly separate in notes and reports (`[T]`/`[O]` observed original behavior, `[A]`/`[D]`/`[E]` static/emulated analysis, guest QEMU tests, replacement hardware execution).
|
||||
|
||||
4. **Validation gate.**
|
||||
- Always pass 31/31 `tools/validate_all.sh` (including `check_kernel_module.py`: 0 GOT relocations, 0 `memcpy`/`memset`/`memmove`, stack <= 1,024 bytes, no SIMD, and `tests/kernel-module-gate/test_gate_cases.py`: while IBT is enforced, every data relocation that resolves to code must resolve to an instruction boundary and a target's entity is identified from the ELF tables rather than from a printed name (including the header-0 escape fields for extended section numbering, and a raw reserved `st_shndx` read as a special value rather than a section reference), so a printed form belonging to two entities, a shared truncation or a duplicate full name, is refused as unattributable, and the export set counts only defined symbol-table entries so a name that is only referenced is not an export, and the gate test sets `NV_RS_KERNEL_IBT=1` rather than reading the host's kernel config so a refusal expectation holds on a non-IBT host; a green check with IBT not enforced means the rule was skipped, not that the targets resolved) on a quiet tree before any hardware run.
|
||||
- Always pass 36/36 `tools/validate_all.sh` (including `check_kernel_module.py`: 0 GOT relocations, 0 `memcpy`/`memset`/`memmove`, stack <= 1,024 bytes, no SIMD, and `tests/kernel-module-gate/test_gate_cases.py`: while IBT is enforced, every data relocation that resolves to code must resolve to an instruction boundary and a target's entity is identified from the ELF tables rather than from a printed name (including the header-0 escape fields for extended section numbering, and a raw reserved `st_shndx` read as a special value rather than a section reference), so a printed form belonging to two entities, a shared truncation or a duplicate full name, is refused as unattributable, and the export set counts only defined symbol-table entries so a name that is only referenced is not an export, and the gate test sets `NV_RS_KERNEL_IBT=1` rather than reading the host's kernel config so a refusal expectation holds on a non-IBT host; a green check with IBT not enforced means the rule was skipped, not that the targets resolved) on a quiet tree before any hardware run.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ The points most likely to be violated by accident:
|
||||
Run everything from the repository root so rustup picks the pinned toolchain (`rust-toolchain.toml`, 1.100.0, target `x86_64-unknown-none`).
|
||||
|
||||
```sh
|
||||
sh tools/validate_all.sh # the 30-step gate; one PASS/FAIL line per step, logs in target/validate-logs/<step>.log
|
||||
sh tools/validate_all.sh # the 36-step gate; one PASS/FAIL/SKIP line per step, logs in target/validate-logs/<step>.log
|
||||
make modules # Rust core -> nv-rust.o_binary, Kbuild -> kernel-open/*.ko, then tools/check_kernel_module.py
|
||||
make check # fmt + clippy -D warnings + `--check` of every generated table (needs REA_PYTHON)
|
||||
make test # cargo test --workspace
|
||||
|
||||
@ -129,7 +129,7 @@ For a step-by-step distro install guide (Ubuntu/Debian, Arch/CachyOS, Fedora, Ni
|
||||
|
||||
### Build & Validate
|
||||
```sh
|
||||
# Build nvidia_rs.ko and run the 34-step unit, oracle, QEMU guest & kernel-hygiene gate
|
||||
# Build nvidia_rs.ko and run the 36-step unit, oracle, QEMU guest & kernel-hygiene gate
|
||||
sh tools/validate_all.sh
|
||||
|
||||
# ARM64 / SBC PCIe build (RK3588, Ampere Altra, Apple Silicon Linux)
|
||||
|
||||
@ -61,7 +61,7 @@ python3 tests/vm/test_result_gate.py
|
||||
```
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Before any hardware run (Step 2 or Step 3), run the full 31/31 validation gate on a quiet tree (`sh tools/validate_all.sh`, which runs all offline checks, component suites, software QEMU EDU guests, and the empty-`pci_target` live control check via `sudo -n python3 tools/run_live_control.py`). Use the strictly offline commands above only while iterating locally before you are ready to run the full gate.
|
||||
> Before any hardware run (Step 2 or Step 3), run the full 36/36 validation gate on a quiet tree (`sh tools/validate_all.sh`, which runs all offline checks, component suites, software QEMU EDU guests, and the empty-`pci_target` live control check via `sudo -n python3 tools/run_live_control.py`). Use the strictly offline commands above only while iterating locally before you are ready to run the full gate.
|
||||
|
||||
Key kernel-module hygiene invariants enforced automatically by `tools/check_kernel_module.py`:
|
||||
- **0** unsupported GOT relocations (`R_X86_64_GOTPCREL`)
|
||||
|
||||
@ -19,12 +19,16 @@ Run a single area with `bash tools/gp106/check.sh <area>`. Run the full GP106
|
||||
offline set from the repository root with:
|
||||
|
||||
```sh
|
||||
for area in memory legacy layout regions heap-inputs acr wpr sec2 hs-wpr upload \
|
||||
launch run unmap control inputs tlb pf-cpu bar2; do
|
||||
bash tools/gp106/check.sh "$area" || exit
|
||||
done
|
||||
bash tools/gp106/check.sh all
|
||||
```
|
||||
|
||||
`all` runs the areas `memory legacy layout regions heap-inputs acr wpr sec2
|
||||
hs-wpr upload launch run unmap control inputs tlb pf-cpu pte-policy bar2` in
|
||||
that order and stops at the first failure. It exits 2 without running anything
|
||||
when the interpreter cannot import Unicorn and pyelftools or the original
|
||||
object is not found. `tools/validate_all.sh` runs it as the `gp106_oracles`
|
||||
step and reports that exit status as SKIP.
|
||||
|
||||
The checks generate fixtures and firmware-derived data under `target/`. JSON
|
||||
summaries from the original-instruction checks are under
|
||||
`target/gp106-reports/`. The PF CPU check compares generated metadata with
|
||||
|
||||
61
tests/gp106/test_check_all.py
Normal file
61
tests/gp106/test_check_all.py
Normal file
@ -0,0 +1,61 @@
|
||||
"""Check how `tools/gp106/check.sh all` reports missing oracle prerequisites.
|
||||
|
||||
Nothing here runs an oracle: the interpreters are stand-ins that only answer the
|
||||
two prerequisite probes, so the test needs neither Unicorn nor the original object.
|
||||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
NO_MODULES = "#!/bin/sh\nexit 1\n"
|
||||
NO_BINARY = """#!/bin/sh
|
||||
case "$2" in
|
||||
"import unicorn, elftools") exit 0 ;;
|
||||
*) echo /nonexistent/nv-kernel.o_binary; exit 1 ;;
|
||||
esac
|
||||
"""
|
||||
|
||||
|
||||
class CheckAllPrerequisiteTests(unittest.TestCase):
|
||||
def run_all(self, interpreter_text):
|
||||
work = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(work.cleanup)
|
||||
interpreter = Path(work.name) / "python"
|
||||
interpreter.write_text(interpreter_text, encoding="utf-8")
|
||||
interpreter.chmod(0o755)
|
||||
return subprocess.run(
|
||||
["bash", str(ROOT / "tools/gp106/check.sh"), "all"],
|
||||
env=dict(os.environ, REA_PYTHON=str(interpreter)),
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
def test_missing_python_modules_exit_2(self):
|
||||
result = self.run_all(NO_MODULES)
|
||||
self.assertEqual(result.returncode, 2, result.stderr)
|
||||
self.assertIn("SKIP: ", result.stderr)
|
||||
self.assertIn("Unicorn and pyelftools", result.stderr)
|
||||
self.assertNotIn("== gp106", result.stdout)
|
||||
|
||||
def test_missing_original_object_exit_2(self):
|
||||
result = self.run_all(NO_BINARY)
|
||||
self.assertEqual(result.returncode, 2, result.stderr)
|
||||
self.assertIn("SKIP: reference 580.178.04 object not found at /nonexistent/nv-kernel.o_binary", result.stderr)
|
||||
self.assertNotIn("== gp106", result.stdout)
|
||||
|
||||
def test_usage_lists_all_and_every_area(self):
|
||||
result = subprocess.run(
|
||||
["bash", str(ROOT / "tools/gp106/check.sh"), "no-such-area"], capture_output=True, text=True
|
||||
)
|
||||
self.assertEqual(result.returncode, 2)
|
||||
self.assertIn("{all|memory|legacy|", result.stderr)
|
||||
self.assertIn("|pte-policy|bar2}", result.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@ -19,7 +19,12 @@ sh() {
|
||||
*) return 0 ;;
|
||||
esac
|
||||
}
|
||||
bash() { return 0; }
|
||||
bash() {
|
||||
case "$*" in
|
||||
"tools/gp106/check.sh all") return "${GP106_STATUS:-0}" ;;
|
||||
*) return 0 ;;
|
||||
esac
|
||||
}
|
||||
python3() {
|
||||
case "$*" in
|
||||
tools/vm/run_guest.py) [ "$FAILED_STEP" != guest ] ;;
|
||||
@ -100,6 +105,21 @@ class GuestStepTests(unittest.TestCase):
|
||||
self.assertEqual(result.returncode, 0)
|
||||
self.assertIn("PASS live\n", result.stdout)
|
||||
|
||||
def test_gp106_oracles_pass(self):
|
||||
result, _ = self.simulate("", extra_args=("--offline",))
|
||||
self.assertEqual(result.returncode, 0)
|
||||
self.assertIn("PASS gp106_oracles\n", result.stdout)
|
||||
|
||||
def test_gp106_oracles_without_prerequisites_skip(self):
|
||||
result, _ = self.simulate("", extra_args=("--offline",), extra_env={"GP106_STATUS": "2"})
|
||||
self.assertEqual(result.returncode, 0)
|
||||
self.assertIn("SKIP gp106_oracles ", result.stdout)
|
||||
|
||||
def test_gp106_oracles_failure_fails_the_run(self):
|
||||
result, _ = self.simulate("", extra_args=("--offline",), extra_env={"GP106_STATUS": "1"})
|
||||
self.assertEqual(result.returncode, 1)
|
||||
self.assertIn("FAIL gp106_oracles ", result.stdout)
|
||||
|
||||
def test_unknown_option_fails_with_code_2(self):
|
||||
result, _ = self.simulate("", extra_args=("--bogus-option",))
|
||||
self.assertEqual(result.returncode, 2)
|
||||
|
||||
@ -3,7 +3,33 @@
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/../.."
|
||||
|
||||
AREAS="memory legacy layout regions heap-inputs acr wpr sec2 hs-wpr upload launch run unmap control inputs tlb pf-cpu pte-policy bar2"
|
||||
|
||||
case "${1:-}" in
|
||||
all)
|
||||
# Every area in turn, for tools/validate_all.sh. Exit 2 (SKIP there) when the
|
||||
# oracle prerequisites are absent; any area that fails is exit 1.
|
||||
# The interpreter default is the top-level Makefile's.
|
||||
if [ -z "${REA_PYTHON:-}" ] && [ -x "$HOME/.local/opt/rea-python/bin/python" ]; then
|
||||
REA_PYTHON="$HOME/.local/opt/rea-python/bin/python"
|
||||
fi
|
||||
export REA_PYTHON="${REA_PYTHON:-python3}"
|
||||
if ! "$REA_PYTHON" -c 'import unicorn, elftools' >/dev/null 2>&1; then
|
||||
echo "SKIP: $REA_PYTHON cannot import Unicorn and pyelftools (set REA_PYTHON to run)" >&2
|
||||
exit 2
|
||||
fi
|
||||
if ! binary=$("$REA_PYTHON" -c 'import sys; sys.path.insert(0, "tools"); from _binary_path import resolve_580_binary; p = resolve_580_binary(); print(p); sys.exit(0 if p.is_file() else 1)'); then
|
||||
echo "SKIP: reference 580.178.04 object not found at ${binary:-<unresolved>} (set NV_RS_580_BINARY to run)" >&2
|
||||
exit 2
|
||||
fi
|
||||
for area in $AREAS; do
|
||||
echo "== gp106 $area"
|
||||
if ! bash tools/gp106/check.sh "$area"; then
|
||||
echo "FAIL: gp106 $area" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
;;
|
||||
memory)
|
||||
cargo test -p nv-rs-core --lib mmu::vram::
|
||||
"${REA_PYTHON:-python3}" tools/check_vram_size_binary.py --check
|
||||
@ -122,7 +148,7 @@ case "${1:-}" in
|
||||
cargo test -p nv-rs-core --lib original_gp106_pte_policy -- --include-ignored
|
||||
;;
|
||||
*)
|
||||
echo "Usage: bash tools/gp106/check.sh {memory|layout|regions|heap-inputs|acr|wpr|sec2|hs-wpr|upload|launch|run|unmap|control|inputs|tlb|pf-cpu|pte-policy|bar2|legacy}" >&2
|
||||
echo "Usage: bash tools/gp106/check.sh {all|${AREAS// /|}}" >&2
|
||||
echo "Oracle checks require Unicorn, pyelftools and the extracted 580.178.04 object." >&2
|
||||
exit 2
|
||||
;;
|
||||
|
||||
@ -56,6 +56,7 @@ step modules make modules
|
||||
step audit make -C src/nvidia audit-codegen
|
||||
step native_codegen python3 tools/check_native_codegen.py
|
||||
optional_step gsp_620_headers python3 tools/oracle_gsp_620.py
|
||||
optional_step gp106_oracles bash tools/gp106/check.sh all
|
||||
guest_skip() {
|
||||
local name=$1 reason=$2
|
||||
echo "$reason" >"$LOGS/$name.log"
|
||||
|
||||
Reference in New Issue
Block a user