Changeset 70917 in vbox for trunk/src/VBox/HostDrivers/Support
- Timestamp:
- Feb 8, 2018 3:56:43 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120745
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.cpp
r69500 r70917 204 204 { "SUPR0GetSvmUsability", (void *)(uintptr_t)SUPR0GetSvmUsability }, 205 205 { "SUPR0GetVmxUsability", (void *)(uintptr_t)SUPR0GetVmxUsability }, 206 { "SUPR0GetRawModeUsability", (void *)(uintptr_t)SUPR0GetRawModeUsability }, 206 207 { "SUPR0LockMem", (void *)(uintptr_t)SUPR0LockMem }, 207 208 { "SUPR0LowAlloc", (void *)(uintptr_t)SUPR0LowAlloc }, … … 2258 2259 2259 2260 /* execute */ 2260 pReq->Hdr.rc = SUPR0QueryVTCaps(pSession, &pReq->u.Out. Caps);2261 pReq->Hdr.rc = SUPR0QueryVTCaps(pSession, &pReq->u.Out.fCaps); 2261 2262 if (RT_FAILURE(pReq->Hdr.rc)) 2262 2263 pReq->Hdr.cbOut = sizeof(pReq->Hdr); … … 2477 2478 2478 2479 /* execute */ 2479 pReq->Hdr.rc = SUPR0QueryVTCaps(pSession, &pReq->u.Out. Caps);2480 pReq->Hdr.rc = SUPR0QueryVTCaps(pSession, &pReq->u.Out.fCaps); 2480 2481 if (RT_FAILURE(pReq->Hdr.rc)) 2481 2482 pReq->Hdr.cbOut = sizeof(pReq->Hdr); … … 4062 4063 4063 4064 /** 4065 * Checks if raw-mode is usable on this system. 4066 * 4067 * The reasons why raw-mode isn't safe to use are host specific. For example on 4068 * Windows the Hyper-V root partition may perhapse not allow important bits in 4069 * CR4 to be changed, which would make it impossible to do a world switch. 4070 * 4071 * @returns VBox status code. 4072 */ 4073 SUPR0DECL(int) SUPR0GetRawModeUsability(void) 4074 { 4075 #ifdef RT_OS_WINDOWS 4076 return supdrvOSGetRawModeUsability(); 4077 #else 4078 return VINF_SUCCESS; 4079 #endif 4080 } 4081 4082 4083 4084 /** 4064 4085 * Checks if Intel VT-x feature is usable on this CPU. 4065 4086 * … … 4077 4098 SUPR0DECL(int) SUPR0GetVmxUsability(bool *pfIsSmxModeAmbiguous) 4078 4099 { 4079 uint64_t u64FeatMsr;4100 uint64_t fFeatMsr; 4080 4101 bool fMaybeSmxMode; 4081 4102 bool fMsrLocked; … … 4087 4108 Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD)); 4088 4109 4089 u64FeatMsr= ASMRdMsr(MSR_IA32_FEATURE_CONTROL);4110 fFeatMsr = ASMRdMsr(MSR_IA32_FEATURE_CONTROL); 4090 4111 fMaybeSmxMode = RT_BOOL(ASMGetCR4() & X86_CR4_SMXE); 4091 fMsrLocked = RT_BOOL( u64FeatMsr & MSR_IA32_FEATURE_CONTROL_LOCK);4092 fSmxVmxAllowed = RT_BOOL( u64FeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON);4093 fVmxAllowed = RT_BOOL( u64FeatMsr & MSR_IA32_FEATURE_CONTROL_VMXON);4112 fMsrLocked = RT_BOOL(fFeatMsr & MSR_IA32_FEATURE_CONTROL_LOCK); 4113 fSmxVmxAllowed = RT_BOOL(fFeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON); 4114 fVmxAllowed = RT_BOOL(fFeatMsr & MSR_IA32_FEATURE_CONTROL_VMXON); 4094 4115 fIsSmxModeAmbiguous = false; 4095 4116 rc = VERR_INTERNAL_ERROR_5; … … 4149 4170 fSmxVmxHwSupport = true; 4150 4171 4151 u64FeatMsr |= MSR_IA32_FEATURE_CONTROL_LOCK4152 |MSR_IA32_FEATURE_CONTROL_VMXON;4172 fFeatMsr |= MSR_IA32_FEATURE_CONTROL_LOCK 4173 | MSR_IA32_FEATURE_CONTROL_VMXON; 4153 4174 if (fSmxVmxHwSupport) 4154 u64FeatMsr |= MSR_IA32_FEATURE_CONTROL_SMX_VMXON;4175 fFeatMsr |= MSR_IA32_FEATURE_CONTROL_SMX_VMXON; 4155 4176 4156 4177 /* 4157 4178 * Commit. 4158 4179 */ 4159 ASMWrMsr(MSR_IA32_FEATURE_CONTROL, u64FeatMsr);4180 ASMWrMsr(MSR_IA32_FEATURE_CONTROL, fFeatMsr); 4160 4181 4161 4182 /* 4162 4183 * Verify. 4163 4184 */ 4164 u64FeatMsr = ASMRdMsr(MSR_IA32_FEATURE_CONTROL);4165 fMsrLocked = RT_BOOL( u64FeatMsr & MSR_IA32_FEATURE_CONTROL_LOCK);4185 fFeatMsr = ASMRdMsr(MSR_IA32_FEATURE_CONTROL); 4186 fMsrLocked = RT_BOOL(fFeatMsr & MSR_IA32_FEATURE_CONTROL_LOCK); 4166 4187 if (fMsrLocked) 4167 4188 { 4168 fSmxVmxAllowed = RT_BOOL( u64FeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON);4169 fVmxAllowed = RT_BOOL( u64FeatMsr & MSR_IA32_FEATURE_CONTROL_VMXON);4189 fSmxVmxAllowed = RT_BOOL(fFeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON); 4190 fVmxAllowed = RT_BOOL(fFeatMsr & MSR_IA32_FEATURE_CONTROL_VMXON); 4170 4191 if ( fVmxAllowed 4171 4192 && ( !fSmxVmxHwSupport 4172 4193 || fSmxVmxAllowed)) 4173 {4174 4194 rc = VINF_SUCCESS; 4175 }4176 4195 else 4177 4196 rc = !fSmxVmxHwSupport ? VERR_VMX_MSR_VMX_ENABLE_FAILED : VERR_VMX_MSR_SMX_VMX_ENABLE_FAILED; -
trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h
r69500 r70917 214 214 * @remarks 0x002a0000 is used by 5.1. The next version number must be 0x002b0000. 215 215 */ 216 #define SUPDRV_IOC_VERSION 0x0029000 0216 #define SUPDRV_IOC_VERSION 0x00290001 217 217 218 218 /** SUP_IOCTL_COOKIE. */ … … 1209 1209 { 1210 1210 /** The VT capability dword. */ 1211 uint32_t Caps;1211 uint32_t fCaps; 1212 1212 } Out; 1213 1213 } u; -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r69500 r70917 850 850 void VBOXCALL supdrvOSResumeVTxOnCpu(bool fSuspended); 851 851 int VBOXCALL supdrvOSGetCurrentGdtRw(RTHCUINTPTR *pGdtRw); 852 int VBOXCALL supdrvOSGetRawModeUsability(void); 852 853 853 854 /** -
trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
r69500 r70917 276 276 strcpy(CookieReq.u.In.szMagic, SUPCOOKIE_MAGIC); 277 277 CookieReq.u.In.u32ReqVersion = SUPDRV_IOC_VERSION; 278 const uint32_t uMinVersion = (SUPDRV_IOC_VERSION & 0xffff0000) == 0x002 80000279 ? 0x002 80002278 const uint32_t uMinVersion = (SUPDRV_IOC_VERSION & 0xffff0000) == 0x00290000 279 ? 0x00290001 280 280 : SUPDRV_IOC_VERSION & 0xffff0000; 281 281 CookieReq.u.In.u32MinVersion = uMinVersion; … … 1689 1689 Req.Hdr.fFlags = SUPREQHDR_FLAGS_DEFAULT; 1690 1690 Req.Hdr.rc = VERR_INTERNAL_ERROR; 1691 Req.u.Out. Caps = 0;1691 Req.u.Out.fCaps = 0; 1692 1692 int rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_VT_CAPS, &Req, SUP_IOCTL_VT_CAPS_SIZE); 1693 1693 if (RT_SUCCESS(rc)) … … 1695 1695 rc = Req.Hdr.rc; 1696 1696 if (RT_SUCCESS(rc)) 1697 *pfCaps = Req.u.Out. Caps;1697 *pfCaps = Req.u.Out.fCaps; 1698 1698 } 1699 1699 return rc; -
trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
r69500 r70917 46 46 #include <iprt/spinlock.h> 47 47 #include <iprt/string.h> 48 #include <iprt/x86.h> 48 49 #include <VBox/log.h> 49 50 #include <VBox/err.h> … … 1873 1874 1874 1875 1876 /** 1877 * Checks whether we're allowed by Hyper-V to modify CR4. 1878 */ 1879 int VBOXCALL supdrvOSGetRawModeUsability(void) 1880 { 1881 int rc = VINF_SUCCESS; 1882 1883 #ifdef RT_ARCH_AMD64 1884 /* 1885 * Broadwell running W10 17083.100: 1886 * CR4: 0x170678 1887 * Evil mask: 0x170638 1888 * X86_CR4_SMEP - evil 1889 * X86_CR4_FSGSBASE - evil 1890 * X86_CR4_PCIDE - evil 1891 * X86_CR4_OSXSAVE - evil 1892 * X86_CR4_OSFXSR - evil 1893 * X86_CR4_OSXMMEEXCPT - evil 1894 * X86_CR4_PSE - evil 1895 * X86_CR4_PAE - evil 1896 * X86_CR4_MCE - okay 1897 * X86_CR4_DE - evil 1898 */ 1899 if (ASMHasCpuId()) 1900 { 1901 uint32_t cStd = ASMCpuId_EAX(0); 1902 if (ASMIsValidStdRange(cStd)) 1903 { 1904 uint32_t uIgn = 0; 1905 uint32_t fEdxFeatures = 0; 1906 uint32_t fEcxFeatures = 0; 1907 ASMCpuIdExSlow(1, 0, 0, 0, &uIgn, &uIgn, &fEcxFeatures, &fEdxFeatures); 1908 if (fEcxFeatures & X86_CPUID_FEATURE_ECX_HVP) 1909 { 1910 RTCCUINTREG const fOldFlags = ASMIntDisableFlags(); 1911 RTCCUINTXREG const fCr4 = ASMGetCR4(); 1912 1913 RTCCUINTXREG const fSafeToClear = X86_CR4_TSD | X86_CR4_DE | X86_CR4_PGE | X86_CR4_PCE 1914 | X86_CR4_FSGSBASE | X86_CR4_PCIDE | X86_CR4_SMEP | X86_CR4_SMAP 1915 | X86_CR4_OSXSAVE | X86_CR4_OSFXSR | X86_CR4_OSXMMEEXCPT; 1916 RTCCUINTXREG fLoadCr4 = fCr4 & ~fSafeToClear; 1917 RTCCUINTXREG const fCleared = fCr4 & fSafeToClear; 1918 if (!(fCleared & X86_CR4_TSD) && (fEdxFeatures & X86_CPUID_FEATURE_EDX_TSC)) 1919 fLoadCr4 |= X86_CR4_TSD; 1920 if (!(fCleared & X86_CR4_PGE) && (fEdxFeatures & X86_CPUID_FEATURE_EDX_PGE)) 1921 fLoadCr4 |= X86_CR4_PGE; 1922 __try 1923 { 1924 ASMSetCR4(fLoadCr4); 1925 } 1926 __except(EXCEPTION_EXECUTE_HANDLER) 1927 { 1928 rc = VERR_SUPDRV_NO_RAW_MODE_HYPER_V_ROOT; 1929 } 1930 if (RT_SUCCESS(rc)) 1931 ASMSetCR4(fCr4); 1932 ASMSetFlags(fOldFlags); 1933 } 1934 } 1935 } 1936 #endif 1937 return rc; 1938 } 1939 1940 1875 1941 #define MY_SystemLoadGdiDriverInSystemSpaceInformation 54 1876 1942 #define MY_SystemUnloadGdiDriverInformation 27
Note:
See TracChangeset
for help on using the changeset viewer.