Commit Graph
128 Commits
Author SHA1 Message Date
zachdoxsee db40a1307d loader, cli: bound delay-load tables by their declared size (#244)
Address review on the delay-import probe change:

- Read only descriptors inside the delay import directory's declared
  size, and require that size to hold the terminating empty descriptor.
- Require each descriptor's DLL name, import address table and import
  name table to be present and to start in section data, with a
  diagnostic naming the missing field.
- Leave delayed rows out of the xenora imports sync backlog, so its
  totals stay ordinary-only.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 16:28:02 +01:00
zachdoxsee b174b45bed loader: report delay-loaded PE imports in the static probe (#244)
Read the PE32+ delay-load directory (data directory 13) with a bounded
parser and list each delay-loaded import in imports.csv, marked by a new
import_table column. Ordinary totals and missing_imports.csv are
unchanged; the JSON report counts delayed slots and DLLs separately and
carries a diagnostic for truncated, out-of-range or unsupported tables.

Adds an original fixture with ordinary and delayed imports, generated by
fixtures/pe/delay-imports.py and cross-checked with llvm-readobj.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 16:25:14 +01:00
Ranveer Soni 2b858ab7c6 Merge branch 'main' into runtime/last-error-per-thread 2026-11-24 20:52:39 +05:30
Ranveer Soni 1915e2374c Merge pull request #297 from Swastickc/task/196-bit-scan-bit-test
loader: lower BSF, BSR and register BT in the ARM64 DBT (#196)
2026-11-24 20:49:54 +05:30
LanaCodes-Boop 7623fde0e7 loader: retire a guest thread's last error and test the per-TEB contract (#202)
main keeps the last error per TEB since #310. This adds the missing
retirement step, so a reused TEB address starts at zero, and two
conformance tests: a successful call keeps a nonzero error, and one
thread's failure does not reach another.

Signed-off-by: LanaCodes-Boop <139008131+LanaCodes-Boop@users.noreply.github.com>
2026-11-24 12:10:20 -03:00
Adeeb RahmanandCursor 17fa47f058 Add CRT onexit tables, atexit and _cexit
Exit functions are guest code run through callback tasks in reverse
registration order. Table storage lives on the default guest heap.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-24 09:52:50 -05:00
Adeeb Rahman 6c460f7c1c Merge upstream main a2a6a56 into system runtime branch
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 09:48:20 -05:00
Adeeb RahmanandCursor 8d7f7fadb4 Add guest system information, calendar time and sleeping
The guest sees a configurable simulated machine, kept separate from the
detected host hardware. Sleeping goes through the injectable clock.
Move the PE fixture harness into a shared test support module.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-24 09:48:16 -05:00
Adeeb RahmanandCursor 1eae910ce1 Let services call guest code and continue after it returns
Add callback tasks to the import dispatcher. A task runs guest callbacks
on a reserved stack frame, checks the nonvolatile registers after each,
and returns to the original caller. Use it for qsort, qsort_s, bsearch,
bsearch_s, _initterm, _initterm_e, InitOnceExecuteOnce and FlsFree
cleanup callbacks.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-24 09:41:39 -05:00
jelly013 c586a4a82a test(loader): tighten the x86-64 known answers after review (#155)
Pin MXCSR for a flushed exact tiny result, PE for unmasked overflow and
underflow, and run the sweeps with each exception unmasked alone. Require a
refused form to stop at its exact instruction with all state unchanged,
assert the cached DBT run hits the cache, and check the fallback counter for
every straight-line case. Add a faulting zero-count memory shift.

The tighter checks expose one more defect, kept as an ignored test: an exact
unmasked overflow sets PE as well as OE.

Correct the chronology: 700 table cases were written before the CPU source
was read, and the other cases and the sweeps afterwards. The message of
1c5c320 says otherwise.

Signed-off-by: jelly013 <22855910+jelly013@users.noreply.github.com>
2026-11-24 15:41:20 +01:00
Adeeb RahmanandCursor ac6f9daff3 Add guest mutexes, locks, one-time init, SLists and TLS slots
Ownership is keyed by guest TEB. Operations that would block another
guest thread stop with the runtime-limit fault because no guest
scheduler exists. Also stop the import generator from overriding the
semaphore handlers with stubs, and check every generator standard
service against the loader registry.

Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-24 09:33:07 -05:00
jelly013 1c5c320437 test(loader): x86-64 architectural known answers from the Intel SDM (#155)
Add 727 cases and definition-based sweeps for the guest CPU, derived from
the Intel SDM (revision 093) before the CPU code was read. The interpreter
and the DBT run the same cases.

588 cases are verified, 133 use forms both engines refuse, and four ignored
tests state open defects: stale DBT blocks after the guest rewrites code,
the address of a page-crossing fault, and the fault class of a
non-canonical address and of an instruction over 15 bytes.

Signed-off-by: jelly013 <22855910+jelly013@users.noreply.github.com>
2026-11-24 15:02:24 +01:00
Adeeb Rahman 105bf8a65c Add local fixture profiles and selection notifications
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:58:40 -05:00
Adeeb Rahman 9da73f8ad8 Expose fixture save quota usage and platform capabilities
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:57:03 -05:00
Adeeb Rahman 9241630f6c Add quota-checked save slots for original guest fixtures
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:56:19 -05:00
Adeeb Rahman 542684612d Add process-local platform lifecycle identity and settings
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:55:17 -05:00
Adeeb Rahman f9a7d99638 Drain terminated manual GDK queues with canceled callbacks
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:54:10 -05:00
Adeeb Rahman 32e41e3890 Schedule delayed GDK callbacks on manual ports
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:52:34 -05:00
Adeeb Rahman bf56047db9 Wait for manual GDK callbacks with bounded dispatch deadlines
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:51:29 -05:00
Adeeb Rahman fa2e89cc06 Dispatch queued GDK callbacks through translated guest execution
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:50:31 -05:00
Adeeb Rahman b8fae106af Queue bounded GDK guest callbacks on shared ports
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:48:46 -05:00
Swastick Chowdhury 547b10250d loader: lower BSF, BSR and register BT in the ARM64 DBT (#196)
BSF, BSR and BT were decoded and executed by the interpreter, but every
occurrence of them in a translated block fell back to the shared semantics,
because `is_native` did not list them. The static probe therefore counted
them among the instructions the ARM64 DBT does not support.

Lower them to ARM64:

- BSF writes the index of the lowest set bit of the source and BSR the index
  of the highest set bit. The lowest set bit is the highest set bit of the
  reversed value, so BSF is `RBIT` followed by `CLZ`, and BSR is 63 minus the
  leading zero count.
- A zero source sets the zero flag and leaves the destination undefined, so
  the destination keeps its value. The interpreter and the independent
  reference apply the same rule, and the reference marks the destination as
  undefined so it is not compared.
- BT sets the carry flag from the tested bit, with the bit index masked to
  the operand width. The bit string is not modified.

Only the `0F A3` form of BT is lowered. The `0F BA` group form takes an
immediate index and may write memory, so it stays on the shared semantics and
is not advertised as natively supported.

The new encodings of RBIT, CLZ and LSLV were cross-checked against LLVM 23.1.6
`llvm-mc -show-encoding`.

The BSF, BSR and BT fixtures in `tests/x86/integer.txt` already cover the
16-bit, 32-bit and 64-bit forms with register and memory sources, and the
fixture test asserts that a native form never reaches the shared-semantics
helper, so those fixtures now exercise the new native path against the
independent reference. A new test pins the zero source, the highest bit, the
operand widths, the flag results and the masked bit index.

Closes #196

Signed-off-by: Swastick Chowdhury <28708247+Swastickc@users.noreply.github.com>
2026-11-24 19:17:53 +05:30
Adeeb Rahman 4b370efa12 Expose shared ports for manual GDK composite queues
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:47:43 -05:00
Adeeb Rahman f6c87de433 Add manual GDK task queue handle ownership
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:46:45 -05:00
Adeeb Rahman 0b6ab43ad4 Apply task deadlines to cooperative background work
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:45:32 -05:00
Adeeb Rahman aa93665b97 Allow cooperative cancellation of running runtime tasks
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:44:37 -05:00
Adeeb Rahman 565c144a39 Run runtime tasks on a managed background worker
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:43:38 -05:00
Adeeb Rahman ed33b57c8d Exercise manual asynchronous tasks through original guest services
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:42:27 -05:00
Adeeb Rahman 9e2c7b6e0b Add bounded manual work and completion ports for runtime tasks
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:41:17 -05:00
Adeeb Rahman 88e7dad8b2 Verify UDP polling wakes on a concurrent send
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:40:20 -05:00
Adeeb Rahman 7ff88bc3f4 Support bounded positive timeouts in guest UDP polling
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:39:27 -05:00
Adeeb Rahman 0109aea9ea Report synthetic UDP socket type and datagram limit
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:38:28 -05:00
Adeeb Rahman ce2a753d2f Expose guest UDP local and peer addresses
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:37:34 -05:00
Adeeb Rahman 342fcbd17d Format guest IPv4 addresses through Winsock inet_ntop
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:36:38 -05:00
Adeeb Rahman 7a91e11742 Report immediate Winsock UDP readiness through WSAPoll
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:35:53 -05:00
Adeeb Rahman e3cd65cb79 Build guest UDP endpoints through Winsock address conversion
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:34:40 -05:00
Adeeb Rahman 731f9448c3 Verify guest UDP loopback over bound Winsock imports
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:33:38 -05:00
Adeeb Rahman 198242e5e4 Deliver bounded UDP datagrams inside guest loopback
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:32:34 -05:00
Adeeb Rahman aacd160626 Add bounded guest Winsock startup and UDP socket lifecycle
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:30:55 -05:00
Adeeb Rahman 73764899c2 Isolate Win32 last-error state by guest thread
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:27:46 -05:00
Adeeb Rahman 51269bb714 Isolate CRT errno by guest thread within the address space
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:25:33 -05:00
Adeeb Rahman c1e6646bf2 Use typed HRESULT results at the guest graphics boundary
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:24:10 -05:00
Adeeb Rahman 2367414be5 Preserve typed import identities in probe and sync reports
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:20:01 -05:00
Adeeb Rahman 1d0b0d1547 Generate documented ordinal aliases for typed runtime services
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:18:16 -05:00
Adeeb Rahman fbb487384f Resolve registered ordinals through guest module handles
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:16:53 -05:00
Adeeb Rahman ac13c59b7d Track built-in guest module references and revoke released exports
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:15:06 -05:00
Adeeb Rahman 3922f56d68 Cover CRT boundary faults and atomic overlapping moves
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>
2026-11-24 08:07:05 -05:00
Adeeb Rahman 017b303e79 Merge remote-tracking branch 'origin/main' into feat/system-runtime-expansion
Signed-off-by: Adeeb Rahman <therealabeeb@icloud.com>

# Conflicts:
#	CHANGELOG.md
#	crates/import-gen/src/codegen.rs
#	crates/loader/src/imports.rs
#	crates/loader/src/services.rs
2026-11-24 08:07:05 -05:00
Ranveer Soni c7351c846d Merge pull request #291 from Swastickc/task/289-segment-tests
loader: restore and complete FS/GS segment-override tests (#289)
2026-11-24 18:13:09 +05:30
Swastick Chowdhury 8cae9772b6 loader: restore and complete FS/GS segment-override tests (#289)
Restore the six #280 regression tests that the merge resolving #280's
conflict with #283 removed. Add FS and GS RIP-relative loads and stores
with positive and negative displacements, a differential run comparing
the native DBT and interpreter registers and memory bytes, and
RIP-relative faults reporting the segment-adjusted address. Make the
existing differential test compare both paths' memory.

Signed-off-by: Swastick Chowdhury <28708247+Swastickc@users.noreply.github.com>
2026-11-24 18:08:32 +05:30