get_eff_addr_reg(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ‘‘ get_eff_addr_reg(9) β€” Kernel API Manual

🌸 NAME

get_eff_addr_reg β€” Obtain effective address from register operand. That’s the whole quest, bestie: pull the effective address out of a register operand. We are literally doing address extraction. ✨

✨ SYNOPSIS

int get_eff_addr_reg (struct insn *insn , struct pt_regs *regs , int
       *regoff , long *eff_addr );

πŸŽ€ ARGUMENTS

  • insn β€” Instruction. Must be valid. Like, actually valid, please. πŸ’…
  • regs β€” Register values as seen when entering kernel mode. This is the kernel-entry vibe check. 🫢
  • regoff β€” Obtained operand offset, in pt_regs, with the effective address. It’s giving β€œwhere in pt_regs did this operand live?” energy. 🌸
  • eff_addr β€” Obtained effective address. The effective address itself lands here. πŸŽ€

πŸ¦‹ DESCRIPTION

Okay so get_eff_addr_reg obtains the effective address stored in the register operand as indicated by the ModRM byte. It is to be used only with register addressing β€” i.e., ModRM.mod is 3. That is the rule, bestie, and we are not testing it. 😭

The effective address is saved in eff_addr. The register operand, as an offset from the base of pt_regs, is saved in regoff; such offset can then be used to resolve the segment associated with the operand. This function can be used with any of the supported address sizes in x86. Iconic x86 behavior, tbh. 🌈

⚠️ Register addressing only: ModRM.mod is 3. No memory-addressing detours, no β€œbut what if” β€” the manual says use it only with register addressing. Periodt. πŸ’…

Return tea: 0 on success. eff_addr will have the effective address stored in the operand indicated by ModRM. regoff will have such operand as an offset from the base of pt_regs. -EINVAL on error. πŸ“

πŸ’… SEE ALSO

Kernel file ./arch/x86/lib/insn-eval.c β€” and the whole friend group is here, iykyk:


xoxo, your local kernel bestie πŸ’– β€” source/version: ./arch/x86/lib, date: October 2026, page: get_eff_addr_reg(9). Slay and decode responsibly. πŸ’…βœ¨

πŸ“¦ where this page comes from