Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\lib\insn-eval.c Create Date:2022-07-28 07:25:30
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:get_reg_offset

Proto:static int get_reg_offset(struct insn *insn, struct pt_regs *regs, enum reg_type type)

Type:int

Parameter:

TypeParameterName
struct insn *insn
struct pt_regs *regs
enum reg_typetype
399  regno = 0
401  static const int regoff[] = {offsetof(structpt_regs, ax), offsetof(structpt_regs, cx), offsetof(structpt_regs, dx), offsetof(structpt_regs, bx), offsetof(structpt_regs, sp), offsetof(structpt_regs, bp), offsetof(structpt_regs, si), offsetof(structpt_regs, di), offsetof(structpt_regs, r8), offsetof(structpt_regs, r9), offsetof(structpt_regs, r10), offsetof(structpt_regs, r11), offsetof(structpt_regs, r12), offsetof(structpt_regs, r13), offsetof(structpt_regs, r14), offsetof(structpt_regs, r15), }
421  nr_registers = ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(regoff)
426  If IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_X86_64) && Not x86_64 Then nr_registers -= 8
430  Case type == REG_TYPE_RM
431  regno = X86_MODRM_RM(value)
437  If Not X86_MODRM_MOD(value) && regno == 5 Then Return -EDOM
440  If X86_REX_B(value) Then regno += 8
442  Break
444  Case type == REG_TYPE_INDEX
445  regno = X86_SIB_INDEX(value)
446  If X86_REX_X(value) Then regno += 8
455  If X86_MODRM_MOD(value) != 3 && regno == 4 Then Return -EDOM
457  Break
459  Case type == REG_TYPE_BASE
460  regno = X86_SIB_BASE(value)
466  If Not X86_MODRM_MOD(value) && regno == 5 Then Return -EDOM
469  If X86_REX_B(value) Then regno += 8
471  Break
473  Default
474  pr_err_ratelimited("invalid register type: %d\n", type)
475  Return -EINVAL
478  If regno >= nr_registers Then
479  WARN_ONCE(1, "decoded an instruction with an invalid register")
480  Return -EINVAL
482  Return regoff[regno]
Caller
NameDescribe
insn_get_modrm_rm_offsn_get_modrm_rm_off() - Obtain register in r/m part of the ModRM byte*@insn: Instruction containing the ModRM byte*@regs: Register values as seen when entering kernel mode* Returns:* The register indicated by the r/m part of the ModRM byte. The
get_eff_addr_regget_eff_addr_reg() - Obtain effective address from register operand*@insn: Instruction
get_eff_addr_modrmget_eff_addr_modrm() - Obtain referenced effective address via ModRM*@insn: Instruction
get_eff_addr_sibget_eff_addr_sib() - Obtain referenced effective address via SIB*@insn: Instruction