Changeset 81161 in vbox for trunk/src/VBox
- Timestamp:
- Oct 8, 2019 3:21:59 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 133795
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.cpp
r81006 r81161 206 206 { "SUPR0GetVTSupport", (void *)(uintptr_t)SUPR0GetVTSupport }, 207 207 { "SUPR0GetVmxUsability", (void *)(uintptr_t)SUPR0GetVmxUsability }, 208 { "SUPR0GetRawModeUsability", (void *)(uintptr_t)SUPR0GetRawModeUsability },209 208 { "SUPR0LdrIsLockOwnerByMod", (void *)(uintptr_t)SUPR0LdrIsLockOwnerByMod }, 210 209 { "SUPR0LdrLock", (void *)(uintptr_t)SUPR0LdrLock }, … … 4111 4110 4112 4111 /** 4113 * Checks if raw-mode is usable on this system.4114 *4115 * The reasons why raw-mode isn't safe to use are host specific. For example on4116 * Windows the Hyper-V root partition may perhapse not allow important bits in4117 * CR4 to be changed, which would make it impossible to do a world switch.4118 *4119 * @returns VBox status code.4120 */4121 SUPR0DECL(int) SUPR0GetRawModeUsability(void)4122 {4123 #ifdef RT_OS_WINDOWS4124 return supdrvOSGetRawModeUsability();4125 #else4126 return VINF_SUCCESS;4127 #endif4128 }4129 4130 4131 /**4132 4112 * Gets AMD-V and VT-x support for the calling CPU. 4133 4113 * -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r80531 r81161 901 901 void VBOXCALL supdrvOSResumeVTxOnCpu(bool fSuspended); 902 902 int VBOXCALL supdrvOSGetCurrentGdtRw(RTHCUINTPTR *pGdtRw); 903 int VBOXCALL supdrvOSGetRawModeUsability(void);904 903 905 904 /** -
trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
r81106 r81161 1903 1903 1904 1904 1905 /**1906 * Checks whether we're allowed by Hyper-V to modify CR4.1907 */1908 int VBOXCALL supdrvOSGetRawModeUsability(void)1909 {1910 int rc = VINF_SUCCESS;1911 1912 #ifdef RT_ARCH_AMD641913 /*1914 * Broadwell running W10 17083.100:1915 * CR4: 0x1706781916 * Evil mask: 0x1706381917 * X86_CR4_SMEP - evil1918 * X86_CR4_FSGSBASE - evil1919 * X86_CR4_PCIDE - evil1920 * X86_CR4_OSXSAVE - evil1921 * X86_CR4_OSFXSR - evil1922 * X86_CR4_OSXMMEEXCPT - evil1923 * X86_CR4_PSE - evil1924 * X86_CR4_PAE - evil1925 * X86_CR4_MCE - okay1926 * X86_CR4_DE - evil1927 */1928 if (ASMHasCpuId())1929 {1930 uint32_t cStd = ASMCpuId_EAX(0);1931 if (ASMIsValidStdRange(cStd))1932 {1933 uint32_t uIgn = 0;1934 uint32_t fEdxFeatures = 0;1935 uint32_t fEcxFeatures = 0;1936 ASMCpuIdExSlow(1, 0, 0, 0, &uIgn, &uIgn, &fEcxFeatures, &fEdxFeatures);1937 if (fEcxFeatures & X86_CPUID_FEATURE_ECX_HVP)1938 {1939 RTCCUINTREG const fOldFlags = ASMIntDisableFlags();1940 RTCCUINTXREG const fCr4 = ASMGetCR4();1941 1942 RTCCUINTXREG const fSafeToClear = X86_CR4_TSD | X86_CR4_DE | X86_CR4_PGE | X86_CR4_PCE1943 | X86_CR4_FSGSBASE | X86_CR4_PCIDE | X86_CR4_SMEP | X86_CR4_SMAP1944 | X86_CR4_OSXSAVE | X86_CR4_OSFXSR | X86_CR4_OSXMMEEXCPT;1945 RTCCUINTXREG fLoadCr4 = fCr4 & ~fSafeToClear;1946 RTCCUINTXREG const fCleared = fCr4 & fSafeToClear;1947 if (!(fCleared & X86_CR4_TSD) && (fEdxFeatures & X86_CPUID_FEATURE_EDX_TSC))1948 fLoadCr4 |= X86_CR4_TSD;1949 if (!(fCleared & X86_CR4_PGE) && (fEdxFeatures & X86_CPUID_FEATURE_EDX_PGE))1950 fLoadCr4 |= X86_CR4_PGE;1951 __try1952 {1953 ASMSetCR4(fLoadCr4);1954 }1955 __except(EXCEPTION_EXECUTE_HANDLER)1956 {1957 rc = VERR_SUPDRV_NO_RAW_MODE_HYPER_V_ROOT;1958 }1959 if (RT_SUCCESS(rc))1960 ASMSetCR4(fCr4);1961 ASMSetFlags(fOldFlags);1962 }1963 }1964 }1965 #endif1966 return rc;1967 }1968 1969 1970 1905 #define MY_SystemLoadGdiDriverInSystemSpaceInformation 54 1971 1906 #define MY_SystemUnloadGdiDriverInformation 27 -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r81153 r81161 164 164 #endif 165 165 166 /** The result of SUPR0GetRawModeUsability(), set by ModuleInit(). */167 int g_rcRawModeUsability = VINF_SUCCESS;168 169 166 170 167 /** … … 257 254 if (RT_SUCCESS(rc)) 258 255 { 259 g_rcRawModeUsability = SUPR0GetRawModeUsability();260 if (g_rcRawModeUsability != VINF_SUCCESS)261 SUPR0Printf("VMMR0!ModuleInit: SUPR0GetRawModeUsability -> %Rrc\n",262 g_rcRawModeUsability);263 256 LogFlow(("ModuleInit: returns success\n")); 264 257 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.