x86/insn-eval: Remove unused regs arg some functions
PATCH 1/5 x86/insn-eval: Remove unused regs arg some functions
hi,
regs argument is not used in several insn-eval functions, removing it.
I have some changes based on these functions and it feels wrong to pass NULL in regs argument. Also I don't want to send 5 extra patches with my other change, so sending this separately.
thanks,
jirka
---
Jiri Olsa (5):
x86/insn-eval: Remove regs arg from pt_regs_offset x86/insn-eval: Remove regs arg from get_reg_offset x86/insn-eval: Remove regs arg from insn_get_modrm_rm_off x86/insn-eval: Remove regs arg from insn_get_modrm_reg_off x86/insn-eval: Remove regs arg from get_reg_offset_16
arch/x86/coco/sev/vc-handle.c | 2 +- arch/x86/include/asm/insn-eval.h | 6 +++--- arch/x86/kernel/cfi.c | 2 +- arch/x86/kernel/umip.c | 2 +- arch/x86/lib/insn-eval.c | 35 +++++++++++++++-------------------- arch/x86/mm/extable.c | 2 +- 6 files changed, 22 insertions(+), 27 deletions(-)
PATCH 1/5 x86/insn-eval: Remove regs arg from pt_regs_offset
It's not used, pt_regs_offset returns only offset to struct pt_regs, not the actual register values.
--- arch/x86/include/asm/insn-eval.h | 2 +- arch/x86/lib/insn-eval.c | 4 ++-- arch/x86/mm/extable.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/include/asm/insn-eval.h +1 -1
@@ -15,7 +15,7 @@#define INSN_CODE_SEG_OPND_SZ (params) (params & 0xf)#define INSN_CODE_SEG_PARAMS (oper_sz, addr_sz) (oper_sz | (addr_sz << 4)) -int pt_regs_offset (struct pt_regs *regs,int regno); +int pt_regs_offset (int regno);bool insn_has_rep_prefix (struct insn *insn);void __user *insn_get_addr_ref (struct insn *insn,struct pt_regs *regs);
arch/x86/lib/insn-eval.c +2 -2
@@ -437,7 +437,7 @@ static const int pt_regoff[] = {#endif }; -int pt_regs_offset (struct pt_regs *regs,int regno) +int pt_regs_offset (int regno) {if ((unsigned )regno <ARRAY_SIZE (pt_regoff))return pt_regoff[regno];
@@ -527,7 +527,7 @@ static int get_reg_offset(struct insn *insn, struct pt_regs *regs,if (regno <0 )return regno; -return pt_regs_offset (regs, regno); +return pt_regs_offset (regno); }/**
arch/x86/mm/extable.c +1 -1
@@ -15,7 +15,7 @@static inline unsigned long *pt_regs_nr (struct pt_regs *regs,int nr) { -int reg_offset =pt_regs_offset (regs, nr); +int reg_offset =pt_regs_offset (nr);static unsigned long __dummy;if (WARN_ON_ONCE (reg_offset <0 ))
Signature · 1 line
2.51.1
PATCH 2/5 x86/insn-eval: Remove regs arg from get_reg_offset
In reply to Jiri OlsaIt's not used, get_reg_offset returns only offset to struct pt_regs, not the actual register values.
--- arch/x86/lib/insn-eval.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
arch/x86/lib/insn-eval.c +7 -8
@@ -519,8 +519,7 @@ static int get_regno(struct insn *insn, enum reg_type type)return regno; } -static int get_reg_offset (struct insn *insn,struct pt_regs *regs, -enum reg_type type) +static int get_reg_offset (struct insn *insn,enum reg_type type) {int regno =get_regno (insn, type);
@@ -861,7 +860,7 @@ int insn_get_code_seg_params(struct pt_regs *regs)*/ int insn_get_modrm_rm_off (struct insn *insn,struct pt_regs *regs) { -return get_reg_offset (insn, regs,REG_TYPE_RM ); +return get_reg_offset (insn,REG_TYPE_RM ); }/**
@@ -876,7 +875,7 @@ int insn_get_modrm_rm_off(struct insn *insn, struct pt_regs *regs)*/ int insn_get_modrm_reg_off (struct insn *insn,struct pt_regs *regs) { -return get_reg_offset (insn, regs,REG_TYPE_REG ); +return get_reg_offset (insn,REG_TYPE_REG ); }/**
@@ -982,7 +981,7 @@ static int get_eff_addr_reg(struct insn *insn, struct pt_regs *regs,if (X86_MODRM_MOD (insn->modrm.value) !=3 )return -EINVAL ; - *regoff =get_reg_offset (insn, regs,REG_TYPE_RM ); + *regoff =get_reg_offset (insn,REG_TYPE_RM );if (*regoff <0 )return -EINVAL ;
@@ -1035,7 +1034,7 @@ static int get_eff_addr_modrm(struct insn *insn, struct pt_regs *regs,if (X86_MODRM_MOD (insn->modrm.value) >2 )return -EINVAL ; - *regoff =get_reg_offset (insn, regs,REG_TYPE_RM ); + *regoff =get_reg_offset (insn,REG_TYPE_RM );/* * -EDOM means that we must ignore the address_offset. In such a case,
@@ -1181,8 +1180,8 @@ static int get_eff_addr_sib(struct insn *insn, struct pt_regs *regs,if (!insn->sib.nbytes)return -EINVAL ; - *base_offset =get_reg_offset (insn, regs,REG_TYPE_BASE ); - indx_offset =get_reg_offset (insn, regs,REG_TYPE_INDEX ); + *base_offset =get_reg_offset (insn,REG_TYPE_BASE ); + indx_offset =get_reg_offset (insn,REG_TYPE_INDEX );/* * Negative values in the base and index offset means an error when
Signature · 1 line
2.51.1
PATCH 3/5 x86/insn-eval: Remove regs arg from insn_get_modrm_rm_off
In reply to Jiri OlsaIt's not used, insn_get_modrm_rm_off returns only offset to struct pt_regs, not the actual register values.
--- arch/x86/coco/sev/vc-handle.c | 2 +- arch/x86/include/asm/insn-eval.h | 2 +- arch/x86/kernel/cfi.c | 2 +- arch/x86/kernel/umip.c | 2 +- arch/x86/lib/insn-eval.c | 5 ++--- 5 files changed, 6 insertions(+), 7 deletions(-)
arch/x86/coco/sev/vc-handle.c +1 -1
@@ -467,7 +467,7 @@ static long *vc_insn_get_rm(struct es_em_ctxt *ctxt)int offset; reg_array = (long *)ctxt->regs; - offset =insn_get_modrm_rm_off (&ctxt->insn, ctxt->regs); + offset =insn_get_modrm_rm_off (&ctxt->insn);if (offset <0 )return NULL ;
arch/x86/include/asm/insn-eval.h +1 -1
@@ -19,7 +19,7 @@ int pt_regs_offset(int regno);bool insn_has_rep_prefix (struct insn *insn);void __user *insn_get_addr_ref (struct insn *insn,struct pt_regs *regs); -int insn_get_modrm_rm_off (struct insn *insn,struct pt_regs *regs); +int insn_get_modrm_rm_off (struct insn *insn);int insn_get_modrm_reg_off (struct insn *insn,struct pt_regs *regs);unsigned long *insn_get_modrm_reg_ptr (struct insn *insn,struct pt_regs *regs);unsigned long insn_get_seg_base (struct pt_regs *regs,int seg_reg_idx);
arch/x86/kernel/cfi.c +1 -1
@@ -52,7 +52,7 @@ static bool decode_cfi_insn(struct pt_regs *regs, unsigned long *target,return false;/* Read the target address from the register. */ - offset =insn_get_modrm_rm_off (&insn, regs); + offset =insn_get_modrm_rm_off (&insn);if (offset <0 )return false;
arch/x86/kernel/umip.c +1 -1
@@ -388,7 +388,7 @@ bool fixup_umip_exception(struct pt_regs *regs)* register. */ if (X86_MODRM_MOD (insn.modrm.value) ==3 ) { - reg_offset =insn_get_modrm_rm_off (&insn, regs); + reg_offset =insn_get_modrm_rm_off (&insn);/* * Negative values are usually errors. In memory addressing,
arch/x86/lib/insn-eval.c +2 -3
@@ -581,7 +581,7 @@ static int get_reg_offset_16(struct insn *insn, struct pt_regs *regs,/* Operand is a register, use the generic function. */ if (X86_MODRM_MOD (insn->modrm.value) ==3 ) { - *offs1 =insn_get_modrm_rm_off (insn, regs); + *offs1 =insn_get_modrm_rm_off (insn); *offs2 = -EDOM ;return 0 ; }
@@ -849,7 +849,6 @@ int insn_get_code_seg_params(struct pt_regs *regs)/** * insn_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: *
@@ -858,7 +857,7 @@ int insn_get_code_seg_params(struct pt_regs *regs)* cases, the returned value can be -EDOM to indicate that the particular value * of ModRM does not refer to a register and shall be ignored. */ -int insn_get_modrm_rm_off (struct insn *insn,struct pt_regs *regs) +int insn_get_modrm_rm_off (struct insn *insn) {return get_reg_offset (insn,REG_TYPE_RM ); }
Signature · 1 line
2.51.1
PATCH 4/5 x86/insn-eval: Remove regs arg from insn_get_modrm_reg_off
In reply to Jiri OlsaIt's not used, insn_get_modrm_reg_off returns only offset to struct pt_regs, not the actual register values.
--- arch/x86/include/asm/insn-eval.h | 2 +- arch/x86/lib/insn-eval.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-)
arch/x86/include/asm/insn-eval.h +1 -1
@@ -20,7 +20,7 @@ int pt_regs_offset(int regno);bool insn_has_rep_prefix (struct insn *insn);void __user *insn_get_addr_ref (struct insn *insn,struct pt_regs *regs);int insn_get_modrm_rm_off (struct insn *insn); -int insn_get_modrm_reg_off (struct insn *insn,struct pt_regs *regs); +int insn_get_modrm_reg_off (struct insn *insn);unsigned long *insn_get_modrm_reg_ptr (struct insn *insn,struct pt_regs *regs);unsigned long insn_get_seg_base (struct pt_regs *regs,int seg_reg_idx);int insn_get_code_seg_params (struct pt_regs *regs);
arch/x86/lib/insn-eval.c +2 -3
@@ -865,14 +865,13 @@ int insn_get_modrm_rm_off(struct insn *insn)/** * insn_get_modrm_reg_off() - Obtain register in reg 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 reg part of the ModRM byte. The * register is obtained as an offset from the base of pt_regs. */ -int insn_get_modrm_reg_off (struct insn *insn,struct pt_regs *regs) +int insn_get_modrm_reg_off (struct insn *insn) {return get_reg_offset (insn,REG_TYPE_REG ); }
@@ -891,7 +890,7 @@ unsigned long *insn_get_modrm_reg_ptr(struct insn *insn, struct pt_regs *regs) {int offset; - offset =insn_get_modrm_reg_off (insn, regs); + offset =insn_get_modrm_reg_off (insn);if (offset <0 )return NULL ;return (void *)regs + offset;
Signature · 1 line
2.51.1
PATCH 5/5 x86/insn-eval: Remove regs arg from get_reg_offset_16
In reply to Jiri OlsaIt's not used, get_reg_offset_16 returns only offset to struct pt_regs, not the actual register values.
--- arch/x86/lib/insn-eval.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/x86/lib/insn-eval.c +2 -4
@@ -532,7 +532,6 @@ static int get_reg_offset(struct insn *insn, enum reg_type type)/** * get_reg_offset_16() - Obtain offset of register indicated by instruction * @insn: Instruction containing ModRM byte -* @regs: Register values as seen when entering kernel mode * @offs1: Offset of the first operand register * @offs2: Offset of the second operand register, if applicable *
@@ -546,8 +545,7 @@ static int get_reg_offset(struct insn *insn, enum reg_type type)* * 0 on success, -EINVAL on error. */ -static int get_reg_offset_16 (struct insn *insn,struct pt_regs *regs, -int *offs1,int *offs2) +static int get_reg_offset_16 (struct insn *insn,int *offs1,int *offs2) {/* * 16-bit addressing can use one or two registers. Specifics of
@@ -1100,7 +1098,7 @@ static int get_eff_addr_modrm_16(struct insn *insn, struct pt_regs *regs,if (X86_MODRM_MOD (insn->modrm.value) >2 )return -EINVAL ; - ret =get_reg_offset_16 (insn, regs, &addr_offset1, &addr_offset2); + ret =get_reg_offset_16 (insn, &addr_offset1, &addr_offset2);if (ret <0 )return -EINVAL ;
Signature · 1 line
2.51.1
Quoted 19 lines · Jiri Olsa
hi,
regs argument is not used in several insn-eval functions, removing it.I have some changes based on these functions and it feels wrong to pass NULL in regs argument. Also I don't want to send 5 extra patches with my other change, so sending this separately.
thanks,
jirka---
Jiri Olsa (5):
x86/insn-eval: Remove regs arg frompt_regs_offsetx86/insn-eval: Remove regs arg fromget_reg_offsetx86/insn-eval: Remove regs arg frominsn_get_modrm_rm_offx86/insn-eval: Remove regs arg frominsn_get_modrm_reg_offx86/insn-eval: Remove regs arg fromget_reg_offset_16
Quoted 7 lines
arch/x86/coco/sev/vc-handle.c | 2 +- arch/x86/include/asm/insn-eval.h | 6 +++--- arch/x86/kernel/cfi.c | 2 +- arch/x86/kernel/umip.c | 2 +- arch/x86/lib/insn-eval.c | 35 +++++++++++++++-------------------- arch/x86/mm/extable.c | 2 +- 6 files changed, 22 insertions(+), 27 deletions(-)