interplane.Get Omega
Read in your language

physics-mv

FORGE: request-bound machine realization, providers and verification for AienOS. Host, simulated and GB10 hardware paths have separate evidence.

Brought by drakestapleton

GitHub aien-dev/physics-mv#49 (code only)

closed derived feda59ae98f9dd06 #49

Imported from GitHub aien-dev/physics-mv#49 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 9f96f2557c2ec265bc51a3a5df35ee033576684c · Head 3b16902faca64d56b4b5fb0985d9c72ec640b69c

Apply it

git checkout -b patch-feda59ae98f9dd06 9f96f2557c2ec265bc51a3a5df35ee033576684c
curl -fsSL https://interplane.io/drakestapleton/physics-mv/patches/feda59ae98f9dd06.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/physics-mv
49
3b16902faca64d56b4b5fb0985d9c72ec640b69c
{"kind":"github-import","owner":"aien-dev","repo":"physics-mv","number":49,"url":"https://github.com/aien-dev/physics-mv/pull/49","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:39:27Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 27d691c..111e985 100644
--- a/.crumb
+++ b/.crumb
@@ -86,14 +86,14 @@
         }
       ],
       "children_root": "sha256:d274fc9707332eea17973f05e53075630ed1ce2ec3c190d591d445282f19997f",
-      "compiled_at": "2026-10-05T04:08:30Z",
+      "compiled_at": "2026-10-10T10:32:03Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:7c691e8a3f7476bb5b4e256b771e03757d0ddd6b00405dc616aab503e786c0fa",
+      "digest": "sha256:b9a0f6de775c45f01726cf1691ba06c24d42cc5b7a6f3b2884d0e42fc1c34b3c",
       "evidence_files": 81,
       "evidence_root": "sha256:0a0459a4517679721bb2817540dd06995500a1c1ede079bc4665d9da5c39183d",
       "files": 261,
-      "generated_at_commit": "a25df81079bf9d314918e344ef30ba31e34b1523",
-      "source_tree": "sha256:044cfee4a2b9de4d914f7c9f1a0329d29d2130b2d0b80d536e62105be81305a1"
+      "generated_at_commit": "1e995328248a80c074e82b47c43f0c4836e77522",
+      "source_tree": "sha256:54c776a35e6b4aaf3f2a76ef9d42f255c3e5e5601f789448c23e9c805b72a132"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/nvrm/nvrm.c b/nvrm/nvrm.c
index a7cea38..45808fe 100644
--- a/nvrm/nvrm.c
+++ b/nvrm/nvrm.c
@@ -55,6 +55,29 @@ static int fail(Nvrm *rm, const char *fmt, ...) {
     return -1;
 }
 
+/* MemAvailable from /proc/meminfo in kB, or 0 when it cannot be read. An
+ * RM_ALLOC refused with NV_ERR_NO_MEMORY is only explained next to the size
+ * asked for and the host's free memory at that moment (sovereign-core #239). */
+static unsigned long long mem_available_kb(void) {
+    FILE *f = fopen("/proc/meminfo", "r");
+    if (!f) return 0;
+    char line[256];
+    unsigned long long kb = 0;
+    while (fgets(line, sizeof line, f))
+        if (sscanf(line, "MemAvailable: %llu kB", &kb) == 1) break;
+    fclose(f);
+    return kb;
+}
+
+/* Rewrite rm->err after a failed memory RM_ALLOC so it also carries the
+ * requested size and MemAvailable. */
+static int fail_alloc_context(Nvrm *rm, uint64_t size) {
+    char prev[sizeof rm->err];
+    memcpy(prev, rm->err, sizeof prev);
+    return fail(rm, "%s for %llu bytes, MemAvailable %llu kB", prev, (unsigned long long)size,
+                mem_available_kb());
+}
+
 static int nv_ioctl(int fd, unsigned nr, void *arg, size_t sz) {
     return ioctl(fd, NV_IOWR(nr, sz), arg);
 }
@@ -75,7 +98,9 @@ static int rm_alloc(Nvrm *rm, uint32_t parent, uint32_t cls, void *params, uint3
     p.paramsSize = psz;
     if (nv_ioctl(rm->fd_ctl, NV_ESC_RM_ALLOC, &p, sizeof p) != 0)
         return fail(rm, "RM_ALLOC class 0x%x ioctl errno %d", cls, errno);
-    if (p.status != 0) return fail(rm, "RM_ALLOC class 0x%x status 0x%x", cls, p.status);
+    if (p.status != 0)
+        return fail(rm, "RM_ALLOC class 0x%x status 0x%x%s", cls, p.status,
+                    p.status == NV_ERR_NO_MEMORY ? " (NV_ERR_NO_MEMORY)" : "");
     rm->rm_alloc_accepted++;
     *out = p.hObjectNew;
     return 0;
@@ -506,7 +531,7 @@ static int alloc_with_cacheability(Nvrm *rm, uint64_t size, NvrmMem *out, uint32
     if (rm_alloc(rm, rm->device, NV01_MEMORY_SYSTEM, &mp, sizeof mp, &h)) {
         if (munmap(res, size) != 0) rm->faulted = 1;
         rm->faulted = 1; /* unknown driver state: do not recycle this VA */
-        return -1;
+        return fail_alloc_context(rm, size);
     }
     void *cpu = map_to_cpu(rm, h, size, (void *)va, 0, 1);
     if (cpu != (void *)va) {