Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/cre-gpu-r04-arm64-ioctl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CRE GPU R04 authentic nvgpu AArch64 ioctl value and layout check
on:
pull_request:
paths:
- ".github/workflows/cre-gpu-r04-arm64-ioctl.yml"
- "qualification/cre_gpu_r04/abi_native/**"
permissions:
contents: read
jobs:
native-aarch64-ioctl:
runs-on: ubuntu-latest
timeout-minutes: 18
steps:
- uses: actions/checkout@v4
- name: Install public GNU AArch64 compiler and user-mode emulator
run: |
set -euo pipefail
sudo apt-get update -qq
sudo apt-get install -y -qq --no-install-recommends gcc-aarch64-linux-gnu qemu-user binutils-aarch64-linux-gnu libc6-dev-arm64-cross
aarch64-linux-gnu-gcc --version | head -n 1
qemu-aarch64 --version | head -n 1
- name: Reacquire exact verified public GPL source with existing merged intake
run: |
set -euo pipefail
go run qualification/cre_gpu_r03/nvgpu/source_intake.go -out working
test -s working/source-files/include/uapi/linux/nvgpu.h
test -s working/source-intake.json
- name: Compile and execute authentic AArch64 UAPI reference code
run: |
set -euo pipefail
mkdir -p out
aarch64-linux-gnu-gcc -std=c11 -O2 -Wall -Wextra -Werror -static -I working/source-files/include/uapi \
qualification/cre_gpu_r04/abi_native/reference.c -o out/nvgpu-abi-arm64
readelf -h out/nvgpu-abi-arm64 | tee out/arm64-elf-header.txt
readelf -h out/nvgpu-abi-arm64 | grep -q AArch64
qemu-aarch64 out/nvgpu-abi-arm64 | tee out/nvgpu-ioctls-native.txt
test "$(wc -l < out/nvgpu-ioctls-native.txt)" -eq 6
- name: Independently derive _IOC values and exercise falsification controls
run: |
set -euo pipefail
python3 qualification/cre_gpu_r04/abi_native/verify.py \
--header working/source-files/include/uapi/linux/nvgpu.h \
--native out/nvgpu-ioctls-native.txt --out out
python3 - <<'PY'
import json, pathlib
x=json.loads(pathlib.Path("out/aarch64-ioctl-abi.json").read_text())
assert x["schema"]=="cre.gpu.r04.nvgpu-aarch64-ioctl/1"
assert len(x["linux_aarch64_ioctl_records"]) == 6
assert x["changed_number_refused"] and x["missing_source_ioctl_refused"]
assert not x["guest_nvgpu_driver_executed"] and not x["physical_jetson_observed"]
assert not x["ioctl_backend_implemented"]
for r in x["linux_aarch64_ioctl_records"].values():
assert r["numeric_ioctl"] == ((r["direction"]<<30)|(r["argument_bytes_aarch64"]<<16)|(r["type"]<<8)|r["number"])
print("INDEPENDENT_ARM64_UAPI_CRITIC_PASS 6 authentic AArch64 results")
PY
- name: Retain bounded ABI evidence only, not compiled binaries or source
if: always()
uses: actions/upload-artifact@v4
with:
name: cre-gpu-r04-arm64-ioctl-layout-evidence
path: |
out/nvgpu-ioctls-native.txt
out/arm64-elf-header.txt
out/aarch64-ioctl-abi.json
retention-days: 7
9 changes: 9 additions & 0 deletions qualification/cre_gpu_r04/abi_native/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# R04: true Linux AArch64 numeric nvgpu ioctl ABI boundary

This module builds an original read-only reference program for AArch64, using the original GPL NVIDIA R32.7.6 UAPI header from the already source-qualified open OE4T mirror. It runs that actual AArch64 executable under QEMU user-mode in public GitHub Actions, not on the Nano and not with a working GPU kernel device.

