<feed xmlns='http://www.w3.org/2005/Atom'>
<title>npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/runtime/test/cpu_emulation_test.cpp, branch main</title>
<subtitle>[no description]</subtitle>
<id>https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/atom?h=main</id>
<link rel='self' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/'/>
<updated>2026-11-28T17:53:57+00:00</updated>
<entry>
<title>Merge pull request #2035 from IlyassRS3/fix/rt-cpu-emulation-clzero-region-and-bounds</title>
<updated>2026-11-28T17:53:57+00:00</updated>
<author>
<name>MoonEyes</name>
<email>ducoinbenjamin@yahoo.fr</email>
</author>
<published>2026-11-28T17:53:57+00:00</published>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/commit/?id=3107c8a2a8adbbfe588c6022085bc41c4fe09a81'/>
<id>urn:sha1:3107c8a2a8adbbfe588c6022085bc41c4fe09a81</id>
<content type='text'>
runtime: step try_clzero_loop by VirtualQuery regions and guard wraparound in cpu_emulation</content>
</entry>
<entry>
<title>cpu_emulation: a CLWB #UD on a site another thread rewrote continues at it (RT-CLWB-PATCH)</title>
<updated>2026-11-28T04:28:00+00:00</updated>
<author>
<name>OreoFR</name>
<email>noreply@users.noreply.github.com</email>
</author>
<published>2026-11-28T04:28:00+00:00</published>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/commit/?id=5d677b7ba2b2dd5b128455edf2b92bea6da4dcc2'/>
<id>urn:sha1:5d677b7ba2b2dd5b128455edf2b92bea6da4dcc2</id>
<content type='text'>
Threads that fault on the same CLWB site together lost the race: a #UD handled
after another thread rewrote the site decoded CLFLUSHOPT (or the NOP), did not
know it and returned EXCEPTION_CONTINUE_SEARCH, which ends the title.

