From 5df9e846ffedb0e2e26a6883f6520bf546249407 Mon Sep 17 00:00:00 2001 From: Nathaniel Pawelczyk Date: Tue, 1 Dec 2026 20:30:50 -0600 Subject: [PATCH] Runtime loader and upload controller to GPL-2.0-or-later (rides Octatrack base 0.8.6) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit repeat98 (Jannik Aßfalg) agreed for his loader, upload and diagnostics layout (relayed by Nathaniel Pavel, 1 December 2026). The two short loader changes by other authors, twwwy's engine price check (2eed068ca) and ex1010's image check hook (00ecaf529), are rewritten by Nathaniel Pavel with the same behaviour and interface: engine_priced() is the old condition, and a nonzero refusal is still refused. The Python tools and the tests under sdk/runtime keep GPL-3.0-or-later; nothing in a base compiles them. The Octatrack base is built from these files (src/engine/assets/octatrack-base-sources.json), so this makes the committed base stale: it is regenerated with the rest of base 0.8.6 (base/octatrack-next, #2473). This is the same change as 0eb7a85e9, which #1934 left out so as not to force an Octatrack release. Co-Authored-By: Claude Opus 5.5 --- changelog/2026-12-01-runtime-loader-gpl2.md | 1 + sdk/runtime/loader/context.h | 2 +- sdk/runtime/loader/journal.h | 2 +- sdk/runtime/loader/loader.c | 28 +++++++++++++++------ sdk/runtime/loader/loader.h | 14 ++++++----- sdk/runtime/loader/modwerk_module.h | 2 +- sdk/runtime/loader/set_package.h | 2 +- sdk/runtime/upload/README.md | 3 ++- sdk/runtime/upload/sha256.c | 2 +- sdk/runtime/upload/upload.c | 2 +- sdk/runtime/upload/upload.h | 2 +- sdk/runtime/upload/vendor.c | 2 +- sdk/runtime/upload/vendor.h | 2 +- sdk/runtime/upload/wire.c | 2 +- sdk/runtime/upload/wire.h | 2 +- 15 files changed, 42 insertions(+), 26 deletions(-) create mode 100644 changelog/2026-12-01-runtime-loader-gpl2.md diff --git a/changelog/2026-12-01-runtime-loader-gpl2.md b/changelog/2026-12-01-runtime-loader-gpl2.md new file mode 100644 index 0000000000..f230999346 --- /dev/null +++ b/changelog/2026-12-01-runtime-loader-gpl2.md @@ -0,0 +1 @@ +Runtime loader and upload controller: their C sources (`sdk/runtime/loader`, `sdk/runtime/upload`) are now GPL-2.0-or-later, with their authors' agreement, so a base whose release set may hold GPL-2.0-only modules (the Analog Rytm MKII's) can carry the loader. Two small loader checks (an engine's price per voice, the machine's look at a rebuilt DSP image) were rewritten; they accept and refuse the same packages. The Octatrack base is built from these files, so it is rebuilt with base 0.8.6. diff --git a/sdk/runtime/loader/context.h b/sdk/runtime/loader/context.h index 6261abf89e..daaa7d6d76 100644 --- a/sdk/runtime/loader/context.h +++ b/sdk/runtime/loader/context.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ #ifndef MODWERK_RUNTIME_CONTEXT_H #define MODWERK_RUNTIME_CONTEXT_H /* ColdFire backend-entry wrappers capture before a C prologue can reuse a diff --git a/sdk/runtime/loader/journal.h b/sdk/runtime/loader/journal.h index 91d6a32a2a..1049cece72 100644 --- a/sdk/runtime/loader/journal.h +++ b/sdk/runtime/loader/journal.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later +/* SPDX-License-Identifier: GPL-2.0-or-later * Private engine-only volatile publication journal. No host-supplied image, * generation, readiness, extent or ACK authority. Feature64 remains closed. */ #ifndef MODWERK_RUNTIME_JOURNAL_H diff --git a/sdk/runtime/loader/loader.c b/sdk/runtime/loader/loader.c index 047501a2be..416c5f728a 100644 --- a/sdk/runtime/loader/loader.c +++ b/sdk/runtime/loader/loader.c @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later +/* SPDX-License-Identifier: GPL-2.0-or-later * Machine-neutral runtime module loader (README.md). Several modules are * live at once, each at its own dispatch position with its own pool extent. * Prepare admits a package (memory, a position, and sites no other live @@ -120,10 +120,20 @@ __attribute__((weak)) int modwerk_machine_metadata_admit(const struct runtime_ds #endif #ifndef MODWERK_RUNTIME_IMAGE_EXTERNAL -__attribute__((weak)) int modwerk_machine_image_validate(const struct runtime_dsp *d) -{ (void)d;return RUNTIME_OK; } +/* A machine without its own check takes every rebuilt image. */ +__attribute__((weak)) int modwerk_machine_image_validate(const struct runtime_dsp *dsp) +{ + (void)dsp; + return RUNTIME_OK; +} #endif +/* An engine's price per voice: a nonzero cycle count, measured by running it or on the hardware. */ +static int engine_priced(const struct runtime_dsp *dsp) +{ + return dsp->cycles != 0u && (dsp->kind == RUNTIME_EXECUTED || dsp->kind == RUNTIME_HARDWARE); +} + const struct runtime_module *modwerk_runtime_module(unsigned i) { return i < RUNTIME_MODULES ? live[i] : 0; } /* The engine task is the only writer. Add the new bits before publishing the module and clear its absent * hooks afterwards. A reader can interrupt anywhere: an extra bit just makes it look at the live slot. */ @@ -1136,8 +1146,7 @@ static int __attribute__((used)) prepare_context(void *u, const uint8_t *data, u if (dsp.count > RUNTIME_DSP_WORDS || dsp.relocation_count > RUNTIME_DSP_RELOCATIONS || left != 4u * dsp.count + 2u * dsp.relocation_count + 4u * init_words || (!dsp.count && dsp.relocation_count) || (dsp.count && !engine && (dsp.init >= dsp.count || dsp.proc >= dsp.count || !dsp.slots || dsp.slots > 3u)) || - (engine && (dsp.init || dsp.proc || !dsp.cycles || (dsp.kind != RUNTIME_EXECUTED && dsp.kind != RUNTIME_HARDWARE) || - dsp.state || dsp.buffer || dsp.id || !entries))) + (engine && (dsp.init || dsp.proc || !engine_priced(&dsp) || dsp.state || dsp.buffer || dsp.id || !entries))) return refuse(RUNTIME_MALFORMED); for (uint32_t i = 0; i < dsp.count; ++i) if (be32(words + 4u * i) > 0xffffffu) return refuse(RUNTIME_MALFORMED); for (uint32_t i = 0; i < init_words; ++i) if (be32(init + 4u * i) > 0xffffffu) return refuse(RUNTIME_MALFORMED); @@ -1222,11 +1231,14 @@ static int __attribute__((used)) prepare_context(void *u, const uint8_t *data, u p += site_bytes(abi, n, r); } dsp.image = to; - if (be16(data + 6) & 1u) dsp.page = to, dsp.page_bytes = image; /* a page recipe heads the image */ - admission_lock = modwerk_machine_lock(); + if (be16(data + 6) & 1u) { /* the image starts with a page recipe */ + dsp.page = to; + dsp.page_bytes = image; + } + admission_lock = modwerk_machine_lock(); /* the machine looks at the rebuilt image before anyone can use it */ why = modwerk_machine_image_validate(&dsp); modwerk_machine_unlock(admission_lock); - if (why) return refuse((enum runtime_refusal)why); + if (why != RUNTIME_OK) return refuse((enum runtime_refusal)why); #if CACHED_MODULES /* instruction fetches read memory, not the data cache: the extent's lines reach memory first */ modwerk_machine_flush_data((uint32_t)(uintptr_t)m, head + code + tail); #endif diff --git a/sdk/runtime/loader/loader.h b/sdk/runtime/loader/loader.h index 19e5510aa2..cc5915d1c5 100644 --- a/sdk/runtime/loader/loader.h +++ b/sdk/runtime/loader/loader.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later +/* SPDX-License-Identifier: GPL-2.0-or-later * Machine-neutral runtime module loader: the upload controller's backend * (README.md). A machine adds the glue declared at the end and trampolines * from its hook bus that call the active module's hooks. */ @@ -100,8 +100,9 @@ struct runtime_dsp { const struct runtime_dsp_claim *claims; /* ABI 10: an engine instead of an effect (the package's slots 0): DSP words for the base's hook sites, at base 0, * each relocation an index (| 0x8000: the word holds a fixed P address, value - base; else an offset, value + - * base); count 0 here, so nothing takes it for an effect. Kept in its pool extent, as the claims are. Its `cycles` - * and `kind` are its price per voice (never 0, executed or hardware), outside the controller digest. */ + * base); count 0 here, so nothing takes it for an effect. Kept in its pool extent, as the claims are. An engine + * prices each voice in `cycles` (more than 0) and says how in `kind` (executed or hardware); the controller digest + * leaves both out. */ uint32_t engine_count, init_count; /* init_count: every init claim's words, in claim order (`initial`) */ uint16_t engine_relocation_count; uint8_t entry_count, pad; @@ -266,9 +267,10 @@ enum runtime_metadata_operation { RUNTIME_METADATA_PREPARE=1, RUNTIME_METADATA_S * declaration and current/paused consumer checks. */ int modwerk_machine_metadata_admit(const struct runtime_dsp *from, struct runtime_dsp *to, const struct runtime_context *,enum runtime_metadata_operation); -/* Read-only format check of the reconstructed image, after relocations/copies/fills and before it receives an - * owner identity or can be published. Locked; no roots, retirement, DSP commands or admission side effects. - * image/page name reconstructed bytes; other arrays are still temporary. Default accepts. A runtime_refusal. */ +/* The machine's look at a module's DSP image once the loader has rebuilt it (relocated, copied, filled), before + * the image has an owner or is published. Called under the machine lock; it only reads: it starts no DSP command, + * takes no root and admits or retires nothing. `image` and `page` point at the rebuilt bytes; the other arrays are + * scratch at this point. Returns RUNTIME_OK, or the runtime_refusal to give; without a machine's own, it accepts. */ int modwerk_machine_image_validate(const struct runtime_dsp *); int modwerk_machine_dsp_admit(const struct runtime_dsp *from, struct runtime_dsp *to); /* may set to->id */ /* 1 while a restore switches (an Undo, or the rollback after a failed self-test): it puts a position back as it was diff --git a/sdk/runtime/loader/modwerk_module.h b/sdk/runtime/loader/modwerk_module.h index 6941f9dd50..5a9fca32c6 100644 --- a/sdk/runtime/loader/modwerk_module.h +++ b/sdk/runtime/loader/modwerk_module.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later +/* SPDX-License-Identifier: GPL-2.0-or-later * What a runtime module sees (ABI 2, README.md): build it with build.py. * Define any of these handlers. They are the events every Elekloader core's * hook bus has, with its conventions (Elekloader docs/ADAPTING.md), and run diff --git a/sdk/runtime/loader/set_package.h b/sdk/runtime/loader/set_package.h index 68a797bf40..d13ddaa626 100644 --- a/sdk/runtime/loader/set_package.h +++ b/sdk/runtime/loader/set_package.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later +/* SPDX-License-Identifier: GPL-2.0-or-later * MWMS v1: one stopped module-set transaction, over the production lifecycle. * Header: magic, version u16, count u16, total u32, reserved-zero u32, * exact base SHA-256, baseline MWS1 SHA-256. Then length u32 and an MWRM diff --git a/sdk/runtime/upload/README.md b/sdk/runtime/upload/README.md index 1cc2cc3c7e..cdf593e5be 100644 --- a/sdk/runtime/upload/README.md +++ b/sdk/runtime/upload/README.md @@ -218,7 +218,8 @@ Native compilation uses GNU `m68k-elf` for MCF54455, strict warnings, no libc assumptions and no unresolved symbols. Compiler stack reports are recorded privately; they are not chip timing or complete call/interrupt-stack bounds. Objects contain only authored code and standard SHA constants. No stock, -firmware or device is read by either command. Authored code is GPL-3.0-or-later. +firmware or device is read by either command. The C sources here are GPL-2.0-or-later (1 December 2026), so a +release base carries them beside GPL-2.0-only modules; the rest of the authored code is GPL-3.0-or-later. ## Remaining integration diff --git a/sdk/runtime/upload/sha256.c b/sdk/runtime/upload/sha256.c index 6f81455964..d1f3a8aa79 100644 --- a/sdk/runtime/upload/sha256.c +++ b/sdk/runtime/upload/sha256.c @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later +/* SPDX-License-Identifier: GPL-2.0-or-later * Original freestanding SHA-256 implementation. All input lengths are bounded * by the upload controller; no heap or firmware-derived data. */ #include "upload.h" diff --git a/sdk/runtime/upload/upload.c b/sdk/runtime/upload/upload.c index a5f5dfd3ae..c805c75b51 100644 --- a/sdk/runtime/upload/upload.c +++ b/sdk/runtime/upload/upload.c @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later +/* SPDX-License-Identifier: GPL-2.0-or-later * No OS calls, malloc, filesystem, raw destination addresses or flash writes. * Preparation/publishing is deliberately impossible without a complete adapter. */ #include "upload.h" diff --git a/sdk/runtime/upload/upload.h b/sdk/runtime/upload/upload.h index abd97da070..20d133cf3b 100644 --- a/sdk/runtime/upload/upload.h +++ b/sdk/runtime/upload/upload.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ #ifndef MODWERK_UPLOAD_H #define MODWERK_UPLOAD_H #include diff --git a/sdk/runtime/upload/vendor.c b/sdk/runtime/upload/vendor.c index 3d7f897617..79be719734 100644 --- a/sdk/runtime/upload/vendor.c +++ b/sdk/runtime/upload/vendor.c @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ #include "vendor.h" enum { IDLE, RECEIVING, QUEUED, READY, REFUSED }; diff --git a/sdk/runtime/upload/vendor.h b/sdk/runtime/upload/vendor.h index 2be5449553..70224f4fab 100644 --- a/sdk/runtime/upload/vendor.h +++ b/sdk/runtime/upload/vendor.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ #ifndef MODWERK_UPLOAD_VENDOR_H #define MODWERK_UPLOAD_VENDOR_H #include "wire.h" diff --git a/sdk/runtime/upload/wire.c b/sdk/runtime/upload/wire.c index 19289ea137..18f104191a 100644 --- a/sdk/runtime/upload/wire.c +++ b/sdk/runtime/upload/wire.c @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ #include "wire.h" static uint32_t read32(const uint8_t *p) { diff --git a/sdk/runtime/upload/wire.h b/sdk/runtime/upload/wire.h index 87cf20d5da..6e8f23a1c1 100644 --- a/sdk/runtime/upload/wire.h +++ b/sdk/runtime/upload/wire.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ #ifndef MODWERK_UPLOAD_WIRE_H #define MODWERK_UPLOAD_WIRE_H #include "upload.h"