Changeset 14672 in vbox for trunk/src/VBox/VMM/VMMR0
- Timestamp:
- Nov 27, 2008 12:19:22 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 39982
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/VMMR0A.asm
r14505 r14672 30 30 %ifdef RT_ARCH_X86 ; The other architecture(s) use(s) C99 variadict macros. 31 31 extern IMPNAME(RTLogLogger) 32 %endif 33 34 %ifdef RT_OS_DARWIN 35 %define VMM_R0_SWITCH_STACK 32 36 %endif 33 37 … … 71 75 jnz .resume 72 76 77 mov ebx, edx ; pJmpBuf -> ebx (persistent reg) 78 %ifdef VMM_R0_SWITCH_STACK 79 mov esi, [ebx + VMMR0JMPBUF.pvSavedStack] 80 test esi, esi 81 jz .entry_error 82 %ifdef VBOX_STRICT 83 mov edx, esi 84 mov edi, esi 85 mov ecx, 2048 86 mov eax, 0eeeeeeeeh 87 repne stosd 88 %endif 89 lea esi, [esi + 8192 - 32] 90 mov [esi + 1ch], dword 0deadbeefh ; Marker 1. 91 mov [esi + 18h], ebx ; Save pJmpBuf pointer. 92 mov [esi + 14h], dword 00c00ffeeh ; Marker 2. 93 mov [esi + 10h], dword 0f00dbeefh ; Marker 3. 94 mov edx, [esp + 10h] ; pvArg2 95 mov [esi + 04h], edx 96 mov ecx, [esp + 0ch] ; pvArg1 97 mov [esi ], ecx 98 mov eax, [esp + 08h] ; pfn 99 mov esp, esi ; Switch stack! 100 call eax 101 and dword [esi + 1ch], byte 0 ; clear marker. 102 103 %else ; !VMM_R0_SWITCH_STACK 73 104 mov ecx, [esp + 0ch] ; pvArg1 74 105 mov edx, [esp + 10h] ; pvArg2 75 106 mov eax, [esp + 08h] ; pfn 76 sub esp, 1 6; align the stack on a 16-byte boundrary.77 mov [esp ], ecx78 mov [esp +4], edx107 sub esp, 12 ; align the stack on a 16-byte boundrary. 108 mov [esp ], ecx 109 mov [esp + 04h], edx 79 110 call eax 80 add esp, 16 81 mov edx, [esp + 4h] ; pJmpBuf 82 83 ; restore the registers that we're not allowed to modify 84 ; otherwise a resume might restore the wrong values (from the previous run) 111 %endif ; !VMM_R0_SWITCH_STACK 112 mov edx, ebx ; pJmpBuf -> edx (volatile reg) 113 114 ; 115 ; Return like in the long jump. 116 ; (It is vital that we restore all registers since they might've changed 117 ; by a long jump.) 118 ; 119 .proper_return: 120 mov ebx, [edx + VMMR0JMPBUF.ebx] 121 mov esi, [edx + VMMR0JMPBUF.esi] 85 122 mov edi, [edx + VMMR0JMPBUF.edi] 86 mov esi, [edx + VMMR0JMPBUF.esi]87 mov ebx, [edx + VMMR0JMPBUF.ebx]88 123 mov ebp, [edx + VMMR0JMPBUF.ebp] 89 124 mov ecx, [edx + VMMR0JMPBUF.eip] 90 125 and dword [edx + VMMR0JMPBUF.eip], byte 0 ; used for valid check. 91 ret 126 mov esp, [edx + VMMR0JMPBUF.esp] 127 jmp ecx 128 129 .entry_error: 130 mov eax, VERR_INTERNAL_ERROR 131 jmp .proper_return 92 132 93 133 ; … … 95 135 ; 96 136 .resume: 137 %ifdef VMM_R0_SWITCH_STACK 138 ; Switch stack. 139 mov esp, [edx + VMMR0JMPBUF.SpResume] 140 %else ; !VMM_R0_SWITCH_STACK 97 141 ; Sanity checks. 98 142 cmp ecx, [edx + VMMR0JMPBUF.SpCheck] … … 120 164 ; Restore the stack. 121 165 ; 122 mov byte [edx + VMMR0JMPBUF.fInRing3Call], 0123 166 mov ecx, [edx + VMMR0JMPBUF.cbSavedStack] 124 167 shr ecx, 2 … … 127 170 mov esp, edi 128 171 rep movsd 172 %endif ; !VMM_R0_SWITCH_STACK 173 mov byte [edx + VMMR0JMPBUF.fInRing3Call], 0 129 174 130 175 ; 131 176 ; Continue where we left off. 132 177 ; 178 %ifdef VBOX_STRICT 179 pop eax ; magic 180 cmp eax, 0f00dbed0h 181 je .magic_ok 182 mov ecx, 0123h 183 mov [ecx], edx 184 .magic_ok: 185 %endif 133 186 popf 134 187 pop ebx … … 288 341 push ebx 289 342 pushf 343 %ifdef VBOX_STRICT 344 push dword 0f00dbed0h 345 %endif 290 346 291 347 ; … … 302 358 303 359 ; 304 ; Sa ve the stack.360 ; Sanity checks. 305 361 ; 306 362 mov edi, [edx + VMMR0JMPBUF.pvSavedStack] … … 308 364 jz .nok 309 365 mov [edx + VMMR0JMPBUF.SpResume], esp 366 %ifndef VMM_R0_SWITCH_STACK 310 367 mov esi, esp 311 368 mov ecx, [edx + VMMR0JMPBUF.esp] … … 314 371 ; two sanity checks on the size. 315 372 cmp ecx, 8192 ; check max size. 316 jbe .ok 317 .nok: 318 mov eax, VERR_INTERNAL_ERROR 319 popf 320 pop ebx 321 pop esi 322 pop edi 323 leave 324 ret 325 .ok: 373 jnbe .nok 374 375 ; 376 ; Copy the stack. 377 ; 326 378 test ecx, 3 ; check alignment 327 379 jnz .nok … … 329 381 shr ecx, 2 330 382 rep movsd 383 %endif ; !VMM_R0_SWITCH_STACK 331 384 332 385 ; store the last pieces of info. … … 345 398 mov esp, [edx + VMMR0JMPBUF.esp] 346 399 jmp ecx 400 401 ; 402 ; Failure 403 ; 404 .nok: 405 %ifdef VBOX_STRICT 406 pop eax ; magic 407 cmp eax, 0f00dbed0h 408 je .magic_ok 409 mov ecx, 0123h 410 mov [ecx], edx 411 .magic_ok: 412 %endif 413 popf 414 pop ebx 415 pop esi 416 pop edi 417 mov eax, VERR_INTERNAL_ERROR 418 leave 419 ret 347 420 %endif ; RT_ARCH_X86 348 421
Note:
See TracChangeset
for help on using the changeset viewer.