mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-22 04:24:02 +08:00
x86/insn: Add insn_has_rep_prefix() helper
Add a function to check whether an instruction has a REP prefix. Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org> Link: https://lkml.kernel.org/r/20200907131613.12703-12-joro@8bytes.org
This commit is contained in:
parent
7af1bd822d
commit
5901781a11
@ -15,6 +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))
|
||||
|
||||
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_reg_off(struct insn *insn, struct pt_regs *regs);
|
||||
|
@ -53,6 +53,30 @@ static bool is_string_insn(struct insn *insn)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* insn_has_rep_prefix() - Determine if instruction has a REP prefix
|
||||
* @insn: Instruction containing the prefix to inspect
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* true if the instruction has a REP prefix, false if not.
|
||||
*/
|
||||
bool insn_has_rep_prefix(struct insn *insn)
|
||||
{
|
||||
int i;
|
||||
|
||||
insn_get_prefixes(insn);
|
||||
|
||||
for (i = 0; i < insn->prefixes.nbytes; i++) {
|
||||
insn_byte_t p = insn->prefixes.bytes[i];
|
||||
|
||||
if (p == 0xf2 || p == 0xf3)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get_seg_reg_override_idx() - obtain segment register override index
|
||||
* @insn: Valid instruction with segment override prefixes
|
||||
|
Loading…
Reference in New Issue
Block a user