VirtualBox

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

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

ValKit/bs3-cpu-basic-2: Working a JMP test... bugref:9898

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.4 KB
Line 
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
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_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jb_back__ud2
520BS3_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
529AssertCompile(.post_jmp - .start == 2)
530BS3_PROC_END_CMN bs3CpuBasic2_jmp_jb_back__ud2
531
532
533; jmp rel16 (forwards)
534BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv__ud2
535BS3_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
543AssertCompile(.post_jmp - BS3_LAST_LABEL == 3)
544 %else
545AssertCompile(.post_jmp - BS3_LAST_LABEL == 5)
546 %endif
547BS3_PROC_END_CMN bs3CpuBasic2_jmp_jv__ud2
548
549
550; jmp rel16 (backwards)
551BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv_back__ud2
552BS3_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
562AssertCompile(.post_jmp - .start == 3)
563 %else
564AssertCompile(.post_jmp - .start == 5)
565 %endif
566BS3_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;
576BS3_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
583BS3_GLOBAL_NAME_EX BS3_CMN_NM(bs3CpuBasic2_jmp_opsize_begin), , 1
584
585
586; jmp rel8 (forwards) with opsize override.
587BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jb_opsize__ud2
588BS3_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
596AssertCompile(.post_jmp - BS3_LAST_LABEL == 3)
597BS3_PROC_END_CMN bs3CpuBasic2_jmp_jb_opsize__ud2
598
599
600; jmp rel8 (backwards) with opsize override.
601BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jb_opsize_back__ud2
602BS3_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
612AssertCompile(.post_jmp - .start == 3)
613BS3_PROC_END_CMN bs3CpuBasic2_jmp_jb_opsize_back__ud2
614
615
616; jmp rel16 (forwards) with opsize override.
617BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv_opsize__ud2
618BS3_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
630BS3_PROC_END_CMN bs3CpuBasic2_jmp_jv_opsize__ud2
631
632
633; jmp rel16 (backwards) with opsize override.
634BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmp_jv_opsize_back__ud2
635BS3_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
650BS3_PROC_END_CMN bs3CpuBasic2_jmp_jv_opsize_back__ud2
651
652
653BS3_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
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