VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR3/PGMR3DbgA.asm@ 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: 14.2 KB
Line 
1; $Id: PGMR3DbgA.asm 69111 2017-10-17 14:26:02Z vboxsync $
2;; @file
3; PGM - Page Manager and Monitor - Debugger & Debugging API Optimizations.
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
19;*******************************************************************************
20;* Header Files *
21;*******************************************************************************
22%define RT_ASM_WITH_SEH64
23%include "VBox/asmdefs.mac"
24
25BEGINCODE ;; Doesn't end up in code seg on 64-bit darwin. weird.
26
27
28;
29; Common to all code below.
30;
31%ifdef ASM_CALL64_MSC
32 %define pvNeedle r8
33 %define cbNeedle r9d
34 %define bTmp dl
35%elifdef ASM_CALL64_GCC
36 %define pvNeedle rdx
37 %define cbNeedle esi
38 %define bTmp r9b
39%elifdef RT_ARCH_X86
40 %define pvNeedle dword [esp + 8h]
41 %define cbNeedle dword [esp + 10h]
42%else
43 %error "Unsupported arch!"
44%endif
45
46;;
47; Searches for a 8 byte needle in steps of 8.
48;
49; In 32-bit mode, this will only actually search for a 8 byte needle.
50;
51; @param pbHaystack [msc:rcx, gcc:rdi, x86:ebp+08h] What to search thru.
52; @param cbHaystack [msc:edx, gcc:rsi, x86:ebp+0ch] The amount of hay to search.
53; @param pvNeedle [msc:r8, gcc:rdx, x86:ebp+10h] What we're searching for
54; @param cbNeedle [msc:r9, gcc:rcx, x86:esp+10h] Size of what we're searcing for. Currently ignored.
55;
56; @remarks ASSUMES pbHaystack is aligned at uAlign.
57;
58BEGINPROC pgmR3DbgFixedMemScan8Wide8Step
59%ifdef ASM_CALL64_MSC
60 mov r10, rdi ; save it
61 mov rdi, rcx ; rdi=pbHaystack
62 mov ecx, edx ; rcx=cbHaystack
63 mov rax, [r8] ; *(uint64_t *)pvNeedle
64%elifdef ASM_CALL64_GCC
65 xchg rcx, rsi ; rcx=cbHaystack, rsi=cbNeedle
66 mov rax, [rdx] ; *(uint64_t *)pvNeedle
67%elifdef RT_ARCH_X86
68 push ebp
69 mov ebp, esp
70 push edi ; save it
71 mov edi, [ebp + 08h] ; pbHaystack
72 mov ecx, [ebp + 0ch] ; cbHaystack
73 mov eax, [ebp + 10h] ; pvNeedle
74 mov edx, [eax + 4] ; ((uint32_t *)pvNeedle)[1]
75 mov eax, [eax] ; ((uint32_t *)pvNeedle)[0]
76%else
77 %error "Unsupported arch!"
78%endif
79SEH64_END_PROLOGUE
80
81%ifdef RT_ARCH_X86
82 ;
83 ; No string instruction to help us here. Do a simple tight loop instead.
84 ;
85 shr ecx, 3
86 jz .return_null
87.again:
88 cmp [edi], eax
89 je .needle_check
90.continue:
91 add edi, 8
92 dec ecx
93 jnz .again
94 jmp .return_null
95
96 ; Check the needle 2nd dword, caller can do the rest.
97.needle_check:
98 cmp edx, [edi + 4]
99 jne .continue
100
101.return_edi:
102 mov eax, edi
103
104%else ; RT_ARCH_AMD64
105 cmp ecx, 8
106 jb .return_null
107.continue:
108 shr ecx, 3
109 repne scasq
110 jne .return_null
111 ; check more of the needle if we can.
112 mov r11d, 8
113 shl ecx, 3
114.needle_check:
115 cmp cbNeedle, r11d
116 je .return_edi
117 cmp ecx, r11d
118 jb .return_edi ; returns success here as we've might've lost stuff while shifting ecx around.
119 mov bTmp, [pvNeedle + r11]
120 cmp bTmp, [xDI + r11 - 8]
121 jne .continue
122 inc r11d
123 jmp .needle_check
124
125.return_edi:
126 lea xAX, [xDI - 8]
127%endif ; RT_ARCH_AMD64
128
129.return:
130%ifdef ASM_CALL64_MSC
131 mov rdi, r10
132%elifdef RT_ARCH_X86
133 pop edi
134 leave
135%endif
136 ret
137
138.return_null:
139 xor eax, eax
140 jmp .return
141ENDPROC pgmR3DbgFixedMemScan8Wide8Step
142
143
144;;
145; Searches for a 4 byte needle in steps of 4.
146;
147; @param pbHaystack [msc:rcx, gcc:rdi, x86:esp+04h] What to search thru.
148; @param cbHaystack [msc:edx, gcc:rsi, x86:esp+08h] The amount of hay to search.
149; @param pvNeedle [msc:r8, gcc:rdx, x86:esp+0ch] What we're searching for
150; @param cbNeedle [msc:r9, gcc:rcx, x86:esp+10h] Size of what we're searcing for. Currently ignored.
151;
152; @remarks ASSUMES pbHaystack is aligned at uAlign.
153;
154BEGINPROC pgmR3DbgFixedMemScan4Wide4Step
155%ifdef ASM_CALL64_MSC
156 mov r10, rdi ; save it
157 mov rdi, rcx ; rdi=pbHaystack
158 mov ecx, edx ; rcx=cbHaystack
159 mov eax, [r8] ; *(uint32_t *)pvNeedle
160%elifdef ASM_CALL64_GCC
161 xchg rcx, rsi ; rcx=cbHaystack, rsi=cbNeedle
162 mov eax, [rdx] ; *(uint32_t *)pvNeedle
163%elifdef RT_ARCH_X86
164 mov edx, edi ; save it
165 mov edi, [esp + 04h] ; pbHaystack
166 mov ecx, [esp + 08h] ; cbHaystack
167 mov eax, [esp + 0ch] ; pvNeedle
168 mov eax, [eax] ; *(uint32_t *)pvNeedle
169%else
170 %error "Unsupported arch!"
171%endif
172SEH64_END_PROLOGUE
173
174.continue:
175 cmp ecx, 4
176 jb .return_null
177 shr ecx, 2
178 repne scasd
179 jne .return_null
180
181%ifdef RT_ARCH_AMD64
182 ; check more of the needle if we can.
183 mov r11d, 4
184.needle_check:
185 cmp cbNeedle, r11d
186 je .return_edi
187 cmp ecx, r11d ; don't bother converting ecx to bytes.
188 jb .return_edi
189 mov bTmp, [pvNeedle + r11]
190 cmp bTmp, [xDI + r11 - 4]
191 jne .continue
192 inc r11d
193 jmp .needle_check
194%endif
195
196.return_edi:
197 lea xAX, [xDI - 4]
198.return:
199%ifdef ASM_CALL64_MSC
200 mov rdi, r10
201%elifdef RT_ARCH_X86
202 mov edi, edx
203%endif
204 ret
205
206.return_null:
207 xor eax, eax
208 jmp .return
209ENDPROC pgmR3DbgFixedMemScan4Wide4Step
210
211
212;;
213; Searches for a 2 byte needle in steps of 2.
214;
215; @param pbHaystack [msc:rcx, gcc:rdi, x86:esp+04h] What to search thru.
216; @param cbHaystack [msc:edx, gcc:rsi, x86:esp+08h] The amount of hay to search.
217; @param pvNeedle [msc:r8, gcc:rdx, x86:esp+0ch] What we're searching for
218; @param cbNeedle [msc:r9, gcc:rcx, x86:esp+10h] Size of what we're searcing for. Currently ignored.
219;
220; @remarks ASSUMES pbHaystack is aligned at uAlign.
221;
222BEGINPROC pgmR3DbgFixedMemScan2Wide2Step
223%ifdef ASM_CALL64_MSC
224 mov r10, rdi ; save it
225 mov rdi, rcx ; rdi=pbHaystack
226 mov ecx, edx ; rcx=cbHaystack
227 mov ax, [r8] ; *(uint16_t *)pvNeedle
228%elifdef ASM_CALL64_GCC
229 xchg rcx, rsi ; rcx=cbHaystack, rsi=cbNeedle
230 mov ax, [rdx] ; *(uint16_t *)pvNeedle
231%elifdef RT_ARCH_X86
232 mov edx, edi ; save it
233 mov edi, [esp + 04h] ; pbHaystack
234 mov ecx, [esp + 08h] ; cbHaystack
235 mov eax, [esp + 0ch] ; pvNeedle
236 mov ax, [eax] ; *(uint16_t *)pvNeedle
237%else
238 %error "Unsupported arch!"
239%endif
240SEH64_END_PROLOGUE
241
242.continue:
243 cmp ecx, 2
244 jb .return_null
245 shr ecx, 1
246 repne scasw
247 jne .return_null
248
249%ifdef RT_ARCH_AMD64
250 ; check more of the needle if we can.
251 mov r11d, 2
252.needle_check:
253 cmp cbNeedle, r11d
254 je .return_edi
255 cmp ecx, r11d ; don't bother converting ecx to bytes.
256 jb .return_edi
257 mov bTmp, [pvNeedle + r11]
258 cmp bTmp, [xDI + r11 - 2]
259 jne .continue
260 inc r11d
261 jmp .needle_check
262%endif
263
264.return_edi:
265 lea xAX, [xDI - 2]
266.return:
267%ifdef ASM_CALL64_MSC
268 mov rdi, r10
269%elifdef RT_ARCH_X86
270 mov edi, edx
271%endif
272 ret
273
274.return_null:
275 xor eax, eax
276 jmp .return
277ENDPROC pgmR3DbgFixedMemScan2Wide2Step
278
279
280;;
281; Searches for a 1 byte needle in steps of 1.
282;
283; @param pbHaystack [msc:rcx, gcc:rdi, x86:esp+04h] What to search thru.
284; @param cbHaystack [msc:edx, gcc:rsi, x86:esp+08h] The amount of hay to search.
285; @param pvNeedle [msc:r8, gcc:rdx, x86:esp+0ch] What we're searching for
286; @param cbNeedle [msc:r9, gcc:rcx, x86:esp+10h] Size of what we're searcing for. Currently ignored.
287;
288BEGINPROC pgmR3DbgFixedMemScan1Wide1Step
289%ifdef ASM_CALL64_MSC
290 mov r10, rdi ; save it
291 mov rdi, rcx ; rdi=pbHaystack
292 mov ecx, edx ; rcx=cbHaystack
293 mov al, [r8] ; *(uint8_t *)pvNeedle
294%elifdef ASM_CALL64_GCC
295 xchg rcx, rsi ; rcx=cbHaystack, rsi=cbNeedle
296 mov al, [rdx] ; *(uint8_t *)pvNeedle
297%elifdef RT_ARCH_X86
298 mov edx, edi ; save it
299 mov edi, [esp + 04h] ; pbHaystack
300 mov ecx, [esp + 08h] ; cbHaystack
301 mov eax, [esp + 0ch] ; pvNeedle
302 mov al, [eax] ; *(uint8_t *)pvNeedle
303%else
304 %error "Unsupported arch!"
305%endif
306SEH64_END_PROLOGUE
307
308 cmp ecx, 1
309 jb .return_null
310.continue:
311 repne scasb
312 jne .return_null
313
314%ifdef RT_ARCH_AMD64
315 ; check more of the needle if we can.
316 mov r11d, 1
317.needle_check:
318 cmp cbNeedle, r11d
319 je .return_edi
320 cmp ecx, r11d
321 jb .return_edi
322 mov bTmp, [pvNeedle + r11]
323 cmp bTmp, [xDI + r11 - 1]
324 jne .continue
325 inc r11d
326 jmp .needle_check
327%endif
328
329.return_edi:
330 lea xAX, [xDI - 1]
331.return:
332%ifdef ASM_CALL64_MSC
333 mov rdi, r10
334%elifdef RT_ARCH_X86
335 mov edi, edx
336%endif
337 ret
338
339.return_null:
340 xor eax, eax
341%ifdef ASM_CALL64_MSC
342 mov rdi, r10
343%elifdef RT_ARCH_X86
344 mov edi, edx
345%endif
346 ret
347ENDPROC pgmR3DbgFixedMemScan1Wide1Step
348
349
350;;
351; Searches for a 4 byte needle in steps of 1.
352;
353; @param pbHaystack [msc:rcx, gcc:rdi, x86:esp+04h] What to search thru.
354; @param cbHaystack [msc:edx, gcc:rsi, x86:esp+08h] The amount of hay to search.
355; @param pvNeedle [msc:r8, gcc:rdx, x86:esp+0ch] What we're searching for
356; @param cbNeedle [msc:r9, gcc:rcx, x86:esp+10h] Size of what we're searcing for. Currently ignored.
357;
358BEGINPROC pgmR3DbgFixedMemScan4Wide1Step
359%ifdef ASM_CALL64_MSC
360 mov r10, rdi ; save it
361 mov rdi, rcx ; rdi=pbHaystack
362 mov ecx, edx ; rcx=cbHaystack
363 mov eax, [r8] ; *(uint32_t *)pvNeedle
364%elifdef ASM_CALL64_GCC
365 xchg rcx, rsi ; rcx=cbHaystack, rsi=cbNeedle
366 mov eax, [rdx] ; *(uint32_t *)pvNeedle
367%elifdef RT_ARCH_X86
368 mov edx, edi ; save it
369 mov edi, [esp + 04h] ; pbHaystack
370 mov ecx, [esp + 08h] ; cbHaystack
371 mov eax, [esp + 0ch] ; pvNeedle
372 mov eax, [eax] ; *(uint32_t *)pvNeedle
373%else
374 %error "Unsupported arch!"
375%endif
376SEH64_END_PROLOGUE
377
378 cmp ecx, 1
379 jb .return_null
380.continue:
381 repne scasb
382 jne .return_null
383 cmp ecx, 3
384 jb .return_null
385 cmp eax, [xDI - 1]
386 jne .continue
387
388.return_edi:
389 lea xAX, [xDI - 1]
390.return:
391%ifdef ASM_CALL64_MSC
392 mov rdi, r10
393%elifdef RT_ARCH_X86
394 mov edi, edx
395%endif
396 ret
397
398.return_null:
399 xor eax, eax
400%ifdef ASM_CALL64_MSC
401 mov rdi, r10
402%elifdef RT_ARCH_X86
403 mov edi, edx
404%endif
405 ret
406ENDPROC pgmR3DbgFixedMemScan4Wide1Step
407
408;;
409; Searches for a 8 byte needle in steps of 1.
410;
411; @param pbHaystack [msc:rcx, gcc:rdi, x86:esp+04h] What to search thru.
412; @param cbHaystack [msc:edx, gcc:rsi, x86:esp+08h] The amount of hay to search.
413; @param pvNeedle [msc:r8, gcc:rdx, x86:esp+0ch] What we're searching for
414; @param cbNeedle [msc:r9, gcc:rcx, x86:esp+10h] Size of what we're searcing for. Currently ignored.
415;
416; @remarks The 32-bit version is currently identical to pgmR3DbgFixedMemScan4Wide1Step.
417;
418BEGINPROC pgmR3DbgFixedMemScan8Wide1Step
419%ifdef ASM_CALL64_MSC
420 mov r10, rdi ; save it
421 mov rdi, rcx ; rdi=pbHaystack
422 mov ecx, edx ; rcx=cbHaystack
423 mov rax, [r8] ; *(uint64_t *)pvNeedle
424%elifdef ASM_CALL64_GCC
425 xchg rcx, rsi ; rcx=cbHaystack, rsi=cbNeedle
426 mov rax, [rdx] ; *(uint64_t *)pvNeedle
427%elifdef RT_ARCH_X86
428 mov edx, edi ; save it
429 mov edi, [esp + 04h] ; pbHaystack
430 mov ecx, [esp + 08h] ; cbHaystack
431 mov eax, [esp + 0ch] ; pvNeedle
432 mov eax, [eax] ; *(uint32_t *)pvNeedle
433%else
434 %error "Unsupported arch!"
435%endif
436SEH64_END_PROLOGUE
437
438 cmp ecx, 1
439 jb .return_null
440.continue:
441 repne scasb
442 jne .return_null
443%ifdef RT_ARCH_AMD64
444 cmp ecx, 7
445 jb .check_smaller
446 cmp rax, [xDI - 1]
447 jne .continue
448 jmp .return_edi
449.check_smaller:
450%endif
451 cmp ecx, 3
452 jb .return_null
453 cmp eax, [xDI - 1]
454 jne .continue
455
456.return_edi:
457 lea xAX, [xDI - 1]
458.return:
459%ifdef ASM_CALL64_MSC
460 mov rdi, r10
461%elifdef RT_ARCH_X86
462 mov edi, edx
463%endif
464 ret
465
466.return_null:
467 xor eax, eax
468%ifdef ASM_CALL64_MSC
469 mov rdi, r10
470%elifdef RT_ARCH_X86
471 mov edi, edx
472%endif
473 ret
474ENDPROC pgmR3DbgFixedMemScan8Wide1Step
475
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