- The handler continues at a site that already holds the form written on this
  host (or the NOP's halfway state): the CPU runs it.
- One lock around unprotect, re-check, write and protect again, so two threads
  never interleave on a page; a site found rewritten under it is not written.
- The NOP is written opcode first (66 0F 1F /6 in between is a NOP too).
- The sites counter counts each site once, by the thread that wrote it.

cpu_emulation_test calls the handler with a made-up #UD, so it runs on hosts
with CLWB: first #UD, a second one on the rewritten site, and 16 threads on
2048 fresh execute-read sites. Before the fix 27958 of 32768 concurrent #UDs
were passed on, 4810 rewrites were counted for 2048 sites and pages were left
writable; with it all checks pass.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>runtime: step try_clzero_loop by VirtualQuery regions and guard wraparound in cpu_emulation</title>
<updated>2026-11-25T18:39:50+00:00</updated>
<author>
<name>IlyassRS</name>
<email>ilyassroussi2000@gmail.com</email>
</author>
<published>2026-11-25T18:39:50+00:00</published>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/commit/?id=7f56e6a50b45ea8d760d93df855b6acc04594f0c'/>
<id>urn:sha1:7f56e6a50b45ea8d760d93df855b6acc04594f0c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>cpu_emulation: rewrite CLWB in place at its first #UD (RT-CLWB-PATCH)</title>
<updated>2026-11-25T00:58:20+00:00</updated>
<author>
<name>ImLele69</name>
<email>gabrieledilauro99@gmail.com</email>
</author>
<published>2026-11-25T00:58:20+00:00</published>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/commit/?id=85b8f5b7f098223a02267667b391ff3d7e984c14'/>
<id>urn:sha1:85b8f5b7f098223a02267667b391ff3d7e984c14</id>
<content type='text'>
On a host without CLWB every execution of the instruction raised #UD and the vectored handler emulated it. The
retail title's GPU upload worker flushes whole buffers with CLWB in a 64-byte loop (exe+0x532f1b0 on 1.0.2.1), so a
buffer cost one exception per cache line; under Wine that kept the worker busy for minutes and the main thread
polling its event in session 0xd, so the boot never left the first-run pages.

The handler now rewrites the instruction at its first #UD: 66 0F AE /6 becomes 66 0F AE /7 (CLFLUSHOPT), the same
operand and length, which also writes the line back; a host without CLFLUSHOPT gets 66 0F 1F /0, a NOP of the same
length. LEONIDA_CLWB_PATCH=0 keeps the old per-execution emulation.

Tested: cpu_emulation_test under Wine 11.21 on an i9-9900KF (no CLWB, has CLFLUSHOPT): both sites rewritten, SIB and
displacement kept, the code runs again. Retail boot on the same machine with #984 + #968 (RTX 2070 SUPER, Fedora 44):
the worker that sat in the CLWB loop at 420, 540 and 660 s now moves on, and the title gets past the first-run pages
into the story load.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_01RBZntAmGCDe3LdLjbzZzuc
</content>
</entry>
<entry>
<title>cpu_emulation: update CMP flags on partial CLZERO batches and post-prefix faults</title>
<updated>2026-11-24T06:25:21+00:00</updated>
<author>
<name>oscarlosu-lab</name>
<email>251827664+oscarlosu-lab@users.noreply.github.com</email>
</author>
<published>2026-11-24T06:25:21+00:00</published>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/commit/?id=3b8c1555d8d375762e907927417bbaca96accbbf'/>
<id>urn:sha1:3b8c1555d8d375762e907927417bbaca96accbbf</id>
<content type='text'>
</content>
</entry>
<entry>
<title>cpu_emulation: run a whole CLZERO zeroing loop in one emulated step</title>
<updated>2026-11-24T04:54:10+00:00</updated>
<author>
<name>oscarlosu-lab</name>
<email>251827664+oscarlosu-lab@users.noreply.github.com</email>
</author>
<published>2026-11-24T04:54:10+00:00</published>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/commit/?id=361e8455a20aa6606fb542d86e39b552da2e60e6'/>
<id>urn:sha1:361e8455a20aa6606fb542d86e39b552da2e60e6</id>
<content type='text'>
</content>
</entry>
<entry>
<title>cpu_emulation: INSERTQ register form reads len from xmm2[69:64]; zero xmm1[127:64]; AMD prefix forms; no SEH</title>
<updated>2026-11-23T16:41:46+00:00</updated>
<author>
<name>Krashgamer</name>
<email>64923888+Krashgamer@users.noreply.github.com</email>
</author>
<published>2026-11-23T16:41:46+00:00</published>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/commit/?id=978d525d99413cce232efde07efbf392d1e782a5'/>
<id>urn:sha1:978d525d99413cce232efde07efbf392d1e782a5</id>
<content type='text'>
- INSERTQ xmm, xmm took the length and index from swapped fields. The APM (vol. 4) has the length in
  xmm2[69:64] and the index in xmm2[77:72]; a Ryzen 9800X3D and a Ryzen 5700X agree (TheHoracio,
  Mayzkl on #7111). The measured 0x0810 case is a unit check now.
- INSERTQ/EXTRQ zero xmm1[127:64], as the Zen 3 measured in the same review does in all four forms.
- Decode REX bytes among the legacy prefixes (a non-final REX is ignored) and accept F2/F3 on CLZERO,
  as Zen 3 runs them (#7055's reviews); F2/F3 stay #UD on MONITORX/MWAITX.
- Check the CLZERO line's page and the instruction bytes' readability with VirtualQuery instead of
  catching a fault in a local __try, which clang-cl without /EHa does not cover for inline stores
  (venetanji on #7111).

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>cpu_emulation: CLZERO on an unwritable line raises the CPU's write fault; accept 66 on 0F 01 FC/FA/FB</title>
<updated>2026-11-23T16:07:09+00:00</updated>
<author>
<name>Krashgamer</name>
<email>64923888+Krashgamer@users.noreply.github.com</email>
</author>
<published>2026-11-23T16:07:09+00:00</published>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/commit/?id=3fe388b39daccee1e8ff1b595be3889260552518'/>
<id>urn:sha1:3fe388b39daccee1e8ff1b595be3889260552518</id>
<content type='text'>
A line CLZERO cannot write now reaches the next handlers as the access violation (or guard-page
violation) the instruction raises, with the write flag and the line address, instead of the #UD.
The 66 prefix and segment overrides are accepted on CLZERO/MONITORX/MWAITX; F2/F3 (other
instructions there, F3 0F 01 FA is MCOMMIT) and LOCK stay #UD. Points raised by SirKingg on #7055.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>gta6rt: emulate the Zen 2 instructions a desktop CPU may lack (INSERTQ/EXTRQ, CLZERO, MONITORX/MWAITX, CLWB)</title>
<updated>2026-11-23T15:57:59+00:00</updated>
<author>
<name>Krashgamer</name>
<email>64923888+Krashgamer@users.noreply.github.com</email>
</author>
<published>2026-11-23T15:56:57+00:00</published>
<link rel='alternate' type='text/html' href='https://upleb.uk/npub1w4dsu3e6hzjehh7l3c9njhtwwtgk9g209ylqf4tvdn2m07xjq06se9ett9/Leonida/commit/?id=62b410e75640c12a672f73552c754ca7945bf265'/>
<id>urn:sha1:62b410e75640c12a672f73552c754ca7945bf265</id>
<content type='text'>
The executable uses SSE4a INSERTQ, CLZERO and MONITORX/MWAITX (AMD only) and CLWB (Intel since Ice Lake)
without asking CPUID (docs/cpu_features.md). A host without one raises #UD there. src/cpu_emulation.h adds
a vectored handler that recognises those encodings at the faulting RIP, does the same work on the CONTEXT
and steps past the instruction; gta6rt installs it before any image code runs, after the startup trace's
handler so it runs first. One [rt] line names what the host lacks, one more per instruction on first use.

cpu_emulation_test checks the decoder on hand-written encodings, the bit-field helpers and apply() on a
synthetic CONTEXT, then runs every form for real from an executable buffer: natively on a Zen host,
through the handler on an Intel one, with the same expected values.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
</feed>
