Upstream version 11.39.250.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / validator_ragel / instruction_definitions / general_purpose_instructions.def
1 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 ################################################################################
5 # This file describes instructions from AMD64 Architecture Programmer's Manual
6 #                               Volume 3: General-Purpose and System Instruction
7 #                               Chapter 3: General-Purpose Instruction Reference
8 ################################################################################
9 # File format: see def_format.py
10 ######## ADC ###################################################################
11 # "adc" is not marked as nacl-amd64-zero-extends since borrows/carries should
12 # not be need when calculating an address.
13 adc I a, 0x14
14 adc I E, 0x80 /2, lock
15 adc Ib Ev, 0x83 /2, lock
16 adc G E, 0x10, lock
17 adc E G, 0x12
18 ######## ADD ###################################################################
19 add I a, 0x04, nacl-amd64-zero-extends
20 add I E, 0x80 /0, lock nacl-amd64-zero-extends
21 add Ib Ev, 0x83 /0, lock nacl-amd64-zero-extends
22 add G E, 0x00, lock nacl-amd64-zero-extends
23 add E G, 0x02, nacl-amd64-zero-extends
24 ######## AND ###################################################################
25 and I a, 0x24, nacl-amd64-zero-extends
26 and I E, 0x80 /4, lock nacl-amd64-zero-extends
27 and Ib Ev, 0x83 /4, lock nacl-amd64-zero-extends
28 and G E, 0x20, lock nacl-amd64-zero-extends
29 and E G, 0x22, nacl-amd64-zero-extends
30 ######## ANDN ##################################################################
31 andn Ey By Gy, 0xc4 RXB.02 W.src1.0.00 0xf2, CPUFeature_BMI1
32 ######## BEXTR #################################################################
33 bextr By Ey Gy, 0xc4 RXB.02 W.cntl.0.00 0xf7, CPUFeature_BMI1
34 bextr Id Ey Gy, 0x8f RXB.0A W.1111.0.00 0x10, CPUFeature_BMI1
35 ######## BLCFILL ###############################################################
36 # "blcfill" is not marked as nacl-amd64-zero-extends out of caution.  We assume
37 # that this instruction is used for bit manipulation rather than computing
38 # viable addresses.
39 blcfill Ey By, 0x8f RXB.09 W.dest.0.00 0x01 /1, CPUFeature_TBM
40 ######## BLCI ##################################################################
41 # "blci" is not marked as nacl-amd64-zero-extends out of caution.  We assume
42 # that this instruction is used for bit manipulation rather than computing
43 # viable addresses.
44 blci Ey By, 0x8f RXB.09 W.dest.0.00 0x02 /6, CPUFeature_TBM
45 ######## BLCIC #################################################################
46 # "blcic" is not marked as nacl-amd64-zero-extends out of caution.  We assume
47 # that this instruction is used for bit manipulation rather than computing
48 # viable addresses.
49 blcic Ey By, 0x8f RXB.09 W.dest.0.00 0x01 /5, CPUFeature_TBM
50 ######## BLCMSK ################################################################
51 # "blcmsk" is not marked as nacl-amd64-zero-extends out of caution.  We assume
52 # that this instruction is used for bit manipulation rather than computing
53 # viable addresses.
54 blcmsk Ey By, 0x8f RXB.09 W.dest.0.00 0x02 /1, CPUFeature_TBM
55 ######## BLCS ##################################################################
56 # "blcs" is not marked as nacl-amd64-zero-extends out of caution.  We assume
57 # that this instruction is used for bit manipulation rather than computing
58 # viable addresses.
59 blcs Ey By, 0x8f RXB.09 W.dest.0.00 0x01 /3, CPUFeature_TBM
60 ######## BLSFILL ###############################################################
61 # "blsfill" is not marked as nacl-amd64-zero-extends out of caution.  We assume
62 # that this instruction is used for bit manipulation rather than computing
63 # viable addresses.
64 blsfill Ey By, 0x8f RXB.09 W.dest.0.00 0x01 /2, CPUFeature_TBM
65 ######## BLSI ##################################################################
66 # "blsi" is not marked as nacl-amd64-zero-extends out of caution.  We assume
67 # that this instruction is used for bit manipulation rather than computing
68 # viable addresses.
69 blsi Ey By, 0xc4 RXB.02 W.dest.0.00 0xf3 /3, CPUFeature_BMI1
70 ######## BLSIC #################################################################
71 # "blsic" is not marked as nacl-amd64-zero-extends out of caution.  We assume
72 # that this instruction is used for bit manipulation rather than computing
73 # viable addresses.
74 blsic Ey By, 0x8f RXB.09 W.dest.0.00 0x01 /6, CPUFeature_TBM
75 ######## BLSMSK ################################################################
76 # "blsmsk" is not marked as nacl-amd64-zero-extends out of caution.  We assume
77 # that this instruction is used for bit manipulation rather than computing
78 # viable addresses.
79 blsmsk Ey By, 0xc4 RXB.02 W.dest.0.00 0xf3 /2, CPUFeature_BMI1
80 ######## BLSR ##################################################################
81 # "blsr" is not marked as nacl-amd64-zero-extends out of caution.  We assume
82 # that this instruction is used for bit manipulation rather than computing
83 # viable addresses.
84 blsr Ey By, 0xc4 RXB.02 W.dest.0.00 0xf3 /1, CPUFeature_BMI1
85 ######## BSF ###################################################################
86 # Textbook definition of "bsf" as per AMD/Intel manuals looks like this:
87 #  bsf Ev Gv, 0x0f 0xbc
88 # For consistency with the production validators, drop support for the 16-bit
89 #  version of "bsf" in ia32 mode.
90 # Note that the former 32- and 64-bit validators treat "bsf" inconsistently:
91 #  http://code.google.com/p/nativeclient/issues/detail?id=2972
92 #
93 # "bsf" is not marked as nacl-amd64-zero-extends because it does not always
94 # writes to it's second operand:
95 #  http://code.google.com/p/nativeclient/issues/detail?id=2010
96 bsf Ew Gw, data16 0x0f 0xbc, norexw nacl-ia32-forbidden
97 bsf Ed Gd, 0x0f 0xbc, norexw
98 bsf Eq Gq, rexw 0x0f 0xbc, amd64
99 bsf Eq Gq, data16 rexw 0x0f 0xbc, amd64 nacl-forbidden
100 ######## BSR ###################################################################
101 # Textbook definition of "bsr" as per AMD/Intel manuals looks like this:
102 #  bsr Ev Gv, 0x0f 0xbd
103 # For consistency with the production validators, drop support for the 16-bit
104 #  version of "bsr" in ia32 mode.
105 # Note that the former 32- and 64-bit validators treat "bsr" inconsistently:
106 #  http://code.google.com/p/nativeclient/issues/detail?id=2973
107 #
108 # "bsr" is not marked as nacl-amd64-zero-extends because it does not always
109 # writes to it's second operand:
110 #  http://code.google.com/p/nativeclient/issues/detail?id=2010
111 bsr Ew Gw, data16 0x0f 0xbd, norexw nacl-ia32-forbidden
112 bsr Ed Gd, 0x0f 0xbd, norexw
113 bsr Eq Gq, rexw 0x0f 0xbd, amd64
114 bsr Eq Gq, data16 rexw 0x0f 0xbd, amd64 nacl-forbidden
115 ######## BSWAP #################################################################
116 # "bswap" is not marked as nacl-amd64-zero-extends because we don't really think
117 # that swapping the bottom bytes is a good thing to do to mask a memory
118 # reference.
119 bswap ry, 0x0f 0xc8
120 ######## BT ####################################################################
121 #   bt <register>, <memory>
122 # is unsafe in 64-bit mode, because <register> could be
123 # 64-bit.
124 #   bt <immediate>, <whatever>
125 # only uses few least significant bits of <immediate>, so it's safe.
126 # Moreover, it's necessary to test higher bits of 64-bit operands
127 # (which can't be done with test instruction), so it's the only form that is
128 # allowed.
129 bt Gv =Ev, 0x0f 0xa3, nacl-forbidden
130 bt Ib =Ev, 0x0f 0xba /4, nacl-ia32-forbidden
131 ######## BTC ###################################################################
132 # "btc" is not marked as nacl-amd64-zero-extends out of caution.  We assume that
133 # this instruction is used for bit manipulation rather than computing viable
134 # addresses.
135 # Also, see comment for bt.
136 btc Gv Ev, 0x0f 0xbb, lock nacl-forbidden
137 btc Ib Ev, 0x0f 0xba /7, lock nacl-ia32-forbidden
138 ######## BTR ###################################################################
139 # "btr" is not marked as nacl-amd64-zero-extends out of caution.  We assume that
140 # this instruction is used for bit manipulation rather than computing viable
141 # addresses.
142 # Also, see comment for bt.
143 btr Gv Ev, 0x0f 0xb3, lock nacl-forbidden
144 btr Ib Ev, 0x0f 0xba /6, lock nacl-ia32-forbidden
145 ######## BTS ###################################################################
146 # "bts" is not marked as nacl-amd64-zero-extends out of caution.  We assume that
147 # this instruction is used for bit manipulation rather than computing viable
148 # addresses.
149 # Also, see comment for bt.
150 bts Gv Ev, 0x0f 0xab, lock nacl-forbidden
151 bts Ib Ev, 0x0f 0xba /5, lock nacl-ia32-forbidden
152 ######## CALL (Near) ###########################################################
153 call Jw, data16 0xe8, att-show-name-suffix-w nacl-forbidden
154 call Jd, 0xe8, ia32
155 call Jd, 0xe8, amd64 att-show-name-suffix-q nacl-amd64-modifiable
156 call Jd, data16 rexw 0xe8, amd64 att-show-name-suffix-q nacl-forbidden
157 # "call" does not require rex prefix and always uses 64bit addresses in x86-64
158 # mode unless data16 prefix is used.  We use simple solution: 16bit call is
159 # declared as common for 32bit/64bit mode and 32bit/64bit versions are described
160 # separately.
161 call Ew, data16 0xff /2, norexw att-show-name-suffix-w nacl-forbidden
162 call Ed, 0xff /2, ia32 nacl-forbidden
163 call Eq, 0xff /2, amd64 att-show-name-suffix-q nacl-forbidden
164 call Eq, data16 rexw 0xff /2, amd64 att-show-name-suffix-q nacl-forbidden
165 ######## CALL (Far) ############################################################
166 # "lcall" does not require rex prefix and always uses 64bit addresses in x86-64
167 # mode unless data16 prefix is used.  We use simple solution: 16bit call is
168 # declared as common for 32bit/64bit mode and 32bit/64bit versions are described
169 # separately.
170 lcall Mp, data16 0xff /3, norexw att-show-name-suffix-w nacl-forbidden
171 lcall Mp, 0xff /3, ia32 nacl-forbidden
172 lcall Mp, 0xff /3, amd64 att-show-name-suffix-q nacl-forbidden
173 lcall Mp, data16 rexw 0xff /3, amd64 att-show-name-suffix-q nacl-forbidden
174 ######## CBW/CWDE/CDQE #########################################################
175 cwtl, 0x98, norexw
176 cbtw, data16 0x98, norexw
177 cltq, data16 rexw 0x98, amd64 nacl-forbidden
178 cltq, rexw 0x98, amd64
179 ######## CWD/CDQ/CQO ###########################################################
180 cltd, 0x99, norexw
181 cwtd, data16 0x99, norexw
182 cqto, data16 rexw 0x99, amd64 nacl-forbidden
183 cqto, rexw 0x99, amd64
184 ######## CLC ###################################################################
185 clc, 0xf8
186 ######## CLD ###################################################################
187 cld, 0xfc
188 ######## CLFLUSH ###############################################################
189 # clflush disabled because it is unused and may potentially be unsafe.
190 # see: https://code.google.com/p/nativeclient/issues/detail?id=3944
191 clflush Mb, 0x0f 0xae /7, CPUFeature_CLFLUSH nacl-forbidden
192 ######## CMC ###################################################################
193 cmc, 0xf5
194 ######## CMOVCC ################################################################
195 # "cmovcc" instructions are not marked as nacl-amd64-zero-extends out of caution.
196 # AMD/Intel manual state that these instrucitons always zero extends 32 bit
197 # register results to 64 bits, and that this occurs even if the condition is
198 # false. However, we decided to be safe and omit these instructions anyway.
199 cmova Ev Gv, 0x0f 0x47, CPUFeature_CMOV
200 cmovae Ev Gv, 0x0f 0x43, CPUFeature_CMOV
201 cmovbe Ev Gv, 0x0f 0x46, CPUFeature_CMOV
202 cmovb Ev Gv, 0x0f 0x42, CPUFeature_CMOV
203 cmove Ev Gv, 0x0f 0x44, CPUFeature_CMOV
204 cmovg Ev Gv, 0x0f 0x4f, CPUFeature_CMOV
205 cmovge Ev Gv, 0x0f 0x4d, CPUFeature_CMOV
206 cmovle Ev Gv, 0x0f 0x4e, CPUFeature_CMOV
207 cmovl Ev Gv, 0x0f 0x4c, CPUFeature_CMOV
208 cmovne Ev Gv, 0x0f 0x45, CPUFeature_CMOV
209 cmovno Ev Gv, 0x0f 0x41, CPUFeature_CMOV
210 cmovnp Ev Gv, 0x0f 0x4b, CPUFeature_CMOV
211 cmovns Ev Gv, 0x0f 0x49, CPUFeature_CMOV
212 cmovo Ev Gv, 0x0f 0x40, CPUFeature_CMOV
213 cmovp Ev Gv, 0x0f 0x4a, CPUFeature_CMOV
214 cmovs Ev Gv, 0x0f 0x48, CPUFeature_CMOV
215 ######## CMP ###################################################################
216 cmp I =a, 0x3c
217 cmp I =E, 0x80 /7
218 cmp Ib =Ev, 0x83 /7
219 cmp G =E, 0x38
220 cmp E =G, 0x3a
221 ######## CMPS/CMPSB/CMPSW/CMPSD/CMPSQ ##########################################
222 cmps Y X, 0xa6, condrep nacl-amd64-forbidden
223 ######## CMPXCHG ###############################################################
224 # Textbook definition of "cmpxchg" as per AMD/Intel manuals looks like this:
225 #  cmpxchg G E, 0x0f 0xb0, lock
226 # For consistency with the production validators:
227 #  * treat both explicit arguments as read-write
228 #  * drop support for the 16-bit version
229 # Note1: "cmpxchg" indeed writes to two arguments, but these areguments are
230 #  implicit %al/%ax/%eax/%rax and second explicit argument.  First explicit
231 #  argument is read-only.
232 # Note2: the former 32- and 64-bit validators treat "cmpxchg" inconsistently:
233 #  http://code.google.com/p/nativeclient/issues/detail?id=2974
234 #
235 # "cmpxchg" is not marked as nacl-amd64-zero-extends because it conditionally
236 # writes to different destinations.
237 cmpxchg &Gb Eb, 0x0f 0xb0, lock
238 cmpxchg &Gw Ew, data16 0x0f 0xb1, norexw lock nacl-ia32-forbidden
239 cmpxchg &Gd Ed, 0x0f 0xb1, norexw lock
240 cmpxchg &Gq Eq, rexw 0x0f 0xb1, amd64 lock
241 cmpxchg &Gq Eq, data16 rexw 0x0f 0xb1, amd64 lock nacl-forbidden
242 ######## CMPXCHG8B/CMPXCHG16B ##################################################
243 cmpxchg8b Mq, 0x0f 0xc7 /1, norexw lock CPUFeature_CX8
244 cmpxchg16b Mo, rexw 0x0f 0xc7 /1, amd64 lock CPUFeature_CX16
245 ######## CPUID #################################################################
246 # "cpuid" is not marked as nacl-amd64-zero-extends just because it shouldn't be.
247 cpuid, 0x0f 0xa2
248 ######## CRC32 #################################################################
249 # In principle, this instruction can be defined as
250 #   crc32b E Gy, 0xf2 0x0f 0x38 0xf0, CPUFeature_SSE42
251 # but first, it's somewhat counterintuitive how splitting can produce the
252 # following five variations, so it's better to make it explicit, and second,
253 # rules to determine what suffix instruction name is followed with, special
254 # treatment would be required (for compatibility with objdump).
255 # Note: crc32 Ew Gd is disallowed for consistency with old validator, see
256 #  https://code.google.com/p/nativeclient/issues/detail?id=3356
257 crc32b Eb Gd, 0xf2 0x0f 0x38 0xf0, norexw CPUFeature_SSE42
258 crc32b Eb Gq, rexw 0xf2 0x0f 0x38 0xf0, amd64 CPUFeature_SSE42
259 crc32w Ew Gd, data16 0xf2 0x0f 0x38 0xf1, norexw CPUFeature_SSE42 nacl-forbidden
260 crc32l Ed Gd, 0xf2 0x0f 0x38 0xf1, norexw CPUFeature_SSE42
261 crc32q Eq Gq, rexw 0xf2 0x0f 0x38 0xf1, amd64 CPUFeature_SSE42
262 ######## DEC ###################################################################
263 dec E, 0xfe /1, lock nacl-amd64-zero-extends
264 dec rz, 0x48, ia32
265 ######## DIV ###################################################################
266 # "div" is not marked as nacl-amd64-zero-extends because we never allowed it.
267 div =E, 0xf6 /6
268 ######## ENTER #################################################################
269 # Enter is safe in amd64 mode, but it's safety relies on minute details of
270 # implementation which can be changed in the future thus we prefer to disable
271 # it.  It's uncoditionally safe in ia32 mode as per the textbook definition in
272 # AMD/Intel manual but it does complex manipulations and is very rarely used
273 # (GCC, in particular, never uses it).  As a rule we don't allow complex and
274 # rarely used instructions such as "aaa" or "bound".  Disable it for now.
275 enter Iw =ib, 0xc8, ia32 nacl-forbidden
276 enter Iw =ib, 0xc8, amd64 att-show-name-suffix-q nacl-forbidden
277 ######## IDIV ##################################################################
278 # "idiv" is not marked as nacl-amd64-zero-extends because we never allowed it.
279 idiv =E, 0xf6 /7
280 ######## IMUL ##################################################################
281 imul =E, 0xf6 /5
282 imul Ev Gv, 0x0f 0xaf, nacl-amd64-zero-extends
283 imul Ib Ev Gv, 0x6b, nacl-amd64-zero-extends
284 imul Iz Ev Gv, 0x69, nacl-amd64-zero-extends
285 ######## IN ####################################################################
286 # "in" is not marked as nacl-amd64-zero-extends just because it shouldn't be.
287 in Ib ab, 0xe4, nacl-forbidden
288 in Ib az, 0xe5, nacl-forbidden
289 in ob ab, 0xec, nacl-forbidden
290 in oz az, 0xed, nacl-forbidden
291 ######## INC ###################################################################
292 inc E, 0xfe /0, lock nacl-amd64-zero-extends
293 inc rz, 0x40, ia32
294 ######## INS/INSB/INSW/INSD ####################################################
295 ins ob Yb, 0x6c, rep att-show-name-suffix-b nacl-forbidden
296 ins ow Yw, data16 0x6d, rep att-show-name-suffix-w nacl-forbidden
297 ins od Yd, 0x6d, rep att-show-name-suffix-l nacl-forbidden
298 ins od Yd, rexw 0x6d, amd64 rep att-show-name-suffix-l nacl-forbidden
299 ins od Yd, data16 rexw 0x6d, amd64 rep att-show-name-suffix-l nacl-forbidden
300 ######## INT ###################################################################
301 int =Ib, 0xcd, nacl-forbidden
302 ######## JCXZ/JECXZ/JRCXZ ######################################################
303 jecxz Jb, 0xe3, ia32 branch_hint nacl-forbidden
304 jrcxz Jb, 0xe3, amd64 branch_hint
305 ######## Jcc ###################################################################
306 ja Jb, 0x77, branch_hint
307 ja Jw, data16 0x0f 0x87, branch_hint nacl-forbidden
308 ja Jd, 0x0f 0x87, branch_hint
309 jae Jb, 0x73, branch_hint
310 jae Jw, data16 0x0f 0x83, branch_hint nacl-forbidden
311 jae Jd, 0x0f 0x83, branch_hint
312 jb Jb, 0x72, branch_hint
313 jb Jw, data16 0x0f 0x82, branch_hint nacl-forbidden
314 jb Jd, 0x0f 0x82, branch_hint
315 jbe Jb, 0x76, branch_hint
316 jbe Jw, data16 0x0f 0x86, branch_hint nacl-forbidden
317 jbe Jd, 0x0f 0x86, branch_hint
318 je Jb, 0x74, branch_hint
319 je Jw, data16 0x0f 0x84, branch_hint nacl-forbidden
320 je Jd, 0x0f 0x84, branch_hint
321 jg Jb, 0x7f, branch_hint
322 jg Jw, data16 0x0f 0x8f, branch_hint nacl-forbidden
323 jg Jd, 0x0f 0x8f, branch_hint
324 jge Jb, 0x7d, branch_hint
325 jge Jw, data16 0x0f 0x8d, branch_hint nacl-forbidden
326 jge Jd, 0x0f 0x8d, branch_hint
327 jl Jb, 0x7c, branch_hint
328 jl Jw, data16 0x0f 0x8c, branch_hint nacl-forbidden
329 jl Jd, 0x0f 0x8c, branch_hint
330 jle Jb, 0x7e, branch_hint
331 jle Jw, data16 0x0f 0x8e, branch_hint nacl-forbidden
332 jle Jd, 0x0f 0x8e, branch_hint
333 jne Jb, 0x75, branch_hint
334 jne Jw, data16 0x0f 0x85, branch_hint nacl-forbidden
335 jne Jd, 0x0f 0x85, branch_hint
336 jno Jb, 0x71, branch_hint
337 jno Jw, data16 0x0f 0x81, branch_hint nacl-forbidden
338 jno Jd, 0x0f 0x81, branch_hint
339 jnp Jb, 0x7b, branch_hint
340 jnp Jw, data16 0x0f 0x8b, branch_hint nacl-forbidden
341 jnp Jd, 0x0f 0x8b, branch_hint
342 jns Jb, 0x79, branch_hint
343 jns Jw, data16 0x0f 0x89, branch_hint nacl-forbidden
344 jns Jd, 0x0f 0x89, branch_hint
345 jo Jb, 0x70, branch_hint
346 jo Jw, data16 0x0f 0x80, branch_hint nacl-forbidden
347 jo Jd, 0x0f 0x80, branch_hint
348 jp Jb, 0x7a, branch_hint
349 jp Jw, data16 0x0f 0x8a, branch_hint nacl-forbidden
350 jp Jd, 0x0f 0x8a, branch_hint
351 js Jb, 0x78, branch_hint
352 js Jw, data16 0x0f 0x88, branch_hint nacl-forbidden
353 js Jd, 0x0f 0x88, branch_hint
354 ######## JMP (Near) ############################################################
355 jmp Jb, 0xeb
356 jmp Jw, data16 0xe9, norexw att-show-name-suffix-w nacl-forbidden
357 jmp Jd, 0xe9, ia32
358 jmp Jd, 0xe9, amd64 att-show-name-suffix-q
359 jmp Jd, data16 rexw 0xe9, amd64 att-show-name-suffix-q nacl-forbidden
360 # "jmp" does not require rex prefix and always uses 64bit addresses in x86-64
361 # mode unless data16 prefix is used.  We use simple solution: 16bit jump is
362 # declared as common for 32bit/64bit mode and 32bit/64bit versions are described
363 # separately.
364 jmp Ew, data16 0xff /4, norexw att-show-name-suffix-w nacl-forbidden
365 jmp Ed, 0xff /4, ia32 nacl-forbidden
366 jmp Eq, 0xff /4, amd64 att-show-name-suffix-q nacl-forbidden
367 jmp Eq, data16 rexw 0xff /4, amd64 att-show-name-suffix-q nacl-forbidden
368 ######## JMP (Far) #############################################################
369 # "ljmp" does not require rex prefix and always uses 64bit addresses in x86-64
370 # mode unless data16 prefix is used.  We use simple solution: 16bit jump is
371 # declared as common for 32bit/64bit mode and 32bit/64bit versions are described
372 # separately.
373 ljmp Mp, data16 0xff /5, norexw att-show-name-suffix-w nacl-forbidden
374 ljmp Mp, 0xff /5, ia32 nacl-forbidden
375 ljmp Mp, 0xff /5, amd64 att-show-name-suffix-q nacl-forbidden
376 ljmp Mp, data16 rexw 0xff /5, amd64 att-show-name-suffix-q nacl-forbidden
377 ######## LAHF ##################################################################
378 # LAHF is always available in 16bit/32bit mode, but not always in 64bit mode
379 lahf, 0x9f, ia32
380 lahf, 0x9f, amd64 CPUFeature_LAHF
381 ######## LDS/LES/LFS/LGS/LSS (AMD version) #####################################
382 # AMD manual says "executing LFS, LGS, or LSS with a 64-bit operand size only
383 # loads a 32-bit general purpose register and the specified segment register".
384 # lds Mp Gz, 0xc5, ia32 nacl-forbidden
385 # les Mp Gz, 0xc4, ia32 nacl-forbidden
386 # lfs Mp Gz, 0x0f 0xb4, nacl-forbidden
387 # lgs Mp Gz, 0x0f 0xb5, nacl-forbidden
388 # lss Mp Gz, 0x0f 0xb2, nacl-forbidden
389 ######## LDS/LES/LFS/LGS/LSS (Intel version) ###################################
390 # Intel manual says: "Using a REX prefix in the form of REX.W promotes operation
391 # to specify a source operand referencing an 80-bit pointer (16-bit selector,
392 # 64-bit offset) in memory".
393 lds Mp Gv, 0xc5, ia32 nacl-forbidden
394 les Mp Gv, 0xc4, ia32 nacl-forbidden
395 # "lfs", "lgs", and "lss" are not marked as nacl-amd64-zero-extends because
396 # segment addresses shouldn't be used.
397 lfs Mp Gv, 0x0f 0xb4, nacl-forbidden
398 lgs Mp Gv, 0x0f 0xb5, nacl-forbidden
399 lss Mp Gv, 0x0f 0xb2, nacl-forbidden
400 ######## LEA ###################################################################
401 lea 'Mv !Gv, 0x8d, no_memory_access nacl-amd64-zero-extends
402 ######## LEAVE #################################################################
403 leave, 0xc9, ia32
404 leave, 0xc9, amd64 att-show-name-suffix-q nacl-forbidden
405 ######## LFENCE ################################################################
406 lfence, 0x0f 0xae 0xe8, CPUFeature_SSE2
407 ######## LLWPCB ################################################################
408 llwpcb =Ry, 0x8f RXB.09 W.1111.0.00 0x12 /0, CPUFeature_LWP
409 ######## LODS/LODSB/LODSW/LODSD/LODSQ ##########################################
410 # Textbook definition of "lods[bwdq]" as per AMD/Intel manuals looks like this:
411 #  lods X a, 0xac, rep nacl-amd64-forbidden
412 # For consistency with the production validators, drop support for the "lods" in
413 #  ia32 mode.
414 # Note that the former 32- and 64-bit validators treat "lods" inconsistently:
415 #  http://code.google.com/p/nativeclient/issues/detail?id=2975
416 # It's "special" instruction in amd64 mode (and is accepted with "special"
417 #  sandboxing), but forbidden instruction in ia32 mode.
418 lods X a, 0xac, rep nacl-forbidden
419 ######## LOOP/LOOPE/LOOPNE/LOOPNZ/LOOPZ ########################################
420 # Manual is quite vague WRT usability of branch prediction prefixes combined
421 # with "loop/loope/loopne" instructions. Old optimization manual (from P4) says
422 # about them the following: "These hints take the form of prefixes to any type
423 # of branch instruction.  Branch hints are not guaranteed to have any effect,
424 # and their function may vary across implementations. On the Pentium 4
425 # processor, branch hints are active only for relative conditional branches."
426 # And today's manual says:
427 #   - Branch hints:
428 #     * 2EH - Branch not taken (used only with Jcc instructions)
429 #     * 3EH - Branch taken (used only with Jcc instructions)
430 # Since they never had any effect on the code execution their usability is
431 # quite limited.  We disable them for now.
432 loop Jb, 0xe2, nacl-ia32-forbidden
433 loop Jb, 0xe2, branch_hint nacl-forbidden
434 loope Jb, 0xe1, nacl-ia32-forbidden
435 loope Jb, 0xe1, branch_hint nacl-forbidden
436 loopne Jb, 0xe0, nacl-ia32-forbidden
437 loopne Jb, 0xe0, branch_hint nacl-forbidden
438 ######## LWPINS ################################################################
439 lwpins Id Ed =By, 0x8f RXB.0A W.src1.0.00 0x12 /0, CPUFeature_LWP
440 ######## LWPVAL ################################################################
441 lwpval Id Ed =By, 0x8f RXB.0A W.src1.0.00 0x12 /1, CPUFeature_LWP
442 ######## LZCNT #################################################################
443 # Textbook definition of "lzcnt" as per AMD/Intel manuals looks like this:
444 #   lzcnt Ev Gv, 0xf3 0x0f 0xbd, CPUFeature_LZCNT nacl-amd64-zero-extends
445 # "lzcnt" is not marked as nacl-amd64-zero-extends because it is unlikely to be
446 # useful for computing an address based on the number of leading zeros of a
447 # value.
448 # Also, since f3 opcode extension is counted as rep prefix, it is not allowed
449 # together with data16 prefix.
450 # See http://code.google.com/p/nativeclient/issues/detail?id=3076
451 lzcnt Ew Gw, data16 0xf3 0x0f 0xbd, norexw CPUFeature_LZCNT nacl-forbidden
452 lzcnt Ed Gd, 0xf3 0x0f 0xbd, norexw CPUFeature_LZCNT
453 lzcnt Eq Gq, rexw 0xf3 0x0f 0xbd, amd64 CPUFeature_LZCNT
454 lzcnt Eq Gq, data16 rexw 0xf3 0x0f 0xbd, amd64 CPUFeature_LZCNT nacl-forbidden
455 ######## MFENCE ################################################################
456 mfence, 0x0f 0xae 0xf0, CPUFeature_SSE2
457 ######## MOV ###################################################################
458 mov G !E, 0x88, nacl-amd64-modifiable nacl-amd64-zero-extends
459 mov E !G, 0x8a, nacl-amd64-modifiable nacl-amd64-zero-extends
460 mov Sw !Mw, 0x8c, nacl-forbidden
461 mov Sw !Rv, 0x8c, nacl-forbidden
462 mov Ew !Sw, 0x8e, nacl-forbidden
463 mov Ib !rb, 0xb0, nacl-amd64-modifiable nacl-amd64-zero-extends
464 mov Iv !rv, 0xb8, nacl-amd64-modifiable nacl-amd64-zero-extends
465 mov I !E, 0xc6 /0, nacl-amd64-modifiable nacl-amd64-zero-extends
466 mov O !a, 0xa0, ia32
467 mov a !O, 0xa2, ia32
468 movabs O !a, 0xa0, amd64 nacl-forbidden
469 movabs a !O, 0xa2, amd64 nacl-forbidden
470 ######## MOVBE #################################################################
471 # Textbook definition of "movbe" as per AMD/Intel manuals looks like this:
472 #  movbe Mv Gv, 0x0f 0x38 0xf0, CPUFeature_MOVBE
473 #  movbe Gv Mv, 0x0f 0x38 0xf1, CPUFeature_MOVBE
474 # For consistency with the production validators, drop support for the 16-bit
475 #  version of "movbe" in ia32 mode.
476 # Note that the former 32- and 64-bit validators treat "movbe" inconsistently:
477 #  http://code.google.com/p/nativeclient/issues/detail?id=2976
478 movbe Mw Gw, data16 0x0f 0x38 0xf0, norexw CPUFeature_MOVBE nacl-ia32-forbidden
479 movbe Gw Mw, data16 0x0f 0x38 0xf1, norexw CPUFeature_MOVBE nacl-ia32-forbidden
480 movbe Md Gd, 0x0f 0x38 0xf0, norexw CPUFeature_MOVBE
481 movbe Gd Md, 0x0f 0x38 0xf1, norexw CPUFeature_MOVBE
482 movbe Mq Gq, rexw 0x0f 0x38 0xf0, amd64 CPUFeature_MOVBE
483 movbe Gq Mq, rexw 0x0f 0x38 0xf1, amd64 CPUFeature_MOVBE
484 movbe Mq Gq, data16 rexw 0x0f 0x38 0xf0, amd64 CPUFeature_MOVBE nacl-forbidden
485 movbe Gq Mq, data16 rexw 0x0f 0x38 0xf1, amd64 CPUFeature_MOVBE nacl-forbidden
486 ######## MOVD ##################################################################
487 # Textbook definition of "movd" as per AMD/Intel manuals looks like this:
488 #  movd Ey Vy, 0x66 0x0f 0x6e, CPUFeature_SSE2
489 #  movd Vy Ey, 0x66 0x0f 0x7e, CPUFeature_SSE2
490 #  movd Ey Py, 0x0f 0x6e, CPUFeature_MMX
491 #  movd Py Ey, 0x0f 0x7e, CPUFeature_MMX
492 # Objdump names 64bit version not "movd" but movq".  We describe 32bit version
493 #  and 64bit version separately.
494 movd Ed Vq, 0x66 0x0f 0x6e, norexw CPUFeature_SSE2
495 movd Vq Ed, 0x66 0x0f 0x7e, norexw CPUFeature_SSE2 nacl-amd64-zero-extends
496 movd Ed Pq, 0x0f 0x6e, norexw CPUFeature_MMX
497 movd Pq Ed, 0x0f 0x7e, norexw CPUFeature_MMX nacl-amd64-zero-extends
498 movq Eq Vq, 0x66 rexw 0x0f 0x6e, amd64 CPUFeature_SSE2
499 movq Vq Eq, 0x66 rexw 0x0f 0x7e, amd64 CPUFeature_SSE2
500 movq Eq Pq, rexw 0x0f 0x6e, amd64 CPUFeature_MMX
501 movq Pq Eq, rexw 0x0f 0x7e, amd64 CPUFeature_MMX
502 ######## MOVMSKPD ##############################################################
503 # Textbook definition of "movmskpd" as per AMD/Intel manuals looks like this:
504 #  movmskpd Upd Gd, 0x66 0x0f 0x50, CPUFeature_SSE2
505 # GNU as accepts this description, but objdump decodes last operand as "Gy".
506 # Technically it makes no difference: "movmskpd" clears everything except least
507 # significant two bits and this operation produces precisely idential output for
508 # "Gy" and "Gd" operands.  We use objdump's description.
509 movmskpd Upd Gy, 0x66 0x0f 0x50, CPUFeature_SSE2
510 ######## MOVMSKPS ##############################################################
511 # Textbook definition of "movmskps" as per AMD/Intel manuals looks like this:
512 #  movmskps Ups Gd, 0x0f 0x50, CPUFeature_SSE2
513 # GNU as accepts this description, but objdump decodes last operand as "Gy".
514 # Technically it makes no difference: "movmskps" clears everything except least
515 # significant four bits and this operation produces precisely idential output
516 # for "Gy" and "Gd" operands.  We use objdump's description.
517 movmskps Ups Gy, 0x0f 0x50, CPUFeature_SSE
518 ######## MOVNTI ################################################################
519 movnti Gy My, 0x0f 0xc3, CPUFeature_SSE2
520 ######## MOVS/MOVSB/MOVSW/MOVSD/MOVSQ ##########################################
521 movs X Y, 0xa4, rep nacl-amd64-forbidden
522 ######## MOVSX #################################################################
523 # Textbook definition of "movsx" as per AMD/Intel manuals looks like this:
524 #  movsx Eb Gv, 0x0f 0xbe
525 #  movsx Ew Gy, 0x0f 0xbf
526 # Objdump has different names for this instrustion: "movsbw", "movsbl", "movsbq",
527 # "movswl", "movswq" depending on operand size.  We describe 32bit versions and
528 # 64bit version separately.
529 movsbl Eb Gd, 0x0f 0xbe, norexw nacl-amd64-zero-extends
530 movsbq Eb Gq, rexw 0x0f 0xbe, amd64
531 movsbw Eb Gw, data16 0x0f 0xbe, norexw
532 movswl Ew Gd, 0x0f 0xbf, norexw nacl-amd64-zero-extends
533 movswq Ew Gq, rexw 0x0f 0xbf, amd64
534 movsww Ew Gw, data16 0x0f 0xbf, norexw
535 ######## MOVSXD ################################################################
536 movslq Ed Gv, 0x63, amd64 nacl-amd64-zero-extends
537 ######## MOVZX #################################################################
538 # Textbook definition of "movzx" as per AMD/Intel manuals looks like this:
539 #  movzx Eb Gv, 0x0f 0xb6
540 #  movzx Ew Gy, 0x0f 0xb7
541 # Objdump has different names for this instrustion: "movzbw", "movzbl", "movzbq",
542 # "movzwl", "movzwq" depending on operand size.  We describe 32bit versions and
543 # 64bit version separately.
544 movzbl Eb Gd, 0x0f 0xb6, norexw nacl-amd64-zero-extends
545 movzbq Eb Gq, rexw 0x0f 0xb6, amd64
546 movzbw Eb Gw, data16 0x0f 0xb6, norexw
547 movzwl Ew Gd, 0x0f 0xb7, norexw nacl-amd64-zero-extends
548 movzwq Ew Gq, rexw 0x0f 0xb7, amd64
549 movzww Ew Gw, data16 0x0f 0xb7, norexw
550 ######## MUL ###################################################################
551 # "mul" is not marked as nacl-amd64-zero-extends because we never allowed it.
552 mul =E, 0xf6 /4
553 ######## NEG ###################################################################
554 neg E, 0xf6 /3, lock nacl-amd64-zero-extends
555 ######## NOP ###################################################################
556 nop, 0x90, norex
557 nop, 0x40 0x90, amd64 norex
558 "rex.W nop", 0x48 0x90, amd64 norex
559 # Textbook definition of "nop" as per AMD/Intel manuals looks like this:
560 #  nop 'Ev, 0x0f 0x1f /0, no_memory_access
561 # For consistency with the production validators, drop support for the 16-bit
562 #  version of "nop".
563 nop 'Rw, data16 0x0f 0x1f /0,
564   no_memory_access nacl-forbidden
565 nop 'Mw, data16 0x0f 0x1f /0,
566   no_memory_access att-show-name-suffix-w nacl-forbidden
567 nop 'Rd, 0x0f 0x1f /0,
568   norexw no_memory_access
569 nop 'Md, 0x0f 0x1f /0,
570   norexw att-show-name-suffix-l no_memory_access
571 nop 'Rq, rexw 0x0f 0x1f /0,
572   amd64 no_memory_access
573 nop 'Mq, rexw 0x0f 0x1f /0,
574   amd64 att-show-name-suffix-q no_memory_access
575 nop 'Rq, data16 rexw 0x0f 0x1f /0,
576   amd64 no_memory_access nacl-forbidden
577 nop 'Mq, data16 rexw 0x0f 0x1f /0,
578   amd64 no_memory_access att-show-name-suffix-q nacl-forbidden
579 ######## NOT ###################################################################
580 not E, 0xf6 /2, lock nacl-amd64-zero-extends
581 ######## OR ####################################################################
582 or I a, 0x0c, nacl-amd64-zero-extends
583 or I E, 0x80 /1, lock nacl-amd64-zero-extends
584 or Ib Ev, 0x83 /1, lock nacl-amd64-zero-extends
585 or G E, 0x08, lock nacl-amd64-zero-extends
586 or E G, 0x0a, nacl-amd64-zero-extends
587 ######## OUT ###################################################################
588 out ab =Ib, 0xe6, nacl-forbidden
589 out az =Ib, 0xe7, nacl-forbidden
590 out ab =ob, 0xee, nacl-forbidden
591 out az =oz, 0xef, nacl-forbidden
592 ######## OUTS/OUTSB/OUTSW/OUTSD ################################################
593 outs Xb =ob, 0x6e, rep att-show-name-suffix-b nacl-forbidden
594 outs Xw =ow, data16 0x6f, rep att-show-name-suffix-w nacl-forbidden
595 outs Xd =od, 0x6f, rep att-show-name-suffix-l nacl-forbidden
596 outs Xd =od, rexw 0x6f, amd64 rep att-show-name-suffix-l nacl-forbidden
597 outs Xd =od, data16 rexw 0x6f, amd64 rep att-show-name-suffix-l nacl-forbidden
598 ######## PAUSE #################################################################
599 pause, 0xf3 0x90, norex
600 ######## POP ###################################################################
601 # "pop" does not require rex prefix and always uses 64bit addresses in x86-64
602 # mode unless data16 prefix is used.  We use simple solution: 16bit call is
603 # declared as common for 32bit/64bit mode and 32bit/64bit versions are described
604 # separately.
605 pop Rw, data16 0x8f /0
606 pop Mw, data16 0x8f /0, att-show-name-suffix-w
607 pop Rr, 0x8f /0, ia32
608 pop Mr, 0x8f /0, ia32 att-show-name-suffix-l
609 pop Rr, 0x8f /0, amd64
610 pop Mr, 0x8f /0, amd64 att-show-name-suffix-q
611 pop rw, data16 0x58
612 pop rr, 0x58
613 "pop %es", 0x07, ia32 nacl-forbidden
614 "pop %ss", 0x17, ia32 nacl-forbidden
615 "pop %ds", 0x1f, ia32 nacl-forbidden
616 "pop %fs", 0x0f 0xa1, ia32 nacl-forbidden
617 "pop %gs", 0x0f 0xa9, ia32 nacl-forbidden
618 "popq %fs", 0x0f 0xa1, amd64 nacl-forbidden
619 "popq %gs", 0x0f 0xa9, amd64 nacl-forbidden
620 ######## POPCNT ################################################################
621 # Textbook definition of "popcnt" as per AMD/Intel manuals looks like this:
622 #   popcnt Ev Gv, 0xf3 0x0f 0xb8, CPUFeature_POPCNT nacl-amd64-zero-extends
623 # "popcnt" is not marked as nacl-amd64-zero-extends because it is unlikely to be
624 # useful for computing an address based on the number of ones in a value.
625 # Also, since f3 opcode extension is counted as rep prefix, it is not allowed
626 # together with data16 prefix.
627 # See http://code.google.com/p/nativeclient/issues/detail?id=3076
628 popcnt Ew Gw, data16 0xf3 0x0f 0xb8, norexw CPUFeature_POPCNT nacl-forbidden
629 popcnt Ed Gd, 0xf3 0x0f 0xb8, norexw CPUFeature_POPCNT
630 popcnt Eq Gq, rexw 0xf3 0x0f 0xb8, amd64 CPUFeature_POPCNT
631 popcnt Eq Gq, data16 rexw 0xf3 0x0f 0xb8, amd64 CPUFeature_POPCNT nacl-forbidden
632 ######## POPF/POPFD/POPFQ ######################################################
633 popf, data16 0x9d, norexw att-show-name-suffix-w nacl-forbidden
634 popf, 0x9d, ia32 nacl-forbidden
635 popf, 0x9d, norexw amd64 att-show-name-suffix-q nacl-forbidden
636 popf, data16 rexw 0x9d, amd64 att-show-name-suffix-q nacl-forbidden
637 ######## PREFETCH/PREFETCHW ####################################################
638 prefetch Mb, 0x0f 0x0d /0, CPUFeature_3DPRFTCH no_memory_access
639 prefetchw Mb, 0x0f 0x0d /1, CPUFeature_3DPRFTCH no_memory_access
640 prefetch Mb, 0x0f 0x0d /2, CPUFeature_3DPRFTCH no_memory_access nacl-forbidden
641 # AMD manual desribes this opcode as "reserved" in one place (and clarifies that
642 # it's aliased to prefetch for the compatibility) and as "invalid" in another
643 # place.  It's textbook definition as per AMD manual looks like this:
644 #  prefetch Mb, 0x0f 0x0d /3, CPUFeature_3DPRFTCH no_memory_access
645 # For consistency with the production validators, drop support for this form of
646 # "prefetch" in ia32 mode but support in in amd64 mode.
647 # Note that the former 32- and 64-bit validators treat "prefetch" inconsistently:
648 #  http://code.google.com/p/nativeclient/issues/detail?id=2977
649 prefetch Mb, 0x0f 0x0d /3, CPUFeature_3DPRFTCH no_memory_access nacl-ia32-forbidden
650 prefetch Mb, 0x0f 0x0d /4, CPUFeature_3DPRFTCH no_memory_access nacl-forbidden
651 prefetch Mb, 0x0f 0x0d /5, CPUFeature_3DPRFTCH no_memory_access nacl-forbidden
652 prefetch Mb, 0x0f 0x0d /6, CPUFeature_3DPRFTCH no_memory_access nacl-forbidden
653 prefetch Mb, 0x0f 0x0d /7, CPUFeature_3DPRFTCH no_memory_access nacl-forbidden
654 ######## PREFETCHlevel #########################################################
655 prefetchnta Mb, 0x0f 0x18 /0, CPUFeature_SSE no_memory_access
656 prefetcht0 Mb, 0x0f 0x18 /1, CPUFeature_SSE no_memory_access
657 prefetcht1 Mb, 0x0f 0x18 /2, CPUFeature_SSE no_memory_access
658 prefetcht2 Mb, 0x0f 0x18 /3, CPUFeature_SSE no_memory_access
659 # AMD manual claims this opcode is "nop".  Intel manual says it's "reserved".
660 # Real silicon accepts it and seemingly doing nothing.
661 "nop/reserved" Mb, 0x0f 0x18 /4, CPUFeature_SSE no_memory_access nacl-forbidden
662 "nop/reserved" Mb, 0x0f 0x18 /5, CPUFeature_SSE no_memory_access nacl-forbidden
663 "nop/reserved" Mb, 0x0f 0x18 /6, CPUFeature_SSE no_memory_access nacl-forbidden
664 "nop/reserved" Mb, 0x0f 0x18 /7, CPUFeature_SSE no_memory_access nacl-forbidden
665 ######## PUSH ##################################################################
666 # "push" does not require rex prefix and always uses 64bit addresses in x86-64
667 # mode unless data16 prefix is used.  We use simple solution: 16bit call is
668 # declared as common for 32bit/64bit mode and 32bit/64bit versions are described
669 # separately.
670 push =Rw, data16 0xff /6
671 push =Mw, data16 0xff /6, att-show-name-suffix-w
672 push =Rr, 0xff /6, ia32
673 push =Mr, 0xff /6, ia32 att-show-name-suffix-l
674 push =Rr, 0xff /6, amd64
675 push =Mr, 0xff /6, amd64 att-show-name-suffix-q
676 push =rw, data16 0x50
677 push =rr, 0x50
678 push =Iw, data16 0x68, att-show-name-suffix-w
679 push =Id, 0x68, ia32
680 push =Id, 0x68, amd64 att-show-name-suffix-q
681 push =Id, data16 rexw 0x68, amd64 att-show-name-suffix-q nacl-forbidden
682 push =Ib, 0x6a, ia32
683 push =Ib, 0x6a, amd64 att-show-name-suffix-q
684 "push %es", 0x06, ia32 nacl-forbidden
685 "push %cs", 0x0e, ia32 nacl-forbidden
686 "push %ss", 0x16, ia32 nacl-forbidden
687 "push %ds", 0x1e, ia32 nacl-forbidden
688 "push %fs", 0x0f 0xa0, ia32 nacl-forbidden
689 "push %gs", 0x0f 0xa8, ia32 nacl-forbidden
690 "pushq %fs", 0x0f 0xa0, amd64 nacl-forbidden
691 "pushq %gs", 0x0f 0xa8, amd64 nacl-forbidden
692 ######## PUSHF/PUSHFD/PUSHFQ ###################################################
693 pushf, data16 0x9c, norexw att-show-name-suffix-w nacl-forbidden
694 pushf, 0x9c, ia32 nacl-forbidden
695 pushf, 0x9c, norexw amd64 att-show-name-suffix-q nacl-forbidden
696 pushf, data16 rexw 0x9c, amd64 att-show-name-suffix-q nacl-forbidden
697 ######## RCL ###################################################################
698 # "rcl" is not marked as nacl-amd64-zero-extends out of caution.  We assume that
699 # this instruction is used for bit manipulation rather than computing viable
700 # addresses.
701 rcl E, 0xd0 /2
702 rcl cb E, 0xd2 /2
703 rcl Ib E, 0xc0 /2
704 ######## RCR ###################################################################
705 # "rcr" is not marked as nacl-amd64-zero-extends out of caution.  We assume that
706 # this instruction is used for bit manipulation rather than computing viable
707 # addresses.
708 rcr E, 0xd0 /3
709 rcr cb E, 0xd2 /3
710 rcr Ib E, 0xc0 /3
711 ######## RET (Near) ############################################################
712 ret, 0xc3, rep ia32 nacl-forbidden
713 ret, 0xc3, rep amd64 att-show-name-suffix-q nacl-forbidden
714 ret =Iw, 0xc2, ia32 nacl-forbidden
715 ret =Iw, 0xc2, amd64 att-show-name-suffix-q nacl-forbidden
716 ######## RET (Far) #############################################################
717 lret, 0xcb, norexw nacl-forbidden
718 lret =Iw, 0xca, norexw nacl-forbidden
719 lretq, rexw 0xcb, amd64 nacl-forbidden
720 lretq =Iw, rexw 0xca, amd64 nacl-forbidden
721 ######## ROL ###################################################################
722 # "rol" is not marked as nacl-amd64-zero-extends out of caution.  We assume that
723 # this instruction is used for bit manipulation rather than computing viable
724 # addresses.
725 rol E, 0xd0 /0
726 rol cb E, 0xd2 /0
727 rol Ib E, 0xc0 /0
728 ######## ROR ###################################################################
729 # "ror" is not marked as nacl-amd64-zero-extends out of caution.  We assume that
730 # this instruction is used for bit manipulation rather than computing viable
731 # addresses.
732 ror Ib E, 0xc0 /1
733 ror E, 0xd0 /1
734 ror cb E, 0xd2 /1
735 ######## SAHF ##################################################################
736 # SAHF is always awailable in 16bit/32bit mode, but not always in 64bit mode
737 sahf, 0x9e, ia32
738 sahf, 0x9e, amd64 CPUFeature_LAHF
739 ######## SAL ###################################################################
740 # AMD manual claims this opcode works identically to shl.  Intel manual
741 # says it's reserved.  Objdump does not like it.
742 # sal E, 0xd0 /6
743 # sal cb E, 0xd2 /6
744 # sal Ib E, 0xc0 /6
745 ######## SAL/SHL ###############################################################
746 # "sal"/"shl" is not marked as nacl-amd64-zero-extends out of caution.  We
747 # assume that this instruction is used for bit manipulation rather than
748 # computing viable addresses.
749 shl E, 0xd0 /4
750 shl cb E, 0xd2 /4
751 shl Ib E, 0xc0 /4
752 ######## SAR ###################################################################
753 # "sar" is not marked as nacl-amd64-zero-extends out of caution.  We assume that
754 # this instruction is used for bit manipulation rather than computing viable
755 # addresses.
756 sar Ib E, 0xc0 /7
757 sar E, 0xd0 /7
758 sar cb E, 0xd2 /7
759 ######## SBB ###################################################################
760 # "sbb" is not marked as nacl-amd64-zero-extends since borrows/carries should
761 # not be need when calculating an address.
762 sbb I a, 0x1c
763 sbb I E, 0x80 /3, lock
764 sbb Ib Ev, 0x83 /3, lock
765 sbb G E, 0x18, lock
766 sbb E G, 0x1a
767 ######## SCAS/SCASB/SCASW/SCASD/SCASQ ##########################################
768 scas Y a, 0xae, condrep nacl-amd64-forbidden
769 ######## SETcc #################################################################
770 seta Eb, 0x0f 0x97, CPUFeature_CMOV
771 setae Eb, 0x0f 0x93, CPUFeature_CMOV
772 setbe Eb, 0x0f 0x96, CPUFeature_CMOV
773 setb Eb, 0x0f 0x92, CPUFeature_CMOV
774 sete Eb, 0x0f 0x94, CPUFeature_CMOV
775 setg Eb, 0x0f 0x9f, CPUFeature_CMOV
776 setge Eb, 0x0f 0x9d, CPUFeature_CMOV
777 setle Eb, 0x0f 0x9e, CPUFeature_CMOV
778 setl Eb, 0x0f 0x9c, CPUFeature_CMOV
779 setne Eb, 0x0f 0x95, CPUFeature_CMOV
780 setno Eb, 0x0f 0x91, CPUFeature_CMOV
781 setnp Eb, 0x0f 0x9b, CPUFeature_CMOV
782 setns Eb, 0x0f 0x99, CPUFeature_CMOV
783 seto Eb, 0x0f 0x90, CPUFeature_CMOV
784 setp Eb, 0x0f 0x9a, CPUFeature_CMOV
785 sets Eb, 0x0f 0x98, CPUFeature_CMOV
786 ######## SFENCE ################################################################
787 sfence, 0x0f 0xae 0xf8, CPUFeature_EMMXSSE
788 ######## SHLD ##################################################################
789 # Textbook definition of "shrd" as per AMD/Intel manuals looks like this:
790 #  shld Ib Gv Ev, 0x0f 0xa4
791 #  shld cb Gv Ev, 0x0f 0xa5
792 # For consistency with the production validators, drop support for the 16-bit
793 #  version of "shld" in ia32 mode.
794 # Note that the former 32- and 64-bit validators treat "shld" inconsistently:
795 #  http://code.google.com/p/nativeclient/issues/detail?id=2978
796 #
797 # "shld" is not marked as nacl-amd64-zero-extends out of caution.  We assume
798 # that this instruction is used for bit manipulation rather than computing
799 # viable addresses.
800 shld Ib Gw Ew, data16 0x0f 0xa4, norexw nacl-ia32-forbidden
801 shld cb Gw Ew, data16 0x0f 0xa5, norexw nacl-ia32-forbidden
802 shld Ib Gd Ed, 0x0f 0xa4, norexw
803 shld cb Gd Ed, 0x0f 0xa5, norexw
804 shld Ib Gq Eq, rexw 0x0f 0xa4, amd64
805 shld cb Gq Eq, rexw 0x0f 0xa5, amd64
806 shld Ib Gq Eq, data16 rexw 0x0f 0xa4, amd64 nacl-forbidden
807 shld cb Gq Eq, data16 rexw 0x0f 0xa5, amd64 nacl-forbidden
808 ######## SHR ###################################################################
809 # "shr" is not marked as nacl-amd64-zero-extends out of caution.  We assume that
810 # this instruction is used for bit manipulation rather than computing viable
811 # addresses.
812 shr E, 0xd0 /5
813 shr cb E, 0xd2 /5
814 shr Ib E, 0xc0 /5
815 ######## SHRD ##################################################################
816 # Textbook definition of "shrd" as per AMD/Intel manuals looks like this:
817 #  shld Ib Gv Ev, 0x0f 0xa4
818 #  shld cb Gv Ev, 0x0f 0xa5
819 # For consistency with the production validators, drop support for the 16-bit
820 #  version of "shrd" in ia32 mode.
821 # Note that the former 32- and 64-bit validators treat "shrd" inconsistently:
822 #  http://code.google.com/p/nativeclient/issues/detail?id=2980
823 #
824 # "shrd" is not marked as nacl-amd64-zero-extends out of caution.  We assume
825 # that this instruction is used for bit manipulation rather than computing
826 # viable addresses.
827 shrd Ib Gw Ew, data16 0x0f 0xac, norexw nacl-ia32-forbidden
828 shrd cb Gw Ew, data16 0x0f 0xad, norexw nacl-ia32-forbidden
829 shrd Ib Gd Ed, 0x0f 0xac, norexw
830 shrd cb Gd Ed, 0x0f 0xad, norexw
831 shrd Ib Gq Eq, rexw 0x0f 0xac, amd64
832 shrd cb Gq Eq, rexw 0x0f 0xad, amd64
833 shrd Ib Gq Eq, data16 rexw 0x0f 0xac, amd64 nacl-forbidden
834 shrd cb Gq Eq, data16 rexw 0x0f 0xad, amd64 nacl-forbidden
835 ######## SLWPCB ################################################################
836 slwpcb Ry, 0x8f RXB.09 W.1111.0.00 0x12 /1, CPUFeature_LWP
837 ######## STC ###################################################################
838 stc, 0xf9
839 ######## STD ###################################################################
840 std, 0xfd
841 ######## STOS/STOSB/STOSW/STOSD/STOSQ ##########################################
842 stos a Y, 0xaa, rep nacl-amd64-forbidden
843 ######## SUB ###################################################################
844 sub I a, 0x2c, nacl-amd64-zero-extends
845 sub I E, 0x80 /5, lock nacl-amd64-zero-extends
846 sub Ib Ev, 0x83 /5, lock nacl-amd64-zero-extends
847 sub G E, 0x28, lock nacl-amd64-zero-extends
848 sub E G, 0x2a, nacl-amd64-zero-extends
849 ######## T1MSKC ################################################################
850 t1mskc Ey By, 0x8f RXB.09 W.dest.0.00 0x01 /7, CPUFeature_TBM
851 ######## TEST ##################################################################
852 test I =a, 0xa8
853 test I =E, 0xf6 /0
854 # AMD manual claims this opcode works identically to "/0".  Intel manual
855 # says it's reserved.  Objdump does not like it.
856 # test I =E, 0xf6 /1
857 test G =E, 0x84
858 ######## TZCNT #################################################################
859 # Textbook definition of "tzcnt" as per AMD/Intel manuals looks like this:
860 #   tzcnt Ev Gv, 0xf3 0x0f 0xbc, CPUFeature_TZCNT nacl-amd64-zero-extends
861 # "tzcnt" is not marked as nacl-amd64-zero-extends because it is unlikely to be
862 # useful for computing an address based on the number of trailing zeros of a
863 # value.
864 # We mark tzcnt specially to allow it independently from CPUID
865 # See http://code.google.com/p/nativeclient/issues/detail?id=2869
866 # Also, since f3 opcode extension is counted as rep prefix, it is not allowed
867 # together with data16 prefix.
868 # See http://code.google.com/p/nativeclient/issues/detail?id=3076
869 tzcnt Ew Gw, data16 0xf3 0x0f 0xbc, norexw CPUFeature_TZCNT nacl-forbidden
870 tzcnt Ed Gd, 0xf3 0x0f 0xbc, norexw CPUFeature_TZCNT
871 tzcnt Eq Gq, rexw 0xf3 0x0f 0xbc, amd64 CPUFeature_TZCNT
872 tzcnt Eq Gq, data16 rexw 0xf3 0x0f 0xbc, amd64 CPUFeature_TZCNT nacl-forbidden
873 ######## TZMSK #################################################################
874 tzmsk Ey By, 0x8f RXB.09 W.dest.0.00 0x01 /4, CPUFeature_TBM
875 ######## XADD ##################################################################
876 # Textbook definition of "xadd" as per AMD/Intel manuals looks like this:
877 #  xadd &G E, 0x0f 0xc0, lock nacl-amd64-zero-extends
878 # For consistency with the production validators, drop support for the 16-bit
879 #  version of "xadd" in ia32 mode.
880 # Also, don't consider xadd with memory zero-extending.
881 #  See http://code.google.com/p/nativeclient/issues/detail?id=3077
882 # Note that the former 32- and 64-bit validators treat "xadd" inconsistently:
883 #  http://code.google.com/p/nativeclient/issues/detail?id=2981
884 xadd &Gb Eb, 0x0f 0xc0, lock
885 xadd &Gw Ew, data16 0x0f 0xc1, norexw lock nacl-ia32-forbidden
886 xadd &Gd Rd, 0x0f 0xc1, norexw nacl-amd64-zero-extends
887 xadd &Gd Md, 0x0f 0xc1, norexw lock
888 xadd &Gq Eq, rexw 0x0f 0xc1, lock amd64
889 xadd &Gq Eq, data16 rexw 0x0f 0xc1, lock amd64 nacl-forbidden
890 ######## XCHG ##################################################################
891 # For consistency with prod. validator, don't consider exchange with memory
892 # zero-extending.
893 # See http://code.google.com/p/nativeclient/issues/detail?id=3071
894 xchg &av rv, 0x90, nacl-amd64-zero-extends
895 xchg &G R, 0x86, nacl-amd64-zero-extends
896 xchg &G M, 0x86, lock
897 ######## XLAT ##################################################################
898 xlat xb, 0xd7, nacl-forbidden
899 ######## XOR ###################################################################
900 xor I a, 0x34, nacl-amd64-zero-extends
901 xor I E, 0x80 /6, lock nacl-amd64-zero-extends
902 xor Ib Ev, 0x83 /6, lock nacl-amd64-zero-extends
903 xor G E, 0x30, lock nacl-amd64-zero-extends
904 xor E G, 0x32, nacl-amd64-zero-extends
905 ################################################################################