Changeset 70918 in vbox for trunk/src/VBox/VMM/VMMR3
- Timestamp:
- Feb 8, 2018 4:11:47 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120746
- Location:
- trunk/src/VBox/VMM/VMMR3
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/HM.cpp
r70606 r70918 51 51 #include <VBox/vmm/csam.h> 52 52 #include <VBox/vmm/selm.h> 53 #include <VBox/vmm/nem.h> 53 54 #ifdef VBOX_WITH_REM 54 55 # include <VBox/vmm/rem.h> … … 394 395 * Initializes the HM. 395 396 * 396 * This reads the config and check whether VT-x or AMD-V hardware is available 397 * if configured to use it. This is one of the very first components to be 398 * initialized after CFGM, so that we can fall back to raw-mode early in the 399 * initialization process. 397 * This is the very first component to really do init after CFGM so that we can 398 * establish the predominat execution engine for the VM prior to initializing 399 * other modules. It takes care of NEM initialization if needed (HM disabled or 400 * not available in HW). 401 * 402 * If VT-x or AMD-V hardware isn't available, HM will try fall back on a native 403 * hypervisor API via NEM, and then back on raw-mode if that isn't available 404 * either. The fallback to raw-mode will not happen if /HM/HMForced is set 405 * (like for guest using SMP or 64-bit as well as for complicated guest like OS 406 * X, OS/2 and others). 400 407 * 401 408 * Note that a lot of the set up work is done in ring-0 and thus postponed till … … 449 456 rc = CFGMR3ValidateConfig(pCfgHm, "/HM/", 450 457 "HMForced" 458 "|UseNEMInstead" 459 "|FallbackToNEM" 451 460 "|EnableNestedPaging" 452 461 "|EnableUX" … … 492 501 #endif /* !VBOX_WITH_RAW_MODE */ 493 502 503 /** @cfgm{/HM/UseNEMInstead, bool, true} 504 * Don't use HM, use NEM instead. */ 505 bool fUseNEMInstead = false; 506 rc = CFGMR3QueryBoolDef(pCfgHm, "UseNEMInstead", &fUseNEMInstead, false); 507 AssertRCReturn(rc, rc); 508 if (fUseNEMInstead && pVM->fHMEnabled) 509 { 510 LogRel(("HM: Setting fHMEnabled to false because fUseNEMInstead is set.\n")); 511 pVM->fHMEnabled = false; 512 } 513 514 /** @cfgm{/HM/FallbackToNEM, bool, true} 515 * Enables fallback on NEM. */ 516 bool fFallbackToNEM = true; 517 rc = CFGMR3QueryBoolDef(pCfgHm, "FallbackToNEM", &fFallbackToNEM, true); 518 AssertRCReturn(rc, rc); 519 494 520 /** @cfgm{/HM/EnableNestedPaging, bool, false} 495 521 * Enables nested paging (aka extended page tables). */ … … 643 669 else if (fCaps & SUPVTCAPS_VT_X) 644 670 { 645 rc = SUPR3QueryVTxSupported(); 671 const char *pszWhy; 672 rc = SUPR3QueryVTxSupported(&pszWhy); 646 673 if (RT_SUCCESS(rc)) 647 674 { … … 654 681 else 655 682 { 656 #ifdef RT_OS_LINUX 657 const char *pszMinReq = " Linux 2.6.13 or newer required!"; 658 #else 659 const char *pszMinReq = ""; 660 #endif 661 if (fHMForced) 662 return VMSetError(pVM, rc, RT_SRC_POS, "The host kernel does not support VT-x.%s\n", pszMinReq); 663 664 /* Fall back to raw-mode. */ 665 LogRel(("HM: HMR3Init: Falling back to raw-mode: The host kernel does not support VT-x.%s\n", pszMinReq)); 683 /* 684 * Before failing, try fallback to NEM if we're allowed to do that. 685 */ 666 686 pVM->fHMEnabled = false; 687 if (fFallbackToNEM) 688 { 689 LogRel(("HM: HMR3Init: Attempting fall back to NEM: The host kernel does not support VT-x - %s\n", pszWhy)); 690 int rc2 = NEMR3Init(pVM, true /*fFallback*/, fHMForced); 691 if ( RT_SUCCESS(rc2) 692 && pVM->fNEMActive) 693 rc = VINF_SUCCESS; 694 } 695 if (RT_FAILURE(rc)) 696 { 697 if (fHMForced) 698 return VMSetError(pVM, rc, RT_SRC_POS, "The host kernel does not support VT-x: %s\n", pszWhy); 699 700 /* Fall back to raw-mode. */ 701 LogRel(("HM: HMR3Init: Falling back to raw-mode: The host kernel does not support VT-x - %s\n", pszWhy)); 702 } 667 703 } 668 704 } … … 738 774 739 775 default: 740 pszMsg = NULL; 741 break; 776 return VMSetError(pVM, rc, RT_SRC_POS, "SUPR3QueryVTCaps failed with %Rrc", rc); 742 777 } 743 if (fHMForced && pszMsg) 744 return VM_SET_ERROR(pVM, rc, pszMsg); 745 if (!pszMsg) 746 return VMSetError(pVM, rc, RT_SRC_POS, "SUPR3QueryVTCaps failed with %Rrc", rc); 747 748 /* Fall back to raw-mode. */ 749 LogRel(("HM: HMR3Init: Falling back to raw-mode: %s\n", pszMsg)); 778 779 /* 780 * Before failing, try fallback to NEM if we're allowed to do that. 781 */ 750 782 pVM->fHMEnabled = false; 783 if (fFallbackToNEM) 784 { 785 LogRel(("HM: HMR3Init: Attempting fall back to NEM: %s\n", pszMsg)); 786 int rc2 = NEMR3Init(pVM, true /*fFallback*/, fHMForced); 787 if ( RT_SUCCESS(rc2) 788 && pVM->fNEMActive) 789 rc = VINF_SUCCESS; 790 } 791 if (RT_FAILURE(rc)) 792 { 793 if (fHMForced) 794 return VM_SET_ERROR(pVM, rc, pszMsg); 795 796 LogRel(("HM: HMR3Init: Falling back to raw-mode: %s\n", pszMsg)); 797 } 751 798 } 799 } 800 /* 801 * If NEM is supposed to be used instead, initialize it instead. 802 */ 803 else if (fUseNEMInstead) 804 { 805 rc = NEMR3Init(pVM, false /*fFallback*/, fHMForced); 806 if (RT_FAILURE(rc)) 807 return rc; 752 808 } 753 809 -
trunk/src/VBox/VMM/VMMR3/VM.cpp
r69111 r70918 61 61 # include <VBox/vmm/rem.h> 62 62 #endif 63 #include <VBox/vmm/nem.h> 63 64 #include <VBox/vmm/apic.h> 64 65 #include <VBox/vmm/tm.h> … … 925 926 /* 926 927 * Init all R3 components, the order here might be important. 927 * HM shall be initialized first! 928 */ 929 rc = HMR3Init(pVM); 928 * NEM and HM shall be initialized first! 929 */ 930 rc = NEMR3InitConfig(pVM); 931 if (RT_SUCCESS(rc)) 932 rc = HMR3Init(pVM); 930 933 if (RT_SUCCESS(rc)) 931 934 { … … 1076 1079 AssertRC(rc2); 1077 1080 } 1078 1081 NEMR3Term(pVM); 1079 1082 1080 1083 LogFlow(("vmR3InitRing3: returns %Rrc\n", rc)); … … 1168 1171 if (RT_SUCCESS(rc)) 1169 1172 rc = HMR3InitCompleted(pVM, enmWhat); 1173 if (RT_SUCCESS(rc)) 1174 rc = NEMR3InitCompleted(pVM, enmWhat); 1170 1175 if (RT_SUCCESS(rc)) 1171 1176 rc = PGMR3InitCompleted(pVM, enmWhat); … … 2516 2521 rc = HMR3Term(pVM); 2517 2522 AssertRC(rc); 2523 rc = NEMR3Term(pVM); 2524 AssertRC(rc); 2518 2525 rc = PGMR3Term(pVM); 2519 2526 AssertRC(rc); … … 2804 2811 EMR3Reset(pVM); 2805 2812 HMR3Reset(pVM); /* This must come *after* PATM, CSAM, CPUM, SELM and TRPM. */ 2813 NEMR3Reset(pVM); 2806 2814 2807 2815 /* … … 2907 2915 EMR3Reset(pVM); 2908 2916 HMR3Reset(pVM); /* This must come *after* PATM, CSAM, CPUM, SELM and TRPM. */ 2917 NEMR3Reset(pVM); 2909 2918 2910 2919 /* … … 4632 4641 EMR3ResetCpu(pVCpu); 4633 4642 HMR3ResetCpu(pVCpu); 4643 NEMR3ResetCpu(pVCpu); 4634 4644 return VINF_EM_WAIT_SIPI; 4635 4645 } -
trunk/src/VBox/VMM/VMMR3/VMM.cpp
r70917 r70918 112 112 #include <VBox/vmm/gim.h> 113 113 #include <VBox/vmm/mm.h> 114 #include <VBox/vmm/nem.h> 114 115 #include <VBox/vmm/iom.h> 115 116 #include <VBox/vmm/trpm.h> … … 1494 1495 EMR3ResetCpu(pVCpu); 1495 1496 HMR3ResetCpu(pVCpu); 1497 NEMR3ResetCpu(pVCpu); 1496 1498 1497 1499 /* This will trickle up on the target EMT. */
Note:
See TracChangeset
for help on using the changeset viewer.