VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-asm.asm@ 102128

Last change on this file since 102128 was 102128, checked in by vboxsync, 10 months ago

ValKit/bs3-cpu-basic-2: Working on LEA testing; committing early to preserve a state that causes assertions in EM becuase of some VT-x / IEM fun, involving and pending #GP. Should probably result in a triple fault. Can look at it later, mabye. bugref:10371

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 KB
Line 
1; $Id: bs3-cpu-basic-2-asm.asm 102128 2023-11-16 22:41:56Z vboxsync $
2;; @file
3; BS3Kit - bs3-cpu-basic-2
4;
5
6;
7; Copyright (C) 2007-2023 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; 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.mac"
42
43
44;*********************************************************************************************************************************
45;* Global Variables *
46;*********************************************************************************************************************************
47BS3_BEGIN_DATA16
48BS3_GLOBAL_DATA g_bs3CpuBasic2_ud2_FlatAddr, 4
49 dd _bs3CpuBasic2_ud2 wrt FLAT
50
51;; Place to save esp/rsp when doing LEA variations involving esp/rsp.
52BS3_GLOBAL_DATA g_bs3CpuBasic2_lea_rsp, 8
53 dq 0
54
55
56;
57; CPU mode agnostic test code snippets.
58;
59BS3_BEGIN_TEXT16
60
61BS3_PROC_BEGIN _bs3CpuBasic2_ud2
62.again:
63 ud2
64 jmp .again
65BS3_PROC_END _bs3CpuBasic2_ud2
66
67
68BS3_PROC_BEGIN _bs3CpuBasic2_salc_ud2
69 salc ; #UD in 64-bit mode
70.again:
71 ud2
72 jmp .again
73BS3_PROC_END _bs3CpuBasic2_salc_ud2
74
75BS3_PROC_BEGIN _bs3CpuBasic2_swapgs
76.again:
77 db 00fh, 001h, 0f8h ; swapgs - #UD when not in 64-bit mode.
78 jmp .again
79BS3_PROC_END _bs3CpuBasic2_swapgs
80
81
82BS3_PROC_BEGIN _bs3CpuBasic2_Int80
83 int 80h
84.again: ud2
85 jmp .again
86BS3_PROC_END _bs3CpuBasic2_Int80
87
88
89BS3_PROC_BEGIN _bs3CpuBasic2_Int81
90 int 81h
91.again: ud2
92 jmp .again
93BS3_PROC_END _bs3CpuBasic2_Int81
94
95
96BS3_PROC_BEGIN _bs3CpuBasic2_Int82
97 int 82h
98.again: ud2
99 jmp .again
100BS3_PROC_END _bs3CpuBasic2_Int82
101
102
103BS3_PROC_BEGIN _bs3CpuBasic2_Int83
104 int 83h
105.again: ud2
106 jmp .again
107BS3_PROC_END _bs3CpuBasic2_Int83
108
109
110BS3_PROC_BEGIN _bs3CpuBasic2_iret
111 iret
112BS3_PROC_END _bs3CpuBasic2_iret
113AssertCompile(_bs3CpuBasic2_iret_EndProc - _bs3CpuBasic2_iret == 1)
114
115
116BS3_PROC_BEGIN _bs3CpuBasic2_iret_opsize
117 iretd
118BS3_PROC_END _bs3CpuBasic2_iret_opsize
119AssertCompile(_bs3CpuBasic2_iret_opsize_EndProc - _bs3CpuBasic2_iret_opsize == 2)
120
121
122BS3_PROC_BEGIN _bs3CpuBasic2_iret_rexw
123 BS3_SET_BITS 64
124 iretq
125 BS3_SET_BITS 16
126BS3_PROC_END _bs3CpuBasic2_iret_rexw
127AssertCompile(_bs3CpuBasic2_iret_rexw_EndProc - _bs3CpuBasic2_iret_rexw == 2)
128
129
130;
131; CPU mode agnostic test code snippets.
132;
133BS3_BEGIN_TEXT32
134
135;;
136; @param [xBP + xCB*2] puDst
137; @param [xBP + xCB*3] uNewValue
138BS3_PROC_BEGIN_CMN bs3CpuBasic2_Store_mov, BS3_PBC_NEAR
139 push xBP
140 mov xBP, xSP
141 mov xCX, [xBP + xCB*2]
142 mov xAX, [xBP + xCB*3]
143 mov [xCX], xAX
144 leave
145 ret
146BS3_PROC_END_CMN bs3CpuBasic2_Store_mov
147
148;;
149; @param [xBP + xCB*2] puDst
150; @param [xBP + xCB*3] uNewValue
151BS3_PROC_BEGIN_CMN bs3CpuBasic2_Store_xchg, BS3_PBC_NEAR
152 push xBP
153 mov xBP, xSP
154 mov xCX, [xBP + xCB*2]
155 mov xAX, [xBP + xCB*3]
156 xchg [xCX], xAX
157 leave
158 ret
159BS3_PROC_END_CMN bs3CpuBasic2_Store_xchg
160
161;;
162; @param [xBP + xCB*2] puDst
163; @param [xBP + xCB*3] uNewValue
164; @param [xBP + xCB*4] uOldValue
165BS3_PROC_BEGIN_CMN bs3CpuBasic2_Store_cmpxchg, BS3_PBC_NEAR
166 push xBP
167 mov xBP, xSP
168 mov xCX, [xBP + xCB*2]
169 mov xDX, [xBP + xCB*3]
170 mov xAX, [xBP + xCB*4]
171.again:
172 cmpxchg [xCX], xDX
173 jnz .again
174 leave
175 ret
176BS3_PROC_END_CMN bs3CpuBasic2_Store_cmpxchg
177
178
179;
180; Jump code segment 64KB.
181;
182; There is no ORG directive in OMF mode of course. :-(
183;
184section BS3JMPTEXT16 align=16 CLASS=BS3CLASS16JMPCODE PRIVATE USE16
185 GROUP BS3GROUPJMPTEXT16 BS3JMPTEXT16
186 BS3_SET_BITS 16
187
188; 0000: Start with two int3 filler instructions.
189BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmptext16_start), function, 2
190 int3
191 int3
192
193; 0002: This is the target for forward wrap around jumps, should they succeed.
194BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_target_wrap_forward), function, 2
195 ud2
196 align 8, int3
197
198; 0008
199BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jb_wrap_backward__ud2), function, 2
200 db 0ebh, -012h ; jmp (0x0008 + 2 - 0x12 = 0xFFFFFFF8 (-8))
201 int3
202
203; 000b
204BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jb_opsize_wrap_backward__ud2), function, 3
205 db 066h, 0ebh, -016h ; jmp (0x000b + 3 - 0x16 = 0xFFFFFFF8 (-8))
206 int3
207
208 align 0x80, int3
209; 0080
210BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jv16_wrap_backward__ud2), function, 3
211 db 0e9h ; jmp (0x0080 + 3 - 0x8b = 0xFFFFFFF8 (-8))
212 dw -08bh
213 int3
214
215; 0084
216BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jv16_opsize_wrap_backward__ud2), function, 6
217 db 066h, 0e9h ; jmp (0x0084 + 6 - 0x92 = 0xFFFFFFF8 (-8))
218 dd -092h
219 int3
220
221; 008b
222BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_call_jv16_wrap_backward__ud2), function, 3
223 db 0e8h ; call (0x008b + 3 - 0x96)
224 dw -096h
225 int3
226
227; 008f
228BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_call_jv16_opsize_wrap_backward__ud2), function, 6
229 db 066h, 0e8h ; call (0x008f + 6 - 0x9d = 0xFFFFFFF8 (-8))
230 dd -09dh
231 int3
232
233
234 align 0x100, int3 ; Note! Doesn't work correctly for higher values.
235 times (0xff6b - 0x100) int3
236
237; ff6b
238BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_call_jv16_wrap_forward__ud2), function, 4
239 db 0e8h ; call (0xff6b+3 + 0x94 = 0x10002 (65538))
240 dw 094h
241 int3
242
243; ff6f
244BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_call_jv16_opsize_wrap_forward__ud2), function, 7
245 db 066h, 0e8h ; o32 call (0xff6f+6 + 0x8d = 0x10002 (65538))
246 dd 08dh
247 int3
248
249; ff76
250BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jv16_wrap_forward__ud2), function, 5
251 db 0e9h ; jmp (0xff76+4 + 0x88 = 0x10002 (65538))
252 dw 089h
253 int3
254
255; ff7a
256BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jv16_opsize_wrap_forward__ud2), function, 7
257 db 066h, 0e9h ; o32 jmp (0xff7a+6 + 0x82 = 0x10002 (65538))
258 dd 082h
259 int3
260
261; ff81
262BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jb_wrap_forward__ud2), function, 2
263 db 0ebh, 07fh ; jmp (0xff81+2 + 0x7f = 0x10002 (65538))
264 int3
265
266; ff84
267BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jb_opsize_wrap_forward__ud2), function, 3
268 db 066h, 0ebh, 07bh ; o32 jmp (0xff84+3 + 0x7b = 0x10002 (65538))
269; ff87
270
271 times (0xfff8 - 0xff87) int3
272
273; fff8: This is the target for backward wrap around jumps, should they succeed.
274BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_target_wrap_backward), function, 2
275 ud2
276 times 6 int3
277; End of segment.
278
279BS3_BEGIN_TEXT16
280
281;
282; Instantiate code templates.
283;
284BS3_INSTANTIATE_COMMON_TEMPLATE "bs3-cpu-basic-2-template.mac"
285BS3_INSTANTIATE_TEMPLATE_WITH_WEIRD_ONES "bs3-cpu-basic-2-template.mac"
286
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