kvm_get_badinstr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… kvm_get_badinstr β€” Kernel API Manual, section 9 πŸŽ€

okay so bestie, buckle up, we're diving into kvm_get_badinstr(9) from the Kernel API Manual and honestly? it's giving "small function, big job" energy. let's get into it ✨


🌸 NAME 🌸

kvm_get_badinstr β€” get bad instruction encoding. that's it, that's the whole thing. no cap.


✨ SYNOPSIS ✨

int kvm_get_badinstr (u32 *opc , struct kvm_vcpu *vcpu , u32 *out );

three args, one int coming back at you. keep those spaces exactly like that, she's iconic as-is 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • opc β€” guest pointer to the faulting instruction. like, the address in guest memory where the messy instruction lives πŸ‘€
  • vcpu β€” KVM VCPU information. the whole vibe of the virtual CPU goes here.
  • out β€” -- undescribed -- 😭 yeah, the original literally says that. not me leaving it blank, that's genuinely what the page says, so we're keeping it 100% honest. no invented descriptions here, periodt.

πŸ¦‹ DESCRIPTION πŸ¦‹

so what does she actually do? kvm_get_badinstr gets the instruction encoding of the faulting instruction. and the way that she does it is lowkey elegant:

  • first she reaches for the saved BadInstr register value β€” if it exists, slay, that's the one πŸ’…
  • if it doesn't exist, she falls back to reading guest memory at opc

like, plan A is the register, plan B is reading memory. two paths, one encoding, no drama. ✨


πŸ”₯ RETURN πŸ”₯

she returns the instruction encoding of the faulting instruction. that's the whole return value, that's the tea β˜•


🌈 SEE ALSO 🌈

kernel file ./arch/mips/kvm/emulate.c, plus the whole friend group of related functions β€” every single one, in order, no skips:

kvm_get_badinstrp(9), kvm_mips_count_disabled(9), kvm_mips_ktime_to_count(9), kvm_mips_count_time(9), kvm_mips_read_count_running(9), kvm_mips_read_count(9), kvm_mips_freeze_hrtimer(9), kvm_mips_resume_hrtimer(9), kvm_mips_restore_hrtimer(9), kvm_mips_write_count(9), kvm_mips_init_count(9), kvm_mips_set_count_hz(9), kvm_mips_write_compare(9), kvm_mips_count_disable(9), kvm_mips_count_disable_cause(9), kvm_mips_count_enable_cause(9), kvm_mips_set_count_ctl(9), kvm_mips_set_count_resume(9), kvm_mips_count_timeout(9)

note: that first one is kvm_get_badinstrp(9) with a p on the end β€” not a typo, don't come for me, it's printed exactly like that in the source πŸ™ˆ

okay and that's the whole page!! πŸ§šβ€β™€οΈ this one lives in ./arch/mips/kvm and the date on it is October 2026, which is honestly so far ahead of us but she said what she said. bye bestie, go read those MIPS count registers, mwah πŸ’–πŸŒŸ

πŸ“¦ where this page comes from