miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
IPI – Inter-Processor Interrupts

TLB shootdown and panic-halt IPI infrastructure. More...

Classes

struct  ipi_barrier_t

Functions

static void ipi_barrier_ack (ipi_barrier_t *b)
 Atomically decrement the barrier's ack_count.
static void ipi_barrier_wait (ipi_barrier_t *b)
 Spin until barrier->ack_count reaches 0.
void ipi_tlb_shootdown (uint64_t virt)
 Broadcast TLB-shootdown IPI and wait for all CPUs to flush.
void tlb_shootdown_isr (void *frame)
 ISR for TLB_SHOOTDOWN_VECTOR (51) on remote CPUs.
void ipi_panic_halt (void)
 Broadcast halt IPI to all APs on kernel panic.
void panic_halt_isr (void *frame)
 ISR for PANIC_HALT_VECTOR (52) on APs.

Variables

ipi_barrier_t g_tlb_barrier

Detailed Description

TLB shootdown and panic-halt IPI infrastructure.

Implements two IPI paths:

  • TLB shootdown (vector 51): vmm_unmap_page() calls ipi_tlb_shootdown() to ensure all CPUs flush the invalidated mapping before the caller continues.
  • Panic halt (vector 52): kernel_panic() calls ipi_panic_halt() to halt all APs before the BSP prints the panic message and halts.

Function Documentation

◆ ipi_barrier_ack()

void ipi_barrier_ack ( ipi_barrier_t * b)
inlinestatic

Atomically decrement the barrier's ack_count.

Parameters
bBarrier to acknowledge. Called by ISR handlers BEFORE lapic_eoi().
Here is the caller graph for this function:

◆ ipi_barrier_wait()

void ipi_barrier_wait ( ipi_barrier_t * b)
inlinestatic

Spin until barrier->ack_count reaches 0.

Parameters
bBarrier to wait on. Called by the IPI initiator after broadcasting.
Here is the caller graph for this function:

◆ ipi_panic_halt()

void ipi_panic_halt ( void )

Broadcast halt IPI to all APs on kernel panic.

Sends PANIC_HALT_VECTOR (52) to every CPU except the calling BSP via lapic_send_ipi. Waits up to one LAPIC timer period (lapic_bsp_timer_icr/2 CCR ticks) for APs to halt, then returns to allow the BSP to print the panic message and execute cli;hlt. Called from handle_exception().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ipi_tlb_shootdown()

void ipi_tlb_shootdown ( uint64_t virt)

Broadcast TLB-shootdown IPI and wait for all CPUs to flush.

Parameters
virtVirtual address to invalidate on all CPUs.

Sets g_tlb_barrier.virt = @virt and g_tlb_barrier.ack_count = smp_cpu_count - 1, then broadcasts TLB_SHOOTDOWN_VECTOR (51) to all CPUs except self via lapic_send_ipi. Spins in ipi_barrier_wait() until all handlers have called ipi_barrier_ack(). Caller (sys_munmap) must have already called invlpg locally.

Context: Called with interrupts disabled or spinlock protection on g_tlb_barrier.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ panic_halt_isr()

void panic_halt_isr ( void * frame)

ISR for PANIC_HALT_VECTOR (52) on APs.

Parameters
framePointer to the interrupt frame (unused).

Executes cli; hlt. Does NOT send EOI – the halted CPU never needs the LAPIC unblocked for subsequent interrupts.

◆ tlb_shootdown_isr()

void tlb_shootdown_isr ( void * frame)

ISR for TLB_SHOOTDOWN_VECTOR (51) on remote CPUs.

Parameters
framePointer to the interrupt frame (unused by this handler).

Executes invlpg(g_tlb_barrier.virt), then calls ipi_barrier_ack(&g_tlb_barrier) (decrement-before-EOI guarantees the initiator sees ack_count==0 only after the TLB flush is complete), then calls lapic_eoi_asm().

Here is the call graph for this function:

Variable Documentation

◆ g_tlb_barrier

ipi_barrier_t g_tlb_barrier
extern