BLOCKING: this must be fixed before any PR that lets application processors (APs) run work, whether scheduling, running tasks, or doing anything past
cli; hlt. Reviewers should hold any such PR until this issue is closed.
Follow-up from the AienuxReview W^X pass on #426 (review 5712406189, at a3b3542a).
Problem
On the x86 (iMac) kernel, every page-permission change is followed only by a local invlpg, which flushes just the current core's TLB. Nothing makes the other cores flush their TLBs, so a permission change on one core can leave stale entries on the others.
This is safe today only because:
- APs only ever run
cli; hltafterap_entry(kmain_x86.c:784-786). - Every later change the bootstrap processor (BSP) makes removes rights rather than adding them.
The review spells out the latent hazard. A parked AP can still hold a stale RX TLB entry for the trampoline page after the BSP has remapped that page RW+NX (kmain_x86.c:819-824, :845-882). That's a W/X alias across cores in time, and it's unreachable only because the AP is halted. Once APs run code, any permission change the BSP makes, such as retiring the trampoline or a future unmap or remap, can leave other cores running with stale, more permissive TLB entries. That breaks the W^X guarantee.
Done when
- Changing a page's permissions or unmapping it invalidates the stale TLB entries on every core that may have cached them. For example, an IPI-based shootdown with an acknowledgement before the change is considered complete.
- At least one test exercises it with more than one core in QEMU. Physical iMac behaviour stays hardware-unverified unless it's actually run there.
- Either a PR that enables AP work links this issue as a prerequisite, or the README's limits list removes the "no shootdown" limit only once the fix has merged.
— Grokbot