diff options
author | Masami Hiramatsu <mhiramat@redhat.com> | 2009-10-27 16:42:27 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-29 03:47:46 -0400 |
commit | e0e492e99b372c6990a5daca9e4683c341f1330e (patch) | |
tree | 79704aa82391ff2f54d92fe11b1b7958b09a5bb8 /arch/x86/include/asm/insn.h | |
parent | 82cb57028c864822c5a260f806d051e2ce28c86a (diff) |
x86: AVX instruction set decoder support
Add Intel AVX(Advanced Vector Extensions) instruction set
support to x86 instruction decoder. This adds insn.vex_prefix
field for storing VEX prefixes, and introduces some original
tags for expressing opcodes attributes.
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: <20091027204226.30545.23451.stgit@harusame>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/include/asm/insn.h')
-rw-r--r-- | arch/x86/include/asm/insn.h | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/arch/x86/include/asm/insn.h b/arch/x86/include/asm/insn.h index 12b4e3751d3f..96c2e0ad04ca 100644 --- a/arch/x86/include/asm/insn.h +++ b/arch/x86/include/asm/insn.h | |||
@@ -39,6 +39,7 @@ struct insn { | |||
39 | * prefixes.bytes[3]: last prefix | 39 | * prefixes.bytes[3]: last prefix |
40 | */ | 40 | */ |
41 | struct insn_field rex_prefix; /* REX prefix */ | 41 | struct insn_field rex_prefix; /* REX prefix */ |
42 | struct insn_field vex_prefix; /* VEX prefix */ | ||
42 | struct insn_field opcode; /* | 43 | struct insn_field opcode; /* |
43 | * opcode.bytes[0]: opcode1 | 44 | * opcode.bytes[0]: opcode1 |
44 | * opcode.bytes[1]: opcode2 | 45 | * opcode.bytes[1]: opcode2 |
@@ -80,6 +81,19 @@ struct insn { | |||
80 | #define X86_REX_X(rex) ((rex) & 2) | 81 | #define X86_REX_X(rex) ((rex) & 2) |
81 | #define X86_REX_B(rex) ((rex) & 1) | 82 | #define X86_REX_B(rex) ((rex) & 1) |
82 | 83 | ||
84 | /* VEX bit flags */ | ||
85 | #define X86_VEX_W(vex) ((vex) & 0x80) /* VEX3 Byte2 */ | ||
86 | #define X86_VEX_R(vex) ((vex) & 0x80) /* VEX2/3 Byte1 */ | ||
87 | #define X86_VEX_X(vex) ((vex) & 0x40) /* VEX3 Byte1 */ | ||
88 | #define X86_VEX_B(vex) ((vex) & 0x20) /* VEX3 Byte1 */ | ||
89 | #define X86_VEX_L(vex) ((vex) & 0x04) /* VEX3 Byte2, VEX2 Byte1 */ | ||
90 | /* VEX bit fields */ | ||
91 | #define X86_VEX3_M(vex) ((vex) & 0x1f) /* VEX3 Byte1 */ | ||
92 | #define X86_VEX2_M 1 /* VEX2.M always 1 */ | ||
93 | #define X86_VEX_V(vex) (((vex) & 0x78) >> 3) /* VEX3 Byte2, VEX2 Byte1 */ | ||
94 | #define X86_VEX_P(vex) ((vex) & 0x03) /* VEX3 Byte2, VEX2 Byte1 */ | ||
95 | #define X86_VEX_M_MAX 0x1f /* VEX3.M Maximum value */ | ||
96 | |||
83 | /* The last prefix is needed for two-byte and three-byte opcodes */ | 97 | /* The last prefix is needed for two-byte and three-byte opcodes */ |
84 | static inline insn_byte_t insn_last_prefix(struct insn *insn) | 98 | static inline insn_byte_t insn_last_prefix(struct insn *insn) |
85 | { | 99 | { |
@@ -114,15 +128,42 @@ static inline void kernel_insn_init(struct insn *insn, const void *kaddr) | |||
114 | #endif | 128 | #endif |
115 | } | 129 | } |
116 | 130 | ||
131 | static inline int insn_is_avx(struct insn *insn) | ||
132 | { | ||
133 | if (!insn->prefixes.got) | ||
134 | insn_get_prefixes(insn); | ||
135 | return (insn->vex_prefix.value != 0); | ||
136 | } | ||
137 | |||
138 | static inline insn_byte_t insn_vex_m_bits(struct insn *insn) | ||
139 | { | ||
140 | if (insn->vex_prefix.nbytes == 2) /* 2 bytes VEX */ | ||
141 | return X86_VEX2_M; | ||
142 | else | ||
143 | return X86_VEX3_M(insn->vex_prefix.bytes[1]); | ||
144 | } | ||
145 | |||
146 | static inline insn_byte_t insn_vex_p_bits(struct insn *insn) | ||
147 | { | ||
148 | if (insn->vex_prefix.nbytes == 2) /* 2 bytes VEX */ | ||
149 | return X86_VEX_P(insn->vex_prefix.bytes[1]); | ||
150 | else | ||
151 | return X86_VEX_P(insn->vex_prefix.bytes[2]); | ||
152 | } | ||
153 | |||
117 | /* Offset of each field from kaddr */ | 154 | /* Offset of each field from kaddr */ |
118 | static inline int insn_offset_rex_prefix(struct insn *insn) | 155 | static inline int insn_offset_rex_prefix(struct insn *insn) |
119 | { | 156 | { |
120 | return insn->prefixes.nbytes; | 157 | return insn->prefixes.nbytes; |
121 | } | 158 | } |
122 | static inline int insn_offset_opcode(struct insn *insn) | 159 | static inline int insn_offset_vex_prefix(struct insn *insn) |
123 | { | 160 | { |
124 | return insn_offset_rex_prefix(insn) + insn->rex_prefix.nbytes; | 161 | return insn_offset_rex_prefix(insn) + insn->rex_prefix.nbytes; |
125 | } | 162 | } |
163 | static inline int insn_offset_opcode(struct insn *insn) | ||
164 | { | ||
165 | return insn_offset_vex_prefix(insn) + insn->vex_prefix.nbytes; | ||
166 | } | ||
126 | static inline int insn_offset_modrm(struct insn *insn) | 167 | static inline int insn_offset_modrm(struct insn *insn) |
127 | { | 168 | { |
128 | return insn_offset_opcode(insn) + insn->opcode.nbytes; | 169 | return insn_offset_opcode(insn) + insn->opcode.nbytes; |