upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/thread_stacks.cpp
diff options
context:
space:
mode:
authorrobot00f <robot00f@users.noreply.github.com>2026-11-26 00:56:49 -0300
committerrobot00f <robot00f@users.noreply.github.com>2026-11-27 18:49:03 -0300
commit66ef2bd689a9e273697d2143e082c3288ae81481 (patch)
tree7640b72de1d0fa1254716ad18a13c82771b9366b /runtime/src/thread_stacks.cpp
parent39f52f39c435e04273bc822f258f2c4bb1b7fec0 (diff)
runtime(cpu): emulate BMI1, BMI2, MOVBE and patch LZCNT/TZCNT on AVX1 hosts
Add runtime/src/bmi_emulation.h and wire it into gta6rt and Loader::protect_sections so pre-Haswell AVX1 + SSE4.2 CPUs (Intel Sandy Bridge and Ivy Bridge) can execute the game's integer Haswell/ABM instruction delta: - Decode and emulate VEX-encoded BMI1 (andn, bextr, blsi, blsmsk, blsr), BMI2 (bzhi, mulx, pdep, pext, rorx, sarx, shlx, shrx), and legacy 16/32/64-bit MOVBE on STATUS_ILLEGAL_INSTRUCTION (#UD), using SEH-guarded non-inlined __movsb copies so valid pages take zero syscalls while xmem first-touch, write-watched shadow pages, read-only faults and unmapped faults behave like native accesses. - Patch non-faulting legacy TZCNT (F3 0F BC) and LZCNT (F3 0F BD) before executable sections are protected by walking .pdata functions and 0xCC-delimited leaf routines: >=5-byte 32/64-bit register sites jump to branchless BSF/BSR + CMOV + BT stubs within 2 GiB, and 4-byte, 16-bit or memory sites become UD2 (0F 0B) backed by a side-table for the #UD handler (configurable via LEONIDA_LZCNT_PATCH). - Add runtime/test/bmi_emulation_test.cpp covering decoding, synthetic CONTEXT application, immediate byte-trap rejection, stub/UD2 flag consumers, and live execution on hardware. Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7181466437 AI-assisted: yes (Antigravity, Gemini 4 Carbon)
Diffstat (limited to 'runtime/src/thread_stacks.cpp')
0 files changed, 0 insertions, 0 deletions