diff options
| author | Masami Hiramatsu <mhiramat@redhat.com> | 2009-10-27 16:42:11 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2009-10-29 03:47:45 -0400 |
| commit | 04d46c1b13b02e1e5c24eb270a01cf3f94ee4d04 (patch) | |
| tree | b5a4b8c1229b1b1defe2d6671319ff0cfbe21ada | |
| parent | 7f387d3f2421781610588faa2f49ae5f1737b137 (diff) | |
x86: Merge INAT_REXPFX into INAT_PFX_*
Merge INAT_REXPFX into INAT_PFX_* macro and rename it to
INAT_PFX_REX.
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
LKML-Reference: <20091027204211.30545.58090.stgit@harusame>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
| -rw-r--r-- | arch/x86/include/asm/inat.h | 36 | ||||
| -rw-r--r-- | arch/x86/lib/insn.c | 2 | ||||
| -rw-r--r-- | arch/x86/tools/gen-insn-attr-x86.awk | 6 |
3 files changed, 24 insertions, 20 deletions
diff --git a/arch/x86/include/asm/inat.h b/arch/x86/include/asm/inat.h index 2866fddd1848..c2487d2aca25 100644 --- a/arch/x86/include/asm/inat.h +++ b/arch/x86/include/asm/inat.h | |||
| @@ -30,10 +30,11 @@ | |||
| 30 | #define INAT_OPCODE_TABLE_SIZE 256 | 30 | #define INAT_OPCODE_TABLE_SIZE 256 |
| 31 | #define INAT_GROUP_TABLE_SIZE 8 | 31 | #define INAT_GROUP_TABLE_SIZE 8 |
| 32 | 32 | ||
| 33 | /* Legacy instruction prefixes */ | 33 | /* Legacy last prefixes */ |
| 34 | #define INAT_PFX_OPNDSZ 1 /* 0x66 */ /* LPFX1 */ | 34 | #define INAT_PFX_OPNDSZ 1 /* 0x66 */ /* LPFX1 */ |
| 35 | #define INAT_PFX_REPNE 2 /* 0xF2 */ /* LPFX2 */ | 35 | #define INAT_PFX_REPNE 2 /* 0xF2 */ /* LPFX2 */ |
| 36 | #define INAT_PFX_REPE 3 /* 0xF3 */ /* LPFX3 */ | 36 | #define INAT_PFX_REPE 3 /* 0xF3 */ /* LPFX3 */ |
| 37 | /* Other Legacy prefixes */ | ||
| 37 | #define INAT_PFX_LOCK 4 /* 0xF0 */ | 38 | #define INAT_PFX_LOCK 4 /* 0xF0 */ |
| 38 | #define INAT_PFX_CS 5 /* 0x2E */ | 39 | #define INAT_PFX_CS 5 /* 0x2E */ |
| 39 | #define INAT_PFX_DS 6 /* 0x3E */ | 40 | #define INAT_PFX_DS 6 /* 0x3E */ |
| @@ -42,8 +43,11 @@ | |||
| 42 | #define INAT_PFX_GS 9 /* 0x65 */ | 43 | #define INAT_PFX_GS 9 /* 0x65 */ |
| 43 | #define INAT_PFX_SS 10 /* 0x36 */ | 44 | #define INAT_PFX_SS 10 /* 0x36 */ |
| 44 | #define INAT_PFX_ADDRSZ 11 /* 0x67 */ | 45 | #define INAT_PFX_ADDRSZ 11 /* 0x67 */ |
| 46 | /* x86-64 REX prefix */ | ||
| 47 | #define INAT_PFX_REX 12 /* 0x4X */ | ||
| 45 | 48 | ||
| 46 | #define INAT_LPREFIX_MAX 3 | 49 | #define INAT_LSTPFX_MAX 3 |
| 50 | #define INAT_LGCPFX_MAX 11 | ||
| 47 | 51 | ||
| 48 | /* Immediate size */ | 52 | /* Immediate size */ |
| 49 | #define INAT_IMM_BYTE 1 | 53 | #define INAT_IMM_BYTE 1 |
| @@ -75,12 +79,11 @@ | |||
| 75 | #define INAT_IMM_MASK (((1 << INAT_IMM_BITS) - 1) << INAT_IMM_OFFS) | 79 | #define INAT_IMM_MASK (((1 << INAT_IMM_BITS) - 1) << INAT_IMM_OFFS) |
| 76 | /* Flags */ | 80 | /* Flags */ |
| 77 | #define INAT_FLAG_OFFS (INAT_IMM_OFFS + INAT_IMM_BITS) | 81 | #define INAT_FLAG_OFFS (INAT_IMM_OFFS + INAT_IMM_BITS) |
| 78 | #define INAT_REXPFX (1 << INAT_FLAG_OFFS) | 82 | #define INAT_MODRM (1 << (INAT_FLAG_OFFS)) |
| 79 | #define INAT_MODRM (1 << (INAT_FLAG_OFFS + 1)) | 83 | #define INAT_FORCE64 (1 << (INAT_FLAG_OFFS + 1)) |
| 80 | #define INAT_FORCE64 (1 << (INAT_FLAG_OFFS + 2)) | 84 | #define INAT_SCNDIMM (1 << (INAT_FLAG_OFFS + 2)) |
| 81 | #define INAT_SCNDIMM (1 << (INAT_FLAG_OFFS + 3)) | 85 | #define INAT_MOFFSET (1 << (INAT_FLAG_OFFS + 3)) |
| 82 | #define INAT_MOFFSET (1 << (INAT_FLAG_OFFS + 4)) | 86 | #define INAT_VARIANT (1 << (INAT_FLAG_OFFS + 4)) |
| 83 | #define INAT_VARIANT (1 << (INAT_FLAG_OFFS + 5)) | ||
| 84 | /* Attribute making macros for attribute tables */ | 87 | /* Attribute making macros for attribute tables */ |
| 85 | #define INAT_MAKE_PREFIX(pfx) (pfx << INAT_PFX_OFFS) | 88 | #define INAT_MAKE_PREFIX(pfx) (pfx << INAT_PFX_OFFS) |
| 86 | #define INAT_MAKE_ESCAPE(esc) (esc << INAT_ESC_OFFS) | 89 | #define INAT_MAKE_ESCAPE(esc) (esc << INAT_ESC_OFFS) |
| @@ -97,9 +100,10 @@ extern insn_attr_t inat_get_group_attribute(insn_byte_t modrm, | |||
| 97 | insn_attr_t esc_attr); | 100 | insn_attr_t esc_attr); |
| 98 | 101 | ||
| 99 | /* Attribute checking functions */ | 102 | /* Attribute checking functions */ |
| 100 | static inline int inat_is_prefix(insn_attr_t attr) | 103 | static inline int inat_is_legacy_prefix(insn_attr_t attr) |
| 101 | { | 104 | { |
| 102 | return attr & INAT_PFX_MASK; | 105 | attr &= INAT_PFX_MASK; |
| 106 | return attr && attr <= INAT_LGCPFX_MAX; | ||
| 103 | } | 107 | } |
| 104 | 108 | ||
| 105 | static inline int inat_is_address_size_prefix(insn_attr_t attr) | 109 | static inline int inat_is_address_size_prefix(insn_attr_t attr) |
| @@ -112,9 +116,14 @@ static inline int inat_is_operand_size_prefix(insn_attr_t attr) | |||
| 112 | return (attr & INAT_PFX_MASK) == INAT_PFX_OPNDSZ; | 116 | return (attr & INAT_PFX_MASK) == INAT_PFX_OPNDSZ; |
| 113 | } | 117 | } |
| 114 | 118 | ||
| 119 | static inline int inat_is_rex_prefix(insn_attr_t attr) | ||
| 120 | { | ||
| 121 | return (attr & INAT_PFX_MASK) == INAT_PFX_REX; | ||
| 122 | } | ||
| 123 | |||
| 115 | static inline int inat_last_prefix_id(insn_attr_t attr) | 124 | static inline int inat_last_prefix_id(insn_attr_t attr) |
| 116 | { | 125 | { |
| 117 | if ((attr & INAT_PFX_MASK) > INAT_LPREFIX_MAX) | 126 | if ((attr & INAT_PFX_MASK) > INAT_LSTPFX_MAX) |
| 118 | return 0; | 127 | return 0; |
| 119 | else | 128 | else |
| 120 | return attr & INAT_PFX_MASK; | 129 | return attr & INAT_PFX_MASK; |
| @@ -155,11 +164,6 @@ static inline int inat_immediate_size(insn_attr_t attr) | |||
| 155 | return (attr & INAT_IMM_MASK) >> INAT_IMM_OFFS; | 164 | return (attr & INAT_IMM_MASK) >> INAT_IMM_OFFS; |
| 156 | } | 165 | } |
| 157 | 166 | ||
| 158 | static inline int inat_is_rex_prefix(insn_attr_t attr) | ||
| 159 | { | ||
| 160 | return attr & INAT_REXPFX; | ||
| 161 | } | ||
| 162 | |||
| 163 | static inline int inat_has_modrm(insn_attr_t attr) | 167 | static inline int inat_has_modrm(insn_attr_t attr) |
| 164 | { | 168 | { |
| 165 | return attr & INAT_MODRM; | 169 | return attr & INAT_MODRM; |
diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c index dfd56a30053f..9f483179a8a6 100644 --- a/arch/x86/lib/insn.c +++ b/arch/x86/lib/insn.c | |||
| @@ -69,7 +69,7 @@ void insn_get_prefixes(struct insn *insn) | |||
| 69 | lb = 0; | 69 | lb = 0; |
| 70 | b = peek_next(insn_byte_t, insn); | 70 | b = peek_next(insn_byte_t, insn); |
| 71 | attr = inat_get_opcode_attribute(b); | 71 | attr = inat_get_opcode_attribute(b); |
| 72 | while (inat_is_prefix(attr)) { | 72 | while (inat_is_legacy_prefix(attr)) { |
| 73 | /* Skip if same prefix */ | 73 | /* Skip if same prefix */ |
| 74 | for (i = 0; i < nb; i++) | 74 | for (i = 0; i < nb; i++) |
| 75 | if (prefixes->bytes[i] == b) | 75 | if (prefixes->bytes[i] == b) |
diff --git a/arch/x86/tools/gen-insn-attr-x86.awk b/arch/x86/tools/gen-insn-attr-x86.awk index 19ba096b7dd1..7d5492951e22 100644 --- a/arch/x86/tools/gen-insn-attr-x86.awk +++ b/arch/x86/tools/gen-insn-attr-x86.awk | |||
| @@ -278,7 +278,7 @@ function convert_operands(opnd, i,imm,mod) | |||
| 278 | 278 | ||
| 279 | # check REX prefix | 279 | # check REX prefix |
| 280 | if (match(opcode, rex_expr)) | 280 | if (match(opcode, rex_expr)) |
| 281 | flags = add_flags(flags, "INAT_REXPFX") | 281 | flags = add_flags(flags, "INAT_MAKE_PREFIX(INAT_PFX_REX)") |
| 282 | 282 | ||
| 283 | # check coprocessor escape : TODO | 283 | # check coprocessor escape : TODO |
| 284 | if (match(opcode, fpu_expr)) | 284 | if (match(opcode, fpu_expr)) |
| @@ -316,7 +316,7 @@ END { | |||
| 316 | # print escape opcode map's array | 316 | # print escape opcode map's array |
| 317 | print "/* Escape opcode map array */" | 317 | print "/* Escape opcode map array */" |
| 318 | print "const insn_attr_t const *inat_escape_tables[INAT_ESC_MAX + 1]" \ | 318 | print "const insn_attr_t const *inat_escape_tables[INAT_ESC_MAX + 1]" \ |
| 319 | "[INAT_LPREFIX_MAX + 1] = {" | 319 | "[INAT_LSTPFX_MAX + 1] = {" |
| 320 | for (i = 0; i < geid; i++) | 320 | for (i = 0; i < geid; i++) |
| 321 | for (j = 0; j < max_lprefix; j++) | 321 | for (j = 0; j < max_lprefix; j++) |
| 322 | if (etable[i,j]) | 322 | if (etable[i,j]) |
| @@ -325,7 +325,7 @@ END { | |||
| 325 | # print group opcode map's array | 325 | # print group opcode map's array |
| 326 | print "/* Group opcode map array */" | 326 | print "/* Group opcode map array */" |
| 327 | print "const insn_attr_t const *inat_group_tables[INAT_GRP_MAX + 1]"\ | 327 | print "const insn_attr_t const *inat_group_tables[INAT_GRP_MAX + 1]"\ |
| 328 | "[INAT_LPREFIX_MAX + 1] = {" | 328 | "[INAT_LSTPFX_MAX + 1] = {" |
| 329 | for (i = 0; i < ggid; i++) | 329 | for (i = 0; i < ggid; i++) |
| 330 | for (j = 0; j < max_lprefix; j++) | 330 | for (j = 0; j < max_lprefix; j++) |
| 331 | if (gtable[i,j]) | 331 | if (gtable[i,j]) |
