resolve_default_seg(9)
πΈ NAME πΈ
resolve_default_seg β bestie, this is the one that resolves the default segment register index for an operand β¨
(also hi, you're reading the resolve_default_seg(9) page from the Kernel API Manual, welcome to the group chat π
)
π SYNOPSIS π
int resolve_default_seg (struct insn *insn , struct pt_regs *regs , int off );
π¦ ARGUMENTS π¦
insnβ the instruction, with its opcode and address size. It must be valid β like, non-negotiable, do not pass me a broken one πregsβ the register values as they looked when you entered kernel mode πoffβ the operand offset, inpt_regs, that you need resolved for you π«Ά
π DESCRIPTION π
Okay so picture this: you've got an instruction operand register, and it's sitting there at off. This function resolves the default segment register index that goes with it β¨ The index gets figured out based on the defaults described in the Intel Software Development Manual β yes, that manual, the thick one, iykyk π
Here's the vibe check on what it hands back:
- if you're in protected mode, you get a constant identifying which segment register to use, out of
CS,SS,ESorDSπ - if you're in long mode, you get
INAT_SEG_REG_IGNOREβ literally, that's the whole answer, nothing to see here π¦ - and
-EINVALin case of error π
β SEE ALSO β
Kernel file ./arch/x86/lib/insn-eval.c, plus all these iconic siblings of ours β go say hi, they're all in the same source file π:
is_string_insn(9)insn_has_rep_prefix(9)get_seg_reg_override_idx(9)check_seg_overrides(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_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)
ngl this whole thing lives in ./arch/x86/lib and the page is dated October 2026 β so like, future-era kernel lore ππ«Ά
anyway that's the page bestie, go resolve some segment registers, you're gonna slay ππβ¨
π¦ 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