From 82b8f9abcef82c3bc9cabac928253fb6bdab6d28 Mon Sep 17 00:00:00 2001 From: Derek Bruening Date: Mon, 7 Mar 2016 20:09:49 -0500 Subject: [PATCH] i#1899: suppress decoding warning on MPX prefixes Until we have i#1312 and actual MPX decoding, for now we suppress the repne prefix warning seen on Windows 10. Fixes #1899 Review-URL: https://codereview.appspot.com/290480043 --- core/arch/x86/decode.c | 12 +++++++++--- core/arch/x86/decode_private.h | 5 ++++- core/arch/x86/instr.c | 10 ++++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/core/arch/x86/decode.c b/core/arch/x86/decode.c index 9b010fae0e9..46b631cd70c 100644 --- a/core/arch/x86/decode.c +++ b/core/arch/x86/decode.c @@ -1,5 +1,5 @@ /* ********************************************************** - * Copyright (c) 2011-2015 Google, Inc. All rights reserved. + * Copyright (c) 2011-2016 Google, Inc. All rights reserved. * Copyright (c) 2000-2010 VMware, Inc. All rights reserved. * **********************************************************/ @@ -1104,8 +1104,14 @@ read_instruction(byte *pc, byte *orig_pc, if (report_invalid && ((di->rep_prefix && /* case 6861: AMD64 opt: "rep ret" used if br tgt or after cbr */ - (pc != di->start_pc+2 || *(di->start_pc+1) != RAW_OPCODE_ret)) - || di->repne_prefix)) { + (pc != di->start_pc+2 || *(di->start_pc+1) != RAW_OPCODE_ret)) || + (di->repne_prefix && + /* i#1899: MPX puts repne prior to branches. We ignore here until we have + * full MPX decoding support (i#1312). + */ + info->type != OP_call && info->type != OP_call_ind && info->type != OP_ret && + info->type != OP_jmp && info->type != OP_jmp_short && + !opc_is_cbr_arch(info->type)))) { char bytes[17*3]; int i; dcontext_t *dcontext = get_thread_private_dcontext(); diff --git a/core/arch/x86/decode_private.h b/core/arch/x86/decode_private.h index dc79518d5c6..b41f759f48d 100644 --- a/core/arch/x86/decode_private.h +++ b/core/arch/x86/decode_private.h @@ -1,5 +1,5 @@ /* ********************************************************** - * Copyright (c) 2011-2014 Google, Inc. All rights reserved. + * Copyright (c) 2011-2016 Google, Inc. All rights reserved. * Copyright (c) 2000-2010 VMware, Inc. All rights reserved. * **********************************************************/ @@ -439,6 +439,9 @@ int indir_var_reg_offs_factor(int optype); opnd_size_t expand_subreg_size(opnd_size_t sz); dr_pred_type_t decode_predicate_from_instr_info(uint opcode, const instr_info_t *info); +/* in instr.c, not exported to non-x86 files */ +bool opc_is_cbr_arch(int opc); + /* exported tables */ extern const instr_info_t first_byte[]; extern const instr_info_t second_byte[]; diff --git a/core/arch/x86/instr.c b/core/arch/x86/instr.c index 4462b8b728c..dfb5060788c 100644 --- a/core/arch/x86/instr.c +++ b/core/arch/x86/instr.c @@ -387,14 +387,20 @@ instr_is_return(instr_t *instr) /*** WARNING! The following rely on ordering of opcodes! ***/ bool -instr_is_cbr_arch(instr_t *instr) /* conditional branch */ +opc_is_cbr_arch(int opc) { - int opc = instr->opcode; /* caller ensures opcode is valid */ return ((opc >= OP_jo && opc <= OP_jnle) || (opc >= OP_jo_short && opc <= OP_jnle_short) || (opc >= OP_loopne && opc <= OP_jecxz)); } +bool +instr_is_cbr_arch(instr_t *instr) /* conditional branch */ +{ + int opc = instr->opcode; /* caller ensures opcode is valid */ + return opc_is_cbr_arch(opc); +} + bool instr_is_mbr_arch(instr_t *instr) /* multi-way branch */ {