- Timestamp:
- Apr 24, 2013 2:21:09 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 85247
- Location:
- trunk
- Files:
-
- 2 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/apic.mac
r33935 r45701 2 2 %define ___VBox_apic_h 3 3 %define APIC_REG_VERSION 0x0030 4 %define APIC_REG_VERSION_GET_VER(u32)(u32 & 0xff)5 %define APIC_REG_VERSION_GET_MAX_LVT(u32)((u32 & 0xff0000) >> 16)4 %define APIC_REG_VERSION_GET_VER(u32) (u32 & 0xff) 5 %define APIC_REG_VERSION_GET_MAX_LVT(u32) ((u32 & 0xff0000) >> 16) 6 6 %define APIC_REG_LVT_LINT0 0x0350 7 7 %define APIC_REG_LVT_LINT1 0x0360 … … 9 9 %define APIC_REG_LVT_PC 0x0340 10 10 %define APIC_REG_LVT_THMR 0x0330 11 %define APIC_REG_LVT_MODE_MASK (RT_BIT(8)|RT_BIT(9)|RT_BIT(10))12 %define APIC_REG_LVT_MODE_FIXED013 %define APIC_REG_LVT_MODE_NMI (RT_BIT(10))14 %define APIC_REG_LVT_MODE_EXTINT (RT_BIT(8)|RT_BIT(9)|RT_BIT(10))15 %define APIC_REG_LVT_PIN_POLARIYRT_BIT(13)16 %define APIC_REG_LVT_REMOTE_IRRRT_BIT(14)17 %define APIC_REG_LVT_LEVEL_TRIGGERRT_BIT(15)18 %define APIC_REG_LVT_MASKEDRT_BIT(16)11 %define APIC_REG_LVT_MODE_MASK (RT_BIT(8) | RT_BIT(9) | RT_BIT(10)) 12 %define APIC_REG_LVT_MODE_FIXED 0 13 %define APIC_REG_LVT_MODE_NMI RT_BIT(10) 14 %define APIC_REG_LVT_MODE_EXTINT (RT_BIT(8) | RT_BIT(9) | RT_BIT(10)) 15 %define APIC_REG_LVT_PIN_POLARIY RT_BIT(13) 16 %define APIC_REG_LVT_REMOTE_IRR RT_BIT(14) 17 %define APIC_REG_LVT_LEVEL_TRIGGER RT_BIT(15) 18 %define APIC_REG_LVT_MASKED RT_BIT(16) 19 19 %endif -
trunk/include/VBox/err.h
r45693 r45701 975 975 /** Internal processing error \#3 in TRPM. */ 976 976 #define VERR_TRPM_IPE_3 (-2409) 977 /** Got into a part of TRPM that is not used when HM (VT-x/AMD-V) is enabled. */ 978 #define VERR_TRPM_HM_IPE (-2410) 977 979 /** @} */ 978 980 … … 1006 1008 * selectors. */ 1007 1009 #define VERR_SELM_GDT_TOO_FULL (-2508) 1010 /** Got into a part of SELM that is not used when HM (VT-x/AMD-V) is enabled. */ 1011 #define VERR_SELM_HM_IPE (-2509) 1008 1012 /** @} */ 1009 1013 … … 1126 1130 /** Reason for leaving RZ: Unknown call to ring-3. */ 1127 1131 #define VINF_VMM_UNKNOWN_RING3_CALL (2714) 1132 /** Attempted to use stub switcher. */ 1133 #define VERR_VMM_SWITCHER_STUB (-2715) 1128 1134 /** @} */ 1129 1135 -
trunk/include/VBox/err.mac
r45474 r45701 20 20 %define VERR_TOO_MANY_CPUS (-1019) 21 21 %define VERR_SERVICE_DISABLED (-1020) 22 %define VERR_NOT_SUP_IN_RAW_MODE (-1021) 22 23 %define VINF_EM_FIRST 1100 23 24 %define VINF_EM_TERMINATE 1100 … … 37 38 %define VERR_EM_NO_MEMORY (-1114) 38 39 %define VINF_EM_RESCHEDULE_REM 1115 39 %define VINF_EM_RESCHEDULE_H WACC111640 %define VINF_EM_RESCHEDULE_HM 1116 40 41 %define VINF_EM_RESCHEDULE_RAW 1117 41 42 %define VINF_EM_RESCHEDULE 1118 … … 68 69 %define VINF_EM_RAW_EMULATE_DBG_STEP 1151 69 70 %define VINF_EM_HM_PATCH_TPR_INSTR 1152 70 %define VERR_EM_INTERNAL_DISAS_ERROR (-1153)71 71 %define VERR_EM_UNEXPECTED_MAPPING_CONFLICT (-1154) 72 %define VINF_EM_TRIPLE_FAULT 1155 72 73 %define VERR_DBGF_NOT_ATTACHED (-1200) 73 74 %define VERR_DBGF_ALREADY_ATTACHED (-1201) … … 119 120 %define VINF_PATM_SPINLOCK_FAILED (1429) 120 121 %define VINF_PATCH_CONTINUE (1430) 122 %define VERR_PATM_HM_IPE (-1431) 121 123 %define VWRN_CSAM_TRAP_NOT_HANDLED 1500 122 124 %define VWRN_CSAM_INSTRUCTION_PATCHED 1501 123 125 %define VWRN_CSAM_PAGE_NOT_FOUND 1502 124 126 %define VINF_CSAM_PENDING_ACTION 1503 127 %define VERR_CSAM_HM_IPE (-1504) 125 128 %define VERR_PGM_MAPPING_CONFLICT (-1600) 126 129 %define VERR_PGM_HANDLER_PHYSICAL_NO_RAM_RANGE (-1601) … … 356 359 %define VERR_TRPM_IPE_2 (-2408) 357 360 %define VERR_TRPM_IPE_3 (-2409) 361 %define VERR_TRPM_HM_IPE (-2410) 358 362 %define VERR_SELM_SHADOW_GDT_WRITE (-2500) 359 363 %define VERR_SELM_SHADOW_LDT_WRITE (-2501) … … 365 369 %define VERR_SELM_GDT_READ_ERROR (-2507) 366 370 %define VERR_SELM_GDT_TOO_FULL (-2508) 371 %define VERR_SELM_HM_IPE (-2509) 367 372 %define VERR_IOM_INVALID_IOPORT_RANGE (-2600) 368 373 %define VERR_IOM_NO_R3_IOPORT_RANGE (-2601) … … 408 413 %define VINF_VMM_CALL_TRACER (2712) 409 414 %define VERR_VMM_SWITCHER_IPE_1 (-2713) 415 %define VINF_VMM_UNKNOWN_RING3_CALL (2714) 416 %define VERR_VMM_SWITCHER_STUB (-2715) 410 417 %define VERR_PDM_NO_SUCH_LUN (-2800) 411 418 %define VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES (-2801) … … 442 449 %define VERR_PDM_DRIVER_DETACH_NOT_POSSIBLE (-2832) 443 450 %define VERR_PDM_NO_PCI_BUS (-2833) 444 %define VINF_PDM_PCI_PHYS_READ_BM_DISABLED (2833)445 451 %define VERR_PDM_NOT_PCI_DEVICE (-2834) 446 %define VINF_PDM_PCI_PHYS_WRITE_BM_DISABLED (2834)447 452 %define VERR_PDM_UNKNOWN_DEVREG_VERSION (-2835) 448 453 %define VERR_PDM_INVALID_DEVICE_REGISTRATION (-2836) … … 502 507 %define VERR_PDM_MISCONFIGURED_DRV_TRANSFORMATION (-2889) 503 508 %define VERR_PDM_CANNOT_TRANSFORM_REMOVED_DRIVER (-2890) 509 %define VERR_PDM_NOT_PCI_BUS_MASTER (-2891) 504 510 %define VERR_HGCM_SERVICE_NOT_FOUND (-2900) 505 511 %define VINF_HGCM_CLIENT_REJECTED 2901 … … 684 690 %define VERR_VMX_UNSUPPORTED_MODE (-4004) 685 691 %define VERR_VMX_UNABLE_TO_START_VM (-4005) 686 %define VERR_VMX_UNABLE_TO_RESUME_VM (-4006)687 692 %define VERR_VMX_INVALID_HOST_STATE (-4007) 688 693 %define VERR_VMX_ILLEGAL_FEATURE_CONTROL_MSR (-4008) … … 697 702 %define VERR_VMX_UNEXPECTED_INTERRUPTION_EXIT_CODE (-4017) 698 703 %define VERR_VMX_NOT_IN_VMX_ROOT_MODE (-4018) 699 %define VERR_VMX_UNDEFINED_EXIT_CODE 700 %define VINF_VMX_DOUBLE_FAULT 701 %define VERR_VMX_VMPTRLD_FAILED 704 %define VERR_VMX_UNDEFINED_EXIT_CODE (-4019) 705 %define VINF_VMX_DOUBLE_FAULT 4020 706 %define VERR_VMX_VMPTRLD_FAILED (-4021) 702 707 %define VERR_SVM_UNABLE_TO_START_VM (-4050) 703 708 %define VERR_SVM_ILLEGAL_EFER_MSR (-4051) … … 705 710 %define VERR_SVM_DISABLED (-4053) 706 711 %define VERR_SVM_IN_USE (-4054) 712 %define VERR_SVM_INVALID_PVMCB (-4055) 713 %define VERR_SVM_UNEXPECTED_EXIT (-4056) 714 %define VERR_SVM_UNEXPECTED_XCPT_EXIT (-4057) 715 %define VERR_SVM_UNEXPECTED_PATCH_TYPE (-4058) 707 716 %define VERR_HM_UNKNOWN_CPU (-4100) 708 717 %define VERR_HM_NO_CPUID (-4101) … … 712 721 %define VERR_HM_UNEXPECTED_LD_ST_MSR (-4105) 713 722 %define VERR_HM_NO_32_TO_64_SWITCHER (-4106) 714 %define VERR_HM SVM_INVALID_PVMCB(-4107)715 %define VERR_HM SVM_UNEXPECTED_EXIT(-4108)716 %define VERR_HM SVM_UNEXPECTED_XCPT_EXIT(-4109)717 %define VERR_HM SVM_UNEXPECTED_PATCH_TYPE(-4110)718 %define VERR_HM_ WRONG_CPU_1(-4111)719 %define VERR_HM_ IPE_1(-4112)720 %define VERR_HM_IPE_ 2(-4113)721 %define VERR_HM_ WRONG_SWITCHER(-4114)722 %define VERR_HM_ UNKNOWN_IO_INSTRUCTION(-4115)723 %define VERR_HM_WRONG_CPU_1 (-4107) 724 %define VERR_HM_IPE_1 (-4108) 725 %define VERR_HM_IPE_2 (-4109) 726 %define VERR_HM_WRONG_SWITCHER (-4110) 727 %define VERR_HM_UNKNOWN_IO_INSTRUCTION (-4111) 728 %define VERR_HM_UNSUPPORTED_CPU_FEATURE_COMBO (-4112) 729 %define VERR_HM_IPE_3 (-4113) 730 %define VERR_HM_IPE_4 (-4114) 731 %define VERR_HM_IPE_5 (-4115) 723 732 %define VERR_DIS_INVALID_OPCODE (-4200) 724 733 %define VERR_DIS_GEN_FAILURE (-4201) … … 726 735 %define VERR_DIS_INVALID_MODRM (-4203) 727 736 %define VERR_DIS_INVALID_PARAMETER (-4204) 728 %define VERR_DIS_MEM_READ (-4205)729 737 %define VERR_DIS_TOO_LONG_INSTR (-4206) 730 738 %define VERR_WEB_NOT_AUTHENTICATED (-4300) … … 812 820 %define VERR_EXTPACK_UNSUPPORTED_HOST_UNINSTALL (-6000) 813 821 %define VERR_EXTPACK_VBOX_VERSION_MISMATCH (-6001) 822 %define VERR_GSTCTL_GUEST_ERROR (-6200) 823 %define VWRN_GSTCTL_OBJECTSTATE_CHANGED 6220 814 824 %include "iprt/err.mac" -
trunk/include/VBox/vmm/hm.h
r45618 r45701 40 40 41 41 /** 42 * Query HM state (enabled/disabled)42 * Checks whether HM (VT-x/AMD-V) is being used by this VM. 43 43 * 44 * @returns 0 - disabled, 1 - enabled 45 * @param a_pVM Pointer to the shared VM structure. 44 * @retval @c true if used. 45 * @retval @c false if software virtualization (raw-mode) is used. 46 * 47 * @param a_pVM The cross context VM structure. 46 48 * @sa HMIsEnabledNotMacro, HMR3IsEnabled 47 49 * @internal … … 51 53 #else 52 54 # define HMIsEnabled(a_pVM) ((a_pVM)->fHMEnabled) 55 #endif 56 57 /** 58 * Checks whether raw-mode context is required for any purpose. 59 * 60 * @retval @c true if required either by raw-mode itself or by HM for doing 61 * switching the cpu to 64-bit mode. 62 * @retval @c false if not required. 63 * 64 * @param a_pVM The cross context VM structure. 65 * @internal 66 */ 67 #if HC_ARCH_BITS == 64 68 # define HMIsRawModeCtxNeeded(a_pVM) (!HMIsEnabled(a_pVM)) 69 #else 70 # define HMIsRawModeCtxNeeded(a_pVM) (!HMIsEnabled(a_pVM) || (a_pVM)->fHMNeedRawModeCtx) 53 71 #endif 54 72 -
trunk/include/VBox/vmm/selm.h
r45533 r45701 42 42 VMMDECL(void) SELMSetTrap8EIP(PVM pVM, uint32_t u32EIP); 43 43 VMMDECL(int) SELMGetRing1Stack(PVM pVM, uint32_t *pSS, PRTGCPTR32 pEsp); 44 VMMDECL(RTGCPTR) SELMGetGuestTSS(PVM pVM);45 44 VMMDECL(RTSEL) SELMGetHyperCS(PVM pVM); 46 45 VMMDECL(RTSEL) SELMGetHyperCS64(PVM pVM); -
trunk/include/VBox/vmm/vm.h
r45618 r45701 882 882 /** For asserting on fHMEnable usage. */ 883 883 bool fHMEnabledFixed; 884 /** Hardware VM support requires a minimal raw-mode context. 885 * This is never set on 64-bit hosts, only 32-bit hosts requires it. */ 886 bool fHMNeedRawModeCtx; 884 887 /** Set when this VM is the master FT node. 885 888 * @todo This doesn't need to be here, FTM should store it in it's own … … 893 896 894 897 /** Alignment padding.. */ 895 uint8_t uPadding1[ 3];898 uint8_t uPadding1[2]; 896 899 897 900 /** @name Debugging -
trunk/include/VBox/vmm/vm.mac
r45618 r45701 64 64 .fHMEnabled resb 1 65 65 .fHMEnabledFixed resb 1 66 .fHMNeedRawModeCtx resb 1 66 67 .fFaultTolerantMaster resb 1 67 68 .fUseLargePages resb 1 68 69 69 .uPadding1 resb 370 .uPadding1 resb 2 70 71 71 72 .hTraceBufRC RTRCPTR_RES 1 -
trunk/include/VBox/vmm/vmm.h
r45618 r45701 64 64 /** Switcher for AMD64 host paging to AMD64 shadow paging. */ 65 65 VMMSWITCHER_AMD64_TO_AMD64, 66 /** Stub switcher for 32-bit and PAE. */ 67 VMMSWITCHER_X86_STUB, 68 /** Stub switcher for AMD64. */ 69 VMMSWITCHER_AMD64_STUB, 66 70 /** Used to make a count for array declarations and suchlike. */ 67 71 VMMSWITCHER_MAX, … … 254 258 VMMR3DECL(const char *) VMMR3GetRZAssertMsg2(PVM pVM); 255 259 VMMR3_INT_DECL(int) VMMR3SelectSwitcher(PVM pVM, VMMSWITCHER enmSwitcher); 256 VMMR3_INT_DECL(int) VMMR3DisableSwitcher(PVM pVM);257 260 VMMR3_INT_DECL(RTR0PTR) VMMR3GetHostToGuestSwitcher(PVM pVM, VMMSWITCHER enmSwitcher); 258 261 VMMR3_INT_DECL(int) VMMR3HmRunGC(PVM pVM, PVMCPU pVCpu); -
trunk/include/iprt/err.mac
r41976 r45701 16 16 %define VERR_VERSION_MISMATCH (-11) 17 17 %define VERR_NOT_IMPLEMENTED (-12) 18 %define VERR_INVALID_FLAGS (-13) 18 19 %define VERR_NOT_EQUAL (-18) 19 20 %define VERR_NOT_SYMLINK (-19) … … 122 123 %define VERR_UNEVEN_INPUT (-22402) 123 124 %define VERR_NOT_AVAILABLE (-22403) 125 %define VERR_PROC_DETACH_NOT_SUPPORTED (-22404) 124 126 %define VERR_FILE_IO_ERROR (-100) 125 127 %define VERR_OPEN_FAILED (-101) … … 169 171 %define VERR_PATH_IS_RELATIVE (-143) 170 172 %define VERR_PATH_IS_NOT_RELATIVE (-144) 173 %define VERR_PATH_ZERO_LENGTH (-145) 171 174 %define VERR_DISK_IO_ERROR (-150) 172 175 %define VERR_INVALID_DRIVE (-151) … … 275 278 %define VERR_NET_HOST_UNREACHABLE (-465) 276 279 %define VERR_NET_PROTOCOL_ERROR (-466) 280 %define VERR_NET_INCOMPLETE_TX_PACKET (-467) 277 281 %define VERR_TCP_SERVER_STOP (-500) 278 282 %define VINF_TCP_SERVER_STOP 500 … … 395 399 %define VERR_S3_BUCKET_NOT_EMPTY (-878) 396 400 %define VERR_S3_CANCELED (-879) 401 %define VERR_HTTP_INIT_FAILED (-885) 402 %define VERR_HTTP_NOT_FOUND (-886) 403 %define VERR_HTTP_ACCESS_DENIED (-887) 404 %define VERR_HTTP_BAD_REQUEST (-888) 405 %define VERR_HTTP_COULDNT_CONNECT (-889) 406 %define VERR_HTTP_SSL_CONNECT_ERROR (-890) 407 %define VERR_HTTP_CACERT_WRONG_FORMAT (-891) 408 %define VERR_HTTP_CACERT_CANNOT_AUTHENTICATE (-892) 409 %define VERR_HTTP_ABORTED (-893) 397 410 %define VERR_MANIFEST_UNSUPPORTED_DIGEST_TYPE (-900) 398 411 %define VERR_MANIFEST_WRONG_FILE_FORMAT (-901) -
trunk/include/iprt/x86.mac
r43974 r45701 334 334 %define MSR_IA32_VMX_VMCS_ENUM 0x48A 335 335 %define MSR_IA32_VMX_PROCBASED_CTLS2 0x48B 336 %define MSR_IA32_VMX_EPT_ CAPS0x48C336 %define MSR_IA32_VMX_EPT_VPID_CAP 0x48C 337 337 %define MSR_IA32_DS_AREA 0x600 338 338 %define MSR_IA32_X2APIC_START 0x800 … … 647 647 %define X86_SEL_RPL 0x0003 648 648 %define X86_SEL_RPL_LDT 0x0007 649 %define X86_XCPT_MAX (X86_XCPT_XF) 649 650 %define X86_TRAP_ERR_EXTERNAL 1 650 651 %define X86_TRAP_ERR_IDT 2 -
trunk/src/VBox/VMM/Makefile.kmk
r45529 r45701 241 241 VMMSwitcher/PAETo32Bit.asm \ 242 242 VMMSwitcher/PAEToAMD64.asm \ 243 VMMSwitcher/PAEToPAE.asm 243 VMMSwitcher/PAEToPAE.asm \ 244 VMMSwitcher/X86Stub.asm 244 245 VBoxVMM_SOURCES.amd64 = \ 245 246 VMMSwitcher/AMD64To32Bit.asm \ 246 VMMSwitcher/AMD64ToPAE.asm 247 VMMSwitcher/AMD64ToPAE.asm \ 248 VMMSwitcher/AMD64Stub.asm 247 249 VBoxVMM_SOURCES.darwin.x86 += \ 248 250 VMMSwitcher/AMD64ToPAE.asm -
trunk/src/VBox/VMM/VMMAll/EMAll.cpp
r45620 r45701 1538 1538 # endif 1539 1539 # ifdef VBOX_WITH_RAW_MODE 1540 if (( val ^ oldval) & X86_CR4_VME)1540 if (((val ^ oldval) & X86_CR4_VME) && !HMIsEnabled(pVM)) 1541 1541 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 1542 1542 # endif -
trunk/src/VBox/VMM/VMMAll/HMAll.cpp
r45618 r45701 38 38 39 39 /** 40 * Query HM state (enabled/disabled) 41 * 42 * @returns @c false if disabled, @c true if enabled. 40 * Checks whether HM (VT-x/AMD-V) is being used by this VM. 41 * 42 * @retval @c true if used. 43 * @retval @c false if software virtualization (raw-mode) is used. 43 44 * @param pVM The cross context VM structure. 44 45 * @sa HMIsEnabled, HMR3IsEnabled -
trunk/src/VBox/VMM/VMMAll/IEMAll.cpp
r45531 r45701 87 87 #include <VBox/vmm/iom.h> 88 88 #include <VBox/vmm/em.h> 89 #include <VBox/vmm/hm.h> 89 90 #include <VBox/vmm/tm.h> 90 91 #include <VBox/vmm/dbgf.h> -
trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp.h
r45533 r45701 3417 3417 RT_BOOL(uOldCrX & X86_CR4_VME), RT_BOOL(uNewCrX & X86_CR4_VME) )); 3418 3418 #ifdef VBOX_WITH_RAW_MODE 3419 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 3419 if (!HMIsEnabled(IEMCPU_TO_VM(pIemCpu))) 3420 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 3420 3421 #endif 3421 3422 } -
trunk/src/VBox/VMM/VMMAll/SELMAll.cpp
r45485 r45701 25 25 #include <VBox/vmm/em.h> 26 26 #include <VBox/vmm/mm.h> 27 #include <VBox/vmm/hm.h> 27 28 #include <VBox/vmm/pgm.h> 28 29 #include <VBox/vmm/hm.h> … … 64 65 { 65 66 Assert(pVM->cCpus == 1 && !CPUMIsGuestInLongMode(VMMGetCpu(pVM))); /* DON'T USE! */ 67 Assert(!HMIsEnabled(pVM)); 66 68 67 69 /** @todo check the limit. */ … … 322 324 { 323 325 Assert(!CPUMIsGuestInLongMode(pVCpu)); /* DON'T USE! (Accessing shadow GDT/LDT.) */ 326 Assert(!HMIsEnabled(pVCpu->CTX_SUFF(pVM))); 324 327 325 328 /* … … 488 491 RTGCPTR GCPtrDesc, RTSEL const Sel, uint32_t const iSReg) 489 492 { 493 Assert(!HMIsEnabled(pVCpu->CTX_SUFF(pVM))); 494 490 495 /* 491 496 * Try read the entry. … … 541 546 PVM pVM = pVCpu->CTX_SUFF(pVM); 542 547 Assert(pVM->cCpus == 1); 548 Assert(!HMIsEnabled(pVM)); 543 549 544 550 … … 634 640 { 635 641 NOREF(pVCpu); 642 Assert(!HMIsEnabled(pVM)); 643 636 644 /** @todo validate limit! */ 637 645 X86DESC Desc; … … 836 844 void selmSetRing1Stack(PVM pVM, uint32_t ss, RTGCPTR32 esp) 837 845 { 846 Assert(!HMIsEnabled(pVM)); 838 847 Assert((ss & 1) || esp == 0); 839 848 pVM->selm.s.Tss.ss1 = ss; … … 852 861 void selmSetRing2Stack(PVM pVM, uint32_t ss, RTGCPTR32 esp) 853 862 { 863 Assert(!HMIsEnabled(pVM)); 854 864 Assert((ss & 3) == 2 || esp == 0); 855 865 pVM->selm.s.Tss.ss2 = ss; … … 858 868 #endif 859 869 860 861 870 #ifdef VBOX_WITH_RAW_MODE_NOT_R0 871 862 872 /** 863 873 * Gets ss:esp for ring1 in main Hypervisor's TSS. … … 872 882 VMMDECL(int) SELMGetRing1Stack(PVM pVM, uint32_t *pSS, PRTGCPTR32 pEsp) 873 883 { 884 Assert(!HMIsEnabled(pVM)); 874 885 Assert(pVM->cCpus == 1); 875 886 PVMCPU pVCpu = &pVM->aCpus[0]; … … 944 955 return VINF_SUCCESS; 945 956 } 946 #endif /* VBOX_WITH_RAW_MODE_NOT_R0 */ 947 948 949 /** 950 * Returns Guest TSS pointer 951 * 952 * @returns Pointer to the guest TSS, RTRCPTR_MAX if not being monitored. 953 * @param pVM Pointer to the VM. 954 */ 955 VMMDECL(RTGCPTR) SELMGetGuestTSS(PVM pVM) 956 { 957 return (RTGCPTR)pVM->selm.s.GCPtrGuestTss; 958 } 959 960 #ifdef VBOX_WITH_RAW_MODE_NOT_R0 957 961 958 962 959 /** … … 1079 1076 VMMDECL(void) SELMShadowCR3Changed(PVM pVM, PVMCPU pVCpu) 1080 1077 { 1081 /** @todo SMP support!! */1078 /** @todo SMP support!! (64-bit guest scenario, primarily) */ 1082 1079 pVM->selm.s.Tss.cr3 = PGMGetHyperCR3(pVCpu); 1083 1080 pVM->selm.s.TssTrap08.cr3 = PGMGetInterRCCR3(pVM, pVCpu); -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r44528 r45701 660 660 case VMMR0_DO_RAW_RUN: 661 661 { 662 #ifndef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 662 663 /* Some safety precautions first. */ 663 #ifndef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 664 if (RT_LIKELY( !pVM->vmm.s.fSwitcherDisabled /* hm */ 665 && pVM->cCpus == 1 /* !smp */ 666 && PGMGetHyperCR3(pVCpu))) 667 #else 668 if (RT_LIKELY( !pVM->vmm.s.fSwitcherDisabled 669 && pVM->cCpus == 1)) 670 #endif 664 if (RT_UNLIKELY(!PGMGetHyperCR3(pVCpu))) 671 665 { 672 /* Disable preemption and update the periodic preemption timer. */ 673 RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER; 674 RTThreadPreemptDisable(&PreemptState); 675 RTCPUID idHostCpu = RTMpCpuId(); 666 pVCpu->vmm.s.iLastGZRc = VERR_PGM_NO_CR3_SHADOW_ROOT; 667 break; 668 } 669 #endif 670 671 /* Disable preemption and update the periodic preemption timer. */ 672 RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER; 673 RTThreadPreemptDisable(&PreemptState); 674 RTCPUID idHostCpu = RTMpCpuId(); 676 675 #ifdef VBOX_WITH_VMMR0_DISABLE_LAPIC_NMI 677 CPUMR0SetLApic(pVM, idHostCpu); 678 #endif 679 ASMAtomicWriteU32(&pVCpu->idHostCpu, idHostCpu); 680 if (pVM->vmm.s.fUsePeriodicPreemptionTimers) 681 GVMMR0SchedUpdatePeriodicPreemptionTimer(pVM, pVCpu->idHostCpu, TMCalcHostTimerFrequency(pVM, pVCpu)); 682 683 /* We might need to disable VT-x if the active switcher turns off paging. */ 684 bool fVTxDisabled; 685 int rc = HMR0EnterSwitcher(pVM, pVM->vmm.s.enmSwitcher, &fVTxDisabled); 686 if (RT_SUCCESS(rc)) 676 CPUMR0SetLApic(pVM, idHostCpu); 677 #endif 678 ASMAtomicWriteU32(&pVCpu->idHostCpu, idHostCpu); 679 if (pVM->vmm.s.fUsePeriodicPreemptionTimers) 680 GVMMR0SchedUpdatePeriodicPreemptionTimer(pVM, pVCpu->idHostCpu, TMCalcHostTimerFrequency(pVM, pVCpu)); 681 682 /* We might need to disable VT-x if the active switcher turns off paging. */ 683 bool fVTxDisabled; 684 int rc = HMR0EnterSwitcher(pVM, pVM->vmm.s.enmSwitcher, &fVTxDisabled); 685 if (RT_SUCCESS(rc)) 686 { 687 RTCCUINTREG uFlags = ASMIntDisableFlags(); 688 689 for (;;) 687 690 { 688 RTCCUINTREG uFlags = ASMIntDisableFlags(); 689 690 for (;;) 691 { 692 VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_EXEC); 693 TMNotifyStartOfExecution(pVCpu); 694 695 rc = pVM->vmm.s.pfnR0ToRawMode(pVM); 696 pVCpu->vmm.s.iLastGZRc = rc; 697 698 TMNotifyEndOfExecution(pVCpu); 699 VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED); 700 701 if (rc != VINF_VMM_CALL_TRACER) 702 break; 703 SUPR0TracerUmodProbeFire(pVM->pSession, &pVCpu->vmm.s.TracerCtx); 704 } 705 706 /* Re-enable VT-x if previously turned off. */ 707 HMR0LeaveSwitcher(pVM, fVTxDisabled); 708 709 if ( rc == VINF_EM_RAW_INTERRUPT 710 || rc == VINF_EM_RAW_INTERRUPT_HYPER) 711 TRPMR0DispatchHostInterrupt(pVM); 712 713 ASMSetFlags(uFlags); 691 VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_EXEC); 692 TMNotifyStartOfExecution(pVCpu); 693 694 rc = pVM->vmm.s.pfnR0ToRawMode(pVM); 695 pVCpu->vmm.s.iLastGZRc = rc; 696 697 TMNotifyEndOfExecution(pVCpu); 698 VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED); 699 700 if (rc != VINF_VMM_CALL_TRACER) 701 break; 702 SUPR0TracerUmodProbeFire(pVM->pSession, &pVCpu->vmm.s.TracerCtx); 703 } 704 705 /* Re-enable VT-x if previously turned off. */ 706 HMR0LeaveSwitcher(pVM, fVTxDisabled); 707 708 if ( rc == VINF_EM_RAW_INTERRUPT 709 || rc == VINF_EM_RAW_INTERRUPT_HYPER) 710 TRPMR0DispatchHostInterrupt(pVM); 711 712 ASMSetFlags(uFlags); 714 713 715 714 #ifdef VBOX_WITH_STATISTICS 716 STAM_COUNTER_INC(&pVM->vmm.s.StatRunRC); 717 vmmR0RecordRC(pVM, pVCpu, rc); 718 #endif 719 } 720 else 721 pVCpu->vmm.s.iLastGZRc = rc; 722 ASMAtomicWriteU32(&pVCpu->idHostCpu, NIL_RTCPUID); 723 RTThreadPreemptRestore(&PreemptState); 715 STAM_COUNTER_INC(&pVM->vmm.s.StatRunRC); 716 vmmR0RecordRC(pVM, pVCpu, rc); 717 #endif 724 718 } 725 719 else 726 { 727 Assert(!pVM->vmm.s.fSwitcherDisabled); 728 pVCpu->vmm.s.iLastGZRc = VERR_NOT_SUPPORTED; 729 if (pVM->cCpus != 1) 730 pVCpu->vmm.s.iLastGZRc = VERR_RAW_MODE_INVALID_SMP; 731 #ifndef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 732 if (!PGMGetHyperCR3(pVCpu)) 733 pVCpu->vmm.s.iLastGZRc = VERR_PGM_NO_CR3_SHADOW_ROOT; 734 #endif 735 } 720 pVCpu->vmm.s.iLastGZRc = rc; 721 ASMAtomicWriteU32(&pVCpu->idHostCpu, NIL_RTCPUID); 722 RTThreadPreemptRestore(&PreemptState); 736 723 break; 737 724 } … … 980 967 int rc; 981 968 bool fVTxDisabled; 982 983 /* Safety precaution as HM can disable the switcher. */984 Assert(!pVM->vmm.s.fSwitcherDisabled);985 if (RT_UNLIKELY(pVM->vmm.s.fSwitcherDisabled))986 return VERR_NOT_SUPPORTED;987 969 988 970 #ifndef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0 -
trunk/src/VBox/VMM/VMMR3/DBGF.cpp
r45692 r45701 360 360 361 361 /* 362 * Command s?362 * Command pending? Process it. 363 363 */ 364 364 if (pVM->dbgf.s.enmVMMCmd != DBGFCMD_NO_COMMAND) 365 365 { 366 #ifdef VBOX_WITH_RAW_MODE367 /** @todo stupid GDT/LDT sync hack. go away! */368 SELMR3UpdateFromCPUM(pVM, pVCpu);369 #endif370 371 /*372 * Process the command.373 */374 366 bool fResumeExecution; 375 367 DBGFCMDDATA CmdData = pVM->dbgf.s.VMMCmdData; … … 672 664 673 665 LogFlow(("dbgfR3VMMWait:\n")); 674 675 #ifdef VBOX_WITH_RAW_MODE676 /** @todo stupid GDT/LDT sync hack. go away! */677 SELMR3UpdateFromCPUM(pVM, pVCpu);678 #endif679 666 int rcRet = VINF_SUCCESS; 680 667 -
trunk/src/VBox/VMM/VMMR3/EMHM.cpp
r45533 r45701 84 84 int rc; 85 85 PCPUMCTX pCtx = pVCpu->em.s.pCtx; 86 VMCPU_FF_CLEAR(pVCpu, (VMCPU_FF_SELM_SYNC_GDT | VMCPU_FF_SELM_SYNC_LDT | VMCPU_FF_TRPM_SYNC_IDT | VMCPU_FF_SELM_SYNC_TSS)); 86 # ifdef VBOX_WITH_RAW_MODE 87 Assert(!VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_SELM_SYNC_GDT | VMCPU_FF_SELM_SYNC_LDT | VMCPU_FF_TRPM_SYNC_IDT | VMCPU_FF_SELM_SYNC_TSS)); 88 # endif 87 89 88 90 /* … … 501 503 /** @todo change this FF hack into an assertion, they simply SHALL NOT be set in 502 504 * HM mode. */ 505 Assert(!VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_SELM_SYNC_TSS | VMCPU_FF_SELM_SYNC_GDT | VMCPU_FF_SELM_SYNC_LDT)); 503 506 VMCPU_FF_CLEAR(pVCpu, (VMCPU_FF_SELM_SYNC_GDT | VMCPU_FF_SELM_SYNC_LDT | VMCPU_FF_TRPM_SYNC_IDT | VMCPU_FF_SELM_SYNC_TSS)); /* not relevant in HM mode; shouldn't be set really. */ 504 507 #endif -
trunk/src/VBox/VMM/VMMR3/HM.cpp
r45665 r45701 487 487 AssertLogRelMsgFailedReturn(("SUPR3QueryVTCaps didn't return either AMD-V or VT-x flag set (%#x)!\n", fCaps), 488 488 VERR_INTERNAL_ERROR_5); 489 490 /* 491 * Do we require a little bit or raw-mode for 64-bit guest execution? 492 */ 493 pVM->fHMNeedRawModeCtx = HC_ARCH_BITS == 32 494 && pVM->fHMEnabled 495 && pVM->hm.s.fAllow64BitGuests; 489 496 } 490 497 else … … 831 838 { 832 839 #ifdef VBOX_WITH_RAW_MODE 833 /* Disable PATM & CSAM. */834 PATMR3AllowPatching(pVM->pUVM, false);835 CSAMDisableScanning(pVM);836 837 840 /* Turn off IDT/LDT/GDT and TSS monitoring and sycing. */ 838 841 SELMR3DisableMonitoring(pVM); … … 840 843 #endif 841 844 842 /* Disable the switcher code (safety precaution). */843 VMMR3DisableSwitcher(pVM);844 845 845 /* Disable mapping of the hypervisor into the shadow page table. */ 846 846 PGMR3MappingsDisable(pVM); 847 848 /* Disable the switcher */849 VMMR3DisableSwitcher(pVM);850 847 851 848 /* Reinit the paging mode to force the new shadow mode. */ -
trunk/src/VBox/VMM/VMMR3/PGM.cpp
r45618 r45701 3379 3379 3380 3380 #ifdef VBOX_WITH_RAW_MODE 3381 if (enmSwitcher != VMMSWITCHER_INVALID) 3381 if ( enmSwitcher != VMMSWITCHER_INVALID 3382 && !HMIsEnabled(pVM)) 3382 3383 { 3383 3384 /* -
trunk/src/VBox/VMM/VMMR3/SELM.cpp
r45618 r45701 123 123 VMMR3DECL(int) SELMR3Init(PVM pVM) 124 124 { 125 int rc; 125 126 LogFlow(("SELMR3Init\n")); 126 127 … … 149 150 pVM->selm.s.aHyperSel[SELM_HYPER_SEL_TSS_TRAP08] = (SELM_GDT_ELEMENTS - 0x5) << 3; 150 151 151 /* 152 * Allocate GDT table. 153 */ 154 int rc = MMR3HyperAllocOnceNoRel(pVM, sizeof(pVM->selm.s.paGdtR3[0]) * SELM_GDT_ELEMENTS, 152 if (HMIsRawModeCtxNeeded(pVM)) 153 { 154 /* 155 * Allocate GDT table. 156 */ 157 rc = MMR3HyperAllocOnceNoRel(pVM, sizeof(pVM->selm.s.paGdtR3[0]) * SELM_GDT_ELEMENTS, 155 158 PAGE_SIZE, MM_TAG_SELM, (void **)&pVM->selm.s.paGdtR3); 156 AssertRCReturn(rc, rc); 157 158 /* 159 * Allocate LDT area. 160 */ 161 rc = MMR3HyperAllocOnceNoRel(pVM, _64K + PAGE_SIZE, PAGE_SIZE, MM_TAG_SELM, &pVM->selm.s.pvLdtR3); 162 AssertRCReturn(rc, rc); 159 AssertRCReturn(rc, rc); 160 161 /* 162 * Allocate LDT area. 163 */ 164 rc = MMR3HyperAllocOnceNoRel(pVM, _64K + PAGE_SIZE, PAGE_SIZE, MM_TAG_SELM, &pVM->selm.s.pvLdtR3); 165 AssertRCReturn(rc, rc); 166 } 163 167 164 168 /* … … 178 182 pVM->selm.s.fSyncTSSRing0Stack = false; 179 183 180 /* The I/O bitmap starts right after the virtual interrupt redirection bitmap. Outside the TSS on purpose; the CPU will not check it 181 * for I/O operations. */ 184 /* The I/O bitmap starts right after the virtual interrupt redirection 185 bitmap. Outside the TSS on purpose; the CPU will not check it for 186 I/O operations. */ 182 187 pVM->selm.s.Tss.offIoBitmap = sizeof(VBOXTSS); 183 188 /* bit set to 1 means no redirection */ … … 197 202 * Statistics. 198 203 */ 199 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestGDTHandled, STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/GDTInt", STAMUNIT_OCCURENCES, "The number of handled writes to the Guest GDT."); 200 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestGDTUnhandled, STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/GDTEmu", STAMUNIT_OCCURENCES, "The number of unhandled writes to the Guest GDT."); 201 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestLDT, STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/LDT", STAMUNIT_OCCURENCES, "The number of writes to the Guest LDT was detected."); 202 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestTSSHandled, STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/TSSInt", STAMUNIT_OCCURENCES, "The number of handled writes to the Guest TSS."); 203 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestTSSRedir, STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/TSSRedir",STAMUNIT_OCCURENCES, "The number of handled redir bitmap writes to the Guest TSS."); 204 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestTSSHandledChanged,STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/TSSIntChg", STAMUNIT_OCCURENCES, "The number of handled writes to the Guest TSS where the R0 stack changed."); 205 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestTSSUnhandled, STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/TSSEmu", STAMUNIT_OCCURENCES, "The number of unhandled writes to the Guest TSS."); 206 STAM_REG(pVM, &pVM->selm.s.StatTSSSync, STAMTYPE_PROFILE, "/PROF/SELM/TSSSync", STAMUNIT_TICKS_PER_CALL, "Profiling of the SELMR3SyncTSS() body."); 207 STAM_REG(pVM, &pVM->selm.s.StatUpdateFromCPUM, STAMTYPE_PROFILE, "/PROF/SELM/UpdateFromCPUM", STAMUNIT_TICKS_PER_CALL, "Profiling of the SELMR3UpdateFromCPUM() body."); 208 209 STAM_REL_REG(pVM, &pVM->selm.s.StatHyperSelsChanged, STAMTYPE_COUNTER, "/SELM/HyperSels/Changed", STAMUNIT_OCCURENCES, "The number of times we had to relocate our hypervisor selectors."); 210 STAM_REL_REG(pVM, &pVM->selm.s.StatScanForHyperSels, STAMTYPE_COUNTER, "/SELM/HyperSels/Scan", STAMUNIT_OCCURENCES, "The number of times we had find free hypervisor selectors."); 211 212 STAM_REL_REG(pVM, &pVM->selm.s.aStatDetectedStaleSReg[X86_SREG_ES], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/DetectedStaleES", STAMUNIT_OCCURENCES, "Stale ES was detected in UpdateFromCPUM."); 213 STAM_REL_REG(pVM, &pVM->selm.s.aStatDetectedStaleSReg[X86_SREG_CS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/DetectedStaleCS", STAMUNIT_OCCURENCES, "Stale CS was detected in UpdateFromCPUM."); 214 STAM_REL_REG(pVM, &pVM->selm.s.aStatDetectedStaleSReg[X86_SREG_SS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/DetectedStaleSS", STAMUNIT_OCCURENCES, "Stale SS was detected in UpdateFromCPUM."); 215 STAM_REL_REG(pVM, &pVM->selm.s.aStatDetectedStaleSReg[X86_SREG_DS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/DetectedStaleDS", STAMUNIT_OCCURENCES, "Stale DS was detected in UpdateFromCPUM."); 216 STAM_REL_REG(pVM, &pVM->selm.s.aStatDetectedStaleSReg[X86_SREG_FS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/DetectedStaleFS", STAMUNIT_OCCURENCES, "Stale FS was detected in UpdateFromCPUM."); 217 STAM_REL_REG(pVM, &pVM->selm.s.aStatDetectedStaleSReg[X86_SREG_GS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/DetectedStaleGS", STAMUNIT_OCCURENCES, "Stale GS was detected in UpdateFromCPUM."); 218 219 STAM_REL_REG(pVM, &pVM->selm.s.aStatAlreadyStaleSReg[X86_SREG_ES], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/AlreadyStaleES", STAMUNIT_OCCURENCES, "Already stale ES in UpdateFromCPUM."); 220 STAM_REL_REG(pVM, &pVM->selm.s.aStatAlreadyStaleSReg[X86_SREG_CS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/AlreadyStaleCS", STAMUNIT_OCCURENCES, "Already stale CS in UpdateFromCPUM."); 221 STAM_REL_REG(pVM, &pVM->selm.s.aStatAlreadyStaleSReg[X86_SREG_SS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/AlreadyStaleSS", STAMUNIT_OCCURENCES, "Already stale SS in UpdateFromCPUM."); 222 STAM_REL_REG(pVM, &pVM->selm.s.aStatAlreadyStaleSReg[X86_SREG_DS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/AlreadyStaleDS", STAMUNIT_OCCURENCES, "Already stale DS in UpdateFromCPUM."); 223 STAM_REL_REG(pVM, &pVM->selm.s.aStatAlreadyStaleSReg[X86_SREG_FS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/AlreadyStaleFS", STAMUNIT_OCCURENCES, "Already stale FS in UpdateFromCPUM."); 224 STAM_REL_REG(pVM, &pVM->selm.s.aStatAlreadyStaleSReg[X86_SREG_GS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/AlreadyStaleGS", STAMUNIT_OCCURENCES, "Already stale GS in UpdateFromCPUM."); 225 226 STAM_REL_REG(pVM, &pVM->selm.s.StatStaleToUnstaleSReg, STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/StaleToUnstale", STAMUNIT_OCCURENCES, "Transitions from stale to unstale UpdateFromCPUM."); 227 228 STAM_REG( pVM, &pVM->selm.s.aStatUpdatedSReg[X86_SREG_ES], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/UpdatedES", STAMUNIT_OCCURENCES, "Updated hidden ES values in UpdateFromCPUM."); 229 STAM_REG( pVM, &pVM->selm.s.aStatUpdatedSReg[X86_SREG_CS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/UpdatedCS", STAMUNIT_OCCURENCES, "Updated hidden CS values in UpdateFromCPUM."); 230 STAM_REG( pVM, &pVM->selm.s.aStatUpdatedSReg[X86_SREG_SS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/UpdatedSS", STAMUNIT_OCCURENCES, "Updated hidden SS values in UpdateFromCPUM."); 231 STAM_REG( pVM, &pVM->selm.s.aStatUpdatedSReg[X86_SREG_DS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/UpdatedDS", STAMUNIT_OCCURENCES, "Updated hidden DS values in UpdateFromCPUM."); 232 STAM_REG( pVM, &pVM->selm.s.aStatUpdatedSReg[X86_SREG_FS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/UpdatedFS", STAMUNIT_OCCURENCES, "Updated hidden FS values in UpdateFromCPUM."); 233 STAM_REG( pVM, &pVM->selm.s.aStatUpdatedSReg[X86_SREG_GS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/UpdatedGS", STAMUNIT_OCCURENCES, "Updated hidden GS values in UpdateFromCPUM."); 204 if (!HMIsEnabled(pVM)) 205 { 206 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestGDTHandled, STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/GDTInt", STAMUNIT_OCCURENCES, "The number of handled writes to the Guest GDT."); 207 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestGDTUnhandled, STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/GDTEmu", STAMUNIT_OCCURENCES, "The number of unhandled writes to the Guest GDT."); 208 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestLDT, STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/LDT", STAMUNIT_OCCURENCES, "The number of writes to the Guest LDT was detected."); 209 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestTSSHandled, STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/TSSInt", STAMUNIT_OCCURENCES, "The number of handled writes to the Guest TSS."); 210 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestTSSRedir, STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/TSSRedir",STAMUNIT_OCCURENCES, "The number of handled redir bitmap writes to the Guest TSS."); 211 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestTSSHandledChanged,STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/TSSIntChg", STAMUNIT_OCCURENCES, "The number of handled writes to the Guest TSS where the R0 stack changed."); 212 STAM_REG(pVM, &pVM->selm.s.StatRCWriteGuestTSSUnhandled, STAMTYPE_COUNTER, "/SELM/GC/Write/Guest/TSSEmu", STAMUNIT_OCCURENCES, "The number of unhandled writes to the Guest TSS."); 213 STAM_REG(pVM, &pVM->selm.s.StatTSSSync, STAMTYPE_PROFILE, "/PROF/SELM/TSSSync", STAMUNIT_TICKS_PER_CALL, "Profiling of the SELMR3SyncTSS() body."); 214 STAM_REG(pVM, &pVM->selm.s.StatUpdateFromCPUM, STAMTYPE_PROFILE, "/PROF/SELM/UpdateFromCPUM", STAMUNIT_TICKS_PER_CALL, "Profiling of the SELMR3UpdateFromCPUM() body."); 215 216 STAM_REL_REG(pVM, &pVM->selm.s.StatHyperSelsChanged, STAMTYPE_COUNTER, "/SELM/HyperSels/Changed", STAMUNIT_OCCURENCES, "The number of times we had to relocate our hypervisor selectors."); 217 STAM_REL_REG(pVM, &pVM->selm.s.StatScanForHyperSels, STAMTYPE_COUNTER, "/SELM/HyperSels/Scan", STAMUNIT_OCCURENCES, "The number of times we had find free hypervisor selectors."); 218 219 STAM_REL_REG(pVM, &pVM->selm.s.aStatDetectedStaleSReg[X86_SREG_ES], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/DetectedStaleES", STAMUNIT_OCCURENCES, "Stale ES was detected in UpdateFromCPUM."); 220 STAM_REL_REG(pVM, &pVM->selm.s.aStatDetectedStaleSReg[X86_SREG_CS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/DetectedStaleCS", STAMUNIT_OCCURENCES, "Stale CS was detected in UpdateFromCPUM."); 221 STAM_REL_REG(pVM, &pVM->selm.s.aStatDetectedStaleSReg[X86_SREG_SS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/DetectedStaleSS", STAMUNIT_OCCURENCES, "Stale SS was detected in UpdateFromCPUM."); 222 STAM_REL_REG(pVM, &pVM->selm.s.aStatDetectedStaleSReg[X86_SREG_DS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/DetectedStaleDS", STAMUNIT_OCCURENCES, "Stale DS was detected in UpdateFromCPUM."); 223 STAM_REL_REG(pVM, &pVM->selm.s.aStatDetectedStaleSReg[X86_SREG_FS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/DetectedStaleFS", STAMUNIT_OCCURENCES, "Stale FS was detected in UpdateFromCPUM."); 224 STAM_REL_REG(pVM, &pVM->selm.s.aStatDetectedStaleSReg[X86_SREG_GS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/DetectedStaleGS", STAMUNIT_OCCURENCES, "Stale GS was detected in UpdateFromCPUM."); 225 226 STAM_REL_REG(pVM, &pVM->selm.s.aStatAlreadyStaleSReg[X86_SREG_ES], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/AlreadyStaleES", STAMUNIT_OCCURENCES, "Already stale ES in UpdateFromCPUM."); 227 STAM_REL_REG(pVM, &pVM->selm.s.aStatAlreadyStaleSReg[X86_SREG_CS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/AlreadyStaleCS", STAMUNIT_OCCURENCES, "Already stale CS in UpdateFromCPUM."); 228 STAM_REL_REG(pVM, &pVM->selm.s.aStatAlreadyStaleSReg[X86_SREG_SS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/AlreadyStaleSS", STAMUNIT_OCCURENCES, "Already stale SS in UpdateFromCPUM."); 229 STAM_REL_REG(pVM, &pVM->selm.s.aStatAlreadyStaleSReg[X86_SREG_DS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/AlreadyStaleDS", STAMUNIT_OCCURENCES, "Already stale DS in UpdateFromCPUM."); 230 STAM_REL_REG(pVM, &pVM->selm.s.aStatAlreadyStaleSReg[X86_SREG_FS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/AlreadyStaleFS", STAMUNIT_OCCURENCES, "Already stale FS in UpdateFromCPUM."); 231 STAM_REL_REG(pVM, &pVM->selm.s.aStatAlreadyStaleSReg[X86_SREG_GS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/AlreadyStaleGS", STAMUNIT_OCCURENCES, "Already stale GS in UpdateFromCPUM."); 232 233 STAM_REL_REG(pVM, &pVM->selm.s.StatStaleToUnstaleSReg, STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/StaleToUnstale", STAMUNIT_OCCURENCES, "Transitions from stale to unstale UpdateFromCPUM."); 234 235 STAM_REG( pVM, &pVM->selm.s.aStatUpdatedSReg[X86_SREG_ES], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/UpdatedES", STAMUNIT_OCCURENCES, "Updated hidden ES values in UpdateFromCPUM."); 236 STAM_REG( pVM, &pVM->selm.s.aStatUpdatedSReg[X86_SREG_CS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/UpdatedCS", STAMUNIT_OCCURENCES, "Updated hidden CS values in UpdateFromCPUM."); 237 STAM_REG( pVM, &pVM->selm.s.aStatUpdatedSReg[X86_SREG_SS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/UpdatedSS", STAMUNIT_OCCURENCES, "Updated hidden SS values in UpdateFromCPUM."); 238 STAM_REG( pVM, &pVM->selm.s.aStatUpdatedSReg[X86_SREG_DS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/UpdatedDS", STAMUNIT_OCCURENCES, "Updated hidden DS values in UpdateFromCPUM."); 239 STAM_REG( pVM, &pVM->selm.s.aStatUpdatedSReg[X86_SREG_FS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/UpdatedFS", STAMUNIT_OCCURENCES, "Updated hidden FS values in UpdateFromCPUM."); 240 STAM_REG( pVM, &pVM->selm.s.aStatUpdatedSReg[X86_SREG_GS], STAMTYPE_COUNTER, "/SELM/UpdateFromCPUM/UpdatedGS", STAMUNIT_OCCURENCES, "Updated hidden GS values in UpdateFromCPUM."); 241 } 234 242 235 243 STAM_REG( pVM, &pVM->selm.s.StatLoadHidSelGst, STAMTYPE_COUNTER, "/SELM/LoadHidSel/LoadedGuest", STAMUNIT_OCCURENCES, "SELMLoadHiddenSelectorReg: Loaded from guest tables."); … … 242 250 * Default action when entering raw mode for the first time 243 251 */ 244 PVMCPU pVCpu = &pVM->aCpus[0]; /* raw mode implies on VCPU */ 245 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 246 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_GDT); 247 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT); 252 if (!HMIsEnabled(pVM)) 253 { 254 PVMCPU pVCpu = &pVM->aCpus[0]; /* raw mode implies on VCPU */ 255 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 256 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_GDT); 257 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT); 258 } 248 259 #endif 249 260 … … 251 262 * Register info handlers. 252 263 */ 253 DBGFR3InfoRegisterInternal(pVM, "gdt", "Displays the shadow GDT. No arguments.", &selmR3InfoGdt); 264 if (HMIsRawModeCtxNeeded(pVM)) 265 { 266 DBGFR3InfoRegisterInternal(pVM, "gdt", "Displays the shadow GDT. No arguments.", &selmR3InfoGdt); 267 DBGFR3InfoRegisterInternal(pVM, "ldt", "Displays the shadow LDT. No arguments.", &selmR3InfoLdt); 268 //DBGFR3InfoRegisterInternal(pVM, "tss", "Displays the shadow TSS. No arguments.", &selmR3InfoTss); 269 } 254 270 DBGFR3InfoRegisterInternal(pVM, "gdtguest", "Displays the guest GDT. No arguments.", &selmR3InfoGdtGuest); 255 DBGFR3InfoRegisterInternal(pVM, "ldt", "Displays the shadow LDT. No arguments.", &selmR3InfoLdt);256 271 DBGFR3InfoRegisterInternal(pVM, "ldtguest", "Displays the guest LDT. No arguments.", &selmR3InfoLdtGuest); 257 //DBGFR3InfoRegisterInternal(pVM, "tss", "Displays the shadow TSS. No arguments.", &selmR3InfoTss);258 272 //DBGFR3InfoRegisterInternal(pVM, "tssguest", "Displays the guest TSS. No arguments.", &selmR3InfoTssGuest); 259 273 … … 281 295 */ 282 296 bool f; 283 # if defined(DEBUG_bird)297 # if defined(DEBUG_bird) 284 298 int rc = CFGMR3QueryBoolDef(CFGMR3GetRoot(pVM), "DoubleFault", &f, true); 285 # else299 # else 286 300 int rc = CFGMR3QueryBoolDef(CFGMR3GetRoot(pVM), "DoubleFault", &f, false); 287 # endif301 # endif 288 302 AssertLogRelRCReturn(rc, rc); 289 if (f )303 if (f && HMIsRawModeCtxNeeded(pVM)) 290 304 { 291 305 PX86DESC paGdt = pVM->selm.s.paGdtR3; … … 419 433 LogFlow(("SELMR3Relocate\n")); 420 434 421 for (VMCPUID i = 0; i < pVM->cCpus; i++) 422 { 423 PVMCPU pVCpu = &pVM->aCpus[i]; 424 425 /* 426 * Update GDTR and selector. 427 */ 428 CPUMSetHyperGDTR(pVCpu, MMHyperR3ToRC(pVM, paGdt), SELM_GDT_ELEMENTS * sizeof(paGdt[0]) - 1); 429 430 /** @todo selector relocations should be a separate operation? */ 431 CPUMSetHyperCS(pVCpu, pVM->selm.s.aHyperSel[SELM_HYPER_SEL_CS]); 432 CPUMSetHyperDS(pVCpu, pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS]); 433 CPUMSetHyperES(pVCpu, pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS]); 434 CPUMSetHyperSS(pVCpu, pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS]); 435 CPUMSetHyperTR(pVCpu, pVM->selm.s.aHyperSel[SELM_HYPER_SEL_TSS]); 436 } 437 438 selmR3SetupHyperGDTSelectors(pVM); 435 if (HMIsRawModeCtxNeeded(pVM)) 436 { 437 for (VMCPUID i = 0; i < pVM->cCpus; i++) 438 { 439 PVMCPU pVCpu = &pVM->aCpus[i]; 440 441 /* 442 * Update GDTR and selector. 443 */ 444 CPUMSetHyperGDTR(pVCpu, MMHyperR3ToRC(pVM, paGdt), SELM_GDT_ELEMENTS * sizeof(paGdt[0]) - 1); 445 446 /** @todo selector relocations should be a separate operation? */ 447 CPUMSetHyperCS(pVCpu, pVM->selm.s.aHyperSel[SELM_HYPER_SEL_CS]); 448 CPUMSetHyperDS(pVCpu, pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS]); 449 CPUMSetHyperES(pVCpu, pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS]); 450 CPUMSetHyperSS(pVCpu, pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS]); 451 CPUMSetHyperTR(pVCpu, pVM->selm.s.aHyperSel[SELM_HYPER_SEL_TSS]); 452 } 453 454 selmR3SetupHyperGDTSelectors(pVM); 439 455 440 456 /** @todo SELM must be called when any of the CR3s changes during a cpu mode change. */ 441 457 /** @todo PGM knows the proper CR3 values these days, not CPUM. */ 442 /*443 * Update the TSSes.444 */445 /* Only applies to raw mode which supports only 1 VCPU */446 PVMCPU pVCpu = &pVM->aCpus[0];447 448 /* Current TSS */449 pVM->selm.s.Tss.cr3 = PGMGetHyperCR3(pVCpu);450 pVM->selm.s.Tss.ss0 = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS];451 pVM->selm.s.Tss.esp0 = VMMGetStackRC(pVCpu);452 pVM->selm.s.Tss.cs = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_CS];453 pVM->selm.s.Tss.ds = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS];454 pVM->selm.s.Tss.es = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS];455 pVM->selm.s.Tss.offIoBitmap = sizeof(VBOXTSS);456 457 /* trap 08 */458 pVM->selm.s.TssTrap08.cr3 = PGMGetInterRCCR3(pVM, pVCpu); /* this should give use better survival chances. */459 pVM->selm.s.TssTrap08.ss0 = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS];460 pVM->selm.s.TssTrap08.ss = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS];461 pVM->selm.s.TssTrap08.esp0 = VMMGetStackRC(pVCpu) - PAGE_SIZE / 2; /* upper half can be analysed this way. */462 pVM->selm.s.TssTrap08.esp = pVM->selm.s.TssTrap08.esp0;463 pVM->selm.s.TssTrap08.ebp = pVM->selm.s.TssTrap08.esp0;464 pVM->selm.s.TssTrap08.cs = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_CS];465 pVM->selm.s.TssTrap08.ds = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS];466 pVM->selm.s.TssTrap08.es = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS];467 pVM->selm.s.TssTrap08.fs = 0;468 pVM->selm.s.TssTrap08.gs = 0;469 pVM->selm.s.TssTrap08.selLdt = 0;470 pVM->selm.s.TssTrap08.eflags = 0x2; /* all cleared */471 pVM->selm.s.TssTrap08.ecx = VM_RC_ADDR(pVM, &pVM->selm.s.Tss); /* setup ecx to normal Hypervisor TSS address. */472 pVM->selm.s.TssTrap08.edi = pVM->selm.s.TssTrap08.ecx;473 pVM->selm.s.TssTrap08.eax = pVM->selm.s.TssTrap08.ecx;474 pVM->selm.s.TssTrap08.edx = VM_RC_ADDR(pVM, pVM); /* setup edx VM address. */475 pVM->selm.s.TssTrap08.edi = pVM->selm.s.TssTrap08.edx;476 pVM->selm.s.TssTrap08.ebx = pVM->selm.s.TssTrap08.edx;477 pVM->selm.s.TssTrap08.offIoBitmap = sizeof(VBOXTSS);478 /* TRPM will be updating the eip */479 480 if ( !pVM->selm.s.fDisableMonitoring 481 &&!HMIsEnabled(pVM))458 /* 459 * Update the TSSes. 460 */ 461 /* Only applies to raw mode which supports only 1 VCPU */ 462 PVMCPU pVCpu = &pVM->aCpus[0]; 463 464 /* Current TSS */ 465 pVM->selm.s.Tss.cr3 = PGMGetHyperCR3(pVCpu); 466 pVM->selm.s.Tss.ss0 = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS]; 467 pVM->selm.s.Tss.esp0 = VMMGetStackRC(pVCpu); 468 pVM->selm.s.Tss.cs = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_CS]; 469 pVM->selm.s.Tss.ds = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS]; 470 pVM->selm.s.Tss.es = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS]; 471 pVM->selm.s.Tss.offIoBitmap = sizeof(VBOXTSS); 472 473 /* trap 08 */ 474 pVM->selm.s.TssTrap08.cr3 = PGMGetInterRCCR3(pVM, pVCpu); /* this should give use better survival chances. */ 475 pVM->selm.s.TssTrap08.ss0 = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS]; 476 pVM->selm.s.TssTrap08.ss = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS]; 477 pVM->selm.s.TssTrap08.esp0 = VMMGetStackRC(pVCpu) - PAGE_SIZE / 2; /* upper half can be analysed this way. */ 478 pVM->selm.s.TssTrap08.esp = pVM->selm.s.TssTrap08.esp0; 479 pVM->selm.s.TssTrap08.ebp = pVM->selm.s.TssTrap08.esp0; 480 pVM->selm.s.TssTrap08.cs = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_CS]; 481 pVM->selm.s.TssTrap08.ds = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS]; 482 pVM->selm.s.TssTrap08.es = pVM->selm.s.aHyperSel[SELM_HYPER_SEL_DS]; 483 pVM->selm.s.TssTrap08.fs = 0; 484 pVM->selm.s.TssTrap08.gs = 0; 485 pVM->selm.s.TssTrap08.selLdt = 0; 486 pVM->selm.s.TssTrap08.eflags = 0x2; /* all cleared */ 487 pVM->selm.s.TssTrap08.ecx = VM_RC_ADDR(pVM, &pVM->selm.s.Tss); /* setup ecx to normal Hypervisor TSS address. */ 488 pVM->selm.s.TssTrap08.edi = pVM->selm.s.TssTrap08.ecx; 489 pVM->selm.s.TssTrap08.eax = pVM->selm.s.TssTrap08.ecx; 490 pVM->selm.s.TssTrap08.edx = VM_RC_ADDR(pVM, pVM); /* setup edx VM address. */ 491 pVM->selm.s.TssTrap08.edi = pVM->selm.s.TssTrap08.edx; 492 pVM->selm.s.TssTrap08.ebx = pVM->selm.s.TssTrap08.edx; 493 pVM->selm.s.TssTrap08.offIoBitmap = sizeof(VBOXTSS); 494 /* TRPM will be updating the eip */ 495 } 496 497 if (!HMIsEnabled(pVM)) 482 498 { 483 499 /* … … 543 559 { 544 560 NOREF(pVM); 545 return 0;561 return VINF_SUCCESS; 546 562 } 547 563 … … 602 618 603 619 #ifdef VBOX_WITH_RAW_MODE 604 /* 605 * Default action when entering raw mode for the first time 606 */ 607 PVMCPU pVCpu = &pVM->aCpus[0]; /* raw mode implies on VCPU */ 608 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 609 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_GDT); 610 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT); 620 if (!HMIsEnabled(pVM)) 621 { 622 /* 623 * Default action when entering raw mode for the first time 624 */ 625 PVMCPU pVCpu = &pVM->aCpus[0]; /* raw mode implies on VCPU */ 626 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 627 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_GDT); 628 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT); 629 } 611 630 #endif 612 631 } … … 793 812 { 794 813 #ifdef VBOX_WITH_RAW_MODE 795 PVMCPU pVCpu = VMMGetCpu(pVM); 796 797 LogFlow(("selmR3LoadDone:\n")); 798 799 /* 800 * Don't do anything if it's a load failure. 801 */ 802 int rc = SSMR3HandleGetStatus(pSSM); 803 if (RT_FAILURE(rc)) 804 return VINF_SUCCESS; 805 806 /* 807 * Do the syncing if we're in protected mode. 808 */ 809 if (PGMGetGuestMode(pVCpu) != PGMMODE_REAL) 810 { 814 if (!HMIsEnabled(pVM)) 815 { 816 PVMCPU pVCpu = VMMGetCpu(pVM); 817 818 LogFlow(("selmR3LoadDone:\n")); 819 820 /* 821 * Don't do anything if it's a load failure. 822 */ 823 int rc = SSMR3HandleGetStatus(pSSM); 824 if (RT_FAILURE(rc)) 825 return VINF_SUCCESS; 826 827 /* 828 * Do the syncing if we're in protected mode and using raw-mode. 829 */ 830 if (PGMGetGuestMode(pVCpu) != PGMMODE_REAL) 831 { 832 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_GDT); 833 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT); 834 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 835 SELMR3UpdateFromCPUM(pVM, pVCpu); 836 } 837 838 /* 839 * Flag everything for resync on next raw mode entry. 840 */ 811 841 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_GDT); 812 842 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT); 813 843 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 814 SELMR3UpdateFromCPUM(pVM, pVCpu); 815 } 816 817 /* 818 * Flag everything for resync on next raw mode entry. 819 */ 820 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_GDT); 821 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT); 822 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 823 844 } 824 845 #endif /*VBOX_WITH_RAW_MODE*/ 825 846 return VINF_SUCCESS; … … 837 858 static int selmR3UpdateShadowGdt(PVM pVM, PVMCPU pVCpu) 838 859 { 860 Assert(!HMIsEnabled(pVM)); 861 839 862 /* 840 863 * Always assume the best... … … 1100 1123 { 1101 1124 int rc = VINF_SUCCESS; 1125 Assert(!HMIsEnabled(pVM)); 1102 1126 1103 1127 /* … … 1334 1358 { 1335 1359 Assert(CPUMIsGuestInProtectedMode(pVCpu)); 1360 Assert(!HMIsEnabled(pVM)); 1336 1361 1337 1362 /* … … 1435 1460 VMMR3DECL(VBOXSTRICTRC) SELMR3UpdateFromCPUM(PVM pVM, PVMCPU pVCpu) 1436 1461 { 1437 if (pVM->selm.s.fDisableMonitoring)1438 {1439 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_SELM_SYNC_GDT);1440 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_SELM_SYNC_LDT);1441 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_SELM_SYNC_TSS);1442 return VINF_SUCCESS;1443 }1444 1445 1462 STAM_PROFILE_START(&pVM->selm.s.StatUpdateFromCPUM, a); 1463 AssertReturn(!HMIsEnabled(pVM), VERR_SELM_HM_IPE); 1446 1464 1447 1465 /* … … 1599 1617 VMMR3DECL(int) SELMR3SyncTSS(PVM pVM, PVMCPU pVCpu) 1600 1618 { 1601 int rc; 1602 1603 if (pVM->selm.s.fDisableMonitoring) 1604 { 1605 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 1606 return VINF_SUCCESS; 1607 } 1619 int rc; 1620 AssertReturnStmt(!HMIsEnabled(pVM), VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_SELM_SYNC_TSS), VINF_SUCCESS); 1608 1621 1609 1622 STAM_PROFILE_START(&pVM->selm.s.StatTSSSync, a); … … 1842 1855 #ifdef VBOX_STRICT 1843 1856 PVMCPU pVCpu = VMMGetCpu(pVM); 1857 AssertReturn(!HMIsEnabled(pVM), VERR_SELM_HM_IPE); 1844 1858 1845 1859 /* -
trunk/src/VBox/VMM/VMMR3/VMM.cpp
r45618 r45701 211 211 rc = RTSemEventCreate(&pVM->vmm.s.hEvtRendezvousDoneCaller); 212 212 AssertRCReturn(rc, rc); 213 214 /* GC switchers are enabled by default. Turned off by HM. */215 pVM->vmm.s.fSwitcherDisabled = false;216 213 217 214 /* … … 549 546 550 547 /* In VMX mode, there's no need to init RC. */ 551 if ( pVM->vmm.s.fSwitcherDisabled)548 if (HMIsEnabled(pVM)) 552 549 return VINF_SUCCESS; 553 550 -
trunk/src/VBox/VMM/VMMR3/VMMSwitcher.cpp
r44168 r45701 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 … … 16 16 */ 17 17 18 18 19 /******************************************************************************* 19 20 * Header Files * … … 22 23 #include <VBox/vmm/vmm.h> 23 24 #include <VBox/vmm/pgm.h> 25 #include <VBox/vmm/hm.h> 24 26 #include <VBox/vmm/selm.h> 25 27 #include <VBox/vmm/mm.h> … … 46 48 * The type and index shall match! 47 49 */ 48 static PVMMSWITCHERDEF s_apSwitchers[VMMSWITCHER_MAX] =50 static PVMMSWITCHERDEF g_apRawModeSwitchers[VMMSWITCHER_MAX] = 49 51 { 50 52 NULL, /* invalid entry */ … … 73 75 &vmmR3SwitcherAMD64To32Bit_Def, 74 76 &vmmR3SwitcherAMD64ToPAE_Def, 75 NULL 77 NULL, //&vmmR3SwitcherAMD64ToAMD64_Def, 76 78 # endif /* RT_ARCH_AMD64 */ 77 79 #else /* !VBOX_WITH_RAW_MODE */ … … 84 86 NULL, 85 87 NULL, 86 NULL 88 NULL, 87 89 #endif /* !VBOX_WITH_RAW_MODE */ 90 #ifndef RT_ARCH_AMD64 91 &vmmR3SwitcherX64Stub_Def, 92 NULL, 93 #else 94 NULL, 95 &vmmR3SwitcherAMD64Stub_Def, 96 #endif 97 }; 98 99 /** Array of switcher definitions. 100 * The type and index shall match! 101 */ 102 static PVMMSWITCHERDEF g_apHmSwitchers[VMMSWITCHER_MAX] = 103 { 104 NULL, /* invalid entry */ 105 #if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS) && !defined(VBOX_WITH_HYBRID_32BIT_KERNEL) 106 NULL, //&vmmR3Switcher32BitTo32Bit_Def, 107 NULL, //&vmmR3Switcher32BitToPAE_Def, 108 &vmmR3Switcher32BitToAMD64_Def, 109 NULL, //&vmmR3SwitcherPAETo32Bit_Def, 110 NULL, //&vmmR3SwitcherPAEToPAE_Def, 111 &vmmR3SwitcherPAEToAMD64_Def, 112 NULL, //&vmmR3SwitcherPAETo32Bit_Def, 113 NULL, //&vmmR3SwitcherAMD64ToPAE_Def, 114 NULL, //&vmmR3SwitcherAMD64ToAMD64_Def, 115 #else /* !VBOX_WITH_RAW_MODE */ 116 NULL, 117 NULL, 118 NULL, 119 NULL, 120 NULL, 121 NULL, 122 NULL, 123 NULL, 124 NULL, 125 #endif /* !VBOX_WITH_RAW_MODE */ 126 #ifndef RT_ARCH_AMD64 127 &vmmR3SwitcherX64Stub_Def, 128 NULL, 129 #else 130 NULL, 131 &vmmR3SwitcherAMD64Stub_Def, 132 #endif 88 133 }; 89 134 … … 100 145 int vmmR3SwitcherInit(PVM pVM) 101 146 { 102 #ifndef VBOX_WITH_RAW_MODE 147 #ifndef VBOX_WITH_RAW_MODE /** @todo 64-bit on 32-bit. */ 103 148 return VINF_SUCCESS; 104 149 #else … … 106 151 * Calc the size. 107 152 */ 153 const PVMMSWITCHERDEF *papSwitchers = HMIsEnabled(pVM) ? g_apHmSwitchers : g_apRawModeSwitchers; 108 154 unsigned cbCoreCode = 0; 109 for (unsigned iSwitcher = 0; iSwitcher < RT_ELEMENTS(s_apSwitchers); iSwitcher++)155 for (unsigned iSwitcher = 0; iSwitcher < VMMSWITCHER_MAX; iSwitcher++) 110 156 { 111 157 pVM->vmm.s.aoffSwitchers[iSwitcher] = cbCoreCode; 112 PVMMSWITCHERDEF pSwitcher = s_apSwitchers[iSwitcher];158 PVMMSWITCHERDEF pSwitcher = papSwitchers[iSwitcher]; 113 159 if (pSwitcher) 114 160 { … … 180 226 * copy the code. 181 227 */ 182 for (unsigned iSwitcher = 0; iSwitcher < RT_ELEMENTS(s_apSwitchers); iSwitcher++)228 for (unsigned iSwitcher = 0; iSwitcher < VMMSWITCHER_MAX; iSwitcher++) 183 229 { 184 PVMMSWITCHERDEF pSwitcher = s_apSwitchers[iSwitcher];230 PVMMSWITCHERDEF pSwitcher = papSwitchers[iSwitcher]; 185 231 if (pSwitcher) 186 232 memcpy((uint8_t *)pVM->vmm.s.pvCoreCodeR3 + pVM->vmm.s.aoffSwitchers[iSwitcher], … … 205 251 * to get the routine addresses, so we'll reselect it. 206 252 * This may legally fail so, we're ignoring the rc. 253 * Note! See HMIsEnabled hack in selector function. 207 254 */ 208 255 VMMR3SelectSwitcher(pVM, pVM->vmm.s.enmSwitcher); … … 238 285 * Relocate all the switchers. 239 286 */ 240 for (unsigned iSwitcher = 0; iSwitcher < RT_ELEMENTS(s_apSwitchers); iSwitcher++) 241 { 242 PVMMSWITCHERDEF pSwitcher = s_apSwitchers[iSwitcher]; 287 const PVMMSWITCHERDEF *papSwitchers = HMIsEnabled(pVM) ? g_apHmSwitchers : g_apRawModeSwitchers; 288 for (unsigned iSwitcher = 0; iSwitcher < VMMSWITCHER_MAX; iSwitcher++) 289 { 290 PVMMSWITCHERDEF pSwitcher = papSwitchers[iSwitcher]; 243 291 if (pSwitcher && pSwitcher->pfnRelocate) 244 292 { … … 256 304 * Recalc the RC address for the current switcher. 257 305 */ 258 PVMMSWITCHERDEF pSwitcher = s_apSwitchers[pVM->vmm.s.enmSwitcher]; 259 RTRCPTR RCPtr = pVM->vmm.s.pvCoreCodeRC + pVM->vmm.s.aoffSwitchers[pVM->vmm.s.enmSwitcher]; 260 pVM->vmm.s.pfnRCToHost = RCPtr + pSwitcher->offRCToHost; 261 pVM->vmm.s.pfnCallTrampolineRC = RCPtr + pSwitcher->offRCCallTrampoline; 262 pVM->pfnVMMRCToHostAsm = RCPtr + pSwitcher->offRCToHostAsm; 263 pVM->pfnVMMRCToHostAsmNoReturn = RCPtr + pSwitcher->offRCToHostAsmNoReturn; 306 PVMMSWITCHERDEF pSwitcher = papSwitchers[pVM->vmm.s.enmSwitcher]; 307 if (pSwitcher) 308 { 309 RTRCPTR RCPtr = pVM->vmm.s.pvCoreCodeRC + pVM->vmm.s.aoffSwitchers[pVM->vmm.s.enmSwitcher]; 310 pVM->vmm.s.pfnRCToHost = RCPtr + pSwitcher->offRCToHost; 311 pVM->vmm.s.pfnCallTrampolineRC = RCPtr + pSwitcher->offRCCallTrampoline; 312 pVM->pfnVMMRCToHostAsm = RCPtr + pSwitcher->offRCToHostAsm; 313 pVM->pfnVMMRCToHostAsmNoReturn = RCPtr + pSwitcher->offRCToHostAsmNoReturn; 314 } 315 else 316 AssertRelease(HMIsEnabled(pVM)); 264 317 265 318 // AssertFailed(); … … 962 1015 } 963 1016 964 /* Do nothing if the switcher is disabled. */ 965 if (pVM->vmm.s.fSwitcherDisabled) 966 return VINF_SUCCESS; 1017 /* 1018 * Override it if HM is active. 1019 */ 1020 if (HMIsEnabled(pVM)) 1021 pVM->vmm.s.enmSwitcher = HC_ARCH_BITS == 64 ? VMMSWITCHER_AMD64_STUB : VMMSWITCHER_X86_STUB; 967 1022 968 1023 /* 969 1024 * Select the new switcher. 970 1025 */ 971 PVMMSWITCHERDEF pSwitcher = s_apSwitchers[enmSwitcher]; 1026 const PVMMSWITCHERDEF *papSwitchers = HMIsEnabled(pVM) ? g_apHmSwitchers : g_apRawModeSwitchers; 1027 PVMMSWITCHERDEF pSwitcher = papSwitchers[enmSwitcher]; 972 1028 if (pSwitcher) 973 1029 { … … 993 1049 994 1050 /** 995 * Disable the switcher logic permanently.996 *997 * @returns VBox status code.998 * @param pVM Pointer to the VM.999 */1000 VMMR3_INT_DECL(int) VMMR3DisableSwitcher(PVM pVM)1001 {1002 /** @todo r=bird: I would suggest that we create a dummy switcher which just does something like:1003 * @code1004 * mov eax, VERR_VMM_DUMMY_SWITCHER1005 * ret1006 * @endcode1007 * And then check for fSwitcherDisabled in VMMR3SelectSwitcher() in order to prevent it from being removed.1008 */1009 pVM->vmm.s.fSwitcherDisabled = true;1010 return VINF_SUCCESS;1011 }1012 1013 1014 /**1015 1051 * Gets the switcher to be used for switching to GC. 1016 1052 * … … 1034 1070 * Select the new switcher. 1035 1071 */ 1036 PVMMSWITCHERDEF pSwitcher = s_apSwitchers[enmSwitcher]; 1072 const PVMMSWITCHERDEF *papSwitchers = HMIsEnabled(pVM) ? g_apHmSwitchers : g_apRawModeSwitchers; 1073 PVMMSWITCHERDEF pSwitcher = papSwitchers[enmSwitcher]; 1037 1074 if (pSwitcher) 1038 1075 { -
trunk/src/VBox/VMM/include/VMMInternal.h
r45097 r45701 217 217 /** Pointer to core code guest context mapping. */ 218 218 RTRCPTR pvCoreCodeRC; 219 RTRCPTR pRCPadding0; /**< Alignment padding */219 RTRCPTR pRCPadding0; /**< Alignment padding. */ 220 220 #ifdef VBOX_WITH_NMI 221 221 /** The guest context address of the APIC (host) mapping. */ 222 222 RTRCPTR GCPtrApicBase; 223 RTRCPTR pRCPadding1; /**< Alignment padding */223 RTRCPTR pRCPadding1; /**< Alignment padding. */ 224 224 #endif 225 225 /** The current switcher. 226 226 * This will be set before the VMM is fully initialized. */ 227 227 VMMSWITCHER enmSwitcher; 228 /** Flag to disable the switcher permanently (VMX) (boolean) */229 bool fSwitcherDisabled;230 228 /** Array of offsets to the different switchers within the core code. */ 231 RTUINT aoffSwitchers[VMMSWITCHER_MAX]; 229 uint32_t aoffSwitchers[VMMSWITCHER_MAX]; 230 uint32_t u32Padding2; /**< Alignment padding. */ 232 231 233 232 /** Resume Guest Execution. See CPUMGCResumeGuest(). */ -
trunk/src/VBox/VMM/include/VMMSwitcher.h
r44528 r45701 128 128 129 129 RT_C_DECLS_BEGIN 130 extern VMMSWITCHERDEF vmmR3SwitcherX86Stub_Def; 130 131 extern VMMSWITCHERDEF vmmR3Switcher32BitTo32Bit_Def; 131 132 extern VMMSWITCHERDEF vmmR3Switcher32BitToPAE_Def; … … 134 135 extern VMMSWITCHERDEF vmmR3SwitcherPAEToPAE_Def; 135 136 extern VMMSWITCHERDEF vmmR3SwitcherPAEToAMD64_Def; 137 extern VMMSWITCHERDEF vmmR3SwitcherAMD64Stub_Def; 136 138 extern VMMSWITCHERDEF vmmR3SwitcherAMD64To32Bit_Def; 137 139 extern VMMSWITCHERDEF vmmR3SwitcherAMD64ToPAE_Def; -
trunk/src/VBox/VMM/include/VMMSwitcher.mac
r44528 r45701 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 … … 32 32 %define VMMSWITCHER_AMD64_TO_PAE 8 33 33 %define VMMSWITCHER_AMD64_TO_AMD64 9 34 ;; @todo the rest are all wrong. sync with vmm.h. 35 %define VMMSWITCHER_HOST_TO_VMX 9 36 %define VMMSWITCHER_HOST_TO_SVM 10 34 %define VMMSWITCHER_X86_STUB 10 35 %define VMMSWITCHER_AMD64_STUB 11 37 36 %define VMMSWITCHER_MAX 12 38 37 ; } -
trunk/src/recompiler/VBoxRecompiler.c
r45642 r45701 1797 1797 pCtx->cr3 = env->cr[3]; 1798 1798 #ifdef VBOX_WITH_RAW_MODE 1799 if (( env->cr[4] ^ pCtx->cr4) & X86_CR4_VME)1799 if (((env->cr[4] ^ pCtx->cr4) & X86_CR4_VME) && !HMIsEnabled(pVM)) 1800 1800 VMCPU_FF_SET(env->pVCpu, VMCPU_FF_SELM_SYNC_TSS); 1801 1801 #endif … … 1920 1920 pCtx->cr3 = env->cr[3]; 1921 1921 #ifdef VBOX_WITH_RAW_MODE 1922 if (( env->cr[4] ^ pCtx->cr4) & X86_CR4_VME)1922 if (((env->cr[4] ^ pCtx->cr4) & X86_CR4_VME) && !HMIsEnabled(pVM)) 1923 1923 VMCPU_FF_SET(env->pVCpu, VMCPU_FF_SELM_SYNC_TSS); 1924 1924 #endif … … 1962 1962 pCtx->cr3 = env->cr[3]; 1963 1963 #ifdef VBOX_WITH_RAW_MODE 1964 if (( env->cr[4] ^ pCtx->cr4) & X86_CR4_VME)1964 if (((env->cr[4] ^ pCtx->cr4) & X86_CR4_VME) && !HMIsEnabled(pVM)) 1965 1965 VMCPU_FF_SET(env->pVCpu, VMCPU_FF_SELM_SYNC_TSS); 1966 1966 #endif … … 2654 2654 pCtx->cr3 = pVM->rem.s.Env.cr[3]; 2655 2655 #ifdef VBOX_WITH_RAW_MODE 2656 if (( pVM->rem.s.Env.cr[4] ^ pCtx->cr4) & X86_CR4_VME)2656 if (((pVM->rem.s.Env.cr[4] ^ pCtx->cr4) & X86_CR4_VME) && !HMIsEnabled(pVM)) 2657 2657 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 2658 2658 #endif … … 2668 2668 STAM_COUNTER_INC(&gStatREMGDTChange); 2669 2669 #ifdef VBOX_WITH_RAW_MODE 2670 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_GDT); 2670 if (!HMIsEnabled(pVM)) 2671 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_GDT); 2671 2672 #endif 2672 2673 } … … 2698 2699 STAM_COUNTER_INC(&gStatREMLDTRChange); 2699 2700 #ifdef VBOX_WITH_RAW_MODE 2700 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT); 2701 if (!HMIsEnabled(pVM)) 2702 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT); 2701 2703 #endif 2702 2704 } … … 2727 2729 STAM_COUNTER_INC(&gStatREMTRChange); 2728 2730 #ifdef VBOX_WITH_RAW_MODE 2729 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 2731 if (!HMIsEnabled(pVM)) 2732 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 2730 2733 #endif 2731 2734 } … … 2886 2889 pCtx->cr3 = pVM->rem.s.Env.cr[3]; 2887 2890 #ifdef VBOX_WITH_RAW_MODE 2888 if (( pVM->rem.s.Env.cr[4] ^ pCtx->cr4) & X86_CR4_VME)2891 if (((pVM->rem.s.Env.cr[4] ^ pCtx->cr4) & X86_CR4_VME) && !HMIsEnabled(pVM)) 2889 2892 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 2890 2893 #endif … … 2900 2903 STAM_COUNTER_INC(&gStatREMGDTChange); 2901 2904 #ifdef VBOX_WITH_RAW_MODE 2902 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_GDT); 2905 if (!HMIsEnabled(pVM)) 2906 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_GDT); 2903 2907 #endif 2904 2908 } … … 2930 2934 STAM_COUNTER_INC(&gStatREMLDTRChange); 2931 2935 #ifdef VBOX_WITH_RAW_MODE 2932 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT); 2936 if (!HMIsEnabled(pVM)) 2937 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT); 2933 2938 #endif 2934 2939 } … … 2959 2964 STAM_COUNTER_INC(&gStatREMTRChange); 2960 2965 #ifdef VBOX_WITH_RAW_MODE 2961 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 2966 if (!HMIsEnabled(pVM)) 2967 VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS); 2962 2968 #endif 2963 2969 }
Note:
See TracChangeset
for help on using the changeset viewer.