kvm_mips_restore_hrtimer(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– kvm_mips_restore_hrtimer(9) πŸ’–

okay so bestie, welcome to the kvm_mips_restore_hrtimer page from the Kernel API Manual β€” yes it's a (9) section, yes it's kernel-internal, no you may not skip it, we're doing this together 🫢


✨ NAME ✨

kvm_mips_restore_hrtimer β€” restores the hrtimer after a gap, and updates the expiry while it's at it. literally the glow-up-your-timer function πŸ’…


🌸 SYNOPSIS 🌸

int kvm_mips_restore_hrtimer (struct kvm_vcpu *vcpu , ktime_t before ,
u32 count , int min_drift );

that's the whole vibe check right there, no cap ✨


πŸŽ€ ARGUMENTS πŸŽ€

  • vcpu β€” the virtual CPU. the main character, obviously πŸ‘‘
  • before β€” the time before Count was saved. it's the lower bound of the drift calculation, so think of it as the "no drift earlier than this, bestie" line πŸ¦‹
  • count β€” CP0_Count at the point of restore. the number we're bringing back 🌸
  • min_drift β€” the minimum amount of drift that's permitted before we bother correcting. and here's the rule, highkey important: must be <= 0 ⚠️

πŸ’œ DESCRIPTION πŸ’œ

so what this does: it restores the timer from a particular count, and it accounts for drift while doing it. that's the whole point 🎯

you'd use this together with kvm_mips_freeze_timer β€” like, when a hardware timer is gonna be used for a period of time, but the exact ktime that corresponds to the final Count you have to restore is... not known. yeah. awkward. this function is the friend who steps in πŸ™ˆ

it's guaranteed that a timer interrupt right after the restore will be handled βœ… β€” but like, not if CP0_Compare is exactly at count. that specific case should already be handled when the hardware timer state is saved, so don't come for this function about it πŸ’€

also it assumes !kvm_mips_count_disabled(vcpu) β€” i.e. the guest CP0_Count timer is not stopped. if it is stopped, that's not our problem, that's your problem πŸ“

⭐ RETURN ⭐

returns the amount of correction to count_bias due to drift. it's giving "here's your receipt" 🧾✨


🌈 SEE ALSO 🌈

kernel file ./arch/mips/kvm/emulate.c β€” and honestly, the whole friend group πŸ”₯


this page lives in ./arch/mips/kvm, dated October 2026 β€” the Kernel API Manual said so, and the manual never lies πŸ’œ

okay that's the whole page, you ate it, mwah πŸ’‹ periodt 🌈

πŸ“¦ where this page comes from