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/CUDApp/blob/main/m16/m16_requalify.c # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / m16 / m16_requalify.c` 149 lines · 6312 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 /* 3 * m16_requalify.c -- M16 libcuda-free causality qualification test. 4 * 5 * Sequence: 6 * 1. Initialize raw RM client (zero libcuda). 7 * 2. Create independent channel, USERD, and obtain work-submit token. 8 * 3. Allocate coherent marker memory, initialize marker = 0. 9 * 4. Construct M16 semaphore-release method stream (expected payload: 0x16c0ffee). 10 * 5. Enqueue work to GPFIFO ring WITHOUT ringing doorbell. 11 * 6. Negative control: wait 100ms, assert marker remains strictly 0. 12 * 7. Positive stimulus: ring doorbell with session work-submit token. 13 * 8. Assert marker changes to 0x16c0ffee. 14 * 9. Inspect /proc/self/maps to prove libcuda.so was never loaded. 15 * 10. Output machine-parsable receipts. 16 */ 17 #include "m16_native.h" 18 /* The pass/fail decisions (word count, withheld marker, positive wait, libcuda 19 * audit) and the 0x16c0ffee payload come from om/engine/eng.om (op REQF, 20 * src/omega_eng_gates.h); the C oracle is behind CUDAPP_MIGRATION_PENDING_C_REQUALIFY. 21 * Exit codes are unchanged. */ 22 #if defined(CUDAPP_MIGRATION_PENDING_C_REQUALIFY) 23 #define ENG_C_PART 1 24 #endif 25 #include "omega_eng_gates.h" 26 #include "omega_fixture_rest.h" 27 #include 28 #include 29 #include 30 #include 31 32 static int check_proc_maps(void) { 33 FILE *f = fopen("/proc/self/maps", "r"); 34 if (!f) return -1; 35 unsigned char line[512] = {0}; 36 int hit = 0; 37 while (fgets((char *)line, sizeof(line), f)) { 38 if (omega_fixture_text(line, (const unsigned char[32]){"libcuda.so"}, 10) || 39 omega_fixture_text(line, (const unsigned char[32]){"libcudart.so"}, 12)) { 40 hit = 1; 41 break; 42 } 43 } 44 fclose(f); 45 return hit; 46 } 47 48 int main(int argc, char **argv) { 49 (void)argc; 50 (void)argv; 51 52 printf("=== M16 CORRECTIVE REQUALIFICATION: CONTROLLED CAUSALITY TRANSACTION ===\n"); 53 54 M16NativeContext ctx; 55 if (m16_native_open(&ctx) != 0) { 56 fprintf(stderr, "FATAL: m16_native_open failed: %s\n", ctx.rm.err); 57 return 1; 58 } 59 printf("[OBSERVED] RM client opened: GPU minor=%u compute_class=0x%x sm_version=0x%x\n", 60 ctx.rm.minor, ctx.rm.compute_class, ctx.rm.sm_version); 61 62 if (m16_native_create_channel(&ctx) != 0) { 63 fprintf(stderr, "FATAL: m16_native_create_channel failed: %s\n", ctx.rm.err); 64 m16_native_close(&ctx); 65 return 1; 66 } 67 printf("[OBSERVED] Channel initialized: token=0x%08x gpfifo=0x%08x fifo_va=0x%lx doorbell=%p\n", 68 ctx.rm.token, ctx.rm.gpfifo, (unsigned long)ctx.rm.fifo.va, (void *)ctx.rm.doorbell); 69 70 void *marker_cpu = NULL; 71 uint64_t marker_va = 0; 72 if (m16_native_alloc_memory(&ctx, 0x1000, &marker_cpu, &marker_va) != 0) { 73 fprintf(stderr, "FATAL: alloc marker failed: %s\n", ctx.rm.err); 74 m16_native_close(&ctx); 75 return 1; 76 } 77 volatile uint32_t *marker = (volatile uint32_t *)marker_cpu; 78 *marker = 0; 79 printf("[OBSERVED] Coherent marker allocated at VA=0x%lx CPU=%p (initial=0x%08x)\n", 80 (unsigned long)marker_va, marker_cpu, *marker); 81 82 uint32_t methods[32]; 83 uint32_t payload = omega_gate_reqf_payload(); 84 if (!omega_fixture_calc(FR_EQ, payload, 0x16c0ffeeu, 0)) { 85 fprintf(stderr, "FATAL: requalify payload unavailable (0x%08x)\n", payload); 86 m16_native_close(&ctx); 87 return 1; 88 } 89 int nwords = m16_native_build_release(methods, marker_va, payload, ctx.rm.compute_class); 90 if (!omega_gate_reqf(OMEGA_REQF_WORDS, nwords)) { 91 fprintf(stderr, "FATAL: build release failed\n"); 92 m16_native_close(&ctx); 93 return 1; 94 } 95 96 /* Step 1: Enqueue to GPFIFO without ringing doorbell */ 97 printf("\n--- STEP 1: NEGATIVE CONTROL (DOORBELL WITHHELD) ---\n"); 98 if (m16_native_enqueue_methods(&ctx, methods, (size_t)nwords) != 0) { 99 fprintf(stderr, "FATAL: enqueue failed: %s\n", ctx.rm.err); 100 m16_native_close(&ctx); 101 return 1; 102 } 103 printf("[OBSERVED] Enqueued %d words to GPFIFO index %u. Withholding doorbell notification...\n", 104 nwords, (uint32_t)omega_fixture_calc(FR_PREV32, ctx.rm.put, 0, 0)); 105 106 /* Wait 100ms and verify marker has NOT changed */ 107 usleep(100000); 108 printf("[OBSERVED] Marker after 100ms without doorbell: 0x%08x (expected 0x00000000)\n", *marker); 109 if (!omega_gate_reqf(OMEGA_REQF_MARKER_ZERO, (int64_t)*marker)) { 110 fprintf(stderr, "FATAL: Negative control failed: marker changed without doorbell!\n"); 111 m16_native_close(&ctx); 112 return 2; 113 } 114 printf("NEGATIVE_CONTROL_PASS: Marker strictly remained 0x00000000 while doorbell was withheld.\n"); 115 116 /* Step 2: Positive stimulus (Ring doorbell) */ 117 printf("\n--- STEP 2: POSITIVE STIMULUS (DOORBELL RUNG) ---\n"); 118 printf("[OBSERVED] Storing work-submit token 0x%08x to doorbell MMIO at %p...\n", 119 ctx.rm.token, (void *)ctx.rm.doorbell); 120 m16_native_ring_doorbell(&ctx); 121 122 if (!omega_gate_reqf(OMEGA_REQF_WAIT_OK, m16_native_wait_marker(marker, payload, 2000))) { 123 fprintf(stderr, "FATAL: Positive control failed: timeout waiting for marker 0x16c0ffee! Actual=0x%08x\n", 124 *marker); 125 m16_native_close(&ctx); 126 return 3; 127 } 128 printf("[OBSERVED] Marker after doorbell rung: 0x%08x (expected 0x16c0ffee)\n", *marker); 129 printf("POSITIVE_CONTROL_PASS: Marker successfully updated to 0x16c0ffee upon doorbell store.\n"); 130 131 /* Step 3: Process mappings audit */ 132 int cuda_mapped = check_proc_maps(); 133 printf("\n--- STEP 3: RUNTIME LIBCUDA AUDIT ---\n"); 134 printf("[OBSERVED] libcuda.so / libcudart.so present in /proc/self/maps: %s\n", 135 cuda_mapped ? "YES (FAIL)" : "NO (PASS)"); 136 if (!omega_gate_reqf(OMEGA_REQF_NO_LIBCUDA, cuda_mapped)) { 137 fprintf(stderr, "FATAL: libcuda detected in process address space!\n"); 138 m16_native_close(&ctx); 139 return 4; 140 } 141 printf("NO_LIBCUDA_PASS: Zero libcuda / libcudart mappings present in live process.\n"); 142 143 printf("\nCAUSALITY_VERIFICATION_PASS: Doorbell causality strictly confirmed.\n"); 144 printf("M16_REQUALIFICATION_PASS: Milestone 16 native execution verified.\n"); 145 146 nvrm_retire(&ctx.rm, ctx.rm.put); 147 m16_native_close(&ctx); 148 return 0; 149 }