diff options
author | Joerg Roedel <jroedel@suse.de> | 2020-09-07 15:15:12 +0200 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2020-09-07 19:45:25 +0200 |
commit | 5901781a11175a5e5ee91746ec8627f18d47eebd (patch) | |
tree | 0db5b70b8a19c0e47e46f485d971175dac5f6aaf /arch/x86/lib | |
parent | 7af1bd822dd45a669fc178a35cc8183922333d56 (diff) | |
download | linux-stable-5901781a11175a5e5ee91746ec8627f18d47eebd.tar.gz linux-stable-5901781a11175a5e5ee91746ec8627f18d47eebd.tar.bz2 linux-stable-5901781a11175a5e5ee91746ec8627f18d47eebd.zip |
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
Diffstat (limited to 'arch/x86/lib')
-rw-r--r-- | arch/x86/lib/insn-eval.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/arch/x86/lib/insn-eval.c b/arch/x86/lib/insn-eval.c index f20942ce76c6..58f7fb95c7f4 100644 --- a/arch/x86/lib/insn-eval.c +++ b/arch/x86/lib/insn-eval.c @@ -54,6 +54,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 * |