Skip to content

Commit 84da009

Browse files
mhiramatsuryasaimadhu
authored andcommitted
x86/sev-es: Use new for_each_insn_prefix() macro to loop over prefixes bytes
Since insn.prefixes.nbytes can be bigger than the size of insn.prefixes.bytes[] when a prefix is repeated, the proper check must be: insn.prefixes.bytes[i] != 0 and i < 4 instead of using insn.prefixes.nbytes. Use the new for_each_insn_prefix() macro which does it correctly. Debugged by Kees Cook <[email protected]>. [ bp: Massage commit message. ] Fixes: 25189d0 ("x86/sev-es: Add support for handling IOIO exceptions") Reported-by: [email protected] Signed-off-by: Masami Hiramatsu <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/160697106089.3146288.2052422845039649176.stgit@devnote2
1 parent 12cb908 commit 84da009

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

arch/x86/boot/compressed/sev-es.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ struct ghcb *boot_ghcb;
3232
*/
3333
static bool insn_has_rep_prefix(struct insn *insn)
3434
{
35+
insn_byte_t p;
3536
int i;
3637

3738
insn_get_prefixes(insn);
3839

39-
for (i = 0; i < insn->prefixes.nbytes; i++) {
40-
insn_byte_t p = insn->prefixes.bytes[i];
41-
40+
for_each_insn_prefix(insn, i, p) {
4241
if (p == 0xf2 || p == 0xf3)
4342
return true;
4443
}

0 commit comments

Comments
 (0)