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.
8 * Captures instructions that allow REP and REPNE prefixes (other than
9 * multibyte instructions that require the REP/REPNE prefix bytes).
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
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
20 #ifndef NACL_TRUSTED_BUT_NOT_TCB
21 #error("This file is not meant for use in the TCB")
24 #include "native_client/src/trusted/validator/x86/decoder/generator/nc_rep_prefix.h"
26 #include "native_client/src/include/nacl_macros.h"
27 #include "native_client/src/trusted/validator/x86/decoder/generator/ncdecode_forms.h"
28 #include "native_client/src/trusted/validator/x86/decoder/generator/ncdecode_tablegen.h"
30 /* List of instruction mnemonics that always can have a REP/REPE/REPZ (F3)
31 * prefix associated with the instruction.
33 static const NaClMnemonic kAllowableRepMnemonic[] = {
58 /* List of instruction mnemonics that always can have a REPNE/REPNZ (F2) preix
59 * associated with the instruction.
61 static const NaClMnemonic kAllowableRepneMnemonic[] = {
72 /* List of instruction opcode sequences that can have a REP/REPE/REPZ
73 * (F3) prefix associated with the opcode sequence.
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 } },
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));
89 if (NaClInInstructionSet(kAllowableRepneMnemonic,
90 NACL_ARRAY_SIZE(kAllowableRepneMnemonic),
92 NaClAddIFlags(NACL_IFLAG(OpcodeAllowsRepne));