It obtains six representative ioctl numeric values/directions/type/number/struct size. The independent Python verifier parses original C preprocessor definitions and reconstructs Linux asm-generic _IOC bits, rejects wrong native outputs and missing source macros. Host Linux/x86 ioctl numbers are not substituted for AArch64; exact compiler, cross-target and emulator should be captured in workflow logs.

The output JSON explicitly says ioctl_backend_implemented=false and guest_nvgpu_driver_executed=false. Not a claimed full 128-op implementation or hardware equivalence. Numeric _IOC stability and actual C argument struct sizes from the official NVIDIA tar remain to be independently compared with the OE4T mirrored tree after rights-approved official acquisition.

Public GHA files are source and metadata only, no vendor binary/firmware, credentials, actual host GPU, private MAF authority, or live CRE adapter. DLE: GPU #27, MAF #40, JFL #26.
25 changes: 25 additions & 0 deletions qualification/cre_gpu_r04/abi_native/reference.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: MIT */
/* Original R04 numeric ioctl probe against immutable open GPL nvgpu.h.
* This only compiles and executes Linux arm64 UAPI constants. No ioctl calls.
*/
#include <stdio.h>
#include <linux/ioctl.h>
#include <linux/nvgpu.h>

#define EMIT(x) do { \
unsigned long v = (unsigned long)(x); \
printf("%s %lu %u %u %u %u\n", #x, v, \
(unsigned)_IOC_DIR(v), (unsigned)_IOC_TYPE(v), \
(unsigned)_IOC_NR(v), (unsigned)_IOC_SIZE(v)); \
} while (0)

int main(void)
{
EMIT(NVGPU_GPU_IOCTL_GET_CHARACTERISTICS);
EMIT(NVGPU_GPU_IOCTL_OPEN_CHANNEL);
EMIT(NVGPU_TSG_IOCTL_BIND_CHANNEL);
EMIT(NVGPU_AS_IOCTL_MAP_BUFFER_EX);
EMIT(NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO);
EMIT(NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO);
return 0;
}
152 changes: 152 additions & 0 deletions qualification/cre_gpu_r04/abi_native/verify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#!/usr/bin/env python3
"""Independent AArch64 ioctl calculation from exact R32.7.6 public UAPI."""
import argparse
import hashlib
import json
import pathlib
import re
import sys

SOURCE_REV = "7fbefcbf4b39643ab414454e6e4154865b333757"
SOURCE_GIT_BLOB = "873e787f17b67e8140fc7fc6d95b055f31de8ae2"
NAMES = (
"NVGPU_GPU_IOCTL_GET_CHARACTERISTICS",
"NVGPU_GPU_IOCTL_OPEN_CHANNEL",
"NVGPU_TSG_IOCTL_BIND_CHANNEL",
"NVGPU_AS_IOCTL_MAP_BUFFER_EX",
"NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO",
"NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO",
)
DIR = {"IO": 0, "IOR": 2, "IOW": 1, "IOWR": 3}


def git_blob(b):
return hashlib.sha1(f"blob {len(b)}\0".encode() + b).hexdigest()


def source_macros(b):
s = b.decode("utf-8")
magics = {
x: ord(y)
for x, y in re.findall(
r"(?m)^#define\s+(NVGPU_[A-Z0-9_]*MAGIC)\s+'(.)'\s*$", s
)
}
out = {}
for name in NAMES:
pattern = (
r"(?m)^#define\s+"
+ re.escape(name)
+ r"\s*\\\s*\n\s*_(IOWR|IOR|IOW|IO)\(\s*"
+ r"(NVGPU_[A-Z0-9_]+)\s*,\s*(\d+)\s*[,)]"
)
m = re.search(pattern, s)
if not m:
raise ValueError(f"source macro missing/unknown: {name}")
kind, magic, number = m.groups()
if magic not in magics:
raise ValueError(f"unbound ioctl magic {magic}")
out[name] = (DIR[kind], magics[magic], int(number), kind, magic)
return out


