VirtualBox

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

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

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

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 27.6 KB
Line 
1; $Id: bs3-cpu-basic-2-template.mac 97477 2022-11-09 10:37:00Z 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
660;
661; When applying opsize, we need to put this in the 16-bit text segment to
662; better control where we end up in 32-bit and 64-bit mode.
663;
664; Try keep the code out of the IVT and BIOS data area. This unfortunately
665; requires manual padding here.
666;
667BS3_BEGIN_TEXT16
668 BS3_SET_BITS TMPL_BITS
669%if TMPL_BITS == 32
670 align 0x100, int3 ; Currently takes us up to 0x400 (max align value is 0x100)
671 times 0x200 int3 ; Brings us up to 0x600.
672%endif
673
674BS3_GLOBAL_NAME_EX BS3_CMN_NM(bs3CpuBasic2_jmp_opsize_begin), , 1
675
676
677; jmp rel8 (forwards) with opsize override.
678BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jb_opsize__ud2
679BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jb_opsize__ud2, BS3_PBC_NEAR
680 db 66h
681 jmp short .again
682.post_jmp:
683 times 8 int3
684.again: ud2
685 int3
686 jmp .again
687AssertCompile(.post_jmp - BS3_LAST_LABEL == 3)
688BS3_PROC_END_CMN bs3CpuBasic2_jmp_jb_opsize__ud2
689
690
691; jmp rel8 (backwards) with opsize override.
692BS3_GLOBAL_NAME_EX RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_jmp_jb_opsize_back__ud2),.again), function, 2
693 ud2
694 times 19 int3
695BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jb_opsize_back__ud2
696BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jb_opsize_back__ud2, BS3_PBC_NEAR
697 db 66h
698 jmp short .again
699.post_jmp:
700 int3
701AssertCompile(.post_jmp - BS3_LAST_LABEL == 3)
702BS3_PROC_END_CMN bs3CpuBasic2_jmp_jb_opsize_back__ud2
703
704
705; jmp rel16 (forwards) with opsize override.
706BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv_opsize__ud2
707BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jv_opsize__ud2, BS3_PBC_NEAR
708 db 66h, 0e9h ; o32 jmp near .again
709 %if TMPL_BITS != 32
710 dd 11
711 %else
712 dw 11
713 %endif
714.post_jmp:
715 times 11 int3
716.again: ud2
717 int3
718 jmp .again
719BS3_PROC_END_CMN bs3CpuBasic2_jmp_jv_opsize__ud2
720
721
722; jmp rel16 (backwards) with opsize override.
723BS3_GLOBAL_NAME_EX RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_jmp_jv_opsize_back__ud2),.again), function, 2
724 ud2
725 times 19 int3
726BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv_opsize_back__ud2
727BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_jv_opsize_back__ud2, BS3_PBC_NEAR
728 %if TMPL_BITS != 32
729 db 66h, 0e9h ; o32 jmp near .again
730 dd RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_jmp_jv_opsize_back__ud2),.again) - .post_jmp
731 %else
732 db 66h, 0e9h ; o16 jmp near .again
733 dw RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_jmp_jv_opsize_back__ud2),.again) - .post_jmp
734 %endif
735.post_jmp:
736 int3
737BS3_PROC_END_CMN bs3CpuBasic2_jmp_jv_opsize_back__ud2
738
739
740BS3_GLOBAL_NAME_EX BS3_CMN_NM(bs3CpuBasic2_jmp_opsize_end), , 1
741 int3
742
743; jmp [indirect]
744BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_ind_mem_opsize__ud2
745BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_ind_mem_opsize__ud2, BS3_PBC_NEAR
746 db 66h
747 %if TMPL_BITS == 16
748 jmp [word cs:.npAgain]
749 %elif TMPL_BITS == 32
750 jmp [dword cs:.npAgain wrt FLAT]
751 %else
752 jmp [.npAgain wrt FLAT]
753 %endif
754.post_jmp:
755 times 9 int3
756.npAgain:
757 %if TMPL_BITS == 16
758 dw BS3_TEXT16_WRT(.again)
759 dw 0
760 %else
761 dw .again wrt CGROUP16
762 dw 0faceh, 0f00dh, 07777h ; non-canonical address
763 %endif
764.again: ud2
765 int3
766 jmp .again
767BS3_PROC_END_CMN bs3CpuBasic2_jmp_ind_mem_opsize__ud2
768
769 %if TMPL_BITS == 64
770; jmp [indirect] - 64-bit intel version
771BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_ind_mem_opsize__ud2__intel
772BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_ind_mem_opsize__ud2__intel, BS3_PBC_NEAR
773 db 66h
774 jmp [.npAgain wrt FLAT]
775.post_jmp:
776 times 8 int3
777.npAgain:
778 dd .again wrt FLAT
779 dd 0
780.again: ud2
781 int3
782 jmp .again
783BS3_PROC_END_CMN bs3CpuBasic2_jmp_ind_mem_opsize__ud2__intel
784 %endif
785
786; jmp [xAX]
787BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_ind_xAX_opsize__ud2
788BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmp_ind_xAX_opsize__ud2, BS3_PBC_NEAR
789 db 66h
790 jmp xAX
791.post_jmp:
792 times 8 int3
793.again: ud2
794 int3
795 jmp .again
796BS3_PROC_END_CMN bs3CpuBasic2_jmp_ind_xAX_opsize__ud2
797
798
799; call rel16/32 (forwards) with opsize override.
800BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_jv_opsize__ud2
801BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_jv_opsize__ud2, BS3_PBC_NEAR
802 db 66h, 0e8h ; o32 jmp near .again
803 %if TMPL_BITS != 32
804 dd 12
805 %else
806 dw 12
807 %endif
808.post_call:
809 times 12 int3
810.again: ud2
811 int3
812 jmp .again
813BS3_PROC_END_CMN bs3CpuBasic2_call_jv_opsize__ud2
814
815
816; call rel16/32 (backwards) with opsize override.
817BS3_GLOBAL_NAME_EX RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_call_jv_opsize_back__ud2),.again), function, 2
818 ud2
819 times 19 int3
820BS3_CPUBAS2_UD_OFF bs3CpuBasic2_call_jv_opsize_back__ud2
821BS3_PROC_BEGIN_CMN bs3CpuBasic2_call_jv_opsize_back__ud2, BS3_PBC_NEAR
822 %if TMPL_BITS != 32
823 db 66h, 0e8h ; o32 call near .again
824 dd RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_call_jv_opsize_back__ud2),.again) - .post_call
825 %else
826 db 66h, 0e8h ; o16 call near .again
827 dw RT_CONCAT(BS3_CMN_NM(bs3CpuBasic2_call_jv_opsize_back__ud2),.again) - .post_call
828 %endif
829.post_call:
830 int3
831BS3_PROC_END_CMN bs3CpuBasic2_call_jv_opsize_back__ud2
832
833
834%endif ; BS3_INSTANTIATING_CMN
835
836%include "bs3kit-template-footer.mac" ; reset environment
837
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