From c17b0d7b903335808cf49496c1a4bba8d7f252ef Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 14 Aug 2026 11:31:24 -0500 Subject: [PATCH] fix(tools/uci): phase3_tcp_echo dies on its own uci_host_buf write (#97) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `phase3_tcp_echo.py` pre-seeds `uci_host_buf` over DMA so the hostname is in place regardless of what `net_dns_resolve` copies. That write has no `override=`, and `uci_host_buf` resolves to $6760 — UCI_BSS, which the post-W1 UCI cfg packs *inside* CRYPTO_HOT ($6000-$9FFF). The harness MemoryPolicy reserves CRYPTO_HOT as one coarse region and cannot tell a writable BSS byte from resident code, so a legitimate write raises MemoryPolicyError: write_memory($6760, 32 B) -> $677F blocked: overlaps reserved region $6000-$9FFF (segment:CRYPTO_HOT) and the script cannot complete on any device. Reported by an outside contributor in #97, where it also blocked the diagnostic baseline run they had been asked for. Fix is an `override=""` at the call site, mirroring the `_OVR` idiom already in `bench_ecdsa_u64e.py:186` — not a policy relaxation, since the guard is doing its job everywhere else. Audited the rest of the tree for the same latent break: `grep -rn 'write_memory(labels' tools/` returns six sites, the other five in `bench_ecdsa_u64e.py` and all already overridden. Every other `write_memory` under `tools/uci/` targets an `arbiter.alloc()` address. This was the only one. Co-Authored-By: Claude Opus 5 (1M context) --- tools/uci/phase3_tcp_echo.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/uci/phase3_tcp_echo.py b/tools/uci/phase3_tcp_echo.py index 3eda53dc..964e0dbd 100644 --- a/tools/uci/phase3_tcp_echo.py +++ b/tools/uci/phase3_tcp_echo.py @@ -436,7 +436,20 @@ def main() -> int: # Also pre-populate uci_host_buf directly — net_dns_resolve in the # routine copies from HOST_BUF_ADDR into uci_host_buf, but we DMA # the string into both locations for belt-and-braces determinism. - transport.write_memory(labels["uci_host_buf"], host_bytes) + # + # uci_host_buf is UCI_BSS, which the post-W1 UCI cfg packs inside + # CRYPTO_HOT ($6000-$9FFF, cfg/c64-https-uci.cfg) — it resolves to + # $6760 at the current pin. The MemoryPolicy reserves CRYPTO_HOT as + # one coarse region and cannot tell a writable BSS byte from resident + # code, so this legitimate write reads as a collision and raises + # MemoryPolicyError (issue #97). Override with a reason rather than + # widening the policy for everyone. + transport.write_memory( + labels["uci_host_buf"], + host_bytes, + override="uci_host_buf is UCI_BSS packed inside CRYPTO_HOT; " + "pre-seeding the hostname buffer is the point of the test", + ) # Clear result area (sentinel + collected bytes) transport.write_memory(RESULT_BUF_ADDR, bytes(0x80))