mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 17:05:18 +07:00
e2a5dca753
In order to save on redundant structs definitions insn_get_code_seg_params() was made to return two 4-bit values in a char but clang complains: arch/x86/lib/insn-eval.c:780:10: warning: implicit conversion from 'int' to 'char' changes value from 132 to -124 [-Wconstant-conversion] return INSN_CODE_SEG_PARAMS(4, 8); ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~ ./arch/x86/include/asm/insn-eval.h:16:57: note: expanded from macro 'INSN_CODE_SEG_PARAMS' #define INSN_CODE_SEG_PARAMS(oper_sz, addr_sz) (oper_sz | (addr_sz << 4)) Those two values do get picked apart afterwards the opposite way of how they were ORed so wrt to the LSByte, the return value is the same. But this function returns -EINVAL in the error case, which is an int. So make it return an int which is the native word size anyway and thus fix the clang warning. Reported-by: Kees Cook <keescook@google.com> Reported-by: Nick Desaulniers <nick.desaulniers@gmail.com> Signed-off-by: Borislav Petkov <bp@suse.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: ricardo.neri-calderon@linux.intel.com Link: https://lkml.kernel.org/r/20171123091951.1462-1-bp@alien8.de
24 lines
837 B
C
24 lines
837 B
C
#ifndef _ASM_X86_INSN_EVAL_H
|
|
#define _ASM_X86_INSN_EVAL_H
|
|
/*
|
|
* A collection of utility functions for x86 instruction analysis to be
|
|
* used in a kernel context. Useful when, for instance, making sense
|
|
* of the registers indicated by operands.
|
|
*/
|
|
|
|
#include <linux/compiler.h>
|
|
#include <linux/bug.h>
|
|
#include <linux/err.h>
|
|
#include <asm/ptrace.h>
|
|
|
|
#define INSN_CODE_SEG_ADDR_SZ(params) ((params >> 4) & 0xf)
|
|
#define INSN_CODE_SEG_OPND_SZ(params) (params & 0xf)
|
|
#define INSN_CODE_SEG_PARAMS(oper_sz, addr_sz) (oper_sz | (addr_sz << 4))
|
|
|
|
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);
|
|
unsigned long insn_get_seg_base(struct pt_regs *regs, int seg_reg_idx);
|
|
int insn_get_code_seg_params(struct pt_regs *regs);
|
|
|
|
#endif /* _ASM_X86_INSN_EVAL_H */
|