insn_get_code_seg_params(9)
π insn_get_code_seg_params π
okay so this is a page from the Kernel API Manual, and we're about to make code-segment parameters make sense, bestie, no cap π«Ά
πΈ NAME πΈ
insn_get_code_seg_params β Obtain code segment parameters β¨
π SYNOPSIS π
int insn_get_code_seg_params (struct pt_regs *regs );
π¦ ARGUMENTS π¦
regsβ Structure with register values as seen when entering kernel mode. it's giving "snapshot of the moment we hopped into the kernel" energy π«
π DESCRIPTION π
so the whole point of this one is: Obtain address and operand sizes of the code segment. literally that's the job π
and where does it get them from?? from the selector contained in the CS register in regs. iykyk π§
now, in protected mode, the default address is determined by inspecting the L and D bits of the segment descriptor. yes bestie, you gotta actually go look at the descriptor bits, we don't just guess π
in virtual-8086 mode tho? the default is always two bytes for both address and operand sizes. always. every time. periodt. π―
so what comes back to you:
- An
intcontaining ORed-in default parameters on success. slay π₯³ -EINVALon error. π it happens to the best of us.
π SEE ALSO π
the whole friend group lives in ./arch/x86/lib/insn-eval.c, and here's the full roster β every single one of them, no skips π:
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)insn_get_seg_base(9)get_seg_limit(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)
and that's the page!! brought to you by the fine folks over in ./arch/x86/lib, dated October 2026 β mwah, love u, go read some segment descriptors πβ¨π
π¦ 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