aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / kernel / gpu / contract / gen / gb10_gsp_boot.md
| 1 | # gb10-gsp-boot (generated from gb10_gsp.devc) |
| 2 | |
| 3 | Contract sha256 `0bc4fee8da8fa819dd3230c3f3ff9c9d4cf35476b2684676c9b3f8de55b98cc0`. Class `gpu-boot`, transport `pci-bar`. |
| 4 | 71 statements compile to 142 lines of C with the API of `native/kernel/gpu/gsp_mmio.h`. |
| 5 | |
| 6 | ## What the compiler refuses (class gpu-boot) |
| 7 | |
| 8 | - any chip access before the packet length is checked against the EMEM channel |
| 9 | - writing EMEM before the SEC2 channel is seen empty (HEAD equal to TAIL) |
| 10 | - the doorbell (HEAD) before the packet and TAIL are written, or a SEC2 write after it |
| 11 | - an EMEM layout where the dword offset field and the dwords-per-block constant disagree |
| 12 | - touching any GSP register before SEC2 releases the GSP target mask |
| 13 | - a write to the GSP (FALCON_OS) before the FMC error mailbox is checked |
| 14 | - a wait with no poll budget, or budgets out of the API's slot order |
| 15 | - writing a read-only register or reading a write-only one |
| 16 | |
| 17 | ## Steps |
| 18 | |
| 19 | - RequirePacket { max: "EMEM_CHANNEL_BYTES", err: "E_ARG" } |
| 20 | - WaitEqual { a: "QHEAD0", b: "QTAIL0", budget: "polls_can_send", err: "E_BUSY" } |
| 21 | - EmemSend { ctrl: "EMEMC0", data: "EMEMD0", ainc: "AINCW", offs: "OFFS", blk: "BLK", per_blk: "EMEM_DW_PER_BLK", err: "E_EMEM" } |
| 22 | - PostTail("QTAIL0") |
| 23 | - Doorbell("QHEAD0") |
| 24 | - WaitNot { reg: "SEC2_MAILBOX0", val: "SEC2_CMD_BUSY", budget: "polls_cmd", into: "sec2_mb0", tread: Some(("SEC2_MAILBOX1", "sec2_mb1")), err: "E_SEC2" } |
| 25 | - WaitReleased { reg: "HWCFG2", locked: "PRIV_LOCKED", mask: "PRIV_LOCKED_MASK", budget: "polls_mask", into: "hwcfg2", err: "E_MASK" } |
| 26 | - WaitLockdown { mb0: "GSP_MAILBOX0", mb1: "GSP_MAILBOX1", bit: "LOCKDOWN", budget: "polls_lockdown", err: "E_LOCKDOWN" } |
| 27 | - RefuseNonzero { reg: "GSP_MAILBOX0", into: "gsp_mb0", err: "E_FMC" } |
| 28 | - Write { reg: "FALCON_OS", val: "app_version" } |
| 29 | - RequireBit { bit: "ACTIVE", into: "cpuctl", err: "E_RISCV" } |
| 30 | |
| 31 | ## Evidence |
| 32 | |
| 33 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/blackwell/gb10b/dev_sec_pri.h:27`: "#define NV_PSEC_FALCON_MAILBOX0 0x00840040 /* RW-4R */" |
| 34 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/blackwell/gb10b/dev_sec_pri.h:30`: "#define NV_PSEC_FALCON_MAILBOX1 0x00840044 /* RW-4R */" |
| 35 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/blackwell/gb10b/dev_sec_pri.h:32`: "#define NV_PSEC_QUEUE_HEAD(i) (0x00840c00+(i)*8) /* RW-4A */" |
| 36 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/blackwell/gb10b/dev_sec_pri.h:36`: "#define NV_PSEC_QUEUE_TAIL(i) (0x00840c04+(i)*8) /* RW-4A */" |
| 37 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/blackwell/gb10b/dev_sec_pri.h:40`: "#define NV_PSEC_EMEMC(i) (0x00840ac0+(i)*8) /* RW-4A */" |
| 38 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/blackwell/gb10b/dev_sec_pri.h:42`: "#define NV_PSEC_EMEMC_OFFS 7:2 /* RWIVF */" |
| 39 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/blackwell/gb10b/dev_sec_pri.h:44`: "#define NV_PSEC_EMEMC_BLK 15:8 /* RWIVF */" |
| 40 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/blackwell/gb10b/dev_sec_pri.h:46`: "#define NV_PSEC_EMEMC_AINCW 24:24 /* RWIVF */" |
| 41 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/blackwell/gb10b/dev_sec_pri.h:54`: "#define NV_PSEC_EMEMD(i) (0x00840ac4+(i)*8) /* RW-4A */" |
| 42 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/blackwell/gb10b/dev_gsp.h:27`: "#define NV_PGSP 0x113fff:0x110000 /* RW--D */" |
| 43 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/hopper/gh100/dev_falcon_v4.h:27`: "#define NV_PFALCON_FALCON_MAILBOX0 0x00000040 /* RW-4R */" |
| 44 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/hopper/gh100/dev_falcon_v4.h:30`: "#define NV_PFALCON_FALCON_MAILBOX1 0x00000044 /* RW-4R */" |
| 45 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/hopper/gh100/dev_falcon_v4.h:34`: "#define NV_PFALCON_FALCON_OS 0x00000080 /* RW-4R */" |
| 46 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/hopper/gh100/dev_falcon_v4.h:39`: "#define NV_PFALCON_FALCON_HWCFG2 0x000000f4 /* R--4R */" |
| 47 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/hopper/gh100/dev_falcon_v4.h:79`: "#define NV_PFALCON_FALCON_HWCFG2_RISCV_BR_PRIV_LOCKDOWN 13:13 /* R--VF */" |
| 48 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/ampere/ga102/dev_riscv_pri.h:27`: "#define NV_FALCON2_GSP_BASE 0x00111000" |
| 49 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/hopper/gh100/dev_riscv_pri.h:58`: "#define NV_PRISCV_RISCV_CPUCTL 0x00000388 /* RW-4R */" |
| 50 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/hopper/gh100/dev_riscv_pri.h:68`: "#define NV_PRISCV_RISCV_CPUCTL_ACTIVE_STAT 7:7 /* R-IVF */" |
| 51 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/inc/swref/published/blackwell/gb20b/dev_gsp.h:33`: "#define NV_PGSP_QUEUE_HEAD(i) (0x00110c00+(i)*8) /* RW-4A */" |
| 52 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/nvidia/src/kernel/gpu/sec2/arch/blackwell/kernel_sec2_gb10b.c:39`: "#define SEC2_EMEM_CHANNEL_RM_SIZE 1024" |
| 53 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/nvidia/src/kernel/gpu/sec2/arch/blackwell/kernel_sec2_gb10b.c:271`: "const NvU32 privErrTargetLocked = 0xBADF4100U;" |
| 54 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/nvidia/src/kernel/gpu/sec2/arch/blackwell/kernel_sec2_gb10b.c:272`: "const NvU32 privErrTargetLockedMask = 0xFFFFFF00U;" |
| 55 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/nvidia/src/kernel/gpu/sec2/arch/blackwell/kernel_sec2_gb10b.c:292`: "const NvU32 cmdHandlingState = 0xc001cafe;" |
| 56 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/nvidia/src/kernel/gpu/sec2/arch/blackwell/kernel_sec2_gb10b.c:730`: "_ksec2UpdateQueueHeadTail_GB10B(pGpu, pKernelSec2, 0, paddedSize - sizeof(NvU32));" |
| 57 | - NVIDIA open-gpu-kernel-modules 580.173.02, `src/nvidia/src/kernel/gpu/gsp/arch/hopper/kernel_gsp_gh100.c:956`: "kflcnRegWrite_HAL(pGpu, pKernelFalcon, NV_PFALCON_FALCON_OS, pRiscvDesc->appVersion);" |
| 58 | |
| 59 | ## Proof on machines |
| 60 | |
| 61 | - gpu-sim aienos-host 2026-10-21 test_gsp_mmio pending |
| 62 | |
| 63 | ## Registers |
| 64 | |
| 65 | - SEC2_MAILBOX0 at bar 0 + 0x840040 (4 bytes, rw) |
| 66 | - SEC2_MAILBOX1 at bar 0 + 0x840044 (4 bytes, rw) |
| 67 | - EMEMC0 at bar 0 + 0x840ac0 (4 bytes, rw) |
| 68 | - EMEMD0 at bar 0 + 0x840ac4 (4 bytes, rw) |
| 69 | - QHEAD0 at bar 0 + 0x840c00 (4 bytes, rw) |
| 70 | - QTAIL0 at bar 0 + 0x840c04 (4 bytes, rw) |
| 71 | - GSP_MAILBOX0 at bar 0 + 0x110040 (4 bytes, rw) |
| 72 | - GSP_MAILBOX1 at bar 0 + 0x110044 (4 bytes, rw) |
| 73 | - FALCON_OS at bar 0 + 0x110080 (4 bytes, rw) |
| 74 | - HWCFG2 at bar 0 + 0x1100f4 (4 bytes, ro) |
| 75 | - GSP_QHEAD0 at bar 0 + 0x110c00 (4 bytes, rw) |
| 76 | - CPUCTL at bar 0 + 0x111388 (4 bytes, rw) |
| 77 | |
| 78 | ## Bits and fields |
| 79 | |
| 80 | - AINCW: EMEMC0 bit 24 |
| 81 | - LOCKDOWN: HWCFG2 bit 13 |
| 82 | - ACTIVE: CPUCTL bit 7 |
| 83 | - OFFS: EMEMC0 bits 7:2 |
| 84 | - BLK: EMEMC0 bits 15:8 |