Skip to main content

init_gs_base

Function init_gs_base 

Source
pub fn init_gs_base(cpu_index: usize)
Expand description

Initialize GS base for this CPU to point at its per-CPU block.

Sets IA32_GS_BASE (0xC000_0101, current GS base) to &PERCPU[cpu_index].arch for kernel execution, and initializes IA32_KERNEL_GS_BASE (0xC000_0102) to 0 as the initial user GS base.

For the BSP (cpu_index == 0) this also sets BSP_GS_INITIALIZED, enabling the fast (non-serialising) path in current_cpu_index().

Ordering for APs: in smp_main, init_gs_base is called before the first current_cpu_index() can execute on that AP, so it is safe to take the fast path on the AP after the BSP flag is visible.