Repository navigation
[AUTOMATED] fix(p2): an inline svc/ecall/syscall/sc returned the registers set up for it, not its result - #826
Merged
Merged
Conversation
mahaloz
force-pushed
the
fix/svc-return-regs
branch
from
October 2, 2026 20:22
29bfe1b to
2e65cb9
Compare
…sters set up for it, not its result New option syscallregs off|auto|on (default auto: only on an ELF the loader proves is OS user-space). When it acts, the system-call user-op writes the ABI result register and reads the number register plus the argument registers written on every path to the call. Fixes #812 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz
force-pushed
the
fix/svc-return-regs
branch
from
October 2, 2026 22:14
276d7ee to
f6e0adf
Compare
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
Both #826 and this branch moved the settable counts from 250 to 251, which merged as one bump. Re-derived on a fresh build: 252 settables. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz
added a commit
to phix33/kuna
that referenced
this pull request
Oct 2, 2026
Brings in Noelo-Lab#826 (syscallregs). Counts re-derived on a fresh build: 252 settables, tiers 81/105/66, 251 catalog rows, corpus 388; the stages baseline is main's plus the three STACK STORE keys. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz
added a commit
that referenced
this pull request
Oct 3, 2026
Both #826 and this branch moved the settable counts from 250 to 251, which merged as one bump. Re-derived on a fresh build: 252 settables. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
kuna treats
svc(ARM, AArch64),ecall(RISC-V),syscall(MIPS) andsc(PowerPC) as writing no register, so after the call a function seems to return or test whatever it put in the result register to set the call up. A Linux wrapper that moves its arguments intor0/r1returns them as a pair:With this change it is
return software_interrupt(0,4,a1,a0,a1);. The same wrapper built for MIPS returns the syscall number it loaded intov0(return 0xfa4;), and in glibc a test of the result (if (r0 < 0)) tests the argument instead.The fix
syscallregs off|auto|on. When it acts, the CALLOTHER writes the result register (r0,x0,a0,v0,r3). It reads the number register, then the argument registers in order up to the first one the function does not write on every path to the call. A printed argument is always in its own position, and no undefined register becomes a parameter.autoacts only on an ELF that says it is a program for an operating system: a Linux/BSDEI_OSABI, aPT_INTERP, a dynamic section naming a shared object, or an ABI-tag note. Bare-metal RTOS handlers use the same instruction for a privilege change or a yield and leaver0alone. FreeRTOS'sxPortRaisePrivilegereturns ther0 = 0it set beforesvc 2, and staysreturn !v1;.onacts on any image.Not fixed:
--option syscallregs onis passed. That includes the.oin [AUTOMATED] An inline svc/ecall/sc whose arguments sit in the return registers comes back as a register-pair return #812.sigpending,pipe,symlink) still return a pair, now with the result as the low half.a3and PowerPCcr0error flags still read their pre-call values.The tests
tests/stages/kuna-syscallregs-{arm,aarch64,riscv,mips,ppc}.xmlshow the fix underon, and the old output underoffand underautoon a bare byte chunk.kuna-syscallregs-cortexm.xmlis the FreeRTOS function: unchanged by default, wrong if forcedon. The ARM and RISC-V tests include a call wherer1/a1is written butr0/a0is not, and a loop with scratch values in higher argument registers. Neither takes an argument position.kuna-cli/tests/syscall_regs_cli.rsloads the ARM witness as an object with and without a GNU ABI-tag note. The default fixes it only with the note.decompile-all,autovsoff, 25 stripped binaries (24,212 functions). The 12 without an OS marker are byte-identical: seven ARM firmware images, FreeRTOS RTOSDemo, p2im, a uClibc busybox and two RISC-V enclaves. So are two x86-64 Linux programs. In 10 non-x86 Linux images, 954 functions with a system call change, and 157 register pairs become single returns. 528 others change only in numbering, types or arguments taken from the wrappers they call. Datatests are unchanged (675/675).decompile-alloffvsauto, interleaved, min of 11 on a shared machine: ARMld.so24.10 s vs 24.26 s, MIPSld.so21.83 s vs 21.43 s, AArch64ld.so24.33 s vs 24.29 s.Fixes #812
🤖 Generated with Claude Code
https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt