Changeset 70917 in vbox for trunk/src/VBox/HostDrivers/Support/win
- Timestamp:
- Feb 8, 2018 3:56:43 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.