Changeset 105254 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jul 10, 2024 9:39:16 AM (7 months ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/HostImpl.h
r101176 r105254 177 177 178 178 HRESULT removeUSBDeviceSource(const com::Utf8Str &aId); 179 HRESULT isExecutionEngineSupported(CPUArchitecture_T enmCpuArchitecture, VMExecutionEngine_T enmExecutionEngine, BOOL *pfIsSupported); 179 180 180 181 // Internal Methods. … … 216 217 HRESULT i_getDrivesPathsList(std::list<std::pair<com::Utf8Str, com::Utf8Str> > &aDriveList) RT_NOEXCEPT; 217 218 219 #ifdef VBOX_WITH_NATIVE_NEM 220 BOOL i_HostIsNativeApiSupported(); 221 #endif 222 218 223 struct Data; // opaque data structure, defined in HostImpl.cpp 219 224 Data *m; -
trunk/src/VBox/Main/src-server/HostImpl.cpp
r104635 r105254 162 162 #include <iprt/string.h> 163 163 #include <iprt/system.h> 164 #ifndef RT_OS_WINDOWS 165 # include <iprt/path.h> 166 #endif 164 #include <iprt/path.h> 167 165 #include <iprt/time.h> 168 166 #ifdef RT_OS_WINDOWS 169 167 # include <iprt/dir.h> 170 168 # include <iprt/vfs.h> 169 # include <iprt/utf16.h> 171 170 #endif 172 171 … … 2083 2082 } 2084 2083 return hrc; 2084 } 2085 2086 2087 HRESULT Host::isExecutionEngineSupported(CPUArchitecture_T enmCpuArchitecture, VMExecutionEngine_T enmExecutionEngine, BOOL *pfIsSupported) 2088 { 2089 *pfIsSupported = FALSE; 2090 2091 /* No need to lock anything as this is constant. */ 2092 switch (enmCpuArchitecture) 2093 { 2094 case CPUArchitecture_x86: 2095 case CPUArchitecture_AMD64: 2096 { 2097 switch (enmExecutionEngine) 2098 { 2099 case VMExecutionEngine_Default: 2100 case VMExecutionEngine_Interpreter: 2101 *pfIsSupported = TRUE; 2102 break; 2103 case VMExecutionEngine_Recompiler: 2104 #ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER 2105 *pfIsSupported = TRUE; 2106 #endif 2107 break; 2108 #ifdef RT_ARCH_AMD64 2109 # ifndef VBOX_WITH_DRIVERLESS_FORCED 2110 case VMExecutionEngine_HwVirt: 2111 *pfIsSupported = TRUE; /** @todo Check whether our driver is actually accessible?. */ 2112 break; 2113 # endif 2114 # ifdef VBOX_WITH_NATIVE_NEM 2115 case VMExecutionEngine_NativeApi: 2116 *pfIsSupported = i_HostIsNativeApiSupported(); 2117 break; 2118 # endif 2119 #endif 2120 default: 2121 break; 2122 } 2123 break; 2124 } 2125 2126 case CPUArchitecture_ARMv8_64: 2127 { 2128 #ifdef VBOX_WITH_VIRT_ARMV8 2129 switch (enmExecutionEngine) 2130 { 2131 #ifdef RT_ARCH_ARM64 2132 # ifdef VBOX_WITH_NATIVE_NEM 2133 case VMExecutionEngine_NativeApi: 2134 *pfIsSupported = i_HostIsNativeApiSupported(); 2135 break; 2136 # endif 2137 #endif 2138 default: 2139 break; 2140 } 2141 #endif 2142 break; 2143 } 2144 2145 /* Not supported at all right now. */ 2146 case CPUArchitecture_ARMv8_32: 2147 break; 2148 2149 default: 2150 AssertFailed(); 2151 break; 2152 } 2153 2154 return S_OK; 2085 2155 } 2086 2156 … … 4192 4262 } 4193 4263 4264 4265 #ifdef VBOX_WITH_NATIVE_NEM 4266 BOOL Host::i_HostIsNativeApiSupported() 4267 { 4268 # ifdef RT_OS_WINDOWS 4269 WCHAR wszPath[MAX_PATH + 64]; 4270 UINT cwcPath = GetSystemDirectoryW(wszPath, MAX_PATH); 4271 if (cwcPath >= MAX_PATH || cwcPath < 2) 4272 return FALSE; 4273 4274 if (wszPath[cwcPath - 1] != '\\' || wszPath[cwcPath - 1] != '/') 4275 wszPath[cwcPath++] = '\\'; 4276 RTUtf16CopyAscii(&wszPath[cwcPath], RT_ELEMENTS(wszPath) - cwcPath, "WinHvPlatform.dll"); 4277 if (GetFileAttributesW(wszPath) == INVALID_FILE_ATTRIBUTES) 4278 return FALSE; 4279 4280 # ifdef RT_ARCH_AMD64 4281 /* 4282 * Check that we're in a VM and that the hypervisor identifies itself as Hyper-V. 4283 */ 4284 if (!ASMHasCpuId()) 4285 return FALSE; 4286 if (!RTX86IsValidStdRange(ASMCpuId_EAX(0))) 4287 return FALSE; 4288 if (!(ASMCpuId_ECX(1) & X86_CPUID_FEATURE_ECX_HVP)) 4289 return FALSE; 4290 4291 uint32_t cMaxHyperLeaf = 0; 4292 uint32_t uEbx = 0; 4293 uint32_t uEcx = 0; 4294 uint32_t uEdx = 0; 4295 ASMCpuIdExSlow(0x40000000, 0, 0, 0, &cMaxHyperLeaf, &uEbx, &uEcx, &uEdx); 4296 if (!RTX86IsValidHypervisorRange(cMaxHyperLeaf)) 4297 return FALSE; 4298 if ( uEbx != UINT32_C(0x7263694d) /* Micr */ 4299 || uEcx != UINT32_C(0x666f736f) /* osof */ 4300 || uEdx != UINT32_C(0x76482074) /* t Hv */) 4301 return FALSE; 4302 if (cMaxHyperLeaf >= UINT32_C(0x40000005)) 4303 return TRUE; 4304 # endif 4305 # elif defined(RT_OS_LINUX) 4306 int fdKvm = open("/dev/kvm", O_RDWR | O_CLOEXEC); 4307 if (fdKvm >= 0) 4308 { 4309 /** @todo Do we need to do anything else here? */ 4310 close(fdKvm); 4311 return TRUE; 4312 } 4313 # elif defined(RT_OS_DARWIN) 4314 /* 4315 * The kern.hv_support parameter indicates support for the hypervisor API 4316 * in the kernel. 4317 */ 4318 int32_t fHvSupport = 0; 4319 size_t cbOld = sizeof(fHvSupport); 4320 if (sysctlbyname("kern.hv_support", &fHvSupport, &cbOld, NULL, 0) == 0) 4321 { 4322 if (fHvSupport != 0) 4323 return TRUE; 4324 } 4325 # endif 4326 return FALSE; 4327 } 4328 #endif 4329 4330 4194 4331 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note:
See TracChangeset
for help on using the changeset viewer.