kvm_get_dirty_log_protect(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– kvm_get_dirty_log_protect β€” bestie edition πŸ’–

Welcome to the Kernel API Manual, bestie! This page is literally all about kvm_get_dirty_log_protect(9), and no cap, it's kind of iconic once you get the vibe. Let's get into it 🫢


✨ NAME ✨

kvm_get_dirty_log_protect β€” grab a snapshot of dirty pages and reenable dirty page tracking for the corresponding pages. Slay, honestly πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

int kvm_get_dirty_log_protect (struct kvm *kvm , struct kvm_dirty_log
*log );

That's the whole signature, periodt. Keep it exactly like that ✨


🌸 ARGUMENTS 🌸

  • kvm β€” pointer to kvm instance. Like, the actual KVM vibe holder πŸ‘‘
  • log β€” slot id and address to which we copy the log. That's where the snapshot goes, iykyk πŸŽ€

πŸ’œ DESCRIPTION πŸ’œ

Okay so first thing, we need to keep it in mind that VCPU threads can write to the bitmap concurrently. Like, at the same time, no warning, just vibes 😭 So to avoid losing track of dirty pages, we keep the following order β€” and the order is literally everything:

  1. Take a snapshot of the bit and clear it if needed.
  2. Write protect the corresponding page.
  3. Copy the snapshot to the userspace.
  4. Upon return caller flushes TLB's if needed.

Between step 2 and step 4, the guest may write to the page using the remaining TLB entry. And bestie, this is not a problem β€” because the page is reported dirty using the snapshot taken before, and step 4 ensures that writes done after exiting to userspace will be logged for the next call. The way that all just works?? Obsessed 😌✨

Lowkey important: the ordering is what keeps dirty tracking from losing pages. Do not shuffle these steps around, fr fr.

πŸ”₯ SEE ALSO πŸ”₯

Go read those too, bestie, they're all part of the same little KVM friend group πŸŒˆπŸ‘‘


And that's the whole page πŸŽ€ This masterpiece comes from ./virt/kvm, dated October 2026, and it's the kvm_get_dirty_log_protect(9) manual β€” ate and left no crumbs πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from