VirtualBox

source: vbox/trunk/src/VBox/Disassembler/DisasmInternal.h@ 95811

Last change on this file since 95811 was 95319, checked in by vboxsync, 2 years ago

DIS: Treat VEX.L=1 as illegal opcode in group 17. bugref:9898 bugref:6251

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.4 KB
Line 
1/* $Id: DisasmInternal.h 95319 2022-06-21 09:53:39Z vboxsync $ */
2/** @file
3 * VBox disassembler - Internal header.
4 */
5
6/*
7 * Copyright (C) 2006-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef VBOX_INCLUDED_SRC_DisasmInternal_h
19#define VBOX_INCLUDED_SRC_DisasmInternal_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <VBox/types.h>
25#include <VBox/dis.h>
26
27
28/** @defgroup grp_dis_int Internals.
29 * @ingroup grp_dis
30 * @{
31 */
32
33/** @name Index into g_apfnCalcSize and g_apfnFullDisasm.
34 * @{ */
35enum IDX_Parse
36{
37 IDX_ParseNop = 0,
38 IDX_ParseModRM,
39 IDX_UseModRM,
40 IDX_ParseImmByte,
41 IDX_ParseImmBRel,
42 IDX_ParseImmUshort,
43 IDX_ParseImmV,
44 IDX_ParseImmVRel,
45 IDX_ParseImmAddr,
46 IDX_ParseFixedReg,
47 IDX_ParseImmUlong,
48 IDX_ParseImmQword,
49 IDX_ParseTwoByteEsc,
50 IDX_ParseGrp1,
51 IDX_ParseShiftGrp2,
52 IDX_ParseGrp3,
53 IDX_ParseGrp4,
54 IDX_ParseGrp5,
55 IDX_Parse3DNow,
56 IDX_ParseGrp6,
57 IDX_ParseGrp7,
58 IDX_ParseGrp8,
59 IDX_ParseGrp9,
60 IDX_ParseGrp10,
61 IDX_ParseGrp12,
62 IDX_ParseGrp13,
63 IDX_ParseGrp14,
64 IDX_ParseGrp15,
65 IDX_ParseGrp16,
66 IDX_ParseGrp17,
67 IDX_ParseModFence,
68 IDX_ParseYv,
69 IDX_ParseYb,
70 IDX_ParseXv,
71 IDX_ParseXb,
72 IDX_ParseEscFP,
73 IDX_ParseNopPause,
74 IDX_ParseImmByteSX,
75 IDX_ParseImmZ,
76 IDX_ParseThreeByteEsc4,
77 IDX_ParseThreeByteEsc5,
78 IDX_ParseImmAddrF,
79 IDX_ParseInvOpModRM,
80 IDX_ParseVex2b,
81 IDX_ParseVex3b,
82 IDX_ParseVexDest,
83 IDX_ParseMax
84};
85AssertCompile(IDX_ParseMax < 64 /* Packed DISOPCODE assumption. */);
86/** @} */
87
88/**
89 * Opcode map descriptor.
90 *
91 * This is used a number of places to save storage space where there are lots of
92 * invalid instructions and the beginning or end of the map.
93 */
94typedef struct DISOPMAPDESC
95{
96 /** Pointer to the opcodes described by this structure. */
97 PCDISOPCODE papOpcodes;
98#if ARCH_BITS <= 32
99 uint16_t
100#else
101 uint32_t
102#endif
103 /** The map index corresponding to the first papOpcodes entry. */
104 idxFirst,
105 /** Number of opcodes in the map. */
106 cOpcodes;
107} DISOPMAPDESC;
108/** Pointer to a const opcode map descriptor. */
109typedef DISOPMAPDESC const *PCDISOPMAPDESC;
110
111/** @name Opcode maps.
112 * @{ */
113extern const DISOPCODE g_InvalidOpcode[1];
114
115extern const DISOPCODE g_aOneByteMapX86[256];
116extern const DISOPCODE g_aOneByteMapX64[256];
117extern const DISOPCODE g_aTwoByteMapX86[256];
118
119/** Two byte opcode map with prefix 0x66 */
120extern const DISOPCODE g_aTwoByteMapX86_PF66[256];
121
122/** Two byte opcode map with prefix 0xF2 */
123extern const DISOPCODE g_aTwoByteMapX86_PFF2[256];
124
125/** Two byte opcode map with prefix 0xF3 */
126extern const DISOPCODE g_aTwoByteMapX86_PFF3[256];
127
128/** Three byte opcode map (0xF 0x38) */
129extern PCDISOPCODE const g_apThreeByteMapX86_0F38[16];
130
131/** Three byte opcode map with prefix 0x66 (0xF 0x38) */
132extern PCDISOPCODE const g_apThreeByteMapX86_660F38[16];
133
134/** Three byte opcode map with prefix 0xF2 (0xF 0x38) */
135extern PCDISOPCODE const g_apThreeByteMapX86_F20F38[16];
136
137/** Three byte opcode map with prefix 0xF3 (0xF 0x38) */
138extern PCDISOPCODE const g_apThreeByteMapX86_F30F38[16];
139
140extern PCDISOPCODE const g_apThreeByteMapX86_0F3A[16];
141
142/** Three byte opcode map with prefix 0x66 (0xF 0x3A) */
143extern PCDISOPCODE const g_apThreeByteMapX86_660F3A[16];
144
145/** Three byte opcode map with prefixes 0x66 0xF2 (0xF 0x38) */
146extern PCDISOPCODE const g_apThreeByteMapX86_66F20F38[16];
147
148/** VEX opcodes table defined by [VEX.m-mmmm - 1].
149 * 0Fh, 0F38h, 0F3Ah correspondingly, VEX.pp = 00b */
150extern PCDISOPMAPDESC const g_apVexOpcodesMapRanges_None[3];
151
152/** VEX opcodes table defined by [VEX.m-mmmm - 1].
153 * 0Fh, 0F38h, 0F3Ah correspondingly, VEX.pp = 01b (66h) */
154extern PCDISOPMAPDESC const g_apVexOpcodesMapRanges_66H[3];
155
156/** 0Fh, 0F38h, 0F3Ah correspondingly, VEX.pp = 10b (F3h) */
157extern PCDISOPMAPDESC const g_apVexOpcodesMapRanges_F3H[3];
158
159/** 0Fh, 0F38h, 0F3Ah correspondingly, VEX.pp = 11b (F2h) */
160extern PCDISOPMAPDESC const g_apVexOpcodesMapRanges_F2H[3];
161
162/** Two dimmentional map descriptor array: first index is by VEX.pp (prefix),
163 * second by the VEX.mmmm (map).
164 * The latter has to be bounced checked as we only have the first 4 maps. */
165extern PCDISOPMAPDESC const g_aapVexOpcodesMapRanges[4][4];
166/** @} */
167
168/** @name Opcode extensions (Group tables)
169 * @{ */
170extern const DISOPCODE g_aMapX86_Group1[8*4];
171extern const DISOPCODE g_aMapX86_Group2[8*6];
172extern const DISOPCODE g_aMapX86_Group3[8*2];
173extern const DISOPCODE g_aMapX86_Group4[8];
174extern const DISOPCODE g_aMapX86_Group5[8];
175extern const DISOPCODE g_aMapX86_Group6[8];
176extern const DISOPCODE g_aMapX86_Group7_mem[8];
177extern const DISOPCODE g_aMapX86_Group7_mod11_rm000[8];
178extern const DISOPCODE g_aMapX86_Group7_mod11_rm001[8];
179extern const DISOPCODE g_aMapX86_Group8[8];
180extern const DISOPCODE g_aMapX86_Group9[8];
181extern const DISOPCODE g_aMapX86_Group10[8];
182extern const DISOPCODE g_aMapX86_Group11[8*2];
183extern const DISOPCODE g_aMapX86_Group12[8*2];
184extern const DISOPCODE g_aMapX86_Group13[8*2];
185extern const DISOPCODE g_aMapX86_Group14[8*2];
186extern const DISOPCODE g_aMapX86_Group15_mem[8];
187extern const DISOPCODE g_aMapX86_Group15_mod11_rm000[8];
188extern const DISOPCODE g_aMapX86_Group16[8];
189extern const DISOPCODE g_aMapX86_Group17[8*2];
190extern const DISOPCODE g_aMapX86_NopPause[2];
191/** @} */
192
193/** 3DNow! map (0x0F 0x0F prefix) */
194extern const DISOPCODE g_aTwoByteMapX86_3DNow[256];
195
196/** Floating point opcodes starting with escape byte 0xDF
197 * @{ */
198extern const DISOPCODE g_aMapX86_EscF0_Low[8];
199extern const DISOPCODE g_aMapX86_EscF0_High[16*4];
200extern const DISOPCODE g_aMapX86_EscF1_Low[8];
201extern const DISOPCODE g_aMapX86_EscF1_High[16*4];
202extern const DISOPCODE g_aMapX86_EscF2_Low[8];
203extern const DISOPCODE g_aMapX86_EscF2_High[16*4];
204extern const DISOPCODE g_aMapX86_EscF3_Low[8];
205extern const DISOPCODE g_aMapX86_EscF3_High[16*4];
206extern const DISOPCODE g_aMapX86_EscF4_Low[8];
207extern const DISOPCODE g_aMapX86_EscF4_High[16*4];
208extern const DISOPCODE g_aMapX86_EscF5_Low[8];
209extern const DISOPCODE g_aMapX86_EscF5_High[16*4];
210extern const DISOPCODE g_aMapX86_EscF6_Low[8];
211extern const DISOPCODE g_aMapX86_EscF6_High[16*4];
212extern const DISOPCODE g_aMapX86_EscF7_Low[8];
213extern const DISOPCODE g_aMapX86_EscF7_High[16*4];
214
215extern const PCDISOPCODE g_apMapX86_FP_Low[8];
216extern const PCDISOPCODE g_apMapX86_FP_High[8];
217/** @} */
218
219/** @def OP
220 * Wrapper which initializes an DISOPCODE.
221 * We must use this so that we can exclude unused fields in order
222 * to save precious bytes in the GC version.
223 *
224 * @internal
225 */
226#if DISOPCODE_FORMAT == 0
227# define OP(pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype) \
228 { pszOpcode, idxParse1, idxParse2, idxParse3, 0, opcode, param1, param2, param3, 0, 0, optype }
229# define OPVEX(pszOpcode, idxParse1, idxParse2, idxParse3, idxParse4, opcode, param1, param2, param3, param4, optype) \
230 { pszOpcode, idxParse1, idxParse2, idxParse3, idxParse4, opcode, param1, param2, param3, param4, 0, optype | DISOPTYPE_SSE }
231
232#elif DISOPCODE_FORMAT == 16
233# define OP(pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype) \
234 { optype, opcode, idxParse1, idxParse2, param1, param2, idxParse3, param3, 0, 0 }
235# define OPVEX(pszOpcode, idxParse1, idxParse2, idxParse3, idxParse4, opcode, param1, param2, param3, param4, optype) \
236 { optype | DISOPTYPE_SSE, opcode, idxParse1, idxParse2, param1, param2, idxParse3, param3, param4, idxParse4 }
237
238#elif DISOPCODE_FORMAT == 15
239# define OP(pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype) \
240 { opcode, idxParse1, idxParse2, idxParse3, param1, param2, param3, optype, 0, 0 }
241# define OPVEX(pszOpcode, idxParse1, idxParse2, idxParse3, idxParse4, opcode, param1, param2, param3, param4, optype) \
242 { opcode, idxParse1, idxParse2, idxParse3, param1, param2, param3, optype | DISOPTYPE_SSE, param4, idxParse4 }
243#else
244# error Unsupported DISOPCODE_FORMAT value
245#endif
246
247
248size_t disFormatBytes(PCDISSTATE pDis, char *pszDst, size_t cchDst, uint32_t fFlags);
249
250/** @} */
251#endif /* !VBOX_INCLUDED_SRC_DisasmInternal_h */
252
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette