insn_get_seg_base(9)
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:
is_string_insn(9)insn_has_rep_prefix(9)get_seg_reg_override_idx(9)check_seg_overrides(9)resolve_default_seg(9)resolve_seg_reg(9)get_segment_selector(9)get_reg_offset_16(9)get_desc(9)get_seg_limit(9)insn_get_code_seg_params(9)insn_get_modrm_rm_off(9)insn_get_modrm_reg_off(9)insn_get_modrm_reg_ptr(9)get_seg_base_limit(9)get_eff_addr_reg(9)get_eff_addr_modrm(9)get_eff_addr_modrm_16(9)get_eff_addr_sib(9)get_addr_ref_16(9)get_addr_ref_32(9)get_addr_ref_64(9)insn_get_addr_ref(9)insn_fetch_from_user(9)insn_fetch_from_user_inatomic(9)insn_decode_from_regs(9)insn_decode_mmio(9)
source/version ./arch/x86/lib, dated October 2026 β bye bestie, go get that segment base πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms