Repository navigation
feat(relinker): support VEX guest GS memory accesses - #11698
Felipebmaitan wants to merge 81 commits into
Conversation
…ower of two ElfReader accepted any p_align on an executable's PT_LOAD, and on the uncovered PT_SCE_RELRO it turns into one, although the gABI says p_align should be 0, 1 or a power of two. When such a segment starts on a page that an earlier segment maps with other bytes, the Linux patcher pads the output one byte at a time to the next offset congruent to its address modulo that alignment: a 3221-byte executable with an alignment of 0xfffffffffffffffb ran for 46 s, reached 12.9 GiB and failed with std::bad_alloc. Both segments are now refused, as the reader already refuses a PT_TLS alignment that is not a power of two. The guest module reader takes its headers from the same function, so the power-of-two half of its own alignment check can no longer fail and is dropped; its offset congruence check stays. A power-of-two alignment still reaches the padding, which the relinker technical debt now records. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # docs/dev/debt/relinker.md
# Conflicts: # core/relinker/relinker/tests/test_windows_guest_gs.py
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Correction to my previous comment, which the shell mangled: I checked the current-main delta in addition to the declared prerequisite stack. This head is based on b986c11, while current main includes #11090 (commit 33b48ba), which changes WindowsTlsBuilder to reject GS traps that would overwrite an executable entry point and adds test_gs_trap_entry_roots.py. This PR also changes that trap-planning path, so the rebase should explicitly preserve the #11090 check and its regression coverage in the VEX case before this can be merge-ready. The PR is already marked needs rebase; I have not submitted a review decision while that integration is unresolved. |
|
Follow-up on the refreshed overlap report for The inherited Windows startup conflict now includes #18523. Its RELRO protection ranges and the GS runtime setup both need to reach the entry stub and guest module writer. The load image also needs to retain both RELRO range collection and GS relocation tracking. #15245 still shares the entry-stub signature and call site, and #19470’s overflow checks touch the inherited ELF alignment checks. Those are merge-order coordination points for the stack. #22422 changes the overlapping-instruction check for FS TLS decoding. #24472 adds FMA lowering targets and tests in separate parts of the relinker build. Neither changes the VEX guest GS replay paths. This was a source comparison. The current-main prerequisite conflicts still govern the draft. |
|
@MarcZX10 I checked the offset finding on I converted a fixture with a conditional branch over an unsupported GS-prefixed VEX instruction to a later supported VEX load. The PE contains the earlier I also reran the focused suite on native Windows with the candidate test scripts and the archived Release binaries whose source inputs were verified against the previous head. 32/32 passed, including both VEX suites, fallback, startup and synthetic |
|
The refreshed overlap report adds #27532. At VEX head When composing the stack, keep the CLZERO handler and the scalar GS fault projection and continuation logic. GS replay entry handling should still run first, and each handler should retain its existing exception checks. This was a source comparison. Combined Windows execution remains untested. |
|
The refreshed overlap report flags #27848. At VEX head The preview already retains guest-module GS registration and the relocation check for borrowed GS followers. The other refreshed peers add no conflicts beyond those against |
|
The refreshed overlap report adds #28282. Its source merge preview conflicts with this PR and with the published scalar prerequisite |
|
CLZERO support from #27532 has landed. A source merge preview of current |
ligmaSec
left a comment
There was a problem hiding this comment.
The trial merge conflicts in ElfReader.cpp and ElfReaderBoundsTests.cpp. The VEX replay path should retain the native comparison for 128- and 256-bit moves, alignment faults, and upper YMM state. Please keep the host-feature-denial control too. Its conversion should still succeed without AVX and the guest instruction should take its documented fallback at execution. Please use debt fragments for the three library and relinker changes. I reviewed this in source and did not run native Windows tests.
AI-assisted: yes.
What
Replay bounded C4/C5 VEX guest GS memory moves through the protected Windows GS frame. The replay preserves effective addresses, native alignment and transfer widths, and upper YMM lane behavior. Unsupported encodings retain their own-length
UD2fallback. Conversion and startup are host-AVX-independent. Reaching VEX replay without OS-enabled AVX state reports an illegal instruction at the original guest RIP with the stack and registers restored.This follow-up adds four cases for C4/C5 RIP-relative
VMOVDQUloads borrowed by a short GS instruction, covering both 128-bit and 256-bit forms. It merges the published #11689 headfaf9d25c09f105a84ed01c3c9785651d9d989281, which adds coverage for a borrowed EBX write feeding an SSE load or store through RBX. The candidate changes two Python tests relative to the previous published VEX head. VEX increment over #11689.This PR stays draft targeting main. The #11661 worker ended with its current-main integration unpublished, so the updated short replay and scalar replay-fault work are still pending in the published stack. The merge preview against main
c8f72e905cce039a05970ed39d2373f770217901has inherited conflicts in the ELF reader, ELF bounds tests and libc/libkernel debt. #10518 and #10861 remain open. The shared entry-stub signatures with #15245 still need merge-order coordination.Tested
On native Windows 11 Pro build 26300, x86-64 Ryzen 7 9800X3D, 79/79 focused tests passed with the test scripts at
74746df3147c84663716e32f0fd7dc920cbe2ed8and archived WinLibs GCC 15.2 Release binaries. Hashes for 774 archived relinker, libc, libkernel and build inputs matched the previous published VEX headf16c9e062bd1d7607e1b3c976a6071904a81960cafter line-ending normalization. The run covered scalar and short GS replay, SSE and VEX faults and fallback, synthetic--no-avxand cached lookup, production-libc replay, executable and module startup, entry roots and bounds, relocations, TLS, deferred dependencies and sysarch/pthread. Both runners passed 81/81 VEX and 85/85 SSE address cases.Negative controls shifted the four new VEX replay displacements by one byte. Each failed the expected YMM-state assertion. Conventions passed against
origin/mainusing both checker versions, and the diff whitespace check passed. The function-name overlap scan found no matching open implementations for the queried names. Existing shared-file and merge-order work remains documented above.One independent reviewer inspected
f16c9e062b..74746df314, verified both published ancestors, checked the archived source correspondence and JUnit results, and reran the four displacement controls. They found no blocking issues. The public-header audit verified unique declarations and umbrella coverage for 407 libraries and 30,931 exports.The earlier contributor-reported 50-test production run and hosted checks apply to
f16c9e062bd1d7607e1b3c976a6071904a81960c. Fresh current-main binaries, hosted production CI and collaborator re-review remain gates. Physical non-AVX hardware and title execution remain unverified.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)