VirtualBox

source: vbox/trunk/src/VBox/Disassembler/DisasmInternal-x86-amd64.h@ 105686

Last change on this file since 105686 was 103717, checked in by vboxsync, 9 months ago

DIS: cmpxchg8b/16b fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/* $Id: DisasmInternal-x86-amd64.h 103717 2024-03-06 21:36:59Z vboxsync $ */
2/** @file
3 * VBox disassembler - Internal header.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VBOX_INCLUDED_SRC_DisasmInternal_x86_amd64_h
29#define VBOX_INCLUDED_SRC_DisasmInternal_x86_amd64_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <VBox/types.h>
35#include <VBox/err.h>
36#include <VBox/dis.h>
37#include <VBox/log.h>
38
39#include <iprt/param.h>
40#include "DisasmInternal.h"
41
42
43/** @addtogroup grp_dis_int Internals.
44 * @ingroup grp_dis
45 * @{
46 */
47
48/** @name Index into g_apfnCalcSize and g_apfnFullDisasm.
49 * @{ */
50enum IDX_Parse
51{
52 IDX_ParseNop = 0,
53 IDX_ParseModRM,
54 IDX_UseModRM,
55 IDX_ParseImmByte,
56 IDX_ParseImmBRel,
57 IDX_ParseImmUshort,
58 IDX_ParseImmV,
59 IDX_ParseImmVRel,
60 IDX_ParseImmAddr,
61 IDX_ParseFixedReg,
62 IDX_ParseImmUlong,
63 IDX_ParseImmQword,
64 IDX_ParseTwoByteEsc,
65 IDX_ParseGrp1,
66 IDX_ParseShiftGrp2,
67 IDX_ParseGrp3,
68 IDX_ParseGrp4,
69 IDX_ParseGrp5,
70 IDX_Parse3DNow,
71 IDX_ParseGrp6,
72 IDX_ParseGrp7,
73 IDX_ParseGrp8,
74 IDX_ParseGrp9,
75 IDX_ParseGrp10,
76 IDX_ParseGrp12,
77 IDX_ParseVGrp12,
78 IDX_ParseGrp13,
79 IDX_ParseVGrp13,
80 IDX_ParseGrp14,
81 IDX_ParseVGrp14,
82 IDX_ParseGrp15,
83 IDX_ParseVGrp15,
84 IDX_ParseGrp16,
85 IDX_ParseVGrp17,
86 IDX_ParseModFence,
87 IDX_ParseYv,
88 IDX_ParseYb,
89 IDX_ParseXv,
90 IDX_ParseXb,
91 IDX_ParseEscFP,
92 IDX_ParseNopPause,
93 IDX_ParseImmByteSX,
94 IDX_ParseImmZ,
95 IDX_ParseThreeByteEsc4,
96 IDX_ParseThreeByteEsc5,
97 IDX_ParseImmAddrF,
98 IDX_ParseInvOpModRM,
99 IDX_ParseVex2b,
100 IDX_ParseVex3b,
101 IDX_ParseVexDest,
102 IDX_ParseMax
103};
104AssertCompile(IDX_ParseMax < 64 /* Packed DISOPCODE assumption. */);
105/** @} */
106
107/**
108 * Opcode map descriptor.
109 *
110 * This is used a number of places to save storage space where there are lots of
111 * invalid instructions and the beginning or end of the map.
112 */
113typedef struct DISOPMAPDESC
114{
115 /** Pointer to the opcodes described by this structure. */
116 PCDISOPCODE papOpcodes;
117#if ARCH_BITS <= 32
118 uint16_t
119#else
120 uint32_t
121#endif
122 /** The map index corresponding to the first papOpcodes entry. */
123 idxFirst,
124 /** Number of opcodes in the map. */
125 cOpcodes;
126} DISOPMAPDESC;
127/** Pointer to a const opcode map descriptor. */
128typedef DISOPMAPDESC const *PCDISOPMAPDESC;
129
130/** @name Opcode maps.
131 * @{ */
132extern const DISOPCODE g_InvalidOpcode[1];
133
134extern const DISOPCODE g_aOneByteMapX86[256];
135extern const DISOPCODE g_aOneByteMapX64[256];
136extern const DISOPCODE g_aTwoByteMapX86[256];
137extern const DISOPCODE g_OpcodeLES;
138extern const DISOPCODE g_OpcodeLDS;
139
140/** Two byte opcode map with prefix 0x66 */
141extern const DISOPCODE g_aTwoByteMapX86_PF66[256];
142
143/** Two byte opcode map with prefix 0xF2 */
144extern const DISOPCODE g_aTwoByteMapX86_PFF2[256];
145
146/** Two byte opcode map with prefix 0xF3 */
147extern const DISOPCODE g_aTwoByteMapX86_PFF3[256];
148
149/** Three byte opcode map (0xF 0x38) */
150extern PCDISOPCODE const g_apThreeByteMapX86_0F38[16];
151
152/** Three byte opcode map with prefix 0x66 (0xF 0x38) */
153extern PCDISOPCODE const g_apThreeByteMapX86_660F38[16];
154
155/** Three byte opcode map with prefix 0xF2 (0xF 0x38) */
156extern PCDISOPCODE const g_apThreeByteMapX86_F20F38[16];
157
158/** Three byte opcode map with prefix 0xF3 (0xF 0x38) */
159extern PCDISOPCODE const g_apThreeByteMapX86_F30F38[16];
160
161extern PCDISOPCODE const g_apThreeByteMapX86_0F3A[16];
162
163/** Three byte opcode map with prefix 0x66 (0xF 0x3A) */
164extern PCDISOPCODE const g_apThreeByteMapX86_660F3A[16];
165
166/** Three byte opcode map with prefixes 0x66 0xF2 (0xF 0x38) */
167extern PCDISOPCODE const g_apThreeByteMapX86_66F20F38[16];
168
169/** VEX opcodes table defined by [VEX.m-mmmm - 1].
170 * 0Fh, 0F38h, 0F3Ah correspondingly, VEX.pp = 00b */
171extern PCDISOPMAPDESC const g_apVexOpcodesMapRanges_None[3];
172
173/** VEX opcodes table defined by [VEX.m-mmmm - 1].
174 * 0Fh, 0F38h, 0F3Ah correspondingly, VEX.pp = 01b (66h) */
175extern PCDISOPMAPDESC const g_apVexOpcodesMapRanges_66H[3];
176
177/** 0Fh, 0F38h, 0F3Ah correspondingly, VEX.pp = 10b (F3h) */
178extern PCDISOPMAPDESC const g_apVexOpcodesMapRanges_F3H[3];
179
180/** 0Fh, 0F38h, 0F3Ah correspondingly, VEX.pp = 11b (F2h) */
181extern PCDISOPMAPDESC const g_apVexOpcodesMapRanges_F2H[3];
182
183/** Two dimmentional map descriptor array: first index is by VEX.pp (prefix),
184 * second by the VEX.mmmm (map).
185 * The latter has to be bounced checked as we only have the first 4 maps. */
186extern PCDISOPMAPDESC const g_aapVexOpcodesMapRanges[4][4];
187/** @} */
188
189/** @name Opcode extensions (Group tables)
190 * @{ */
191extern const DISOPCODE g_aMapX86_Group1[8*4];
192extern const DISOPCODE g_aMapX86_Group2[8*6];
193extern const DISOPCODE g_aMapX86_Group3[8*2];
194extern const DISOPCODE g_aMapX86_Group4[8];
195extern const DISOPCODE g_aMapX86_Group5[8];
196extern const DISOPCODE g_aMapX86_Group6[8];
197extern const DISOPCODE g_aMapX86_Group7_mem[8];
198extern const DISOPCODE g_aMapX86_Group7_mod11_reg000[8];
199extern const DISOPCODE g_aMapX86_Group7_mod11_reg001[8];
200extern const DISOPCODE g_aMapX86_Group7_mod11_reg010[8];
201extern const DISOPCODE g_aMapX86_Group7_mod11_reg111[8];
202extern const DISOPCODE g_aMapX86_Group8[8];
203extern const DISOPCODE g_aMapX86_Group9_mem_none[8*2];
204extern const DISOPCODE g_aMapX86_Group9_mem_66[8];
205extern const DISOPCODE g_aMapX86_Group9_mem_f3[8];
206extern const DISOPCODE g_aMapX86_Group9_mod11_none[8];
207extern const DISOPCODE g_aMapX86_Group9_mod11_f3[8];
208extern const DISOPCODE g_aMapX86_Group10[8];
209extern const DISOPCODE g_aMapX86_Group11[8*2];
210extern const DISOPCODE g_aMapX86_Group12[8*2];
211extern const DISOPCODE g_aMapX86_VGroup12[8];
212extern const DISOPCODE g_aMapX86_Group13[8*2];
213extern const DISOPCODE g_aMapX86_VGroup13[8];
214extern const DISOPCODE g_aMapX86_Group14[8*2];
215extern const DISOPCODE g_aMapX86_VGroup14[8];
216extern const DISOPCODE g_aMapX86_Group15_mem[8];
217extern const DISOPCODE g_aMapX86_Group15_mod11[8*2];
218extern const DISOPCODE g_aMapX86_VGroup15[8];
219extern const DISOPCODE g_aMapX86_Group16[8];
220extern const DISOPCODE g_aMapX86_VGroup17[8*2];
221extern const DISOPCODE g_aMapX86_NopPause[2];
222/** @} */
223
224/** 3DNow! map (0x0F 0x0F prefix) */
225extern const DISOPCODE g_aTwoByteMapX86_3DNow[256];
226
227/** Floating point opcodes starting with escape byte 0xDF
228 * @{ */
229extern const DISOPCODE g_aMapX86_EscF0_Low[8];
230extern const DISOPCODE g_aMapX86_EscF0_High[16*4];
231extern const DISOPCODE g_aMapX86_EscF1_Low[8];
232extern const DISOPCODE g_aMapX86_EscF1_High[16*4];
233extern const DISOPCODE g_aMapX86_EscF2_Low[8];
234extern const DISOPCODE g_aMapX86_EscF2_High[16*4];
235extern const DISOPCODE g_aMapX86_EscF3_Low[8];
236extern const DISOPCODE g_aMapX86_EscF3_High[16*4];
237extern const DISOPCODE g_aMapX86_EscF4_Low[8];
238extern const DISOPCODE g_aMapX86_EscF4_High[16*4];
239extern const DISOPCODE g_aMapX86_EscF5_Low[8];
240extern const DISOPCODE g_aMapX86_EscF5_High[16*4];
241extern const DISOPCODE g_aMapX86_EscF6_Low[8];
242extern const DISOPCODE g_aMapX86_EscF6_High[16*4];
243extern const DISOPCODE g_aMapX86_EscF7_Low[8];
244extern const DISOPCODE g_aMapX86_EscF7_High[16*4];
245
246extern const PCDISOPCODE g_apMapX86_FP_Low[8];
247extern const PCDISOPCODE g_apMapX86_FP_High[8];
248/** @} */
249
250
251/** @} */
252#endif /* !VBOX_INCLUDED_SRC_DisasmInternal_x86_amd64_h */
253
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