1 | ; $Id: bs3-cpu-basic-2-template.mac 97431 2022-11-07 13:53:24Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - bs3-cpu-basic-2 assembly template.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2022 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 | ; The contents of this file may alternatively be used under the terms
|
---|
26 | ; of the Common Development and Distribution License Version 1.0
|
---|
27 | ; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | ; in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | ; CDDL are applicable instead of those of the GPL.
|
---|
30 | ;
|
---|
31 | ; You may elect to license modified versions of this file under the
|
---|
32 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | ;
|
---|
34 | ; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | ;
|
---|
36 |
|
---|
37 |
|
---|
38 | ;*********************************************************************************************************************************
|
---|
39 | ;* Header Files *
|
---|
40 | ;*********************************************************************************************************************************
|
---|
41 | %include "bs3kit-template-header.mac" ; setup environment
|
---|
42 |
|
---|
43 |
|
---|
44 | ;*********************************************************************************************************************************
|
---|
45 | ;* Defined Constants And Macros *
|
---|
46 | ;*********************************************************************************************************************************
|
---|
47 | %ifndef BS3_CPUBAS2_UD_OFF_DEFINED
|
---|
48 | %define BS3_CPUBAS2_UD_OFF_DEFINED
|
---|
49 | %macro BS3_CPUBAS2_UD_OFF 1
|
---|
50 | BS3_GLOBAL_NAME_EX BS3_CMN_NM(%1) %+ _offUD, , 1
|
---|
51 | db BS3_CMN_NM(%1).again - BS3_CMN_NM(%1)
|
---|
52 | %endmacro
|
---|
53 | %endif
|
---|
54 |
|
---|
55 |
|
---|
56 | ;*********************************************************************************************************************************
|
---|
57 | ;* External Symbols *
|
---|
58 | ;*********************************************************************************************************************************
|
---|
59 | TMPL_BEGIN_TEXT
|
---|
60 |
|
---|
61 |
|
---|
62 |
|
---|
63 | ;
|
---|
64 | ; Test code snippets containing code which differs between 16-bit, 32-bit
|
---|
65 | ; and 64-bit CPUs modes.
|
---|
66 | ;
|
---|
67 | %ifdef BS3_INSTANTIATING_CMN
|
---|
68 |
|
---|
69 | ;
|
---|
70 | ; SIDT
|
---|
71 | ;
|
---|
72 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sidt_bx_ud2
|
---|
73 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_bx_ud2, BS3_PBC_NEAR
|
---|
74 | sidt [xBX]
|
---|
75 | .again: ud2
|
---|
76 | jmp .again
|
---|
77 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_bx_ud2) == 3)
|
---|
78 | BS3_PROC_END_CMN bs3CpuBasic2_sidt_bx_ud2
|
---|
79 |
|
---|
80 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sidt_opsize_bx_ud2
|
---|
81 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_opsize_bx_ud2, BS3_PBC_NEAR
|
---|
82 | db X86_OP_PRF_SIZE_OP
|
---|
83 | sidt [xBX]
|
---|
84 | .again: ud2
|
---|
85 | jmp .again
|
---|
86 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_opsize_bx_ud2) == 4)
|
---|
87 | BS3_PROC_END_CMN bs3CpuBasic2_sidt_opsize_bx_ud2
|
---|
88 |
|
---|
89 | %if TMPL_BITS == 64
|
---|
90 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sidt_rexw_bx_ud2
|
---|
91 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_rexw_bx_ud2, BS3_PBC_NEAR
|
---|
92 | db X86_OP_REX_W
|
---|
93 | sidt [xBX]
|
---|
94 | .again: ud2
|
---|
95 | jmp .again
|
---|
96 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_rexw_bx_ud2) == 4)
|
---|
97 | BS3_PROC_END_CMN bs3CpuBasic2_sidt_rexw_bx_ud2
|
---|
98 |
|
---|
99 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sidt_opsize_rexw_bx_ud2
|
---|
100 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_opsize_rexw_bx_ud2, BS3_PBC_NEAR
|
---|
101 | db X86_OP_PRF_SIZE_OP
|
---|
102 | db X86_OP_REX_W
|
---|
103 | sidt [xBX]
|
---|
104 | .again: ud2
|
---|
105 | jmp .again
|
---|
106 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_opsize_rexw_bx_ud2) == 5)
|
---|
107 | BS3_PROC_END_CMN bs3CpuBasic2_sidt_opsize_rexw_bx_ud2
|
---|
108 | %endif
|
---|
109 |
|
---|
110 | %if TMPL_BITS != 64
|
---|
111 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sidt_ss_bx_ud2
|
---|
112 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_ss_bx_ud2, BS3_PBC_NEAR
|
---|
113 | sidt [ss:xBX]
|
---|
114 | .again: ud2
|
---|
115 | jmp .again
|
---|
116 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_ss_bx_ud2) == 4)
|
---|
117 | BS3_PROC_END_CMN bs3CpuBasic2_sidt_ss_bx_ud2
|
---|
118 |
|
---|
119 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sidt_opsize_ss_bx_ud2
|
---|
120 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_opsize_ss_bx_ud2, BS3_PBC_NEAR
|
---|
121 | db X86_OP_PRF_SIZE_OP
|
---|
122 | sidt [ss:xBX]
|
---|
123 | .again: ud2
|
---|
124 | jmp .again
|
---|
125 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_opsize_ss_bx_ud2) == 5)
|
---|
126 | BS3_PROC_END_CMN bs3CpuBasic2_sidt_opsize_ss_bx_ud2
|
---|
127 | %endif
|
---|
128 |
|
---|
129 |
|
---|
130 | ;
|
---|
131 | ; SGDT
|
---|
132 | ;
|
---|
133 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sgdt_bx_ud2
|
---|
134 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_bx_ud2, BS3_PBC_NEAR
|
---|
135 | sgdt [xBX]
|
---|
136 | .again: ud2
|
---|
137 | jmp .again
|
---|
138 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_bx_ud2) == 3)
|
---|
139 | BS3_PROC_END_CMN bs3CpuBasic2_sgdt_bx_ud2
|
---|
140 |
|
---|
141 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sgdt_opsize_bx_ud2
|
---|
142 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_opsize_bx_ud2, BS3_PBC_NEAR
|
---|
143 | db X86_OP_PRF_SIZE_OP
|
---|
144 | sgdt [xBX]
|
---|
145 | .again: ud2
|
---|
146 | jmp .again
|
---|
147 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_opsize_bx_ud2) == 4)
|
---|
148 | BS3_PROC_END_CMN bs3CpuBasic2_sgdt_opsize_bx_ud2
|
---|
149 |
|
---|
150 | %if TMPL_BITS == 64
|
---|
151 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sgdt_rexw_bx_ud2
|
---|
152 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_rexw_bx_ud2, BS3_PBC_NEAR
|
---|
153 | db X86_OP_REX_W
|
---|
154 | sgdt [xBX]
|
---|
155 | .again: ud2
|
---|
156 | jmp .again
|
---|
157 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_rexw_bx_ud2) == 4)
|
---|
158 | BS3_PROC_END_CMN bs3CpuBasic2_sgdt_rexw_bx_ud2
|
---|
159 |
|
---|
160 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2
|
---|
161 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2, BS3_PBC_NEAR
|
---|
162 | db X86_OP_PRF_SIZE_OP
|
---|
163 | db X86_OP_REX_W
|
---|
164 | sgdt [xBX]
|
---|
165 | .again: ud2
|
---|
166 | jmp .again
|
---|
167 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2) == 5)
|
---|
168 | BS3_PROC_END_CMN bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2
|
---|
169 | %endif
|
---|
170 |
|
---|
171 | %if TMPL_BITS != 64
|
---|
172 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sgdt_ss_bx_ud2
|
---|
173 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_ss_bx_ud2, BS3_PBC_NEAR
|
---|
174 | sgdt [ss:xBX]
|
---|
175 | .again: ud2
|
---|
176 | jmp .again
|
---|
177 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_ss_bx_ud2) == 4)
|
---|
178 | BS3_PROC_END_CMN bs3CpuBasic2_sgdt_ss_bx_ud2
|
---|
179 |
|
---|
180 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sgdt_opsize_ss_bx_ud2
|
---|
181 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_opsize_ss_bx_ud2, BS3_PBC_NEAR
|
---|
182 | db X86_OP_PRF_SIZE_OP
|
---|
183 | sgdt [ss:xBX]
|
---|
184 | .again: ud2
|
---|
185 | jmp .again
|
---|
186 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_opsize_ss_bx_ud2) == 5)
|
---|
187 | BS3_PROC_END_CMN bs3CpuBasic2_sgdt_opsize_ss_bx_ud2
|
---|
188 | %endif
|
---|
189 |
|
---|
190 |
|
---|
191 | ;
|
---|
192 | ; LIDT
|
---|
193 | ;
|
---|
194 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_bx__sidt_es_di__lidt_es_si__ud2
|
---|
195 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_lidt_bx__sidt_es_di__lidt_es_si__ud2, BS3_PBC_NEAR
|
---|
196 | lidt [xBX]
|
---|
197 | sidt [BS3_NOT_64BIT(es:) xDI]
|
---|
198 | lidt [BS3_NOT_64BIT(es:) xSI]
|
---|
199 | .again:
|
---|
200 | ud2
|
---|
201 | jmp .again
|
---|
202 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_bx__sidt_es_di__lidt_es_si__ud2) == BS3_IF_64BIT_OTHERWISE(9,11))
|
---|
203 | BS3_PROC_END_CMN bs3CpuBasic2_lidt_bx__sidt_es_di__lidt_es_si__ud2
|
---|
204 |
|
---|
205 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_opsize_bx__sidt_es_di__lidt_es_si__ud2
|
---|
206 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_lidt_opsize_bx__sidt_es_di__lidt_es_si__ud2, BS3_PBC_NEAR
|
---|
207 | db X86_OP_PRF_SIZE_OP
|
---|
208 | lidt [xBX]
|
---|
209 | sidt [BS3_NOT_64BIT(es:) xDI]
|
---|
210 | lidt [BS3_NOT_64BIT(es:) xSI]
|
---|
211 | .again:
|
---|
212 | ud2
|
---|
213 | jmp .again
|
---|
214 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_opsize_bx__sidt_es_di__lidt_es_si__ud2) == BS3_IF_64BIT_OTHERWISE(10,12))
|
---|
215 | BS3_PROC_END_CMN bs3CpuBasic2_lidt_opsize_bx__sidt_es_di__lidt_es_si__ud2
|
---|
216 |
|
---|
217 | %if TMPL_BITS == 16
|
---|
218 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_opsize_bx__sidt32_es_di__lidt_es_si__ud2
|
---|
219 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_lidt_opsize_bx__sidt32_es_di__lidt_es_si__ud2, BS3_PBC_NEAR
|
---|
220 | db X86_OP_PRF_SIZE_OP
|
---|
221 | lidt [xBX]
|
---|
222 | jmp dword BS3_SEL_R0_CS32:.in_32bit wrt FLAT
|
---|
223 | BS3_SET_BITS 32
|
---|
224 | .in_32bit:
|
---|
225 | sidt [es:edi]
|
---|
226 | lidt [es:esi]
|
---|
227 | jmp dword BS3_SEL_R0_CS16:.again wrt CGROUP16
|
---|
228 | BS3_SET_BITS 16
|
---|
229 | .again:
|
---|
230 | ud2
|
---|
231 | jmp .again
|
---|
232 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_opsize_bx__sidt32_es_di__lidt_es_si__ud2) == 27)
|
---|
233 | BS3_PROC_END_CMN bs3CpuBasic2_lidt_opsize_bx__sidt32_es_di__lidt_es_si__ud2
|
---|
234 | %endif
|
---|
235 |
|
---|
236 | %if TMPL_BITS == 64
|
---|
237 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_rexw_bx__sidt_es_di__lidt_es_si__ud2
|
---|
238 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_lidt_rexw_bx__sidt_es_di__lidt_es_si__ud2, BS3_PBC_NEAR
|
---|
239 | db X86_OP_REX_W
|
---|
240 | lidt [xBX]
|
---|
241 | sidt [xDI]
|
---|
242 | lidt [xSI]
|
---|
243 | .again:
|
---|
244 | ud2
|
---|
245 | jmp .again
|
---|
246 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_rexw_bx__sidt_es_di__lidt_es_si__ud2) == 10)
|
---|
247 | BS3_PROC_END_CMN bs3CpuBasic2_lidt_rexw_bx__sidt_es_di__lidt_es_si__ud2
|
---|
248 |
|
---|
249 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_opsize_rexw_bx__sidt_es_di__lidt_es_si__ud2
|
---|
250 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_lidt_opsize_rexw_bx__sidt_es_di__lidt_es_si__ud2, BS3_PBC_NEAR
|
---|
251 | db X86_OP_PRF_SIZE_OP
|
---|
252 | db X86_OP_REX_W
|
---|
253 | lidt [xBX]
|
---|
254 | sidt [xDI]
|
---|
255 | lidt [xSI]
|
---|
256 | .again:
|
---|
257 | ud2
|
---|
258 | jmp .again
|
---|
259 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_opsize_rexw_bx__sidt_es_di__lidt_es_si__ud2) == 11)
|
---|
260 | BS3_PROC_END_CMN bs3CpuBasic2_lidt_opsize_rexw_bx__sidt_es_di__lidt_es_si__ud2
|
---|
261 | %endif
|
---|
262 |
|
---|
263 | %if TMPL_BITS != 64
|
---|
264 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_ss_bx__sidt_es_di__lidt_es_si__ud2
|
---|
265 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_lidt_ss_bx__sidt_es_di__lidt_es_si__ud2, BS3_PBC_NEAR
|
---|
266 | lidt [ss:xBX]
|
---|
267 | sidt [BS3_NOT_64BIT(es:) xDI]
|
---|
268 | lidt [BS3_NOT_64BIT(es:) xSI]
|
---|
269 | .again:
|
---|
270 | ud2
|
---|
271 | jmp .again
|
---|
272 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_ss_bx__sidt_es_di__lidt_es_si__ud2) == 12)
|
---|
273 | BS3_PROC_END_CMN bs3CpuBasic2_lidt_ss_bx__sidt_es_di__lidt_es_si__ud2
|
---|
274 |
|
---|
275 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_opsize_ss_bx__sidt_es_di__lidt_es_si__ud2
|
---|
276 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_lidt_opsize_ss_bx__sidt_es_di__lidt_es_si__ud2, BS3_PBC_NEAR
|
---|
277 | db X86_OP_PRF_SIZE_OP
|
---|
278 | lidt [ss:xBX]
|
---|
279 | sidt [BS3_NOT_64BIT(es:) xDI]
|
---|
280 | lidt [BS3_NOT_64BIT(es:) xSI]
|
---|
281 | .again:
|
---|
282 | ud2
|
---|
283 | jmp .again
|
---|
284 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_opsize_ss_bx__sidt_es_di__lidt_es_si__ud2) == 13)
|
---|
285 | BS3_PROC_END_CMN bs3CpuBasic2_lidt_opsize_ss_bx__sidt_es_di__lidt_es_si__ud2
|
---|
286 | %endif
|
---|
287 |
|
---|
288 |
|
---|
289 | ;
|
---|
290 | ; LGDT
|
---|
291 | ;
|
---|
292 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lgdt_bx__sgdt_es_di__lgdt_es_si__ud2
|
---|
293 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_lgdt_bx__sgdt_es_di__lgdt_es_si__ud2, BS3_PBC_NEAR
|
---|
294 | lgdt [xBX]
|
---|
295 | sgdt [BS3_NOT_64BIT(es:) xDI]
|
---|
296 | lgdt [BS3_NOT_64BIT(es:) xSI]
|
---|
297 | .again:
|
---|
298 | ud2
|
---|
299 | jmp .again
|
---|
300 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lgdt_bx__sgdt_es_di__lgdt_es_si__ud2) == BS3_IF_64BIT_OTHERWISE(9,11))
|
---|
301 | BS3_PROC_END_CMN bs3CpuBasic2_lgdt_bx__sgdt_es_di__lgdt_es_si__ud2
|
---|
302 |
|
---|
303 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lgdt_opsize_bx__sgdt_es_di__lgdt_es_si__ud2
|
---|
304 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_lgdt_opsize_bx__sgdt_es_di__lgdt_es_si__ud2, BS3_PBC_NEAR
|
---|
305 | db X86_OP_PRF_SIZE_OP
|
---|
306 | lgdt [xBX]
|
---|
307 | sgdt [BS3_NOT_64BIT(es:) xDI]
|
---|
308 | lgdt [BS3_NOT_64BIT(es:) xSI]
|
---|
309 | .again:
|
---|
310 | ud2
|
---|
311 | jmp .again
|
---|
312 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lgdt_opsize_bx__sgdt_es_di__lgdt_es_si__ud2) == BS3_IF_64BIT_OTHERWISE(10,12))
|
---|
313 | BS3_PROC_END_CMN bs3CpuBasic2_lgdt_opsize_bx__sgdt_es_di__lgdt_es_si__ud2
|
---|
314 |
|
---|
315 | %if TMPL_BITS == 64
|
---|
316 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lgdt_rexw_bx__sgdt_es_di__lgdt_es_si__ud2
|
---|
317 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_lgdt_rexw_bx__sgdt_es_di__lgdt_es_si__ud2, BS3_PBC_NEAR
|
---|
318 | db X86_OP_REX_W
|
---|
319 | lgdt [xBX]
|
---|
320 | sgdt [xDI]
|
---|
321 | lgdt [xSI]
|
---|
322 | .again:
|
---|
323 | ud2
|
---|
324 | jmp .again
|
---|
325 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lgdt_rexw_bx__sgdt_es_di__lgdt_es_si__ud2) == 10)
|
---|
326 | BS3_PROC_END_CMN bs3CpuBasic2_lgdt_rexw_bx__sgdt_es_di__lgdt_es_si__ud2
|
---|
327 |
|
---|
328 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lgdt_opsize_rexw_bx__sgdt_es_di__lgdt_es_si__ud2
|
---|
329 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_lgdt_opsize_rexw_bx__sgdt_es_di__lgdt_es_si__ud2, BS3_PBC_NEAR
|
---|
330 | db X86_OP_PRF_SIZE_OP
|
---|
331 | db X86_OP_REX_W
|
---|
332 | lgdt [xBX]
|
---|
333 | sgdt [xDI]
|
---|
334 | lgdt [xSI]
|
---|
335 | .again:
|
---|
336 | ud2
|
---|
337 | jmp .again
|
---|
338 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lgdt_opsize_rexw_bx__sgdt_es_di__lgdt_es_si__ud2) == 11)
|
---|
339 | BS3_PROC_END_CMN bs3CpuBasic2_lgdt_opsize_rexw_bx__sgdt_es_di__lgdt_es_si__ud2
|
---|
340 | %endif
|
---|
341 |
|
---|
342 | %if TMPL_BITS != 64
|
---|
343 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lgdt_ss_bx__sgdt_es_di__lgdt_es_si__ud2
|
---|
344 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_lgdt_ss_bx__sgdt_es_di__lgdt_es_si__ud2, BS3_PBC_NEAR
|
---|
345 | lgdt [ss:xBX]
|
---|
346 | sgdt [BS3_NOT_64BIT(es:) xDI]
|
---|
347 | lgdt [BS3_NOT_64BIT(es:) xSI]
|
---|
348 | .again:
|
---|
349 | ud2
|
---|
350 | jmp .again
|
---|
351 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lgdt_ss_bx__sgdt_es_di__lgdt_es_si__ud2) == 12)
|
---|
352 | BS3_PROC_END_CMN bs3CpuBasic2_lgdt_ss_bx__sgdt_es_di__lgdt_es_si__ud2
|
---|
353 |
|
---|
354 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lgdt_opsize_ss_bx__sgdt_es_di__lgdt_es_si__ud2
|
---|
355 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_lgdt_opsize_ss_bx__sgdt_es_di__lgdt_es_si__ud2, BS3_PBC_NEAR
|
---|
356 | db X86_OP_PRF_SIZE_OP
|
---|
357 | lgdt [ss:xBX]
|
---|
358 | sgdt [BS3_NOT_64BIT(es:) xDI]
|
---|
359 | lgdt [BS3_NOT_64BIT(es:) xSI]
|
---|
360 | .again:
|
---|
361 | ud2
|
---|
362 | jmp .again
|
---|
363 | AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lgdt_opsize_ss_bx__sgdt_es_di__lgdt_es_si__ud2) == 13)
|
---|
364 | BS3_PROC_END_CMN bs3CpuBasic2_lgdt_opsize_ss_bx__sgdt_es_di__lgdt_es_si__ud2
|
---|
365 | %endif
|
---|
366 |
|
---|
367 | ;
|
---|
368 | ; #PF & #AC
|
---|
369 | ;
|
---|
370 |
|
---|
371 | ; For testing read access.
|
---|
372 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_mov_ax_ds_bx__ud2
|
---|
373 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_mov_ax_ds_bx__ud2, BS3_PBC_NEAR
|
---|
374 | mov xAX, [xBX]
|
---|
375 | .again: ud2
|
---|
376 | jmp .again
|
---|
377 | AssertCompile(.again - BS3_LAST_LABEL == 2 + (TMPL_BITS == 64))
|
---|
378 | BS3_PROC_END_CMN bs3CpuBasic2_mov_ax_ds_bx__ud2
|
---|
379 |
|
---|
380 |
|
---|
381 | ; For testing write access.
|
---|
382 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_mov_ds_bx_ax__ud2
|
---|
383 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_mov_ds_bx_ax__ud2, BS3_PBC_NEAR
|
---|
384 | mov [xBX], xAX
|
---|
385 | .again: ud2
|
---|
386 | jmp .again
|
---|
387 | AssertCompile(.again - BS3_LAST_LABEL == 2 + (TMPL_BITS == 64))
|
---|
388 | BS3_PROC_END_CMN bs3CpuBasic2_mov_ds_bx_ax__ud2
|
---|
389 |
|
---|
390 |
|
---|
391 | ; For testing read+write access.
|
---|
392 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_xchg_ds_bx_ax__ud2
|
---|
393 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_xchg_ds_bx_ax__ud2, BS3_PBC_NEAR
|
---|
394 | xchg [xBX], xAX
|
---|
395 | .again: ud2
|
---|
396 | jmp .again
|
---|
397 | AssertCompile(.again - BS3_LAST_LABEL == 2 + (TMPL_BITS == 64))
|
---|
398 | BS3_PROC_END_CMN bs3CpuBasic2_xchg_ds_bx_ax__ud2
|
---|
399 |
|
---|
400 |
|
---|
401 | ; Another read+write access test.
|
---|
402 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_cmpxchg_ds_bx_cx__ud2
|
---|
403 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_cmpxchg_ds_bx_cx__ud2, BS3_PBC_NEAR
|
---|
404 | cmpxchg [xBX], xCX
|
---|
405 | .again: ud2
|
---|
406 | jmp .again
|
---|
407 | AssertCompile(.again - BS3_LAST_LABEL == 3 + (TMPL_BITS == 64))
|
---|
408 | BS3_PROC_END_CMN bs3CpuBasic2_cmpxchg_ds_bx_cx__ud2
|
---|
409 |
|
---|
410 |
|
---|
411 | ; For testing read access from an aborted instruction: DIV by zero
|
---|
412 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_div_ds_bx__ud2
|
---|
413 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_div_ds_bx__ud2, BS3_PBC_NEAR
|
---|
414 | div xPRE [xBX]
|
---|
415 | .again: ud2
|
---|
416 | jmp .again
|
---|
417 | AssertCompile(.again - BS3_LAST_LABEL == 2 + (TMPL_BITS == 64))
|
---|
418 | BS3_PROC_END_CMN bs3CpuBasic2_div_ds_bx__ud2
|
---|
419 |
|
---|
420 | ; For testing FLD m80 alignment (#AC).
|
---|
421 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_fninit_fld_ds_bx__ud2
|
---|
422 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_fninit_fld_ds_bx__ud2, BS3_PBC_NEAR
|
---|
423 | fninit ; make sure to not trigger a stack overflow.
|
---|
424 | .actual_test_instruction:
|
---|
425 | fld tword [xBX]
|
---|
426 | .again: ud2
|
---|
427 | jmp .again
|
---|
428 | AssertCompile(.actual_test_instruction - BS3_LAST_LABEL == 2)
|
---|
429 | BS3_PROC_END_CMN bs3CpuBasic2_fninit_fld_ds_bx__ud2
|
---|
430 |
|
---|
431 | ; For testing FBLD m80 alignment (#AC).
|
---|
432 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_fninit_fbld_ds_bx__ud2
|
---|
433 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_fninit_fbld_ds_bx__ud2, BS3_PBC_NEAR
|
---|
434 | fninit ; make sure to not trigger a stack overflow.
|
---|
435 | .actual_test_instruction:
|
---|
436 | fbld tword [xBX]
|
---|
437 | .again: ud2
|
---|
438 | jmp .again
|
---|
439 | AssertCompile(.actual_test_instruction - BS3_LAST_LABEL == 2)
|
---|
440 | BS3_PROC_END_CMN bs3CpuBasic2_fninit_fbld_ds_bx__ud2
|
---|
441 |
|
---|
442 | ; For testing FST m80 alignment (#AC).
|
---|
443 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_fninit_fldz_fstp_ds_bx__ud2
|
---|
444 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_fninit_fldz_fstp_ds_bx__ud2, BS3_PBC_NEAR
|
---|
445 | fninit ; make sure to not trigger a stack overflow.
|
---|
446 | fldz ; make sure we've got something to store
|
---|
447 | .actual_test_instruction:
|
---|
448 | fstp tword [xBX]
|
---|
449 | .again: ud2
|
---|
450 | jmp .again
|
---|
451 | AssertCompile(.actual_test_instruction - BS3_LAST_LABEL == 4)
|
---|
452 | BS3_PROC_END_CMN bs3CpuBasic2_fninit_fldz_fstp_ds_bx__ud2
|
---|
453 |
|
---|
454 | ; For testing FXSAVE alignment (#AC/#GP).
|
---|
455 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_fxsave_ds_bx__ud2
|
---|
456 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_fxsave_ds_bx__ud2, BS3_PBC_NEAR
|
---|
457 | fxsave [xBX]
|
---|
458 | .again: ud2
|
---|
459 | jmp .again
|
---|
460 | BS3_PROC_END_CMN bs3CpuBasic2_fxsave_ds_bx__ud2
|
---|
461 |
|
---|
462 |
|
---|
463 | ; Two memory operands: push [mem]
|
---|
464 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_push_ds_bx__ud2
|
---|
465 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_push_ds_bx__ud2, BS3_PBC_NEAR
|
---|
466 | push xPRE [xBX]
|
---|
467 | .again: ud2
|
---|
468 | jmp .again
|
---|
469 | AssertCompile(.again - BS3_LAST_LABEL == 2)
|
---|
470 | BS3_PROC_END_CMN bs3CpuBasic2_push_ds_bx__ud2
|
---|
471 |
|
---|
472 | ; Two memory operands: pop [mem]
|
---|
473 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_push_ax__pop_ds_bx__ud2
|
---|
474 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_push_ax__pop_ds_bx__ud2, BS3_PBC_NEAR
|
---|
475 | push xAX
|
---|
476 | pop xPRE [xBX]
|
---|
477 | .again: ud2
|
---|
478 | jmp .again
|
---|
479 | AssertCompile(.again - BS3_LAST_LABEL == 3)
|
---|
480 | BS3_PROC_END_CMN bs3CpuBasic2_push_ax__pop_ds_bx__ud2
|
---|
481 |
|
---|
482 | ; Two memory operands: call [mem]
|
---|
483 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_ds_bx__ud2
|
---|
484 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_ds_bx__ud2, BS3_PBC_NEAR
|
---|
485 | call xPRE [xBX]
|
---|
486 | .again: ud2
|
---|
487 | jmp .again
|
---|
488 | AssertCompile(.again - BS3_LAST_LABEL == 2)
|
---|
489 | BS3_PROC_END_CMN bs3CpuBasic2_call_ds_bx__ud2
|
---|
490 |
|
---|
491 | ; For testing #GP vs #PF write
|
---|
492 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_insb__ud2
|
---|
493 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_insb__ud2, BS3_PBC_NEAR
|
---|
494 | insb
|
---|
495 | .again: ud2
|
---|
496 | jmp .again
|
---|
497 | AssertCompile(.again - BS3_LAST_LABEL == 1)
|
---|
498 | BS3_PROC_END_CMN bs3CpuBasic2_insb__ud2
|
---|
499 |
|
---|
500 |
|
---|
501 | ;*********************************************************************************************************************************
|
---|
502 | ;* JMP Tests (simple ones). *
|
---|
503 | ;*********************************************************************************************************************************
|
---|
504 |
|
---|
505 | ; jmp rel8 (forwards)
|
---|
506 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jb__ud2
|
---|
507 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jb__ud2, BS3_PBC_NEAR
|
---|
508 | jmp short .again
|
---|
509 | .post_jmp:
|
---|
510 | times 7 int3
|
---|
511 | .again: ud2
|
---|
512 | int3
|
---|
513 | jmp .again
|
---|
514 | AssertCompile(.post_jmp - BS3_LAST_LABEL == 2)
|
---|
515 | BS3_PROC_END_CMN bs3CpuBasic2_jmp_jb__ud2
|
---|
516 |
|
---|
517 |
|
---|
518 | ; jmp rel8 (backwards)
|
---|
519 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jb_back__ud2
|
---|
520 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jb_back__ud2, BS3_PBC_NEAR
|
---|
521 | jmp .start
|
---|
522 | .again: ud2
|
---|
523 | times 7 int3
|
---|
524 | jmp .again
|
---|
525 | .start:
|
---|
526 | jmp short .again
|
---|
527 | .post_jmp:
|
---|
528 | int3
|
---|
529 | AssertCompile(.post_jmp - .start == 2)
|
---|
530 | BS3_PROC_END_CMN bs3CpuBasic2_jmp_jb_back__ud2
|
---|
531 |
|
---|
532 |
|
---|
533 | ; jmp rel16 (forwards)
|
---|
534 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv__ud2
|
---|
535 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jv__ud2, BS3_PBC_NEAR
|
---|
536 | jmp near .again
|
---|
537 | .post_jmp:
|
---|
538 | times 9 int3
|
---|
539 | .again: ud2
|
---|
540 | int3
|
---|
541 | jmp .again
|
---|
542 | %if TMPL_BITS == 16
|
---|
543 | AssertCompile(.post_jmp - BS3_LAST_LABEL == 3)
|
---|
544 | %else
|
---|
545 | AssertCompile(.post_jmp - BS3_LAST_LABEL == 5)
|
---|
546 | %endif
|
---|
547 | BS3_PROC_END_CMN bs3CpuBasic2_jmp_jv__ud2
|
---|
548 |
|
---|
549 |
|
---|
550 | ; jmp rel16 (backwards)
|
---|
551 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv_back__ud2
|
---|
552 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jv_back__ud2, BS3_PBC_NEAR
|
---|
553 | jmp .start
|
---|
554 | .again: ud2
|
---|
555 | times 6 int3
|
---|
556 | jmp .again
|
---|
557 | .start:
|
---|
558 | jmp near .again
|
---|
559 | .post_jmp:
|
---|
560 | int3
|
---|
561 | %if TMPL_BITS == 16
|
---|
562 | AssertCompile(.post_jmp - .start == 3)
|
---|
563 | %else
|
---|
564 | AssertCompile(.post_jmp - .start == 5)
|
---|
565 | %endif
|
---|
566 | BS3_PROC_END_CMN bs3CpuBasic2_jmp_jv_back__ud2
|
---|
567 |
|
---|
568 |
|
---|
569 | ;
|
---|
570 | ; When applying opsize, we need to put this in the 16-bit text segment to
|
---|
571 | ; better control where we end up in 32-bit and 64-bit mode.
|
---|
572 | ;
|
---|
573 | ; Try keep the code out of the IVT and BIOS data area. This unfortunately
|
---|
574 | ; requires manual padding here.
|
---|
575 | ;
|
---|
576 | BS3_BEGIN_TEXT16
|
---|
577 | BS3_SET_BITS TMPL_BITS
|
---|
578 | %if TMPL_BITS == 32
|
---|
579 | align 0x100, int3 ; Currently takes us up to 0x400 (max align value is 0x100)
|
---|
580 | times 0x200 int3 ; Brings us up to 0x600.
|
---|
581 | %endif
|
---|
582 |
|
---|
583 | BS3_GLOBAL_NAME_EX BS3_CMN_NM(bs3CpuBasic2_jmp_opsize_begin), , 1
|
---|
584 |
|
---|
585 |
|
---|
586 | ; jmp rel8 (forwards) with opsize override.
|
---|
587 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jb_opsize__ud2
|
---|
588 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jb_opsize__ud2, BS3_PBC_NEAR
|
---|
589 | db 66h
|
---|
590 | jmp short .again
|
---|
591 | .post_jmp:
|
---|
592 | times 8 int3
|
---|
593 | .again: ud2
|
---|
594 | int3
|
---|
595 | jmp .again
|
---|
596 | AssertCompile(.post_jmp - BS3_LAST_LABEL == 3)
|
---|
597 | BS3_PROC_END_CMN bs3CpuBasic2_jmp_jb_opsize__ud2
|
---|
598 |
|
---|
599 |
|
---|
600 | ; jmp rel8 (backwards) with opsize override.
|
---|
601 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jb_opsize_back__ud2
|
---|
602 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jb_opsize_back__ud2, BS3_PBC_NEAR
|
---|
603 | jmp .start
|
---|
604 | .again: ud2
|
---|
605 | times 19 int3
|
---|
606 | jmp .again
|
---|
607 | .start:
|
---|
608 | db 66h
|
---|
609 | jmp short .again
|
---|
610 | .post_jmp:
|
---|
611 | int3
|
---|
612 | AssertCompile(.post_jmp - .start == 3)
|
---|
613 | BS3_PROC_END_CMN bs3CpuBasic2_jmp_jb_opsize_back__ud2
|
---|
614 |
|
---|
615 |
|
---|
616 | ; jmp rel16 (forwards) with opsize override.
|
---|
617 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv_opsize__ud2
|
---|
618 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jv_opsize__ud2, BS3_PBC_NEAR
|
---|
619 | db 66h, 0e9h ; o32 jmp near .again
|
---|
620 | %if TMPL_BITS != 32
|
---|
621 | dd 11
|
---|
622 | %else
|
---|
623 | dw 11
|
---|
624 | %endif
|
---|
625 | .post_jmp:
|
---|
626 | times 11 int3
|
---|
627 | .again: ud2
|
---|
628 | int3
|
---|
629 | jmp .again
|
---|
630 | BS3_PROC_END_CMN bs3CpuBasic2_jmp_jv_opsize__ud2
|
---|
631 |
|
---|
632 |
|
---|
633 | ; jmp rel16 (backwards) with opsize override.
|
---|
634 | BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv_opsize_back__ud2
|
---|
635 | BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jv_opsize_back__ud2, BS3_PBC_NEAR
|
---|
636 | jmp .start
|
---|
637 | .again: ud2
|
---|
638 | int3
|
---|
639 | jmp .again
|
---|
640 | .start:
|
---|
641 | %if TMPL_BITS != 32
|
---|
642 | db 66h, 0e9h ; o32 jmp near .again
|
---|
643 | dd -(6 + 1 + 2 + 2)
|
---|
644 | %else
|
---|
645 | db 66h, 0e9h ; o16 jmp near .again
|
---|
646 | dw -(4 + 1 + 2 + 2)
|
---|
647 | %endif
|
---|
648 | .post_jmp:
|
---|
649 | times 11 int3
|
---|
650 | BS3_PROC_END_CMN bs3CpuBasic2_jmp_jv_opsize_back__ud2
|
---|
651 |
|
---|
652 |
|
---|
653 | BS3_GLOBAL_NAME_EX BS3_CMN_NM(bs3CpuBasic2_jmp_opsize_end), , 1
|
---|
654 | int3
|
---|
655 |
|
---|
656 |
|
---|
657 | %endif ; BS3_INSTANTIATING_CMN
|
---|
658 |
|
---|
659 | %include "bs3kit-template-footer.mac" ; reset environment
|
---|
660 |
|
---|