Changeset 47660 in vbox for trunk/src/VBox/VMM/VMMSwitcher
- Timestamp:
- Aug 12, 2013 12:37:34 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 87863
- Location:
- trunk/src/VBox/VMM/VMMSwitcher
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMSwitcher/AMD64andLegacy.mac
r41985 r47660 5 5 6 6 ; 7 ; Copyright (C) 2006-201 2Oracle Corporation7 ; Copyright (C) 2006-2013 Oracle Corporation 8 8 ; 9 9 ; This file is part of VirtualBox Open Source Edition (OSE), as … … 355 355 356 356 ; debug registers. 357 test esi, CPUM_USE_DEBUG_REGS | CPUM_USE_DEBUG_REGS_HOST 358 jz htg_debug_regs_no 359 jmp htg_debug_regs_save 357 test esi, CPUM_USE_DEBUG_REGS_HYPER | CPUM_USE_DEBUG_REGS_HOST 358 jnz htg_debug_regs_save 360 359 htg_debug_regs_no: 361 360 DEBUG_CHAR('a') ; trashes esi … … 439 438 mov rax, dr7 ; not sure, but if I read the docs right this will trap if GD is set. FIXME!!! 440 439 mov [rdx + r8 + CPUMCPU.Host.dr7], rax 441 xor eax, eax ; clear everything. (bit 12? is read as 1...) 442 mov dr7, rax 440 mov ecx, X86_DR7_INIT_VAL 441 cmp eax, ecx 442 je .htg_debug_regs_dr7_disabled 443 mov dr7, rcx 444 .htg_debug_regs_dr7_disabled: 443 445 mov rax, dr6 ; just in case we save the state register too. 444 446 mov [rdx + r8 + CPUMCPU.Host.dr6], rax 445 447 ; save host DR0-3? 446 test esi, CPUM_USE_DEBUG_REGS 447 jz nearhtg_debug_regs_no448 test esi, CPUM_USE_DEBUG_REGS_HYPER 449 jz htg_debug_regs_no 448 450 DEBUG_S_CHAR('S'); 449 451 mov rax, dr0 … … 455 457 mov rax, dr3 456 458 mov [rdx + r8 + CPUMCPU.Host.dr3], rax 459 or dword [rdx + r8 + CPUMCPU.fUseFlags], CPUM_USED_DEBUG_REGS_HOST 457 460 jmp htg_debug_regs_no 458 461 … … 513 516 GLOBALNAME JmpGCTarget 514 517 DEBUG_CHAR('-') 515 ;mov eax, 0ffff0000h516 ;.delay_loop:517 ;nop518 ;dec eax519 ;nop520 ;jnz .delay_loop521 518 ; load final cr3 and do far jump to load cs. 522 519 mov cr3, ebp ; ebp set above … … 565 562 566 563 ; debug registers 567 test esi, CPUM_USE_DEBUG_REGS 564 test esi, CPUM_USE_DEBUG_REGS_HYPER 568 565 jnz htg_debug_regs_guest 569 566 htg_debug_regs_guest_done: … … 622 619 mov ebx, [edx + CPUMCPU.Hyper.dr + 8*3] 623 620 mov dr3, ebx 624 ;mov eax, [edx + CPUMCPU.Hyper.dr + 8*6] 625 mov ecx, 0ffff0ff0h 621 mov ecx, X86_DR6_INIT_VAL 626 622 mov dr6, ecx 627 623 mov eax, [edx + CPUMCPU.Hyper.dr + 8*7] 628 624 mov dr7, eax 625 or dword [edx + CPUMCPU.fUseFlags], CPUM_USED_DEBUG_REGS_HYPER 629 626 jmp htg_debug_regs_guest_done 630 627 … … 793 790 ; FPU context is saved before restore of host saving (another) branch. 794 791 792 ; Disable debug registers if active so they cannot trigger while switching. 793 test dword [edi + CPUMCPU.fUseFlags], CPUM_USED_DEBUG_REGS_HYPER 794 jz .gth_disabled_dr7 795 mov eax, X86_DR7_INIT_VAL 796 mov dr7, eax 797 .gth_disabled_dr7: 795 798 796 799 ;; … … 991 994 ;mov cr2, rcx 992 995 993 ; restore debug registers (if modified) (esi must still be fUseFlags!)994 ; (must be done after cr4 reload because of the debug extension.)995 test esi, CPUM_USE_DEBUG_REGS | CPUM_USE_DEBUG_REGS_HOST996 jz short gth_debug_regs_no997 jmp gth_debug_regs_restore998 gth_debug_regs_no:999 1000 996 ; Restore MSRs 1001 997 mov rbx, rdx … … 1014 1010 mov rdx, rbx 1015 1011 1016 ; restore general registers. 1012 ; Restore debug registers (if modified). (ESI must still be fUseFlags! Must be done late, at least after CR4!) 1013 test esi, CPUM_USE_DEBUG_REGS_HOST | CPUM_USED_DEBUG_REGS_HOST | CPUM_USE_DEBUG_REGS_HYPER 1014 jnz gth_debug_regs_restore 1015 gth_debug_regs_done: 1016 and dword [edx + CPUMCPU.fUseFlags], ~(CPUM_USED_DEBUG_REGS_HOST | CPUM_USED_DEBUG_REGS_HYPER) 1017 1018 ; Restore general registers. 1017 1019 mov eax, edi ; restore return code. eax = return code !! 1018 1020 ; mov rax, [rdx + r8 + CPUMCPU.Host.rax] - scratch + return code … … 1049 1051 gth_debug_regs_restore: 1050 1052 DEBUG_S_CHAR('d') 1051 xor eax, eax 1052 mov dr7, rax ; paranoia or not? 1053 test esi, CPUM_USE_DEBUG_REGS 1054 jz short gth_debug_regs_dr7 1053 mov rax, dr7 ; Some DR7 paranoia first... 1054 mov ecx, X86_DR7_INIT_VAL 1055 cmp rax, rcx 1056 je .gth_debug_skip_dr7_disabling 1057 mov dr7, rcx 1058 .gth_debug_skip_dr7_disabling: 1059 test esi, CPUM_USED_DEBUG_REGS_HOST 1060 jz .gth_debug_regs_dr7 1061 1055 1062 DEBUG_S_CHAR('r') 1056 1063 mov rax, [rdx + r8 + CPUMCPU.Host.dr0] … … 1062 1069 mov rax, [rdx + r8 + CPUMCPU.Host.dr3] 1063 1070 mov dr3, rax 1064 gth_debug_regs_dr7:1071 .gth_debug_regs_dr7: 1065 1072 mov rbx, [rdx + r8 + CPUMCPU.Host.dr6] 1066 1073 mov dr6, rbx 1067 1074 mov rcx, [rdx + r8 + CPUMCPU.Host.dr7] 1068 1075 mov dr7, rcx 1069 jmp gth_debug_regs_no 1076 1077 ; We clear the USED flags in the main code path. 1078 jmp gth_debug_regs_done 1070 1079 1071 1080 ENDPROC vmmRCToHostAsm -
trunk/src/VBox/VMM/VMMSwitcher/LegacyandAMD64.mac
r47652 r47660 445 445 mov esi, [rdx + CPUMCPU.fUseFlags] ; esi == use flags. 446 446 test esi, CPUM_SYNC_FPU_STATE 447 jz near gth_fpu_no447 jz near htg_fpu_no 448 448 449 449 %ifdef VBOX_WITH_CRASHDUMP_MAGIC … … 460 460 and dword [rdx + CPUMCPU.fUseFlags], ~CPUM_SYNC_FPU_STATE 461 461 462 gth_fpu_no:462 htg_fpu_no: 463 463 ; Check if we need to restore the guest debug state 464 test esi, CPUM_SYNC_DEBUG_ STATE465 jz near gth_debug_no464 test esi, CPUM_SYNC_DEBUG_REGS_GUEST | CPUM_SYNC_DEBUG_REGS_HYPER 465 jz htg_debug_done 466 466 467 467 %ifdef VBOX_WITH_CRASHDUMP_MAGIC 468 468 mov dword [rdx + CPUMCPU.Guest.dr + 4*8], 8 469 469 %endif 470 470 test esi, CPUM_SYNC_DEBUG_REGS_HYPER 471 jnz htg_debug_hyper 472 473 ; Guest values in DRx, letting the guest access them directly. 471 474 mov rax, qword [rdx + CPUMCPU.Guest.dr + 0*8] 472 475 mov dr0, rax … … 480 483 mov dr6, rax ; not required for AMD-V 481 484 482 and dword [rdx + CPUMCPU.fUseFlags], ~CPUM_SYNC_DEBUG_STATE 483 484 gth_debug_no: 485 and dword [rdx + CPUMCPU.fUseFlags], ~CPUM_SYNC_DEBUG_REGS_GUEST 486 or dword [rdx + CPUMCPU.fUseFlags], CPUM_USED_DEBUG_REGS_GUEST 487 jmp htg_debug_done 488 489 htg_debug_hyper: 490 ; Combined values in DRx, intercepting all accesses. 491 mov rax, qword [rdx + CPUMCPU.Hyper.dr + 0*8] 492 mov dr0, rax 493 mov rax, qword [rdx + CPUMCPU.Hyper.dr + 1*8] 494 mov dr1, rax 495 mov rax, qword [rdx + CPUMCPU.Hyper.dr + 2*8] 496 mov dr2, rax 497 mov rax, qword [rdx + CPUMCPU.Hyper.dr + 3*8] 498 mov dr3, rax 499 mov rax, qword [rdx + CPUMCPU.Hyper.dr + 6*8] 500 mov dr6, rax ; not required for AMD-V 501 502 and dword [rdx + CPUMCPU.fUseFlags], ~CPUM_SYNC_DEBUG_REGS_HYPER 503 or dword [rdx + CPUMCPU.fUseFlags], CPUM_USED_DEBUG_REGS_HYPER 504 505 htg_debug_done: 485 506 486 507 %ifdef VBOX_WITH_CRASHDUMP_MAGIC 487 508 mov dword [rdx + CPUMCPU.Guest.dr + 4*8], 9 488 509 %endif 510 511 ; 512 ; "Call" the specified helper function. 513 ; 489 514 490 515 ; parameter for all helper functions (pCtx) 491 516 DEBUG64_CHAR('9') 492 517 lea rsi, [rdx + CPUMCPU.Guest.fpu] 493 lea rax, [ gth_return wrt rip]518 lea rax, [htg_return wrt rip] 494 519 push rax ; return address 495 520 … … 505 530 jz NAME(HMRCTestSwitcher64) 506 531 mov eax, VERR_HM_INVALID_HM64ON32OP 507 gth_return:532 htg_return: 508 533 DEBUG64_CHAR('r') 509 534 -
trunk/src/VBox/VMM/VMMSwitcher/PAEand32Bit.mac
r41985 r47660 5 5 6 6 ; 7 ; Copyright (C) 2006-201 2Oracle Corporation7 ; Copyright (C) 2006-2013 Oracle Corporation 8 8 ; 9 9 ; This file is part of VirtualBox Open Source Edition (OSE), as … … 256 256 257 257 ; debug registers. 258 test esi, CPUM_USE_DEBUG_REGS | CPUM_USE_DEBUG_REGS_HOST258 test esi, CPUM_USE_DEBUG_REGS_HYPER | CPUM_USE_DEBUG_REGS_HOST 259 259 jnz htg_debug_regs_save_dr7and6 260 260 htg_debug_regs_no: … … 407 407 408 408 ; debug registers 409 test esi, CPUM_USE_DEBUG_REGS 409 test esi, CPUM_USE_DEBUG_REGS_HYPER 410 410 jnz htg_debug_regs_guest 411 411 htg_debug_regs_guest_done: … … 515 515 mov eax, dr3 516 516 mov [edx + CPUMCPU.Host.dr3], eax 517 or dword [edi + CPUMCPU.fUseFlags], CPUM_USED_DEBUG_REGS_HOST 517 518 518 519 ; load hyper DR0-7 … … 525 526 mov ebx, [edx + CPUMCPU.Hyper.dr + 8*3] 526 527 mov dr3, ebx 527 ;mov eax, [edx + CPUMCPU.Hyper.dr + 8*6] 528 mov ecx, 0ffff0ff0h 528 mov ecx, X86_DR6_INIT_VAL 529 529 mov dr6, ecx 530 530 mov eax, [edx + CPUMCPU.Hyper.dr + 8*7] 531 531 mov dr7, eax 532 or dword [edi + CPUMCPU.fUseFlags], CPUM_USED_DEBUG_REGS_HYPER 532 533 jmp htg_debug_regs_guest_done 533 534 … … 686 687 ; No need to save CRx here. They are set dynamically according to Guest/Host requirements. 687 688 ; FPU context is saved before restore of host saving (another) branch. 689 690 ; Disable debug regsiters if active so they cannot trigger while switching. 691 test dword [edi + CPUMCPU.fUseFlags], CPUM_USED_DEBUG_REGS_HYPER 692 jz .gth_disabled_dr7 693 mov eax, X86_DR7_INIT_VAL 694 mov dr7, eax 695 .gth_disabled_dr7: 688 696 689 697 %ifdef VBOX_WITH_NMI … … 887 895 ; restore debug registers (if modified) (esi must still be fUseFlags!) 888 896 ; (must be done after cr4 reload because of the debug extension.) 889 test esi, CPUM_USE_DEBUG_REGS | CPUM_USE_DEBUG_REGS_HOST 890 jz short gth_debug_regs_no 891 jmp gth_debug_regs_restore 892 gth_debug_regs_no: 897 test esi, CPUM_USE_DEBUG_REGS_HYPER | CPUM_USE_DEBUG_REGS_HOST | CPUM_USED_DEBUG_REGS_HOST 898 jnz gth_debug_regs_restore 899 gth_debug_regs_done: 893 900 894 901 ; restore general registers. … … 911 918 gth_debug_regs_restore: 912 919 DEBUG_S_CHAR('d') 913 xor eax, eax 914 mov dr7, eax ; paranoia or not? 915 test esi, CPUM_USE_DEBUG_REGS 916 jz short gth_debug_regs_dr7 920 mov eax, dr7 ; Some DR7 paranoia first... 921 mov ecx, X86_DR7_INIT_VAL 922 cmp eax, ecx 923 je .gth_debug_skip_dr7_disabling 924 mov dr7, ecx 925 .gth_debug_skip_dr7_disabling: 926 test esi, CPUM_USED_DEBUG_REGS_HOST 927 jz .gth_debug_regs_dr7 928 917 929 DEBUG_S_CHAR('r') 918 930 mov eax, [edx + CPUMCPU.Host.dr0] … … 924 936 mov eax, [edx + CPUMCPU.Host.dr3] 925 937 mov dr3, eax 926 gth_debug_regs_dr7:938 .gth_debug_regs_dr7: 927 939 mov ebx, [edx + CPUMCPU.Host.dr6] 928 940 mov dr6, ebx 929 941 mov ecx, [edx + CPUMCPU.Host.dr7] 930 942 mov dr7, ecx 931 jmp gth_debug_regs_no 943 944 and dword [edx + CPUMCPU.fUseFlags], ~(CPUM_USED_DEBUG_REGS_HOST | CPUM_USED_DEBUG_REGS_HYPER) 945 jmp gth_debug_regs_done 932 946 933 947 ENDPROC vmmRCToHostAsm
Note:
See TracChangeset
for help on using the changeset viewer.