VirtualBox

source: vbox/trunk/src/VBox/VMM/testcase/Instructions/env-common.mac@ 75142

Last change on this file since 75142 was 69111, checked in by vboxsync, 7 years ago

(C) year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.6 KB
Line 
1; $Id: env-common.mac 69111 2017-10-17 14:26:02Z vboxsync $
2;; @file
3; Instruction Test Environment - Common Bits.
4;
5
6;
7; Copyright (C) 2006-2017 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.virtualbox.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17
18%ifndef ___env_common_mac
19%define ___env_common_mac
20
21%include "iprt/x86.mac"
22
23;*******************************************************************************
24;* Defined Constants And Macros *
25;*******************************************************************************
26%ifdef RT_ARCH_AMD64
27 %define MY_PUSH_FLAGS pushfq
28 %define MY_POP_FLAGS popfq
29 %define MY_PUSH_FLAGS_SIZE 8
30
31 %macro MY_PUSH_ALL 0
32 push rbp
33 mov rbp, rsp
34 push rax
35 push rbx
36 push rcx
37 push rdx
38 push rsi
39 push rdi
40 push r8
41 push r9
42 push r10
43 push r11
44 push r12
45 push r13
46 push r14
47 push r15
48 pushfq
49 %endm
50 %macro MY_POP_ALL 0
51 popfq
52 pop r15
53 pop r14
54 pop r13
55 pop r12
56 pop r11
57 pop r10
58 pop r9
59 pop r8
60 pop rdi
61 pop rsi
62 pop rdx
63 pop rcx
64 pop rbx
65 pop rax
66 pop rbp
67 %endm
68
69%else
70 %define MY_PUSH_FLAGS pushfd
71 %define MY_POP_FLAGS popfd
72 %define MY_PUSH_FLAGS_SIZE 4
73
74 %macro MY_PUSH_ALL 0
75 push eBP
76 mov xBP, xSP
77 push eax
78 push ebx
79 push ecx
80 push edx
81 push esi
82 push edi
83 pushfd
84 %endm
85 %macro MY_POP_ALL 0
86 popfd
87 pop edi
88 pop esi
89 pop edx
90 pop ecx
91 pop ebx
92 pop eax
93 pop ebp
94 %endm
95%endif
96
97
98
99;*******************************************************************************
100;* Internal Functions *
101;*******************************************************************************
102
103VBINSTST_BEGINCODE
104
105;;
106; Report bad register value.
107;
108; Primary purpose is save all registers and convert from our stack-based to
109; the correct calling convention for the environment.
110;
111; This function will clean up the stack upon return (to save space in the caller).
112;
113; @param uExpected
114; @param uActual
115; @param uRegisterNo
116;
117VBINSTST_BEGINPROC Common_BadValue
118 MY_PUSH_ALL
119 mov xAX, xSP ; 16-byte align the stack and reserve space for arguments and stuff.
120 sub xSP, 40h
121 and xSP, ~15
122 mov [xSP + 38h], xAX
123
124%ifdef ASM_CALL64_GCC
125 mov r8d, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator) wrt rip]
126 mov rcx, [rbp + 10h] ; expected
127 mov rdx, [rbp + 18h] ; actual
128 mov rsi, [rbp + 20h] ; reg#
129 lea rdi, [.szFmt wrt rip]
130 VBINSTST_CALL_FN_FAILURE_4
131
132%elifdef ASM_CALL64_MSC
133 mov r10d, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator) wrt rip]
134 mov [rsp + 20h], r10
135 mov r9, [rbp + 10h] ; expected
136 mov r8, [rbp + 18h] ; actual
137 mov rdx, [rbp + 20h] ; reg#
138 lea rcx, [.szFmt wrt rip]
139 VBINSTST_CALL_FN_FAILURE_4
140
141%elifdef ASM_CALL64_BS2
142 mov sBX, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator) xWrtRIP]
143 mov sCX, [xBP + xCB + xCB] ; expected
144 mov sAX, [xBP + xCB + xCB + sCB*1] ; actual
145 mov sDX, [xBP + xCB + xCB + sCB*2] ; reg#
146 lea sSI, [.szFmt xWrtRIP]
147 mov qword [xSP + xCB + 3*sCB], sBX
148 mov qword [xSP + xCB + 2*sCB], sCX
149 mov qword [xSP + xCB + 1*sCB], sAX
150 mov qword [xSP + xCB], sDX
151 mov [xSP], sSI
152 VBINSTST_CALL_FN_FAILURE_4
153
154%else
155 mov sBX, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator)]
156 mov sCX, [xBP + xCB + xCB] ; expected
157 mov sAX, [xBP + xCB + xCB + sCB*1] ; actual
158 mov sDX, [xBP + xCB + xCB + sCB*2] ; reg#
159 mov [xSP + xCB + 3*sCB], sBX
160 mov [xSP + xCB + 2*sCB], sCX
161 mov [xSP + xCB + 1*sCB], sAX
162 mov [xSP + xCB], sDX
163 mov [xSP], RTCCPTR_PRE .szFmt
164 VBINSTST_CALL_FN_FAILURE_4
165%endif
166
167 mov xSP, [xSP + 38h]
168 MY_POP_ALL
169 ret 3*sCB
170%if ARCH_BITS == 64
171.szFmt: db 'Bad register 0x%RX32 value 0x%RX64, expected 0x%RX64 (line %RU64)', 13, 0
172%else
173.szFmt: db 'Bad register 0x%RX32 value 0x%RX32, expected 0x%RX32 (line %RU32)', 13, 0
174%endif
175VBINSTST_ENDPROC Common_BadValue
176
177
178%ifdef VBINSTST_CAN_DO_TRAPS
179
180;;
181; Report a missing TRAP.
182;
183; Primary purpose is save all registers and convert from our stack-based to
184; the correct calling convention for the environment.
185;
186; This function will clean up the stack upon return (to save space in the caller).
187;
188; @param uExpected
189;
190VBINSTST_BEGINPROC Common_MissingTrap
191 MY_PUSH_ALL
192 mov xAX, xSP ; 16-byte align the stack and reserve space for arguments and stuff.
193 sub xSP, 40h
194 and xSP, ~15
195 mov [xSP + 38h], xAX
196
197 %ifdef ASM_CALL64_GCC
198 mov rdx, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator) wrt rip]
199 movzx rsi, byte [rbp + 10h] ; expected
200 lea rdi, [.szFmt wrt rip]
201 VBINSTST_CALL_FN_FAILURE_2
202
203 %elifdef ASM_CALL64_MSC
204 mov r8d, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator) wrt rip]
205 movzx rdx, byte [rbp + 10h] ; expected
206 lea rcx, [.szFmt wrt rip]
207 VBINSTST_CALL_FN_FAILURE_2
208
209 %elifdef ASM_CALL64_BS2
210 mov sBX, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator) xWrtRIP]
211 mov sDX, [xBP + xCB + xCB] ; expected
212 lea sSI, [.szFmt xWrtRIP]
213 mov qword [xSP + xCB + 1*sCB], sBX
214 mov qword [xSP + xCB], sDX
215 mov [xSP], sSI
216 VBINSTST_CALL_FN_FAILURE_2
217
218 %else
219 mov sBX, [VBINSTST_NAME(g_uVBInsTstSubTestIndicator)]
220 mov sDX, [xBP + xCB + xCB] ; expected
221 mov [xSP + xCB + 1*sCB], sBX
222 mov [xSP + xCB], sDX
223 mov [xSP], RTCCPTR_PRE .szFmt
224 VBINSTST_CALL_FN_FAILURE_2
225 %endif
226
227 mov xSP, [xSP + 38h]
228 MY_POP_ALL
229 ret 1*sCB
230 %if ARCH_BITS == 64
231.szFmt: db 'Missing trap %RX8 (line %RU64)', 13, 0
232 %else
233.szFmt: db 'Missing trap %RX8 (line %RU32)', 13, 0
234 %endif
235VBINSTST_ENDPROC Common_MissingTrap
236
237 %macro Common_MissingTrapTemplate 1
238 VBINSTST_BEGINPROC Common_MissingTrap_%1
239 push %1
240 call VBINSTST_NAME(Common_MissingTrap)
241 ret
242 VBINSTST_ENDPROC Common_MissingTrap_%1
243 %endmacro
244 Common_MissingTrapTemplate X86_XCPT_DE
245 Common_MissingTrapTemplate X86_XCPT_DB
246 Common_MissingTrapTemplate X86_XCPT_NMI
247 Common_MissingTrapTemplate X86_XCPT_BP
248 Common_MissingTrapTemplate X86_XCPT_OF
249 Common_MissingTrapTemplate X86_XCPT_BR
250 Common_MissingTrapTemplate X86_XCPT_UD
251 Common_MissingTrapTemplate X86_XCPT_NM
252 ;Common_MissingTrapTemplate X86_XCPT_DF
253 ;Common_MissingTrapTemplate X86_XCPT_CO_SEG_OVERRUN
254 Common_MissingTrapTemplate X86_XCPT_TS
255 Common_MissingTrapTemplate X86_XCPT_NP
256 Common_MissingTrapTemplate X86_XCPT_SS
257 Common_MissingTrapTemplate X86_XCPT_GP
258 Common_MissingTrapTemplate X86_XCPT_PF
259 Common_MissingTrapTemplate X86_XCPT_MF
260 Common_MissingTrapTemplate X86_XCPT_AC
261 ;Common_MissingTrapTemplate X86_XCPT_MC
262 Common_MissingTrapTemplate X86_XCPT_XF
263
264%endif ; VBINSTST_CAN_DO_TRAPS
265
266
267;
268; Global data variables used by Common_SetupMemReadUxx.
269; For address calculation reasons, these must be qword aligned.
270;
271VBINSTST_BEGINDATA
272 align 64
273 dd 09d8af498h, 09ab3e5f8h
274VBINSTST_GLOBALNAME_EX g_u64Data, data hidden
275 dq 0
276 dd 07d7af797h, 096b36562h
277VBINSTST_GLOBALNAME_EX g_u32Data, data hidden
278 dd 0
279 dd 012305987h
280VBINSTST_GLOBALNAME_EX g_u16Data, data hidden
281 dw 0
282 dw 05865h
283 dw 03863h
284 dw 02679h
285VBINSTST_GLOBALNAME_EX g_u8Data, data hidden
286 db 0
287 db 90h
288 dw 0865ah
289 dd 058daffe2h
290
291VBINSTST_BEGINCODE
292
293;;
294; Sets up g_u8Data.
295; @param uValue
296VBINSTST_BEGINPROC Common_SetupMemReadU8
297 push sAX
298 mov ax, [xSP + sCB + xCB]
299 mov [VBINSTST_NAME(g_u8Data) xWrtRIP], ax
300 pop sAX
301 ret sCB
302VBINSTST_ENDPROC Common_SetupMemReadU8
303
304;;
305; Sets up g_u16Data.
306; @param uValue
307VBINSTST_BEGINPROC Common_SetupMemReadU16
308 push sAX
309 mov ax, [xSP + sCB + xCB]
310 mov [VBINSTST_NAME(g_u16Data) xWrtRIP], ax
311 pop sAX
312 ret sCB
313VBINSTST_ENDPROC Common_SetupMemReadU16
314
315;;
316; Sets up g_u32Data.
317; @param uValue
318VBINSTST_BEGINPROC Common_SetupMemReadU32
319 push sAX
320 mov eax, [xSP + sCB + xCB]
321 mov [VBINSTST_NAME(g_u32Data) xWrtRIP], eax
322 pop sAX
323 ret sCB
324VBINSTST_ENDPROC Common_SetupMemReadU32
325
326;;
327; Sets up g_u64Data.
328; @param uValue
329VBINSTST_BEGINPROC Common_SetupMemReadU64
330 push sAX
331%ifdef RT_ARCH_AMD64
332 mov rax, [xSP + sCB + xCB]
333 mov [VBINSTST_NAME(g_u64Data) xWrtRIP], rax
334%else
335 mov eax, [xSP + sCB + xCB]
336 mov [VBINSTST_NAME(g_u64Data) xWrtRIP], eax
337 mov eax, [xSP + sCB + xCB + 4]
338 mov [VBINSTST_NAME(g_u64Data) + 4 xWrtRIP], eax
339%endif
340 pop sAX
341 ret sCB
342VBINSTST_ENDPROC Common_SetupMemReadU64
343
344
345%endif
346
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