Commit Graph
8119 Commits
Author SHA1 Message Date
Garvit Surana f7db19a5d9 feat(hle): a guest access's fault inside a composite's fast path puts the call back at the function's entry as the fast path found it and runs the original's first instruction alone, so the original takes the fault, where such a fault stopped the PE as a native failure with no recovery row
native_fault first asks hle_fault: for a block with an HLE mark, a fault
at an offset before the mark's prefix end, from an x86 exception that is
a guest access's as native_fault judges one (a #PF with a plain
read/write error code, or a #GP/#SS of a non-canonical address), settles
the run as native_fault does at the block's first instruction with none
of it retired: pinned::settle over a copy of the state, the chain's
retired instructions added, the PC at the entry, a link's BTYPE applied.
The fast path writes no guest register or frame field before its commit
point, so that is the state the call entered with. It then sets the
bypass and counts it. The scheduler's step takes the bypass beside PACM
(always evaluated, so a stale one is cleared) and fetches the entry as a
single-instruction block: the original runs from its first word and
takes the fault itself, with ESR, FAR, ELR and state as without HLE. A
fault in the bail's code keeps its moved recovery row; any other trap in
a fast path still stops the PE.

The plan bypassed #PF only; accepting the non-canonical #GP/#SS too keeps
a fast path exact where the placement's limit lies past the host's
canonical range (the test host's five-level limit on a four-level host),
the faults native_fault already accepts at a guest access.

Tests: Touch with X0 unreadable equals the original in full and bypasses
once; three such calls on one machine bypass three times and stay exact;
every readable/unreadable/read-only combination of X0 and X1 agrees;
4000 random Touch cases bypass exactly when X0's page is unreadable;
pointers at or past the limit, tagged or in the upper half bail without
a fault, an unmapped one in range bypasses; software step never matches;
a reused session runs as a fresh machine with Touch on as well, and no
call with every page mapped bypasses. Mutations caught: no hook, no
prefix bound, no bypass taken.

Translator id unchanged: engine glue and tests only.
2026-11-22 17:57:06 +00:00
Garvit Surana 976aa6450b feat(hle): install a composite block at a matched function's entry, its first word compiled alone as the bail behind the routine's fast path, with a mark of where the fast path ends, where a match was only counted and the function translated
hle_compile now installs what it accepts (install_hle, after
install_device_stub): a copy of the entry's first word is admitted and
prepared alone in the compile's variant; anything but one instruction's
block counts the bail refusal, a refused layout the compose refusal, and
either is translated as before. The composite's emission holds that word
as its input and installs through Machine::install as a block of one
instruction at the entry's PC and frame, so the board indexes it, links
into and out of it and retires it as any block (an IC IVAU of any word of
the function retires its page's blocks), and nothing stores, offers or
rebases it. Its Block holds hle::Mark, one byte with a niche (the fast
path's length in 64-byte units), set from State::installing as a device
stub's flag is; Block stays within its 72-byte bound. The mark is read by
the fault bypass that follows (expect(dead_code) until then). The plan's
mark held the routine too; nothing reads it, so it is left out.

Tests: a Bail composite at every stand-in, entered directly and through
blr x16 on a guarded page, ends every call exactly as the original
(4000 cases each, a sixteenth through blr), installs and never bypasses;
a composite is installed once and reused; Touch with X1 unreadable takes
the original's fault through the bail's moved recovery row. A match
whose routine has no fast path yet (memmove) is refused as compose and
translated with the same blocks as off.

Translator id unchanged: engine glue and tests only.
2026-11-22 17:43:29 +00:00
Garvit Surana f6042f296e feat(hle): composite blocks of a native fast path and the function's first instruction compiled alone, with the Bail and Touch test routines, a range check that subtracts and clamps past each branch, and a direct success exit to the original's ret, where no block could run a native routine in a function's place
stela_compiler::x86_64::hle::compose lays out a Request (routine, entry
PC, exit ret, max_bytes) in front of the bail, the entry's first word
compiled alone as the engine compiles a block: bytes [0, prefix_end) are
the fast path, built pinned with the block's link slots and padded with
INT3 to a multiple of 64; each bail is a jmp rel32 to prefix_end; from
prefix_end the bail's code follows unchanged, its direct exits, fault
recovery rows and cold code moved by prefix_end, which keeps their patch
points' residues mod 8, and align_exits runs over the whole. The
composite is one instruction: source_bytes 4, relocations None, no
self-loop or region.

emit.rs: Bails, checked() (xor edx; rax = lower_limit - base, bail on
BE; cmp rax, n, bail on B; after each branch a CMOV of the same flags
makes the dereferenced register and n 0, no LFENCE) and success() (a
Direct exit with its forward link slot). Bail's fast path is one jump to
the bail; Touch's checks X0 for one byte, loads it into EAX and bails,
followed by a success exit no path takes, for its layout's tests. The
production routines are refused (NoNative) until their fast paths land.

Two deviations from the plan, both forced by the engine: the source map
is [(pc, 0)] alone, since place() requires one entry per source word and
a second (pc, prefix_end) entry would make the one word two instructions;
and of the three const assertions only the pinned map (X0 in R15, X1 in
RBP) and the frame's X array at offset 0 are const, as link_slot and
offset are not const fns (chain.rs and x86_64.rs stay untouched): tests
pin the forward link slot and X2 at frame byte 16. compose also refuses
a fast path past 255 * 64 bytes (PrefixTooLong), the most the engine's
one-byte mark names.

Translator id CHANGES (crates/stela-compiler/src): together with the
previous commit's move, one refill of the translation store.
2026-11-22 17:36:40 +00:00
Garvit Surana b3cd128715 refactor(hle): move the routine ids into the compiler, beside the composite blocks it will lay out for them, where compose() in stela-compiler could not name an engine type
stela_compiler::x86_64::hle::Routine is the enum that was
stela_engine::hle's routine module, unchanged: the five production
routines and, under test or test-support, Bail and Touch. The engine
re-exports it as hle::Id, and its test-support feature now enables the
compiler's so the test routines exist wherever the engine's do. The
names test moves with it.

Translator id CHANGES: crates/stela-compiler/src is fingerprinted
(STELA_COMPILER_SOURCE_SHA256), so a pack made before this commit is
stale. The composite's emitters land in this same compiler module next,
so an image built from the finished branch refills the translation store
once, as the plan's section C expects.
2026-11-22 17:31:40 +00:00
Garvit Surana cea2a5f852 feat(hle): match signed functions at compile time behind a default-off configuration, once per compile, and count the matches and the refusals of a function that crosses its fetch page, starts at a device site, holds a host breakpoint or trace point or holds a word the chip runs as another, where no compile looked for a signed function
Machine::set_hle takes a Config and hle_statistics reports what it did
(hle::Statistics: matched, the signatures that matched, installed,
bypassed and refusals by reason). compile_window calls hle_compile after
it reads the source and before it looks for a stored, shared or rebased
block. With no routine enabled it returns at once, so a boot without
--hle compiles exactly the blocks it did before (pinned by
hle_off_compiles_the_same_blocks_as_without_it, also for --hle with the
empty generated table). Only an EL0 compile of an ordinary variant
looks: not single-step, translated, DIT-timed or streaming, with FP on and
no alignment checks. A candidate's prefix hash is checked at its own
length, then its digest over the bytes of the window or, for a function
longer than it, of RAM. Only the first window of a compile looks, so the
whole-window compile that may follow does not count the same match twice.
Nothing is installed yet: a match is translated as before.

Beyond the plan's five refusals there is a sixth, admitted: a function
holding a word the chip lacks (Chip::admit makes it UDF or a NOP) is
refused, as the original would not run the bytes its signature was made
from.

The harness's Session::new and run take an Option<Config>, run returns
the run's Statistics, and a reused session runs as a fresh machine with
HLE on (Bail for every stand-in, Touch for touch's) as well as off.

Translator id unchanged: src/hle and the engine glue are not translation
inputs.
2026-11-22 17:27:14 +00:00
Garvit Surana 1ba4a1ea2f test(hle): compare PSTATE and an abort's SPSR, enter the stand-ins through a blr x16 on a guarded page, check X0 against the reference model and start each call of a session with BTYPE 0 and clear syndrome registers, where the harness compared neither BTYPE nor SPSR, entered every call by setting the PC and checked only memory against the model
An Outcome now holds PSTATE, and an abort ESR, FAR, ELR and SPSR_EL1.
StandIn::through_blr appends a `blr x16` after the function and guards
the code mapping (store_host's NativeHost::guard sets GP, bit 50, in its
stage-1 descriptors): memset's `bti c` admits the call's BTYPE 0b10 and
runs as the model says, every other stand-in takes a Branch Target
exception at its entry with BTYPE in ESR and SPSR. A session's call clears
BTYPE, which the abort's ERET brought back from SPSR, and ESR, FAR, ELR
and SPSR, which a Branch Target exception leaves partly as they were, so
a reused session still runs as a fresh machine, now also through blr.
agree() requires PSTATE equal and X0 as the model gives it.

Translator id unchanged: tests only.
2026-11-22 17:14:05 +00:00
Garvit Surana 4dc2b4240f fix(hle): tell an outside branch from a branch to itself, refuse a function that can run past its last word, and refuse reserved words and ordered or tag accesses, where an outside b masked to the word of b . in the digest, a function ending in a NOP or B.cond was eligible and LDAPUR, STLUR, UDF and AMX words were too
The digest now follows each masked word with a byte that says whether
it has a masked field, so a candidate whose word is a branch out of the
function no longer matches a signed function holding `b .` there; the
prefix hash stays a filter. Eligibility refuses a last word other than
`ret` or an inside `b` (FallsThrough), every word with bits 31:25 clear
(Reserved: UDF, AMX's 0x00201000 | op << 5 | Rt, GXF and the SPTM's
maintenance words), and as Exclusive the RCpc forms with an offset or
writeback (LDAPUR, STLUR, their SIMD&FP forms, RCpc3), LSE128 and the MTE
tag accesses of that class. The stand-ins pad with NOPs before their last
`ret` instead of after it.

Translator id unchanged: only crates/stela-engine/src/hle (not a
translation input) and tests change.
2026-11-22 17:10:39 +00:00
Garvit Surana 92d199ee4c test(hle): differential harness and stand-in originals checked against a reference model: byte-loop leaves for memmove, bzero, memset, memcmp, strlen and a test-only touch, random and edge cases with overlaps, page-end NULs and unreadable or read-only pages, the C semantics of each, a comparison of two calls by what the ABI keeps, and sessions that run a suite's cases on one machine, returning from each abort, where a debug build took 0.1 s to make a machine per call and a machine's own test kernel address made two aborted calls differ 2026-11-22 00:06:48 +00:00
Garvit Surana 0fa8bfa87c feat(hle): --hle and --hle-off boot options and the HLE configuration, off by default: a signature table, the routines of it that are on and a bound of 256 bytes to 1 MiB on one call's work, with --hle-off naming distinct routines and an empty generated table, where no option or configuration could turn native routines on or off 2026-11-21 23:42:13 +00:00
Garvit Surana 823dc843aa feat(hle): masked function signatures and phase-1 eligibility, in the engine, which the translator id does not hash: routine ids, a function's SHA-256 with its outside branches, ADR, ADRP and literal loads masked, a prefix hash that depends on its length, and the self-contained leaves a native routine may replace, where nothing identified a guest function by its bytes 2026-11-21 23:32:53 +00:00
Garvit Surana 5bc37ce517 docs(profile): say that a PES PC block's cycles hold its tails and the helper, PAC service and shadow fills it called but not the engine's time between runs, and that gone also counts samples in context-ABI blocks and the boot's diagnostic native runs, which the host enters without a chain control, where the docs named neither 2026-11-21 22:34:33 +00:00
Garvit Surana 064f47f179 test(profile): cover naming a sampled block retired but still in its slot, a kernel or guarded block's vector base at EL1, EL2 and EL0 under VHE, a page that is not RAM naming no key and a page the board knows taking its known key, where no test reached those paths of naming a sample 2026-11-21 22:32:55 +00:00
Garvit Surana 13691d06db fix(xtask): refuse code that runs past the address space with an error, leave out a section that does, skip a cache missing a subcache or a file that cannot be read with a warning, warn of a dyld cache file with a dot and no main file beside it and read one named itself as a main file, where the symbolizer's sums could panic, one missing subcache or broken file aborted the run and a renamed main cache was skipped silently 2026-11-21 22:29:18 +00:00
Garvit Surana f1899c639a test(xtask): read a synthetic dyld cache of the shipping split layout, its main file naming a .01 that holds the image's __LINKEDIT and a .symbols by UUID, and have the real-cache oracle check an address inside each function, function starts for nearly every image and each start inside its image's code, where only the old one-file layout ever ran and the oracle named exact symbol addresses alone 2026-11-21 22:22:40 +00:00
Garvit Surana 3fcfd11de3 fix(xtask): name code outside an image's __text by its section, so stubs read as __auth_stubs or __objc_stubs, where the symbolizer gave them the name of the last __text function before them 2026-11-21 22:18:15 +00:00
Garvit Surana b86fd8f0c5 fix(xtask): keep the file each page key was found in and name its function only from that file's innermost image range, reading a file once and no dSYM, where the symbolizer searched one list of every file's ranges by address and named another kernel's, kext's or cache's symbol, or no image where ranges nested 2026-11-21 22:15:21 +00:00
Garvit Surana 9d98f9c94b fix(profile): trim the PES PC total at each beat to the blocks with the most cycles, folding the rest into other, and have symbolize warn when other holds a tenth of the cycles, where the total kept the first 65536 blocks it saw forever and a later workload's code landed only in the other that symbolize's default reads 2026-11-21 22:11:13 +00:00
Garvit Surana 0f8cbe8975 fix(xtask): skip a PES PC level line without its group's header, or a broken line, with a warning that names it, and apply a level line only whole, where one such line in a wrapped, dropped or cut log aborted the whole symbolize run 2026-11-21 22:06:46 +00:00
Garvit Surana ac070b749d fix(profile): print PES PC cycles whole and show them in the symbolizer's table as millions with a decimal, where each block's cycles were cut to whole millions, a one-sample block read 16M for 16.78M and --beats summed every cut 2026-11-21 22:04:11 +00:00
Garvit Surana 06b40196cf perf(profile): take a full block ring's overflow with a locked swap only when it holds cycles, where every native run's take swapped it even at zero 2026-11-21 21:59:19 +00:00
Garvit Surana 912aa6aed6 feat(xtask): add cargo xtask symbolize, which hashes the guest's dyld shared cache or Mach-O pages as the engine keys them and ranks a log's PES PC blocks by function and image, with an opt-in oracle test on a real cache, where no tool in the tree named a sampled guest PC 2026-11-21 21:33:19 +00:00
Garvit Surana f969b72398 feat(profile): name the guest block each --profile cycles sample finds running in native code, with its 4 KiB page's SHA-256 key and offset, and log them as PES PC lines each beat and PES PC TOTAL every 16 beats, where PES HOT weighed blocks by transfer, undercounted self-loops and named no page an offline tool could map 2026-11-21 21:33:19 +00:00
Garvit Surana 82bd050991 fix(boot): call none of the firmware's variable services after its exit in a boot that only checks the disk chosen for macOS, where a stop there could still write its record to NVRAM 2026-11-21 20:24:15 +00:00
Garvit Surana 4a56ad302d fix(drivers): fill an NVMe read's data pages with a poison at each run, so a read the controller reports done without moving its data reads as 0xa5, where the bounce pool could hand it the pages a write had just filled and a read-back of a write the disk did not take passed 2026-11-21 20:24:15 +00:00
Garvit Surana 993b10b0c0 fix(install): stop before the primary GPT is written when a write of the backup changed any of the primary's blocks, and say a plan's blocks without overflow before it is checked, where only the backup was read back before the log said the primary was as it was, and a range of no blocks, one past the last LBA or a disk no GPT uses panicked the check 2026-11-21 20:24:15 +00:00
Garvit Surana 779d12b39f fix(boot): write neither the USB's chosen-disk record nor BootNext in a boot that only checks the disk chosen for macOS, where Check only would have replaced the record and could set BootNext before the firmware's exit 2026-11-21 19:43:00 +00:00
Garvit Surana 6a14fb719d fix(install): add macOS only in free space beside a disk's partitions, check the plan against both GPT copies as Stela's own driver reads them before anything is written, keep a valid protective MBR, read every write back before the next and offer Check only, which reads the disk, says every write and writes nothing, where one key in the picker deleted a partition or erased the disk, only LBA 0-1 were compared, nothing was read back until all five writes were made and 11 bytes of the MBR changed 2026-11-21 19:43:00 +00:00
Garvit Surana 2451a35253 feat(formats): give a GPT's entry blocks and the protective MBR test to its callers, so the disk plan can keep a disk's own MBR and check its writes against the GPT's blocks 2026-11-21 19:43:00 +00:00
Garvit Surana 7f67ae7f9e fix(drivers): refuse a discard of no ranges where a command meets its device, and an NVMe Deallocate of none or more than 256 ranges before it takes a tag, where an empty one went out as 256 ranges of a stale bounce page, which could free any block 2026-11-21 19:43:00 +00:00
Garvit Surana 7b33d729b8 fix(boot): show an install's system image as all sent once its ASR job is gone, count only the payload's offset as sent, keep the rows of a frame the screen refused pending for a later turn, count the lines under the running step as shown only once the console's text took them and clear them with a finished line, and read the counter for the progress only in an install, where one service turn that sent the last chunk and ended the job left the reading below 100% as waiting for data, the guest's out-of-band reads showed as the image's progress, a frame a busy console refused left the progress panel up until macOS drew again and a hand-back marked a kept console's progress lines as drawn 2026-11-21 19:38:28 +00:00
Garvit Surana 111d932c77 feat(boot): log an install's progress once a minute and at each new restore step, and show it on Stela's console when macOS has drawn no new frame on the firmware's screen for a minute, until its next frame takes the screen back whole, where the console gave the screen up for good at macOS's first frame and an install showed only Apple's progress bar, which could sit at 0% for hours 2026-11-21 18:59:56 +00:00
Garvit Surana c1f6f96a0e feat(boot-core): model an install's progress from its restore step and the system image's bytes, with a smoothed rate, the time left, a stall said as waiting, a once-a-minute INSTALL PROGRESS line, an INSTALL STAGE line per new step, the console's progress panel and when the console takes the screen from macOS's frames, where an install had no measure of how far it had come 2026-11-21 18:59:56 +00:00
Garvit Surana a885a57b17 Merge upstream/main 140ffaf71 into fork/install for the macOS install build
The install build is the RTL8852CE Wi-Fi branch (wifi/rtw8852c-m3, 999c0d361)
with upstream's GPT slot, TRIM and 32 MiB log fixes.

One conflict, in crates/stela-boot/src/engine/network.rs (HostNetwork::open):
the Wi-Fi adapter's address wait still runs through network_link::address,
so its connection keeper's failures are retried until the cut, and upstream's
DHCP and DNS notes (Stack::take_notes) are logged after that wait, before the
keeper's retry line. This matches wifi/rtw8852c-m3-test, without its
host-check-only `pub(crate) mod security`.
2026-11-21 18:25:36 +00:00
Garvit Surana 999c0d361a fix(boot): drive a Wi-Fi adapter's wait for an address past its connection keeper's failures until its carrier wait and then the network stack's DHCP wait, now exported, have passed, as the host check drives its station, where the keeper's first failure, reaching the stack as the link's, ended the wait and gave the adapter up while the keeper's next attempt could still join 2026-11-21 16:34:10 +00:00
Garvit Surana 5cd5570a3e fix(boot): hide the configured Wi-Fi network's name in what a Wi-Fi adapter's link says, its errors and state lines, where the connection keeper's failures named it on the boot's NETWORK adapter failed line, its screen account and the guest network's lines 2026-11-21 16:28:40 +00:00
Garvit Surana 4e0ba3fe8c fix(drivers): print an RTL8852CE's MAC address in its running firmware's warning masked, its vendor half and last byte, as the engine prints an adapter's, where the normal boot's HOST WARNING line held the chip's whole address 2026-11-21 16:24:12 +00:00
Garvit Surana 50cd7ef64e feat(wifi): count an RTL8852CE station's data in its progress line, the MSDUs delivered, the protected frames left sealed or under a key ID with no key, those the station refused and the data frames sent, and drop KEYS_BEFORE_M3B, where a station with its keys and port open but no traffic could not tell an undecrypting key from silence and M3a's refusal outlived its last reader 2026-11-21 15:12:07 +00:00
Garvit Surana 1ef2420880 fix(wifi): drop an RTL8852CE's frames failing their FCS or ICV before the duplicate check, as mac80211's should_drop_frame drops them before any handler, where such a frame recorded its sequence control and the AP's good retry of it was dropped as a duplicate 2026-11-21 15:10:42 +00:00
Garvit Surana 8c1cc3fdb8 docs: name ps.c, regd.c, sar.c, sar.h and the mac80211 and cfg80211 sources among the rtw89 RTL8852C station's Linux sources in NOTICE, where they were unlisted 2026-11-21 14:48:24 +00:00
Garvit Surana bc26901d5f docs(wifi): describe the RTL8852CE station in the ax and realtek module docs, cite mac80211 at the donor commit, name ADDR_CAM_ENT_SHORT_SIZE, and state where a failed key install's rollback leaves Linux's, Stela's own key delete order, what a keeper's into_radio drops, that an AP's country element moves no TX power index and that the RTL8852CE alone waits 30 s for carrier, where the docs said it had no station, cited mac80211 7.2.12 or by name only and claimed rtw89's rollback and mac80211's delete order exactly 2026-11-21 14:48:24 +00:00
Garvit Surana b7b3e94650 feat(drivers): attach an RTL8852CE with a configured network as a Wi-Fi station NIC, where it was brought up, reported and left unsupported 2026-11-21 14:48:24 +00:00
Garvit Surana 221e45c933 fix(wifi): name an RTL8852CE bring-up's read of its firmware's TX power tables the "firmware elements" step, where a file without one failed as "tx power: tx power: firmware lacks …" 2026-11-21 14:48:24 +00:00
Garvit Surana bcffc0edff fix(wifi): reorder an RTL8852CE's protected frames before dropping the ones it cannot open, PN-check each frame as it is drained, and close its port while a replaced key's successor is not installed, as mac80211 and rtw89 do, where an undecryptable frame held its agreement's later frames up to 100 ms, a key install's reset outran the frames its own waits drained, and a refused rekey left the port open without its key 2026-11-21 13:46:05 +00:00
Garvit Surana c8b0dc527e feat(wifi): end an RTL8852CE's association when its firmware reports the AP's beacons lost and give it 30 s to bring carrier up, where a silent AP was never noticed and the link had a wired PHY's 10 s 2026-11-21 13:30:42 +00:00
Garvit Surana df753ca513 fix(wifi): keep an RTL8852CE's SAE exchange going through a deauthentication and take only SAE frames addressed to it, as mac80211 does, where a stray deauthentication ended a WPA3 join and another station's SAE frame failed the keeper 2026-11-21 13:15:29 +00:00
Garvit Surana 7a9620ed93 feat(wifi): authenticate an RTL8852CE to WPA3 networks with SAE through the keeper's external authentication and protect its management frames, where only WPA2-PSK could connect 2026-11-21 12:57:14 +00:00
Garvit Surana d91740c071 feat(wifi): accept an AP's RX Block Ack agreements on an RTL8852CE, program its BA CAM and reorder what they deliver as rtw89_ops_ampdu_action and rtw89_fw_h2c_ba_cam do, where every ADDBA went unanswered 2026-11-21 12:27:15 +00:00
Garvit Surana dcf9c2a2ca feat(wifi): run an RTL8852CE's station data under hardware CCMP with host packet numbers in the TX descriptor, its group key, its port and host-side PMF, where the handshake stopped at the first key 2026-11-21 11:28:02 +00:00
Garvit Surana 8b7028fe5a feat(wifi): install and remove an RTL8852C's CCMP keys in its security CAM and point its address CAM at them, waiting for the firmware's receipt and acknowledgement, as rtw89_cam_sec_key_install and rtw89_cam_sec_key_del do, where no key could reach the hardware 2026-11-21 09:36:53 +00:00
Garvit Surana f531e5446c feat(wifi): attach an RTL8852CE as a kept station from its firmware, regulatory database, network and entropy, where it could only be brought up and powered off 2026-11-21 00:23:06 +00:00