Commit graph

114 commits

Author SHA1 Message Date
Jin Kyu Song
b4e1ae18e2 MPX: Move BND prefix indication from bytecode to iflags
As BND prefix validity check conflicts with jcc8 prefix,
IF_BND is added for the instruction templates which can have
bnd prefix for preserving the content of bound register.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
0304109b3d MPX: Add BND prefix for branch instructions
BND prefix is used for adding bounds checking protection
across flow control changes such as call, ret, jmp and jcc calls.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:42 -08:00
Jin Kyu Song
164d60740f MPX: Add MPX instructions
Added MPX instructions and corresponding parser and encoder.

ICC style mib - base + disp and index are separate - is supported.
E.g. bndstx [ebx+3], bnd2, edx -> ebx+3 : base+disp, edx : index

As a supplement to NASM style mib - split EA - parser,
omitted base+disp is now treated as 0 displacement.
E.g. bndstx [,edx], bnd2 -> bndstx [0,edx], bnd2

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20 11:29:41 -08:00
Jin Kyu Song
36ccfa5fb4 iflags: Eliminate perl smart match operator
As smart match operator reuiqres perl version 5.10.1 or later,
it is replaced with grep function.
This part of code is going to be completely removed once iflags
renovataion is done. This commit is a quick fix for a build error.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-10-07 14:51:09 -07:00
Jin Kyu Song
9bb987d8e0 AVX-512: Change the data type for instruction flags
Increased the size of data type for instruction flags from 32bits to 64bits.
And a new type (iflags_t) is defined for better maintainability.

Bigger data type is needed because more instruction set types are coming
but there were not enough space for them. Since they are not bit masks,
only one instruction set is allowed for each instruction.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-08-28 09:37:21 +04:00
Jin Kyu Song
cc1dc9de53 AVX-512: Add EVEX encoding and new instructions
EVEX encoding support includes 32 vector regs (XMM/YMM/ZMM),
opmask, broadcasting, embedded rounding mode,
suppress all exceptions, compressed displacement.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-08-16 09:06:15 +04:00
Ben Rudiak-Gould
94ba02fa16 Make F2 and F3 SSE prefixes override 66
According to XED and experimentation, the 66 is ignored.

Signed-off-by: Ben Rudiak-Gould <benrudiak@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-03-10 21:46:12 +04:00
Ben Rudiak-Gould
6e87893f06 Drop SAME_AS flag from instruction matcher
It was there to support the SSE5 DREX encoding,
which as far as I know is dead forever.

Signed-off-by: Ben Rudiak-Gould <benrudiak@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-03-04 00:46:16 +04:00
Ben Rudiak-Gould
d1ac29a3cc insns: Remove pushseg/popseg internal bytecodes
This patch is getting rid of the following bytecodes
'pushseg','popseg','pushseg2','popseg2' and simplifies
overall code.

[gorcunov@: a few style fixes]
Signed-off-by: Ben Rudiak-Gould <benrudiak@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-03-03 20:50:46 +04:00
Cyrill Gorcunov
bfb581c8e0 insns.pl: Various style polyshing
- convert tabs to spaces
 - align octal opcodes

No func changes.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-03-02 02:59:29 +04:00
Ben Rudiak-Gould
4e8396b5cf Remove +s
It doesn't seem worth >200 lines of C and Perl to save ~50 lines in insns.dat.

In order to make this work I had to rename sbyte16/sbyte32 so that
they can take an ordinary size suffix (their size suffix was formerly
treated specially).

This fixes one disassembly bug: 48C7C000000080 disassembles to mov
rax,0x80000000, which reassembles to B800000080, which loads a
different value.

Signed-off-by: Ben Rudiak-Gould <benrudiak@gmail.com>
Acked-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-03-01 10:28:32 +04:00
Ben Rudiak-Gould
d7ab1f9638 Add np and similar prefixes to instructions that should have them
This adds "np" to a bunch of SSE-style instructions that should have
it, "norep" (which was implemented but unused) on quasi-SSE instructions
that use F2 and F3 as instruction extensions but 66 for operand size,
"nof3" (newly implemented) on a few instructions, "norexw" on some
instructions that have only 32-bit and 64-bit versions, and one NOLONG.

It also removes some incorrect "np"s, changes some "f3"s to "f3i"s,
and fixes the decoding of the XCHG/NOP/PAUSE mess: F390 is always
PAUSE even when rex.b=1 (at least according to XED).

