Loader: descriptor and write sites reach their stubs without the GPL-2.0-only console_insn helpers #393

Open
github-bot wants to merge 1 commit from github-bot/gh-393 into main AGit
Owner

@⁠MKmajster on GitHub · 2026-11-26 22:43 UTC · original
MKmajster:mk/descriptor-sites-own-helpers → main · +118 −16 · 4 files · 1 commits · open

descriptor_sites.rs (renderer port #2) and write_sites.rs take their jmp rel32 encoder and the room for their stubs (jump, near, STUBS_LEN) from console_insn.rs. That file says it is ported from XCL, which is GPL-2.0-only, while this tree is GPL-3.0-or-later — so the two patchers cannot be taken into GPL-3.0 trees cleanly.

This PR gives them a small module of their own, reach.rs, written from the instruction encoding alone:

  • jump(at, to): E9 and a signed 32-bit displacement counted from the end of the five bytes; None past ±2 GiB.
  • near(at): a 64 KiB region of executable memory, the free one nearest the code (above first, then below), found by walking VirtualQuery on 64 KiB lines.
  • STUBS_LEN: 64 KiB, as before.

All nine call sites move from console_insn:: to reach::. Behaviour is unchanged. console_insn.rs stays for the instructions it emulates; only the patchers no longer need it.

Tests: two new ones in reach.rs — the encoding and its reach in both directions, and that room taken near our own code is within a jump of it, on a 64 KiB line, and usable. cargo test -p victory-loader --lib: 54/54. The diagnostics build of victory compiles. Not run in the title on top of this exact commit; the same helpers (written for an fxceless-based tree) run port 2 there on an RTX 3070 without problems (sync_heaps 17 ms → under 1 ms a frame).

Thank you for port 2 — on NVIDIA it is the one renderer port that clearly helps (see #389).

AI-assisted, no game data attached.

🤖 Generated with Claude Code

**@⁠MKmajster** on GitHub · 2026-11-26 22:43 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/393) `MKmajster:mk/descriptor-sites-own-helpers` → `main` · +118 −16 · 4 files · 1 commits · open `descriptor_sites.rs` (renderer port #2) and `write_sites.rs` take their `jmp rel32` encoder and the room for their stubs (`jump`, `near`, `STUBS_LEN`) from `console_insn.rs`. That file says it is ported from XCL, which is GPL-2.0-only, while this tree is GPL-3.0-or-later — so the two patchers cannot be taken into GPL-3.0 trees cleanly. This PR gives them a small module of their own, `reach.rs`, written from the instruction encoding alone: - `jump(at, to)`: `E9` and a signed 32-bit displacement counted from the end of the five bytes; `None` past ±2 GiB. - `near(at)`: a 64 KiB region of executable memory, the free one nearest the code (above first, then below), found by walking `VirtualQuery` on 64 KiB lines. - `STUBS_LEN`: 64 KiB, as before. All nine call sites move from `console_insn::` to `reach::`. Behaviour is unchanged. `console_insn.rs` stays for the instructions it emulates; only the patchers no longer need it. **Tests:** two new ones in `reach.rs` — the encoding and its reach in both directions, and that room taken near our own code is within a jump of it, on a 64 KiB line, and usable. `cargo test -p victory-loader --lib`: 54/54. The diagnostics build of `victory` compiles. Not run in the title on top of this exact commit; the same helpers (written for an fxceless-based tree) run port 2 there on an RTX 3070 without problems (`sync_heaps` 17 ms → under 1 ms a frame). Thank you for port 2 — on NVIDIA it is the one renderer port that clearly helps (see #389). AI-assisted, no game data attached. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
descriptor_sites (renderer port #2) and write_sites took their jmp rel32
encoder and the room for their stubs (jump, near, STUBS_LEN) from
console_insn.rs, which says it is ported from XCL (GPL-2.0-only), while
this tree is GPL-3.0-or-later. They now use reach.rs, written from the
instruction encoding alone: a jmp rel32 counts from its own end and reaches
+-2 GiB; the stubs' 64 KiB region is the free one nearest the code (above,
else below), found by walking VirtualQuery. Behaviour is unchanged;
console_insn.rs is still used for the instructions it emulates.

Tests: reach (2: the encoding and its reach both ways; room near our own
code is within a jump of it, on a 64 KiB line, and usable), victory-loader
54/54.

AI-assisted (Claude Code), no game data attached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:56:32 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/393/head:github-bot/gh-393'
git switch 'github-bot/gh-393'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-393'
git switch 'github-bot/gh-393'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-393'
git switch 'github-bot/gh-393'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-393'
git switch 'main'
git merge --squash 'github-bot/gh-393'
git switch 'main'
git merge --ff-only 'github-bot/gh-393'
git switch 'main'
git merge 'github-bot/gh-393'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.