Changeset 51333 in vbox for trunk/src/VBox/VMM/VMMR3
- Timestamp:
- May 22, 2014 4:42:22 AM (11 years ago)
- Location:
- trunk/src/VBox/VMM/VMMR3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/GIM.cpp
r50994 r51333 28 28 * A GIM provider implements a particular hypervisor interface such as Microsoft 29 29 * Hyper-V, Linux KVM and so on. It hooks into various components in the VMM to 30 * ease the guest in running under a recognized virtualized environment. Thisis31 * also referred to as paravirtualization interfaces.30 * ease the guest in running under a recognized, virtualized environment. This 31 * is also referred to as paravirtualization interfaces. 32 32 * 33 33 * The idea behind this is primarily for making guests more accurate and … … 39 39 * itself, resulting in higher accuracy and saving several CPU cycles. 40 40 * 41 * Only one provider can be active for a running VM. 41 * At most, only one GIM provider can be active for a running VM and cannot be 42 * changed during the lifetime of the VM. 42 43 */ 43 44 … … 105 106 AssertLogRelRCReturn(rc, rc); 106 107 108 /** @cfgm{GIM/Version, uint32_t} 109 * The interface version. The default is 0, which means "provide the most 110 * up-to-date implementation". */ 111 uint32_t uVersion; 112 rc = CFGMR3QueryU32Def(pCfgNode, "Version", &uVersion, 0 /* default */); 113 AssertLogRelRCReturn(rc, rc); 114 107 115 /* 108 116 * Setup the GIM provider for this VM. 109 117 */ 110 LogRel(("GIM: Using provider \"%s\" \n", szProvider));118 LogRel(("GIM: Using provider \"%s\" version %u\n", szProvider, uVersion)); 111 119 if (!RTStrCmp(szProvider, "None")) 112 120 { 113 121 Assert(!pVM->gim.s.fEnabled); 114 pVM->gim.s.enmProvider = GIMPROVIDER_NONE;122 pVM->gim.s.enmProviderId = GIMPROVIDERID_NONE; 115 123 } 116 124 else 117 125 { 118 126 pVM->gim.s.fEnabled = true; 127 pVM->gim.s.u32Version = uVersion; 119 128 if (!RTStrCmp(szProvider, "Minimal")) 120 129 { 121 pVM->gim.s.enmProvider = GIMPROVIDER_MINIMAL;130 pVM->gim.s.enmProviderId = GIMPROVIDERID_MINIMAL; 122 131 rc = GIMR3MinimalInit(pVM); 123 132 } 124 133 else if (!RTStrCmp(szProvider, "HyperV")) 125 134 { 126 pVM->gim.s.enmProvider = GIMPROVIDER_HYPERV;135 pVM->gim.s.enmProviderId = GIMPROVIDERID_HYPERV; 127 136 rc = GIMR3HvInit(pVM); 128 137 } … … 157 166 } 158 167 159 switch (pVM->gim.s.enmProvider )160 { 161 case GIMPROVIDER _MINIMAL:168 switch (pVM->gim.s.enmProviderId) 169 { 170 case GIMPROVIDERID_MINIMAL: 162 171 { 163 172 GIMR3MinimalRelocate(pVM, offDelta); … … 165 174 } 166 175 167 case GIMPROVIDER _HYPERV:176 case GIMPROVIDERID_HYPERV: 168 177 { 169 178 GIMR3HvRelocate(pVM, offDelta); … … 171 180 } 172 181 173 case GIMPROVIDER _KVM: /** @todo KVM. */182 case GIMPROVIDERID_KVM: /** @todo KVM. */ 174 183 default: 175 184 { 176 AssertMsgFailed(("Invalid provider id %#x\n", pVM->gim.s.enmProvider));185 AssertMsgFailed(("Invalid provider Id %#x\n", pVM->gim.s.enmProviderId)); 177 186 break; 178 187 } -
trunk/src/VBox/VMM/VMMR3/GIMHv.cpp
r50953 r51333 25 25 #include <iprt/assert.h> 26 26 #include <iprt/err.h> 27 #include <iprt/string.h> 27 28 28 29 #include <VBox/vmm/cpum.h> … … 30 31 #include <VBox/vmm/hm.h> 31 32 #include <VBox/vmm/pdmapi.h> 33 #include <VBox/version.h> 32 34 33 35 /******************************************************************************* … … 37 39 38 40 41 /** 42 * Initializes the Hyper-V GIM provider. 43 * 44 * @returns VBox status code. 45 * @param pVM Pointer to the VM. 46 * @param uVersion The interface version this VM should use. 47 */ 39 48 VMMR3_INT_DECL(int) GIMR3HvInit(PVM pVM) 40 49 { 41 50 AssertReturn(pVM, VERR_INVALID_PARAMETER); 42 AssertReturn(pVM->gim.s.enmProvider == GIMPROVIDER_HYPERV, VERR_INTERNAL_ERROR_5);51 AssertReturn(pVM->gim.s.enmProviderId == GIMPROVIDERID_HYPERV, VERR_INTERNAL_ERROR_5); 43 52 44 53 int rc; 54 #if 0 45 55 pVM->gim.s.pfnHypercallR3 = &GIMHvHypercall; 46 56 if (!HMIsEnabled(pVM)) … … 51 61 rc = PDMR3LdrGetSymbolR0(pVM, NULL /* pszModule */, GIMHV_HYPERCALL, &pVM->gim.s.pfnHypercallR0); 52 62 AssertRCReturn(rc, rc); 63 #endif 64 65 /* 66 * Determine interface capabilities based on the version. 67 */ 68 uint32_t uBaseFeat = 0; 69 uint32_t uPartFlags = 0; 70 uint32_t uPowMgmtFeat = 0; 71 uint32_t uMiscFeat = 0; 72 uint32_t uHyperHints = 0; 73 if (!pVM->gim.s.u32Version) 74 { 75 uBaseFeat = GIM_HV_BASE_FEAT_PART_REF_COUNT_MSR; 76 pVM->gim.s.u.hv.u16HyperIdVersionMajor = VBOX_VERSION_MAJOR; 77 pVM->gim.s.u.hv.u16HyperIdVersionMajor = VBOX_VERSION_MINOR; 78 pVM->gim.s.u.hv.u32HyperIdBuildNumber = VBOX_VERSION_BUILD; 79 } 53 80 54 81 /* … … 57 84 CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP); 58 85 59 /** @todo Register CPUID leaves, MSR ranges with CPUM. */ 86 /* 87 * Modify the standard hypervisor leaves for Hyper-V. 88 */ 89 CPUMCPUIDLEAF HyperLeaf; 90 RT_ZERO(HyperLeaf); 91 HyperLeaf.uLeaf = UINT32_C(0x40000000); 92 HyperLeaf.uEax = UINT32_C(0x40000005); /* Minimum value for Hyper-V */ 93 HyperLeaf.uEbx = 0x7263694D; /* 'Micr' */ 94 HyperLeaf.uEcx = 0x666F736F; /* 'osof' */ 95 HyperLeaf.uEdx = 0x76482074; /* 't Hv' */ 96 rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf); 97 AssertLogRelRCReturn(rc, rc); 98 99 HyperLeaf.uLeaf = UINT32_C(0x40000001); 100 HyperLeaf.uEax = 0x31237648; /* 'Hv#1' */ 101 HyperLeaf.uEbx = 0; /* Reserved */ 102 HyperLeaf.uEcx = 0; /* Reserved */ 103 HyperLeaf.uEdx = 0; /* Reserved */ 104 rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf); 105 AssertLogRelRCReturn(rc, rc); 106 107 /* 108 * Add Hyper-V specific leaves. 109 */ 110 HyperLeaf.uLeaf = UINT32_C(0x40000002); /* MBZ until MSR_HV_GUEST_OS_ID is set by the guest. */ 111 HyperLeaf.uEax = 0; 112 HyperLeaf.uEbx = 0; 113 HyperLeaf.uEcx = 0; 114 HyperLeaf.uEdx = 0; 115 rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf); 116 AssertLogRelRCReturn(rc, rc); 117 118 HyperLeaf.uLeaf = UINT32_C(0x40000003); 119 HyperLeaf.uEax = uBaseFeat; 120 HyperLeaf.uEbx = uPartFlags; 121 HyperLeaf.uEcx = uPowMgmtFeat; 122 HyperLeaf.uEdx = uMiscFeat; 123 rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf); 124 AssertLogRelRCReturn(rc, rc); 125 126 /* 127 * Register the complete MSR range for Hyper-V. 128 */ 129 CPUMMSRRANGE MsrRange; 130 RT_ZERO(MsrRange); 131 MsrRange.uFirst = UINT32_C(0x40000000); 132 MsrRange.uLast = UINT32_C(0x40000105); 133 MsrRange.enmRdFn = kCpumMsrRdFn_Gim; 134 MsrRange.enmWrFn = kCpumMsrWrFn_Gim; 135 RTStrCopy(MsrRange.szName, sizeof(MsrRange.szName), "Hyper-V"); 136 rc = CPUMR3MsrRangesInsert(pVM, &MsrRange); 137 AssertLogRelRCReturn(rc, rc); 138 139 60 140 return VINF_SUCCESS; 61 141 } … … 64 144 VMMR3_INT_DECL(void) GIMR3HvRelocate(PVM pVM, RTGCINTPTR offDelta) 65 145 { 66 int rc = PDMR3LdrGetSymbolRC(pVM, NULL /* pszModule */, GIMHV_HYPERCALL, &pVM->gim.s.pfnHypercallRC);67 AssertFatalRC(rc);146 // int rc = PDMR3LdrGetSymbolRC(pVM, NULL /* pszModule */, GIMHV_HYPERCALL, &pVM->gim.s.pfnHypercallRC); 147 // AssertFatalRC(rc); 68 148 } 69 149 -
trunk/src/VBox/VMM/VMMR3/GIMMinimal.cpp
r50994 r51333 36 36 { 37 37 AssertReturn(pVM, VERR_INVALID_PARAMETER); 38 AssertReturn(pVM->gim.s.enmProvider == GIMPROVIDER_MINIMAL, VERR_INTERNAL_ERROR_5);38 AssertReturn(pVM->gim.s.enmProviderId == GIMPROVIDERID_MINIMAL, VERR_INTERNAL_ERROR_5); 39 39 40 40 Assert(CPUMGetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP));
Note:
See TracChangeset
for help on using the changeset viewer.