interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

BLOCKING for AP work: x86 cross-core TLB shootdown (invlpg is local-only)

Closed · #485 · open 2026-10-30 12:45 UTC · closed 2026-11-06 03:18 UTC (reason completed)

Imported from GitHub aien-dev/aienux#485, by drakestapleton

drakestapleton wrote on 2026-10-30 12:45 UTC

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; hlt after ap_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

did:key:z6MkhL6jkVBvyZTg9eMGkJWKQKjnKA1wbA7ym3PkTXt4M6Jd wrote on 2026-11-18 17:19 UTC

Recovered GitHub comment. Original comment 6664690571

Fix in #511 (head 257a793a): tlb_flush_page sends a shootdown IPI to every started core and waits for acks; boot-time self-test plus TEST-ONLY mutant no_shootdown (main's local-only flush) which panics stale_write_allowed=3 stale_read_allowed=3 at -smp 4. QEMU EXERCISED only; physical iMac NOT_RUN.

Sign in to comment