insn_get_seg_base(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

okay bestie, welcome to insn_get_seg_base(9) from the Kernel API Manual β€” the page where we obtain the base address of a segment descriptor, and it’s lowkey giving very specific x86 main-character energy πŸ¦‹

✨ NAME ✨

insn_get_seg_base β€” Obtain base address of segment descriptor. periodt πŸ’…

πŸŽ€ SYNOPSIS πŸŽ€

unsigned long insn_get_seg_base (struct pt_regs *regs , int seg_reg_idx
);

🫢 ARGUMENTS 🫢

  • regs β€” Register values as seen when entering kernel mode. iconic input, no notes πŸ’–
  • seg_reg_idx β€” Index of the segment register pointing to seg descriptor. this is the little index that tells the function which segment register to look at πŸ”₯

πŸ’… DESCRIPTION πŸ’…

So here’s the vibe: this function obtains the base address of the segment as indicated by the segment descriptor pointed by the segment selector. The segment selector is obtained from the input segment register index seg_reg_idx. yep, that’s the whole assignment πŸŽ€

In protected mode, it’s the base address of the segment. In long mode it’s zero, except when FS or GS are used. In virtual-8086 mode, it’s the segment selector shifted 4 bits to the right. those mode differences are literally the plot twists 🌈

and if something goes wrong? -1L in case of error. not cute, but important πŸ’€

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./arch/x86/lib/insn-eval.c and the whole friend group:


source/version ./arch/x86/lib, dated October 2026 β€” bye bestie, go get that segment base πŸ’–βœ¨

πŸ“¦ where this page comes from