Signed-off-by: Ben Rudiak-Gould <benrudiak@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-20 23:25:54 +04:00
H. Peter Anvin
574784d177 HLE: Move byte codes back to \271-\273
Since we are back to three bytecodes, move them back to the \271-\273
slot to free up the \264 complete quad.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-25 22:33:46 -08:00
H. Peter Anvin
fb3f4e6ddb HLE: Change NOHLE to be an instruction flag
The way our matching system works we have to make NOHLE an instruction
flag rather than an byte code; by the time we run the byte code
interpreter we have already picked an instruction pattern once and for
all.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-25 22:22:07 -08:00
H. Peter Anvin
755f5214b7 Remove all remaining explicit bytecodes from insns.dat
Get rid of the last vestiges of the explicit byte codes in insns.dat.
The only files that now depend on actual byte code numbers are
insns.pl, assemble.c and disasm.c.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-25 11:41:34 -08:00
H. Peter Anvin
8ea2200415 Move HLE byte codes to \264..\267
Move the HLE byte codes to \264..\267 so as not to break up an unused
group of 8 (\240..\247).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-25 10:24:24 -08:00
H. Peter Anvin
7849dd07b9 Add a "nohle" byte code to skip an instruction pattern
The a2/a3 mem_offs MOV opcodes are invalid with XRELEASE; those
instructions instead have to use a modrm form.  Therefore give a way
to annotate those instruction patters so the pattern matcher will move
on to the next pattern, rather than selecting them and then issue a
warning.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-25 10:19:56 -08:00
H. Peter Anvin
b9bc63c757 insns.pl: Bundle all "plain bytecodes" into a hash
Instead of a long string of ifs, put all the plain opcodes which just
turn into single bytecodes with no other effect into a hash.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-24 22:06:39 -08:00
H. Peter Anvin
4ecd5d79fc HLE: Implement the basic mechanism for XACQUIRE/XRELEASE
This implements the mechanism for XACQUIRE/XRELEASE.  It does not
include the necessary annotations in insns.dat.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-24 21:57:17 -08:00
H. Peter Anvin
44454be952 insns: create a symbolic "wait" token for the \341 byte code
Create a symbolic name "wait" for the \341 byte code, so we don't have
to open-code it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-10 11:11:08 -08:00
H. Peter Anvin
9d93f4b396 insns: replace open-coded \322 opcode with odf (operand default)
Create a mnemonic for the open-coded opcode \322.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-02-09 16:20:21 -08:00
Anonymous
e837a7b4ea Implement insns.dat in human readable form
I converted almost all instructions in insns.dat (version
 7a6f978698) to the more
 readable format that insns.pl has supported for years.

 I also made some changes to insns.pl. You can verify that the
 new insns.dat and insns.pl produce byte-identical output to
 the old insns.dat and insns.pl, so I think that this change
 is safe to check in, even though it is a large change to
 insns.dat.

The changes to insns.pl are:

 * fixed a bug: ib,u was not recognized
 * added support for a second immediate argument called "j" for
   instructions like ENTER imm,imm
 * added a "+r" syntax for \10..\13

