| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2010 The Native Client Authors. All rights reserved. | |
| 3 * Use of this source code is governed by a BSD-style license that can be | |
| 4 * found in the LICENSE file. | |
| 5 */ | |
| 6 | |
| 7 /* | |
| 8 * Captures instructions that allow REP and REPNE prefixes (other than | |
| 9 * multibyte instructions that require the REP/REPNE prefix bytes). | |
| 10 * | |
| 11 * Extracted from tables 1-6. 1-7, and 1-8 in AMD document 25494 - AMD64 | |
| 12 * Architecture Programmer's Manual, Volume 3: General-Purpose and System | |
| 13 * Instructions. | |
| 14 * | |
| 15 * Note: This is used by the x86-664 validator to decide what instructions | |
| 16 * can have the REP/REPE/REPZ (F3) and the REPNE/REPNZ (F2) prefix byte | |
| 17 * on an instruction. | |
| 18 */ | |
| 19 | |
| 20 #ifndef NACL_TRUSTED_BUT_NOT_TCB | |
| 21 #error("This file is not meant for use in the TCB") | |
| 22 #endif | |
| 23 | |
| 24 #include "native_client/src/trusted/validator/x86/decoder/generator/nc_rep_prefi
x.h" | |
| 25 | |
| 26 #include "native_client/src/include/nacl_macros.h" | |
| 27 #include "native_client/src/trusted/validator/x86/decoder/generator/ncdecode_for
ms.h" | |
| 28 #include "native_client/src/trusted/validator/x86/decoder/generator/ncdecode_tab
legen.h" | |
| 29 | |
| 30 /* List of instruction mnemonics that always can have a REP/REPE/REPZ (F3) | |
| 31 * prefix associated with the instruction. | |
| 32 */ | |
| 33 static const NaClMnemonic kAllowableRepMnemonic[] = { | |
| 34 InstInsb, /* 6c */ | |
| 35 InstInsd, /* 6d */ | |
| 36 InstInsw, /* 6d */ | |
| 37 InstLodsb, /* ac */ | |
| 38 InstLodsd, /* ad */ | |
| 39 InstLodsq, /* ad */ | |
| 40 InstLodsw, /* ad */ | |
| 41 InstOutsb, /* 6e */ | |
| 42 InstOutsd, /* 6f */ | |
| 43 InstOutsw, /* 6f */ | |
| 44 InstStosb, /* aa */ | |
| 45 InstStosd, /* ab */ | |
| 46 InstStosq, /* ab */ | |
| 47 InstStosw, /* ab */ | |
| 48 InstCmpsb, /* a6 */ | |
| 49 InstCmpsd, /* a7 */ | |
| 50 InstCmpsq, /* a7 */ | |
| 51 InstCmpsw, /* a7 */ | |
| 52 InstScasb, /* ae */ | |
| 53 InstScasd, /* af */ | |
| 54 InstScasq, /* af */ | |
| 55 InstScasw, /* af */ | |
| 56 }; | |
| 57 | |
| 58 /* List of instruction mnemonics that always can have a REPNE/REPNZ (F2) preix | |
| 59 * associated with the instruction. | |
| 60 */ | |
| 61 static const NaClMnemonic kAllowableRepneMnemonic[] = { | |
| 62 InstCmpsb, /* a6 */ | |
| 63 InstCmpsd, /* a7 */ | |
| 64 InstCmpsq, /* a7 */ | |
| 65 InstCmpsw, /* a7 */ | |
| 66 InstScasb, /* ae */ | |
| 67 InstScasd, /* af */ | |
| 68 InstScasq, /* af */ | |
| 69 InstScasw, /* af */ | |
| 70 }; | |
| 71 | |
| 72 /* List of instruction opcode sequences that can have a REP/REPE/REPZ | |
| 73 * (F3) prefix associated with the opcode sequence. | |
| 74 */ | |
| 75 static const NaClNameOpcodeSeq kAllowableRepMnemonicOpseq[] = { | |
| 76 { InstMovsb , { 0xa4 , END_OPCODE_SEQ } }, | |
| 77 { InstMovsd , { 0xa5 , END_OPCODE_SEQ } }, | |
| 78 { InstMovsq , { 0xa5 , END_OPCODE_SEQ } }, | |
| 79 { InstMovsw , { 0xa5 , END_OPCODE_SEQ } }, | |
| 80 }; | |
| 81 | |
| 82 void NaClAddRepPrefixFlagsIfApplicable(void) { | |
| 83 if (NaClInInstructionSet(kAllowableRepMnemonic, | |
| 84 NACL_ARRAY_SIZE(kAllowableRepMnemonic), | |
| 85 kAllowableRepMnemonicOpseq, | |
| 86 NACL_ARRAY_SIZE(kAllowableRepMnemonicOpseq))) { | |
| 87 NaClAddIFlags(NACL_IFLAG(OpcodeAllowsRep)); | |
| 88 } | |
| 89 if (NaClInInstructionSet(kAllowableRepneMnemonic, | |
| 90 NACL_ARRAY_SIZE(kAllowableRepneMnemonic), | |
| 91 NULL, 0)) { | |
| 92 NaClAddIFlags(NACL_IFLAG(OpcodeAllowsRepne)); | |
| 93 } | |
| 94 } | |
| OLD | NEW |