set_mtrr(9)
π set_mtrr(9) β like, the Kernel API Manual entry, bestie β¨
okay so this is set_mtrr(9), and honestly? it's giving "trust me, the hardware vendor wrote the instructions for us" energy. let's get into it π
πΈ NAME πΈ
set_mtrr β update mtrrs on all the processors. every single one. no cap π
β¨ SYNOPSIS β¨
void set_mtrr (unsigned int reg , unsigned long base , unsigned long
size , mtrr_type type );
π¦ ARGUMENTS π¦
regβ which mtrr we're talking about, the one in question πbaseβ the mtrr base, periodtsizeβ the mtrr size, as one doestypeβ the mtrr type π
π₯ DESCRIPTION π₯
ngl, this one is kinda tricky π but fortunately Intel spelled it out for us cleanly, so we don't have to vibe-check it ourselves:
- Queue work to do the following on all processors:
- Disable Interrupts
- Wait for all procs to do so
- Enter no-fill cache mode
- Flush caches
- Clear PGE bit
- Flush all TLBs
- Disable all range registers
- Update the MTRRs
- Enable all range registers
- Flush all TLBs and caches again
- Enter normal cache mode and reenable caching
- Set PGE
- Wait for buddies to catch up
- Enable interrupts.
likeβ¦ that's the whole choreo π and yes it's a numbered list inside the description, we don't make the rules, Intel does.
so what does that actually mean for us? well, stop_machine will ensure that the rendezvous handler is started on each CPU π and in lockstep they do the state transition of disabling interrupts, updating MTRR's (the CPU vendors may each do it differently, so we call mtrr_if->set callback and let them take care of it.) and enabling interrupts. iconique, honestly β¨
π note that the mechanism is the same for UP systems, too; all the SMP stuff becomes nops. so it's literally the same dance, the moves just turn into nothing. ate and left no crumbs π«Ά
π§ SEE ALSO π§
- Kernel file
./arch/x86/kernel/cpu/mtrr/mtrr.c mtrr_rendezvous_handler(9)mtrr_add_page(9)mtrr_add(9)mtrr_del_page(9)mtrr_del(9)arch_phys_wc_add(9)mtrr_bp_init(9)mtrr_save_state(9)
k bye bestie π«Ά this page hails from ./arch/x86/kernel/cpu/mtrr, dated October 2026, and it's set_mtrr(9) signing off β mwah π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms