Files
mandy/runtime/src
OreoFR 5d677b7ba2 cpu_emulation: a CLWB #UD on a site another thread rewrote continues at it (RT-CLWB-PATCH)
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 <noreply@anthropic.com>
2026-11-28 05:28:00 +01:00
..
…