VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.mac@ 97489

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

ValKit/bs3-cpu-basic-2: Added tests for the indirect call instructions. bugref:9898

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 30.5 KB
Line 
1; $Id: bs3-cpu-basic-2-template.mac 97489 2022-11-09 21:15:54Z 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
50BS3_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;*********************************************************************************************************************************
59TMPL_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;
72BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sidt_bx_ud2
73BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_bx_ud2, BS3_PBC_NEAR
74 sidt [xBX]
75.again: ud2
76 jmp .again
77AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_bx_ud2) == 3)
78BS3_PROC_END_CMN bs3CpuBasic2_sidt_bx_ud2
79
80BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sidt_opsize_bx_ud2
81BS3_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
86AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_opsize_bx_ud2) == 4)
87BS3_PROC_END_CMN bs3CpuBasic2_sidt_opsize_bx_ud2
88
89 %if TMPL_BITS == 64
90BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sidt_rexw_bx_ud2
91BS3_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
96AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_rexw_bx_ud2) == 4)
97BS3_PROC_END_CMN bs3CpuBasic2_sidt_rexw_bx_ud2
98
99BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sidt_opsize_rexw_bx_ud2
100BS3_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
106AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_opsize_rexw_bx_ud2) == 5)
107BS3_PROC_END_CMN bs3CpuBasic2_sidt_opsize_rexw_bx_ud2
108 %endif
109
110 %if TMPL_BITS != 64
111BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sidt_ss_bx_ud2
112BS3_PROC_BEGIN_CMN bs3CpuBasic2_sidt_ss_bx_ud2, BS3_PBC_NEAR
113 sidt [ss:xBX]
114.again: ud2
115 jmp .again
116AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_ss_bx_ud2) == 4)
117BS3_PROC_END_CMN bs3CpuBasic2_sidt_ss_bx_ud2
118
119BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sidt_opsize_ss_bx_ud2
120BS3_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
125AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sidt_opsize_ss_bx_ud2) == 5)
126BS3_PROC_END_CMN bs3CpuBasic2_sidt_opsize_ss_bx_ud2
127 %endif
128
129
130;
131; SGDT
132;
133BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sgdt_bx_ud2
134BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_bx_ud2, BS3_PBC_NEAR
135 sgdt [xBX]
136.again: ud2
137 jmp .again
138AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_bx_ud2) == 3)
139BS3_PROC_END_CMN bs3CpuBasic2_sgdt_bx_ud2
140
141BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sgdt_opsize_bx_ud2
142BS3_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
147AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_opsize_bx_ud2) == 4)
148BS3_PROC_END_CMN bs3CpuBasic2_sgdt_opsize_bx_ud2
149
150 %if TMPL_BITS == 64
151BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sgdt_rexw_bx_ud2
152BS3_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
157AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_rexw_bx_ud2) == 4)
158BS3_PROC_END_CMN bs3CpuBasic2_sgdt_rexw_bx_ud2
159
160BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2
161BS3_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
167AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2) == 5)
168BS3_PROC_END_CMN bs3CpuBasic2_sgdt_opsize_rexw_bx_ud2
169 %endif
170
171 %if TMPL_BITS != 64
172BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sgdt_ss_bx_ud2
173BS3_PROC_BEGIN_CMN bs3CpuBasic2_sgdt_ss_bx_ud2, BS3_PBC_NEAR
174 sgdt [ss:xBX]
175.again: ud2
176 jmp .again
177AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_ss_bx_ud2) == 4)
178BS3_PROC_END_CMN bs3CpuBasic2_sgdt_ss_bx_ud2
179
180BS3_CPUBAS2_UD_OFF bs3CpuBasic2_sgdt_opsize_ss_bx_ud2
181BS3_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
186AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_sgdt_opsize_ss_bx_ud2) == 5)
187BS3_PROC_END_CMN bs3CpuBasic2_sgdt_opsize_ss_bx_ud2
188 %endif
189
190
191;
192; LIDT
193;
194BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_bx__sidt_es_di__lidt_es_si__ud2
195BS3_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
202AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_bx__sidt_es_di__lidt_es_si__ud2) == BS3_IF_64BIT_OTHERWISE(9,11))
203BS3_PROC_END_CMN bs3CpuBasic2_lidt_bx__sidt_es_di__lidt_es_si__ud2
204
205BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_opsize_bx__sidt_es_di__lidt_es_si__ud2
206BS3_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
214AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_opsize_bx__sidt_es_di__lidt_es_si__ud2) == BS3_IF_64BIT_OTHERWISE(10,12))
215BS3_PROC_END_CMN bs3CpuBasic2_lidt_opsize_bx__sidt_es_di__lidt_es_si__ud2
216
217%if TMPL_BITS == 16
218BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_opsize_bx__sidt32_es_di__lidt_es_si__ud2
219BS3_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
232AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_opsize_bx__sidt32_es_di__lidt_es_si__ud2) == 27)
233BS3_PROC_END_CMN bs3CpuBasic2_lidt_opsize_bx__sidt32_es_di__lidt_es_si__ud2
234%endif
235
236 %if TMPL_BITS == 64
237BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_rexw_bx__sidt_es_di__lidt_es_si__ud2
238BS3_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
246AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_rexw_bx__sidt_es_di__lidt_es_si__ud2) == 10)
247BS3_PROC_END_CMN bs3CpuBasic2_lidt_rexw_bx__sidt_es_di__lidt_es_si__ud2
248
249BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_opsize_rexw_bx__sidt_es_di__lidt_es_si__ud2
250BS3_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
259AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_opsize_rexw_bx__sidt_es_di__lidt_es_si__ud2) == 11)
260BS3_PROC_END_CMN bs3CpuBasic2_lidt_opsize_rexw_bx__sidt_es_di__lidt_es_si__ud2
261 %endif
262
263 %if TMPL_BITS != 64
264BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_ss_bx__sidt_es_di__lidt_es_si__ud2
265BS3_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
272AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_ss_bx__sidt_es_di__lidt_es_si__ud2) == 12)
273BS3_PROC_END_CMN bs3CpuBasic2_lidt_ss_bx__sidt_es_di__lidt_es_si__ud2
274
275BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lidt_opsize_ss_bx__sidt_es_di__lidt_es_si__ud2
276BS3_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
284AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lidt_opsize_ss_bx__sidt_es_di__lidt_es_si__ud2) == 13)
285BS3_PROC_END_CMN bs3CpuBasic2_lidt_opsize_ss_bx__sidt_es_di__lidt_es_si__ud2
286 %endif
287
288
289;
290; LGDT
291;
292BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lgdt_bx__sgdt_es_di__lgdt_es_si__ud2
293BS3_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
300AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lgdt_bx__sgdt_es_di__lgdt_es_si__ud2) == BS3_IF_64BIT_OTHERWISE(9,11))
301BS3_PROC_END_CMN bs3CpuBasic2_lgdt_bx__sgdt_es_di__lgdt_es_si__ud2
302
303BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lgdt_opsize_bx__sgdt_es_di__lgdt_es_si__ud2
304BS3_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
312AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lgdt_opsize_bx__sgdt_es_di__lgdt_es_si__ud2) == BS3_IF_64BIT_OTHERWISE(10,12))
313BS3_PROC_END_CMN bs3CpuBasic2_lgdt_opsize_bx__sgdt_es_di__lgdt_es_si__ud2
314
315 %if TMPL_BITS == 64
316BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lgdt_rexw_bx__sgdt_es_di__lgdt_es_si__ud2
317BS3_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
325AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lgdt_rexw_bx__sgdt_es_di__lgdt_es_si__ud2) == 10)
326BS3_PROC_END_CMN bs3CpuBasic2_lgdt_rexw_bx__sgdt_es_di__lgdt_es_si__ud2
327
328BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lgdt_opsize_rexw_bx__sgdt_es_di__lgdt_es_si__ud2
329BS3_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
338AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lgdt_opsize_rexw_bx__sgdt_es_di__lgdt_es_si__ud2) == 11)
339BS3_PROC_END_CMN bs3CpuBasic2_lgdt_opsize_rexw_bx__sgdt_es_di__lgdt_es_si__ud2
340 %endif
341
342 %if TMPL_BITS != 64
343BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lgdt_ss_bx__sgdt_es_di__lgdt_es_si__ud2
344BS3_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
351AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lgdt_ss_bx__sgdt_es_di__lgdt_es_si__ud2) == 12)
352BS3_PROC_END_CMN bs3CpuBasic2_lgdt_ss_bx__sgdt_es_di__lgdt_es_si__ud2
353
354BS3_CPUBAS2_UD_OFF bs3CpuBasic2_lgdt_opsize_ss_bx__sgdt_es_di__lgdt_es_si__ud2
355BS3_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
363AssertCompile(.again - BS3_CMN_NM(bs3CpuBasic2_lgdt_opsize_ss_bx__sgdt_es_di__lgdt_es_si__ud2) == 13)
364BS3_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.
372BS3_CPUBAS2_UD_OFF bs3CpuBasic2_mov_ax_ds_bx__ud2
373BS3_PROC_BEGIN_CMN bs3CpuBasic2_mov_ax_ds_bx__ud2, BS3_PBC_NEAR
374 mov xAX, [xBX]
375.again: ud2
376 jmp .again
377AssertCompile(.again - BS3_LAST_LABEL == 2 + (TMPL_BITS == 64))
378BS3_PROC_END_CMN bs3CpuBasic2_mov_ax_ds_bx__ud2
379
380
381; For testing write access.
382BS3_CPUBAS2_UD_OFF bs3CpuBasic2_mov_ds_bx_ax__ud2
383BS3_PROC_BEGIN_CMN bs3CpuBasic2_mov_ds_bx_ax__ud2, BS3_PBC_NEAR
384 mov [xBX], xAX
385.again: ud2
386 jmp .again
387AssertCompile(.again - BS3_LAST_LABEL == 2 + (TMPL_BITS == 64))
388BS3_PROC_END_CMN bs3CpuBasic2_mov_ds_bx_ax__ud2
389
390
391; For testing read+write access.
392BS3_CPUBAS2_UD_OFF bs3CpuBasic2_xchg_ds_bx_ax__ud2
393BS3_PROC_BEGIN_CMN bs3CpuBasic2_xchg_ds_bx_ax__ud2, BS3_PBC_NEAR
394 xchg [xBX], xAX
395.again: ud2
396 jmp .again
397AssertCompile(.again - BS3_LAST_LABEL == 2 + (TMPL_BITS == 64))
398BS3_PROC_END_CMN bs3CpuBasic2_xchg_ds_bx_ax__ud2
399
400
401; Another read+write access test.
402BS3_CPUBAS2_UD_OFF bs3CpuBasic2_cmpxchg_ds_bx_cx__ud2
403BS3_PROC_BEGIN_CMN bs3CpuBasic2_cmpxchg_ds_bx_cx__ud2, BS3_PBC_NEAR
404 cmpxchg [xBX], xCX
405.again: ud2
406 jmp .again
407AssertCompile(.again - BS3_LAST_LABEL == 3 + (TMPL_BITS == 64))
408BS3_PROC_END_CMN bs3CpuBasic2_cmpxchg_ds_bx_cx__ud2
409
410
411; For testing read access from an aborted instruction: DIV by zero
412BS3_CPUBAS2_UD_OFF bs3CpuBasic2_div_ds_bx__ud2
413BS3_PROC_BEGIN_CMN bs3CpuBasic2_div_ds_bx__ud2, BS3_PBC_NEAR
414 div xPRE [xBX]
415.again: ud2
416 jmp .again
417AssertCompile(.again - BS3_LAST_LABEL == 2 + (TMPL_BITS == 64))
418BS3_PROC_END_CMN bs3CpuBasic2_div_ds_bx__ud2
419
420; For testing FLD m80 alignment (#AC).
421BS3_CPUBAS2_UD_OFF bs3CpuBasic2_fninit_fld_ds_bx__ud2
422BS3_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
428AssertCompile(.actual_test_instruction - BS3_LAST_LABEL == 2)
429BS3_PROC_END_CMN bs3CpuBasic2_fninit_fld_ds_bx__ud2
430
431; For testing FBLD m80 alignment (#AC).
432BS3_CPUBAS2_UD_OFF bs3CpuBasic2_fninit_fbld_ds_bx__ud2
433BS3_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
439AssertCompile(.actual_test_instruction - BS3_LAST_LABEL == 2)
440BS3_PROC_END_CMN bs3CpuBasic2_fninit_fbld_ds_bx__ud2
441
442; For testing FST m80 alignment (#AC).
443BS3_CPUBAS2_UD_OFF bs3CpuBasic2_fninit_fldz_fstp_ds_bx__ud2
444BS3_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
451AssertCompile(.actual_test_instruction - BS3_LAST_LABEL == 4)
452BS3_PROC_END_CMN bs3CpuBasic2_fninit_fldz_fstp_ds_bx__ud2
453
454; For testing FXSAVE alignment (#AC/#GP).
455BS3_CPUBAS2_UD_OFF bs3CpuBasic2_fxsave_ds_bx__ud2
456BS3_PROC_BEGIN_CMN bs3CpuBasic2_fxsave_ds_bx__ud2, BS3_PBC_NEAR
457 fxsave [xBX]
458.again: ud2
459 jmp .again
460BS3_PROC_END_CMN bs3CpuBasic2_fxsave_ds_bx__ud2
461
462
463; Two memory operands: push [mem]
464BS3_CPUBAS2_UD_OFF bs3CpuBasic2_push_ds_bx__ud2
465BS3_PROC_BEGIN_CMN bs3CpuBasic2_push_ds_bx__ud2, BS3_PBC_NEAR
466 push xPRE [xBX]
467.again: ud2
468 jmp .again
469AssertCompile(.again - BS3_LAST_LABEL == 2)
470BS3_PROC_END_CMN bs3CpuBasic2_push_ds_bx__ud2
471
472; Two memory operands: pop [mem]
473BS3_CPUBAS2_UD_OFF bs3CpuBasic2_push_ax__pop_ds_bx__ud2
474BS3_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
479AssertCompile(.again - BS3_LAST_LABEL == 3)
480BS3_PROC_END_CMN bs3CpuBasic2_push_ax__pop_ds_bx__ud2
481
482; Two memory operands: call [mem]
483BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_ds_bx__ud2
484BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_ds_bx__ud2, BS3_PBC_NEAR
485 call xPRE [xBX]
486.again: ud2
487 jmp .again
488AssertCompile(.again - BS3_LAST_LABEL == 2)
489BS3_PROC_END_CMN bs3CpuBasic2_call_ds_bx__ud2
490
491; For testing #GP vs #PF write
492BS3_CPUBAS2_UD_OFF bs3CpuBasic2_insb__ud2
493BS3_PROC_BEGIN_CMN bs3CpuBasic2_insb__ud2, BS3_PBC_NEAR
494 insb
495.again: ud2
496 jmp .again
497AssertCompile(.again - BS3_LAST_LABEL == 1)
498BS3_PROC_END_CMN bs3CpuBasic2_insb__ud2
499
500
501;*********************************************************************************************************************************
502;* JMP Tests (simple ones). *
503;*********************************************************************************************************************************
504
505; jmp rel8 (forwards)
506BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jb__ud2
507BS3_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
514AssertCompile(.post_jmp - BS3_LAST_LABEL == 2)
515BS3_PROC_END_CMN bs3CpuBasic2_jmp_jb__ud2
516
517
518; jmp rel8 (backwards)
519BS3_GLOBAL_NAME_EX RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_jmp_jb_back__ud2),.again), function, 2
520 ud2
521 times 7 int3
522BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jb_back__ud2
523BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jb_back__ud2, BS3_PBC_NEAR
524 jmp short .again
525.post_jmp:
526 int3
527AssertCompile(.post_jmp - BS3_LAST_LABEL == 2)
528BS3_PROC_END_CMN bs3CpuBasic2_jmp_jb_back__ud2
529
530
531; jmp rel16 (forwards)
532BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv__ud2
533BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jv__ud2, BS3_PBC_NEAR
534 jmp near .again
535.post_jmp:
536 times 9 int3
537.again: ud2
538 int3
539 jmp .again
540 %if TMPL_BITS == 16
541AssertCompile(.post_jmp - BS3_LAST_LABEL == 3)
542 %else
543AssertCompile(.post_jmp - BS3_LAST_LABEL == 5)
544 %endif
545BS3_PROC_END_CMN bs3CpuBasic2_jmp_jv__ud2
546
547
548; jmp rel16 (backwards)
549BS3_GLOBAL_NAME_EX RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_jmp_jv_back__ud2),.again), function, 2
550 ud2
551 times 6 int3
552BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv_back__ud2
553BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jv_back__ud2, BS3_PBC_NEAR
554 jmp near .again
555.post_jmp:
556 int3
557 %if TMPL_BITS == 16
558AssertCompile(.post_jmp - BS3_LAST_LABEL == 3)
559 %else
560AssertCompile(.post_jmp - BS3_LAST_LABEL == 5)
561 %endif
562BS3_PROC_END_CMN bs3CpuBasic2_jmp_jv_back__ud2
563
564
565; jmp [indirect]
566BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_ind_mem__ud2
567BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_ind_mem__ud2, BS3_PBC_NEAR
568%if TMPL_BITS == 16
569 jmp [word cs:.npAgain]
570%elif TMPL_BITS == 32
571 jmp [dword cs:.npAgain]
572%else
573 jmp [.npAgain]
574%endif
575.post_jmp:
576 times 9 int3
577.npAgain:
578 %if TMPL_BITS == 16
579 dw BS3_TEXT16_WRT(.again)
580 %else
581 dd .again wrt FLAT
582 %if TMPL_BITS == 64
583 dd 0
584 %endif
585 %endif
586.again: ud2
587 int3
588 jmp .again
589BS3_PROC_END_CMN bs3CpuBasic2_jmp_ind_mem__ud2
590
591; jmp [xAX]
592BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_ind_xAX__ud2
593BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_ind_xAX__ud2, BS3_PBC_NEAR
594 jmp xAX
595.post_jmp:
596 times 17 int3
597.again: ud2
598 int3
599 jmp .again
600BS3_PROC_END_CMN bs3CpuBasic2_jmp_ind_xAX__ud2
601
602; jmp [xDI]
603BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_ind_xDI__ud2
604BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_ind_xDI__ud2, BS3_PBC_NEAR
605 jmp xDI
606.post_jmp:
607 times 17 int3
608.again: ud2
609 int3
610 jmp .again
611BS3_PROC_END_CMN bs3CpuBasic2_jmp_ind_xDI__ud2
612
613 %if TMPL_BITS == 64
614; jmp [xAX]
615BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_ind_r9__ud2
616BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_ind_r9__ud2, BS3_PBC_NEAR
617 jmp r9
618.post_jmp:
619 times 17 int3
620.again: ud2
621 int3
622 jmp .again
623BS3_PROC_END_CMN bs3CpuBasic2_jmp_ind_r9__ud2
624 %endif
625
626
627; call rel16/32 (forwards)
628BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_jv__ud2
629BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_jv__ud2, BS3_PBC_NEAR
630 call near .again
631.post_call:
632 times 9 int3
633.again: ud2
634 int3
635 jmp .again
636 %if TMPL_BITS == 16
637AssertCompile(.post_call - BS3_LAST_LABEL == 3)
638 %else
639AssertCompile(.post_call - BS3_LAST_LABEL == 5)
640 %endif
641BS3_PROC_END_CMN bs3CpuBasic2_call_jv__ud2
642
643; call rel16/32 (backwards)
644BS3_GLOBAL_NAME_EX RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_call_jv_back__ud2),.again), function, 2
645 ud2
646 times 6 int3
647BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_jv_back__ud2
648BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_jv_back__ud2, BS3_PBC_NEAR
649 call near .again
650.post_call:
651 int3
652 %if TMPL_BITS == 16
653AssertCompile(.post_call - BS3_LAST_LABEL == 3)
654 %else
655AssertCompile(.post_call - BS3_LAST_LABEL == 5)
656 %endif
657BS3_PROC_END_CMN bs3CpuBasic2_call_jv_back__ud2
658
659; call [indirect]
660BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_ind_mem__ud2
661BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_ind_mem__ud2, BS3_PBC_NEAR
662%if TMPL_BITS == 16
663 call [word cs:.npAgain]
664%elif TMPL_BITS == 32
665 call [dword cs:.npAgain]
666%else
667 call [.npAgain]
668%endif
669.post_call:
670 times 9 int3
671.npAgain:
672 %if TMPL_BITS == 16
673 dw BS3_TEXT16_WRT(.again)
674 %else
675 dd .again wrt FLAT
676 %if TMPL_BITS == 64
677 dd 0
678 %endif
679 %endif
680.again: ud2
681 int3
682 jmp .again
683BS3_PROC_END_CMN bs3CpuBasic2_call_ind_mem__ud2
684
685; call [xAX]
686BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_ind_xAX__ud2
687BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_ind_xAX__ud2, BS3_PBC_NEAR
688 call xAX
689.post_call:
690 times 17 int3
691.again: ud2
692 int3
693 jmp .again
694BS3_PROC_END_CMN bs3CpuBasic2_call_ind_xAX__ud2
695
696; call [xDI]
697BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_ind_xDI__ud2
698BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_ind_xDI__ud2, BS3_PBC_NEAR
699 call xDI
700.post_call:
701 times 17 int3
702.again: ud2
703 int3
704 jmp .again
705BS3_PROC_END_CMN bs3CpuBasic2_call_ind_xDI__ud2
706
707 %if TMPL_BITS == 64
708; call [xAX]
709BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_ind_r9__ud2
710BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_ind_r9__ud2, BS3_PBC_NEAR
711 call r9
712.post_call:
713 times 17 int3
714.again: ud2
715 int3
716 jmp .again
717BS3_PROC_END_CMN bs3CpuBasic2_call_ind_r9__ud2
718 %endif
719
720
721;
722; When applying opsize, we need to put this in the 16-bit text segment to
723; better control where we end up in 32-bit and 64-bit mode.
724;
725; Try keep the code out of the IVT and BIOS data area. This unfortunately
726; requires manual padding here.
727;
728BS3_BEGIN_TEXT16
729 BS3_SET_BITS TMPL_BITS
730%if TMPL_BITS == 32
731 align 0x100, int3 ; Currently takes us up to 0x400 (max align value is 0x100)
732 times 0x200 int3 ; Brings us up to 0x600.
733%endif
734
735BS3_GLOBAL_NAME_EX BS3_CMN_NM(bs3CpuBasic2_jmp_opsize_begin), , 1
736
737
738; jmp rel8 (forwards) with opsize override.
739BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jb_opsize__ud2
740BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jb_opsize__ud2, BS3_PBC_NEAR
741 db 66h
742 jmp short .again
743.post_jmp:
744 times 8 int3
745.again: ud2
746 int3
747 jmp .again
748AssertCompile(.post_jmp - BS3_LAST_LABEL == 3)
749BS3_PROC_END_CMN bs3CpuBasic2_jmp_jb_opsize__ud2
750
751
752; jmp rel8 (backwards) with opsize override.
753BS3_GLOBAL_NAME_EX RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_jmp_jb_opsize_back__ud2),.again), function, 2
754 ud2
755 times 19 int3
756BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jb_opsize_back__ud2
757BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jb_opsize_back__ud2, BS3_PBC_NEAR
758 db 66h
759 jmp short .again
760.post_jmp:
761 int3
762AssertCompile(.post_jmp - BS3_LAST_LABEL == 3)
763BS3_PROC_END_CMN bs3CpuBasic2_jmp_jb_opsize_back__ud2
764
765
766; jmp rel16 (forwards) with opsize override.
767BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv_opsize__ud2
768BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jv_opsize__ud2, BS3_PBC_NEAR
769 db 66h, 0e9h ; o32 jmp near .again
770 %if TMPL_BITS != 32
771 dd 11
772 %else
773 dw 11
774 %endif
775.post_jmp:
776 times 11 int3
777.again: ud2
778 int3
779 jmp .again
780BS3_PROC_END_CMN bs3CpuBasic2_jmp_jv_opsize__ud2
781
782
783; jmp rel16 (backwards) with opsize override.
784BS3_GLOBAL_NAME_EX RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_jmp_jv_opsize_back__ud2),.again), function, 2
785 ud2
786 times 19 int3
787BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv_opsize_back__ud2
788BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jv_opsize_back__ud2, BS3_PBC_NEAR
789 %if TMPL_BITS != 32
790 db 66h, 0e9h ; o32 jmp near .again
791 dd RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_jmp_jv_opsize_back__ud2),.again) - .post_jmp
792 %else
793 db 66h, 0e9h ; o16 jmp near .again
794 dw RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_jmp_jv_opsize_back__ud2),.again) - .post_jmp
795 %endif
796.post_jmp:
797 int3
798BS3_PROC_END_CMN bs3CpuBasic2_jmp_jv_opsize_back__ud2
799
800
801BS3_GLOBAL_NAME_EX BS3_CMN_NM(bs3CpuBasic2_jmp_opsize_end), , 1
802 int3
803
804; jmp [indirect]
805BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_ind_mem_opsize__ud2
806BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_ind_mem_opsize__ud2, BS3_PBC_NEAR
807 db 66h
808 %if TMPL_BITS == 16
809 jmp [word cs:.npAgain]
810 %elif TMPL_BITS == 32
811 jmp [dword cs:.npAgain wrt FLAT]
812 %else
813 jmp [.npAgain wrt FLAT]
814 %endif
815.post_jmp:
816 times 9 int3
817.npAgain:
818 %if TMPL_BITS == 16
819 dw BS3_TEXT16_WRT(.again)
820 dw 0
821 %else
822 dw .again wrt CGROUP16
823 dw 0faceh, 0f00dh, 07777h ; non-canonical address
824 %endif
825.again: ud2
826 int3
827 jmp .again
828BS3_PROC_END_CMN bs3CpuBasic2_jmp_ind_mem_opsize__ud2
829
830 %if TMPL_BITS == 64
831; jmp [indirect] - 64-bit intel version
832BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_ind_mem_opsize__ud2__intel
833BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_ind_mem_opsize__ud2__intel, BS3_PBC_NEAR
834 db 66h
835 jmp [.npAgain wrt FLAT]
836.post_jmp:
837 times 8 int3
838.npAgain:
839 dd .again wrt FLAT
840 dd 0
841.again: ud2
842 int3
843 jmp .again
844BS3_PROC_END_CMN bs3CpuBasic2_jmp_ind_mem_opsize__ud2__intel
845 %endif
846
847; jmp [xAX]
848BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_ind_xAX_opsize__ud2
849BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_ind_xAX_opsize__ud2, BS3_PBC_NEAR
850 db 66h
851 jmp xAX
852.post_jmp:
853 times 8 int3
854.again: ud2
855 int3
856 jmp .again
857BS3_PROC_END_CMN bs3CpuBasic2_jmp_ind_xAX_opsize__ud2
858
859
860; call rel16/32 (forwards) with opsize override.
861BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_jv_opsize__ud2
862BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_jv_opsize__ud2, BS3_PBC_NEAR
863 db 66h, 0e8h ; o32 jmp near .again
864 %if TMPL_BITS != 32
865 dd 12
866 %else
867 dw 12
868 %endif
869.post_call:
870 times 12 int3
871.again: ud2
872 int3
873 jmp .again
874BS3_PROC_END_CMN bs3CpuBasic2_call_jv_opsize__ud2
875
876
877; call rel16/32 (backwards) with opsize override.
878BS3_GLOBAL_NAME_EX RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_call_jv_opsize_back__ud2),.again), function, 2
879 ud2
880 times 19 int3
881BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_jv_opsize_back__ud2
882BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_jv_opsize_back__ud2, BS3_PBC_NEAR
883 %if TMPL_BITS != 32
884 db 66h, 0e8h ; o32 call near .again
885 dd RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_call_jv_opsize_back__ud2),.again) - .post_call
886 %else
887 db 66h, 0e8h ; o16 call near .again
888 dw RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_call_jv_opsize_back__ud2),.again) - .post_call
889 %endif
890.post_call:
891 int3
892BS3_PROC_END_CMN bs3CpuBasic2_call_jv_opsize_back__ud2
893
894; call [indirect]
895BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_ind_mem_opsize__ud2
896BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_ind_mem_opsize__ud2, BS3_PBC_NEAR
897 db 66h
898 %if TMPL_BITS == 16
899 call [word cs:.npAgain]
900 %elif TMPL_BITS == 32
901 call [dword cs:.npAgain wrt FLAT]
902 %else
903 call [.npAgain wrt FLAT]
904 %endif
905.post_call:
906 times 9 int3
907.npAgain:
908 %if TMPL_BITS == 16
909 dw BS3_TEXT16_WRT(.again)
910 dw 0
911 %else
912 dw .again wrt CGROUP16
913 dw 0faceh, 0f00dh, 07777h ; non-canonical address
914 %endif
915.again: ud2
916 int3
917 jmp .again
918BS3_PROC_END_CMN bs3CpuBasic2_call_ind_mem_opsize__ud2
919
920 %if TMPL_BITS == 64
921; call [indirect] - 64-bit intel version
922BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_ind_mem_opsize__ud2__intel
923BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_ind_mem_opsize__ud2__intel, BS3_PBC_NEAR
924 db 66h
925 call [.npAgain wrt FLAT]
926.post_call:
927 times 8 int3
928.npAgain:
929 dd .again wrt FLAT
930 dd 0
931.again: ud2
932 int3
933 jmp .again
934BS3_PROC_END_CMN bs3CpuBasic2_call_ind_mem_opsize__ud2__intel
935 %endif
936
937; call [xAX]
938BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_ind_xAX_opsize__ud2
939BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_ind_xAX_opsize__ud2, BS3_PBC_NEAR
940 db 66h
941 call xAX
942.post_call:
943 times 8 int3
944.again: ud2
945 int3
946 jmp .again
947BS3_PROC_END_CMN bs3CpuBasic2_call_ind_xAX_opsize__ud2
948
949
950%endif ; BS3_INSTANTIATING_CMN
951
952%include "bs3kit-template-footer.mac" ; reset environment
953
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