Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/seat_marker_uncached_test.sh # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / seat_marker_uncached_test.sh` 53 lines ยท 3393 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 3 # Copyright 2026 Drake Stapleton (AIEN / aien-dev) 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # Source guard: every page the host POLLS or reads for the resident seat's completion must be GPU-uncached. 18 # NVIDIA nvos.h NVOS32_ATTR2_GPU_CACHEABLE_YES: "For system memory this will not be coherent with direct CPU 19 # mappings"; spark-hardware-manual s4.1: "Any word the host polls ... must be allocated nvrm_alloc_gpu_uncached". 20 # Evidence (CAND-1 window 2 and the R15 seat A/B, 2026-10-05): with a GPU-cacheable marker page the seat's leave 21 # marker reached the host ~1.05 s late in 15 of 16 trials and never within the wait in 3 of 64 (~102 s stalls); 22 # with a GPU-uncached page it arrived in 13 to 20 ms in 16 of 16, no stall. 23 # Two guards: (1) the marker page is allocated uncached; (2) the semaphore word the host reads right after the 24 # marker (gates rx_gpu_seat_finish) lives on that same uncached page, not on the cached QMD page. 25 # The check reads src/runtime/rx_resident_gpu.c; mutants prove it can say no. 26 cd "$(dirname "$0")/.." || exit 1 27 F=${SEAT_SRC:-src/runtime/rx_resident_gpu.c}; fail=0 28 guard() { # file -> 0 when both pages are uncached 29 grep -Eq 'nvrm_alloc_gpu_uncached\([^;]*&job->marker_mem\)' "$1" || return 1 30 grep -Eq '[^_]nvrm_alloc\([^;]*&job->marker_mem\)' "$1" && return 1 31 grep -Eq 'sem_va = marker_mem\.va \+ 0x[0-9a-fA-F]+;' "$1" || return 1 32 grep -Eq '\(uint8_t \*\)marker_mem\.cpu \+ 0x[0-9a-fA-F]+\)' "$1" || return 1 33 grep -Eq 'sem_va = qmd_mem\.va|\(uint8_t \*\)qmd_mem\.cpu \+ 0x2000' "$1" && return 1 34 return 0 35 } 36 chk() { # name file expect(0=guard passes,1=guard must refuse) 37 guard "$2"; got=$? 38 if [ "$got" = "$3" ]; then echo "[+] $1"; else echo "[-] $1 (guard exit $got, want $3)"; fail=$((fail + 1)); fi 39 } 40 W=$(mktemp -d) || exit 1; trap 'rm -rf "$W"' EXIT 41 chk "seat marker page and semaphore are GPU-uncached" "$F" 0 42 sed 's/nvrm_alloc_gpu_uncached(\(&ctx->rm, 0x1000, &job->marker_mem\))/nvrm_alloc(\1)/' "$F" > "$W/m1.c" 43 cmp -s "$F" "$W/m1.c" && { echo "[-] mutant 1 did not change the source"; fail=$((fail + 1)); } 44 chk "mutant: cacheable marker page is refused" "$W/m1.c" 1 45 sed 's/&job->marker_mem/\&job->marker_mem_x/' "$F" > "$W/m2.c" 46 chk "mutant: marker allocation not found is refused" "$W/m2.c" 1 47 sed 's/sem_va = marker_mem\.va + 0x20;/sem_va = qmd_mem.va + 0x2000;/' "$F" > "$W/m3.c" 48 cmp -s "$F" "$W/m3.c" && { echo "[-] mutant 3 did not change the source"; fail=$((fail + 1)); } 49 chk "mutant: semaphore back on the cached QMD page is refused" "$W/m3.c" 1 50 sed 's/(uint8_t \*)marker_mem\.cpu + 0x20)/(uint8_t *)qmd_mem.cpu + 0x2000)/' "$F" > "$W/m4.c" 51 cmp -s "$F" "$W/m4.c" && { echo "[-] mutant 4 did not change the source"; fail=$((fail + 1)); } 52 chk "mutant: host reads the semaphore from the cached page is refused" "$W/m4.c" 1 53 echo "failures $fail"; [ "$fail" = 0 ]