1 | ; $Id: SUPLibTracerA.asm 96407 2022-08-22 17:43:14Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; VirtualBox Support Library - Tracer Interface, Assembly bits.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2012-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 | ;* Header Files *
|
---|
39 | ;*******************************************************************************
|
---|
40 | %include "iprt/asmdefs.mac"
|
---|
41 | %include "VBox/sup.mac"
|
---|
42 |
|
---|
43 | ; This should go into asmdefs.mac
|
---|
44 | %ifdef PIC
|
---|
45 | %ifdef ASM_FORMAT_ELF
|
---|
46 | %define RT_ASM_USE_GOT
|
---|
47 | %define RT_ASM_USE_PLT
|
---|
48 | %endif
|
---|
49 | %endif
|
---|
50 |
|
---|
51 |
|
---|
52 | ;*******************************************************************************
|
---|
53 | ;* Structures and Typedefs *
|
---|
54 | ;*******************************************************************************
|
---|
55 | struc SUPREQHDR
|
---|
56 | .u32Cookie resd 1
|
---|
57 | .u32SessionCookie resd 1
|
---|
58 | .cbIn resd 1
|
---|
59 | .cbOut resd 1
|
---|
60 | .fFlags resd 1
|
---|
61 | .rc resd 1
|
---|
62 | endstruc
|
---|
63 |
|
---|
64 | struc SUPTRACERUMODFIREPROBE
|
---|
65 | .Hdr resb SUPREQHDR_size
|
---|
66 | .In resb SUPDRVTRACERUSRCTX64_size
|
---|
67 | endstruc
|
---|
68 |
|
---|
69 |
|
---|
70 | extern NAME(suplibTracerFireProbe)
|
---|
71 |
|
---|
72 |
|
---|
73 | BEGINCODE
|
---|
74 |
|
---|
75 |
|
---|
76 | ;;
|
---|
77 | ; Set up a SUPTRACERUMODFIREPROBE request package on the stack and a C helper
|
---|
78 | ; function in SUPLib.cpp to do the rest.
|
---|
79 | ;
|
---|
80 | EXPORTEDNAME SUPTracerFireProbe
|
---|
81 | push xBP
|
---|
82 | mov xBP, xSP
|
---|
83 |
|
---|
84 | ;
|
---|
85 | ; Allocate package and set the sizes (the helper does the rest of
|
---|
86 | ; the header). Setting the sizes here allows the helper to verify our
|
---|
87 | ; idea of the request sizes.
|
---|
88 | ;
|
---|
89 | lea xSP, [xBP - SUPTRACERUMODFIREPROBE_size - 8]
|
---|
90 |
|
---|
91 | mov dword [xSP + SUPTRACERUMODFIREPROBE.Hdr + SUPREQHDR.cbIn], SUPTRACERUMODFIREPROBE_size
|
---|
92 | mov dword [xSP + SUPTRACERUMODFIREPROBE.Hdr + SUPREQHDR.cbOut], SUPREQHDR_size
|
---|
93 |
|
---|
94 | %ifdef RT_ARCH_AMD64
|
---|
95 | ;
|
---|
96 | ; Save the AMD64 context.
|
---|
97 | ;
|
---|
98 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.rax], rax
|
---|
99 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.rcx], rcx
|
---|
100 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.rdx], rdx
|
---|
101 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.rbx], rbx
|
---|
102 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.rsi], rsi
|
---|
103 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.rdi], rdi
|
---|
104 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.r8 ], r8
|
---|
105 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.r9 ], r9
|
---|
106 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.r10], r10
|
---|
107 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.r11], r11
|
---|
108 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.r12], r12
|
---|
109 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.r13], r13
|
---|
110 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.r14], r14
|
---|
111 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.r15], r15
|
---|
112 | pushf
|
---|
113 | pop xAX
|
---|
114 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.rflags], xAX
|
---|
115 | mov xAX, [xBP + xCB]
|
---|
116 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.rip], xAX
|
---|
117 | mov xAX, [xBP]
|
---|
118 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.rbp], xAX
|
---|
119 | lea xAX, [xBP + xCB*2]
|
---|
120 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.rsp], xAX
|
---|
121 | %ifdef ASM_CALL64_MSC
|
---|
122 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.uVtgProbeLoc], rcx
|
---|
123 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*0], rdx
|
---|
124 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*1], r8
|
---|
125 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*2], r9
|
---|
126 | mov xAX, [xBP + xCB*2 + 0x20 + xCB*0]
|
---|
127 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*3], xAX
|
---|
128 | mov xAX, [xBP + xCB*2 + 0x20 + xCB*1]
|
---|
129 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*4], xAX
|
---|
130 | mov xAX, [xBP + xCB*2 + 0x20 + xCB*2]
|
---|
131 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*5], xAX
|
---|
132 | mov xAX, [xBP + xCB*2 + 0x20 + xCB*3]
|
---|
133 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*6], xAX
|
---|
134 | mov xAX, [xBP + xCB*2 + 0x20 + xCB*4]
|
---|
135 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*7], xAX
|
---|
136 | mov xAX, [xBP + xCB*2 + 0x20 + xCB*5]
|
---|
137 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*8], xAX
|
---|
138 | mov xAX, [xBP + xCB*2 + 0x20 + xCB*6]
|
---|
139 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*9], xAX
|
---|
140 | mov eax, [xCX + 4] ; VTGPROBELOC::idProbe.
|
---|
141 | %else
|
---|
142 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.uVtgProbeLoc], rdi
|
---|
143 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*0], rsi
|
---|
144 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*1], rdx
|
---|
145 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*2], rcx
|
---|
146 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*3], r8
|
---|
147 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*4], r9
|
---|
148 | mov xAX, [xBP + xCB*2 + xCB*0]
|
---|
149 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*5], xAX
|
---|
150 | mov xAX, [xBP + xCB*2 + xCB*1]
|
---|
151 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*6], xAX
|
---|
152 | mov xAX, [xBP + xCB*2 + xCB*2]
|
---|
153 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*7], xAX
|
---|
154 | mov xAX, [xBP + xCB*2 + xCB*3]
|
---|
155 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*8], xAX
|
---|
156 | mov xAX, [xBP + xCB*2 + xCB*4]
|
---|
157 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.u.Amd64.aArgs + xCB*9], xAX
|
---|
158 | mov eax, [xDI + 4] ; VTGPROBELOC::idProbe.
|
---|
159 | %endif
|
---|
160 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.idProbe], eax
|
---|
161 | mov dword [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX64.cBits], 64
|
---|
162 |
|
---|
163 | ;
|
---|
164 | ; Call the helper.
|
---|
165 | ;
|
---|
166 | %ifdef ASM_CALL64_MSC
|
---|
167 | mov xDX, xSP
|
---|
168 | sub xSP, 0x20
|
---|
169 | call NAME(suplibTracerFireProbe)
|
---|
170 | %else
|
---|
171 | mov xSI, xSP
|
---|
172 | %ifdef RT_ASM_USE_PLT
|
---|
173 | call NAME(suplibTracerFireProbe) wrt ..plt
|
---|
174 | %else
|
---|
175 | call NAME(suplibTracerFireProbe)
|
---|
176 | %endif
|
---|
177 | %endif
|
---|
178 |
|
---|
179 | %elifdef RT_ARCH_X86
|
---|
180 | ;
|
---|
181 | ; Save the X86 context.
|
---|
182 | ;
|
---|
183 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.u.X86.eax], eax
|
---|
184 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.u.X86.ecx], ecx
|
---|
185 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.u.X86.edx], edx
|
---|
186 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.u.X86.ebx], ebx
|
---|
187 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.u.X86.esi], esi
|
---|
188 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.u.X86.edi], edi
|
---|
189 | pushf
|
---|
190 | pop xAX
|
---|
191 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.u.X86.eflags], xAX
|
---|
192 | mov xAX, [xBP + xCB]
|
---|
193 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.u.X86.eip], xAX
|
---|
194 | mov xAX, [xBP]
|
---|
195 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.u.X86.ebp], xAX
|
---|
196 | lea xAX, [xBP + xCB*2]
|
---|
197 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.u.X86.esp], xAX
|
---|
198 |
|
---|
199 | mov xCX, [xBP + xCB*2 + xCB*0]
|
---|
200 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.u.X86.uVtgProbeLoc], xCX ; keep, used below.
|
---|
201 |
|
---|
202 | mov edx, 20
|
---|
203 | .more:
|
---|
204 | dec edx
|
---|
205 | mov xAX, [xBP + xCB*2 + xCB*xDX]
|
---|
206 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.u.X86.aArgs + xCB*xDX], xAX
|
---|
207 | jnz .more
|
---|
208 |
|
---|
209 | mov eax, [xCX + 4] ; VTGPROBELOC::idProbe.
|
---|
210 | mov [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.idProbe], eax
|
---|
211 | mov dword [xSP + SUPTRACERUMODFIREPROBE.In + SUPDRVTRACERUSRCTX32.cBits], 32
|
---|
212 |
|
---|
213 | ;
|
---|
214 | ; Call the helper.
|
---|
215 | ;
|
---|
216 | mov xDX, xSP
|
---|
217 | push xDX
|
---|
218 | push xCX
|
---|
219 | %ifdef RT_ASM_USE_PLT
|
---|
220 | call NAME(suplibTracerFireProbe) wrt ..plt
|
---|
221 | %else
|
---|
222 | call NAME(suplibTracerFireProbe)
|
---|
223 | %endif
|
---|
224 | %else
|
---|
225 | %error "Arch not supported (or correctly defined)."
|
---|
226 | %endif
|
---|
227 |
|
---|
228 |
|
---|
229 | leave
|
---|
230 | ret
|
---|
231 | ENDPROC SUPTracerFireProbe
|
---|
232 |
|
---|