set_mtrr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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, periodt
  • size β€” the mtrr size, as one does
  • type β€” 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:

  1. Queue work to do the following on all processors:
  2. Disable Interrupts
  3. Wait for all procs to do so
  4. Enter no-fill cache mode
  5. Flush caches
  6. Clear PGE bit
  7. Flush all TLBs
  8. Disable all range registers
  9. Update the MTRRs
  10. Enable all range registers
  11. Flush all TLBs and caches again
  12. Enter normal cache mode and reenable caching
  13. Set PGE
  14. Wait for buddies to catch up
  15. 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 🧚


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