[gorcunov: insns files remains the same, great job anonymous!]

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-20 21:47:53 +04:00
H. Peter Anvin
cffe61e776 Use a normal quad-case for valueless /is4
When we don't have an immediate for the i-field in /is4, then use a
normal quad-bytecode encoding for it to save some small amount of
space and re-use existing machinery.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2011-07-07 17:21:24 -07:00
H. Peter Anvin
fc561203fd Remove support for DREX encoding
The DREX encoding never hit production silicon, and has been replaced
by VEX/XOP encoding, so remove support for it.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2011-07-07 16:58:22 -07:00
H. Peter Anvin
3089f7ef8a Add support for VSIB instructions
Add support for VSIB instructions, which use vector registers as the
index registers in an EA.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2011-06-22 18:19:28 -07:00
Cyrill Gorcunov
b8470a4708 insns.pl: Fix up merge conflict for sure
Now it should be fixed in real (one code snipped
escaped me during merge conflict resolving).

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-23 20:21:45 +03:00
Cyrill Gorcunov
a54b5eabd3 insns.pl: Clear tabs/space mess
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-23 18:38:56 +03:00
H. Peter Anvin
e7854b98fd insns.pl: make insnsd.c a bit easier to read
Formatting changes (no object code difference) to insnsd.c for
readability.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-08-19 17:20:18 -07:00
H. Peter Anvin
5d62e57a0c ndisasm: handle VEX.LIG
A lot of instructions ignore the L bit in the VEX prefix, just like
a lot of instructions ignore the W bit, so don't use them in the
sub-table select.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-08-19 17:04:36 -07:00
H. Peter Anvin
421059c689 assemble: handle vex.lig
AVX version 7 introduces the concept of .lig, meaning VEX.L is
ignored.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-08-16 14:56:33 -07:00
H. Peter Anvin
978c2170fc vex: change .wx to .wig to match the latest AVX spec
Change the .wx (ignore the W field) to .wig, to match the latest
version of the AVX specification.  This is not a functional change,
but just makes instruction patterns a little easier to write.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-08-16 13:48:43 -07:00
Cyrill Gorcunov
23c6f213bd insns.pl: remove redundant empty line in enum opcode
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-08-08 14:00:47 -07:00
H. Peter Anvin
109b030f01 insns.pl: smarter handling of operand flags
Handle operand flags like "xmmrm128" correctly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-26 12:52:22 -07:00
H. Peter Anvin
8ee2e244eb NASM: relicense under the 2-clause BSD license
*To the best of my knowledge*, we now have authorization from everyone
who has significantly contributed to NASM in the past.  As such,
change the license to the 2-clause BSD license.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-06 11:09:11 -07:00
H. Peter Anvin
e6ee1a859b Add copyright verbiage to Perl scripts; update LICENSE
This adds copyright verbiage to the Perl scripts.  Scripts that are
known to be clean w.r.t. the 2-clause BSD license are given that
license; unclear ones are given the "LGPL for now".

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-28 16:54:44 -07:00
H. Peter Anvin
98df21629a insns.pl: remove stray whitespace
Clean up whitespace in insns.pl.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 23:18:06 -07:00
H. Peter Anvin
51c7de27e8 insns.pl: add "nohi" code for REX_NH
Add a "nohi" code flag for the \325 byte code, which sets the REX_NH
flag.  That is, REX_P not required to support high registers, high
registers are not supported and spl/bpl/sil/dil enabled even in
non-64-bit mode.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 23:17:52 -07:00
H. Peter Anvin
f5051691c9 insns.pl: fix indentation
Canonicalize indentation of some blocks.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 23:17:52 -07:00
H. Peter Anvin
37b3c59fc8 insns.pl: allow relaxed forms to be created without duplication
Allow a * to be put on an operand, indicating that it is optional and
should be replaced with the immediately preceding operand if it is
omitted.  This allows official and relaxed forms of nondestructive
instructions to be written on one line.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-24 18:06:26 -07:00
Cyrill Gorcunov
52fb2575f3 insns.pl - add handling of pp VEX/XOP fields
We already have such kind of aliases for L field
(via l0 and l1). Via p0,p1,p2 it's become easier
to follow AMD docs while encoding VEX/XOP commands.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-05-15 07:20:02 -07:00
H. Peter Anvin
0bff6a48fd Use lower case for VEX and XOP in instructions table
Use lower case for VEX and XOP ("vex", "xop") to avoid visual
confusion (and in the future potential real confusion) with upper-case
hexadecimal numbers.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-05-03 22:14:03 -07:00
H. Peter Anvin
a04019c7f4 Infrastructure support for AMD's new XOP prefix
Handle AMD's XOP prefixes; they use basically the same encoding as VEX
prefixes, so treat them simply as a variant of VEX.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-05-03 21:42:34 -07:00
H. Peter Anvin
58af1fbbe9 insns.pl: handle the new VEX.DDS flag per AVX spec version 5
The AVX spec version 5 introduces the new VEX.DDS flag; support it.
2009-02-18 14:04:02 -08:00
H. Peter Anvin
dcffe4b9f6 Add extension bytecodes to support operands 4+
The bytecode format assumes max 4 operands pretty strictly, but we
already have one instruction with 5 operands, and it's likely to get
more.  Support them via extension prefixes (similar to REX prefixes).
For bytecodes which use argument bytes we encode the number directly,
however.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-23 23:03:59 -07:00
H. Peter Anvin
ff6e12da50 Reshuffle and move the bytecodes for segment register push/pop
Reshuffle the bytecodes for segment register push/pop to make more
sense, and move them from \4 to \344, thus freeing up the single-digit
bytecodes \4..\7 for future use.  It doesn't really make sense to use
single-digit bytecodes for this very oddball use.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-08 21:17:32 -07:00
H. Peter Anvin
a5c31197f5 Collect statistics on bytecode use in insnsb.c
We are starting to have to worry about running short on available
bytecodes, especially where we encode the operand number in the byte
code.  Thus, compile a table of bytecode usage and include as a
comment in insnsb.c.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-08 16:56:35 -07:00
H. Peter Anvin
588df78b0d New opcode for 32->64 bit sign-extended immediate with warning
Add a new opcode for 32->64 bit sign-extended immediate, with warning
on the number not matching.

This unfortunately calls for an audit of all the \4[0123] opcodes, if
they should be replaced by \25[4567].  This only replaces one
instruction (MOV reg64,imm32); other instructions need to be
considered.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-07 10:05:10 -07:00
H. Peter Anvin
c1377e9a98 New opcodes to deal with 8-bit immediate sign extended to opsize
New opcodes to deal with 8-bit immediates which are then sign-extended
to the operand size.  These allow us to warn appropriately.
Not sure I'm using these in all the proper places; need audit of all
uses of the \14..\17 opcodes.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-06 23:40:31 -07:00
H. Peter Anvin
a0b91037e2 Mark Perl scripts executable
Be consistent about marking Perl scripts executable, even if we always
invoke them with $(PERL) in the Makefiles.
2008-06-15 16:55:39 -07:00
H. Peter Anvin
cb6aaa33ce insnsd.c: don't generate an inaccessible table
Some pseudo-instructions (RESB and EQU) seem to make it into the
instruction table.  This also generates an instruction table for
zero-length instructions, which of course can never actually be
accessed.  Quiet a compiler warning by simply not emitting this
useless table.  Ideally we shouldn't emit the pseudo-instructions
either, but that is a bigger change, and it's hardly a lot of memory
involved.
2008-06-05 12:28:00 -07:00