def parse_native(raw):
records = {}
for line in raw.splitlines():
terms = line.split()
if len(terms) != 6:
raise ValueError(f"unexpected native format: {line!r}")
name = terms[0]
if name in records or name not in NAMES:
raise ValueError("duplicate or unknown ioctl in native output")
code, direction, typ, number, size = map(int, terms[1:])
if not 0 <= code <= 0xFFFFFFFF or not 1 <= size <= 16383:
raise ValueError("ioctl width/size not admitted")
if not 0 <= direction <= 3 or not 0 <= typ <= 255 or not 0 <= number <= 255:
raise ValueError("invalid native field")
records[name] = {
"numeric_ioctl": code,
"hex_ioctl": f"0x{code:08x}",
"direction": direction,
"type": typ,
"number": number,
"argument_bytes_aarch64": size,
}
if set(records) != set(NAMES):
raise ValueError("missing native ioctl")
return records


def verify(records, macros):
if set(records) != set(NAMES):
raise ValueError("missing reference fields")
for name in NAMES:
r = records[name]
direction, typ, number, _, _ = macros[name]
if (r["direction"], r["type"], r["number"]) != (direction, typ, number):
raise ValueError(f"source mismatch: {name}")
reconstructed = (
(direction << 30)
| (r["argument_bytes_aarch64"] << 16)
| (typ << 8)
| number
)
if r["numeric_ioctl"] != reconstructed:
raise ValueError(f"_IOC number mismatch: {name}")
return True


def main():
p = argparse.ArgumentParser()
p.add_argument("--header", required=True, type=pathlib.Path)
p.add_argument("--native", required=True, type=pathlib.Path)
p.add_argument("--out", required=True, type=pathlib.Path)
a = p.parse_args()
b = a.header.read_bytes()
if git_blob(b) != SOURCE_GIT_BLOB:
raise ValueError("unapproved nvgpu source revision or mutated header")
macros = source_macros(b)
records = parse_native(a.native.read_text())
verify(records, macros)
mutated = json.loads(json.dumps(records))
mutated[NAMES[0]]["numeric_ioctl"] ^= 0x100
try:
verify(mutated, macros)
except ValueError:
bad_encoding_refused = True
else:
raise ValueError("altered ioctl number admitted")
try:
source_macros(b.replace(b"NVGPU_GPU_IOCTL_OPEN_CHANNEL", b"NVGPU_GPU_IOCTL_MISSING", 1))
except ValueError:
absent_source_refused = True
else:
raise ValueError("missing ioctl source admitted")
evidence = {
"schema": "cre.gpu.r04.nvgpu-aarch64-ioctl/1",
"source": "OE4T/linux-nvgpu",
"source_revision": SOURCE_REV,
"source_git_blob_sha1": SOURCE_GIT_BLOB,
"source_sha256": hashlib.sha256(b).hexdigest(),
"native_execution": "QEMU_AARCH64_USER_MODE_GPL_HEADER_C_ONLY",
"physical_jetson_observed": False,
"guest_nvgpu_driver_executed": False,
"ioctl_backend_implemented": False,
"linux_aarch64_ioctl_records": records,
"changed_number_refused": bad_encoding_refused,
"missing_source_ioctl_refused": absent_source_refused,
"source_status": "MIRROR_NOT_OFFICIAL_BSP_ARCHIVE_COMPARED",
}
a.out.mkdir(parents=True, exist_ok=True)
(a.out / "aarch64-ioctl-abi.json").write_text(
json.dumps(evidence, indent=2, sort_keys=True) + "\n"
)
print("AARCH64_NVPGU_IOCTL_PASS 6 source-backed constants, 2 negatives, driver UNIMPLEMENTED")


if __name__ == "__main__":
try:
main()
except Exception as exc:
print(f"R04_FAIL {exc}", file=sys.stderr)
raise
Loading