提交 9d5fc5f4 编写于 作者: M MikeBeaton

OcCpuLib: Add EnableVmx UEFI quirk

上级 e7623113
...@@ -13,6 +13,7 @@ OpenCore Changelog ...@@ -13,6 +13,7 @@ OpenCore Changelog
- Added `ReconnectGraphicsOnConnect` option for enabling alternative UEFI graphics drivers - Added `ReconnectGraphicsOnConnect` option for enabling alternative UEFI graphics drivers
- Added BiosVideo.efi driver to use with `ReconnectGraphicsOnConnect` - Added BiosVideo.efi driver to use with `ReconnectGraphicsOnConnect`
- Changed `FadtEnableReset` to avoid unreliable keyboard controller reset - Changed `FadtEnableReset` to avoid unreliable keyboard controller reset
- Added `EnableVmx` quirk to allow virtualization in other OS on some Macs
#### v0.7.5 #### v0.7.5
- Revised OpenLinuxBoot documentation - Revised OpenLinuxBoot documentation
......
...@@ -7623,6 +7623,16 @@ with the boot menu. ...@@ -7623,6 +7623,16 @@ with the boot menu.
\textbf{Failsafe}: \texttt{false}\\ \textbf{Failsafe}: \texttt{false}\\
\textbf{Description}: Enable AVX vector acceleration of SHA-512 and SHA-384 hashing algorithms. \textbf{Description}: Enable AVX vector acceleration of SHA-512 and SHA-384 hashing algorithms.
\item
\texttt{EnableVmx}\\
\textbf{Type}: \texttt{plist\ boolean}\\
\textbf{Failsafe}: \texttt{false}\\
\textbf{Description}: Enable Intel virtual machine extensions.
\emph{Note}: Required to allow virtualization in Windows on some Mac hardware. VMX
is enabled or disabled and locked by BIOS before OpenCore starts on most
firmware. Use BIOS to enable virtualization where possible.
\item \item
\texttt{DisableSecurityPolicy}\\ \texttt{DisableSecurityPolicy}\\
\textbf{Type}: \texttt{plist\ boolean}\\ \textbf{Type}: \texttt{plist\ boolean}\\
......
...@@ -1564,6 +1564,8 @@ ...@@ -1564,6 +1564,8 @@
<false/> <false/>
<key>EnableVectorAcceleration</key> <key>EnableVectorAcceleration</key>
<true/> <true/>
<key>EnableVmx</key>
<false/>
<key>ExitBootServicesDelay</key> <key>ExitBootServicesDelay</key>
<integer>0</integer> <integer>0</integer>
<key>ForceOcWriteFlash</key> <key>ForceOcWriteFlash</key>
......
...@@ -1902,6 +1902,8 @@ ...@@ -1902,6 +1902,8 @@
<false/> <false/>
<key>EnableVectorAcceleration</key> <key>EnableVectorAcceleration</key>
<true/> <true/>
<key>EnableVmx</key>
<false/>
<key>ExitBootServicesDelay</key> <key>ExitBootServicesDelay</key>
<integer>0</integer> <integer>0</integer>
<key>ForceOcWriteFlash</key> <key>ForceOcWriteFlash</key>
......
...@@ -691,6 +691,7 @@ typedef enum { ...@@ -691,6 +691,7 @@ typedef enum {
_(BOOLEAN , ActivateHpetSupport , , FALSE , ()) \ _(BOOLEAN , ActivateHpetSupport , , FALSE , ()) \
_(BOOLEAN , DisableSecurityPolicy , , FALSE , ()) \ _(BOOLEAN , DisableSecurityPolicy , , FALSE , ()) \
_(BOOLEAN , EnableVectorAcceleration , , FALSE , ()) \ _(BOOLEAN , EnableVectorAcceleration , , FALSE , ()) \
_(BOOLEAN , EnableVmx , , FALSE , ()) \
_(BOOLEAN , ForgeUefiSupport , , FALSE , ()) \ _(BOOLEAN , ForgeUefiSupport , , FALSE , ()) \
_(BOOLEAN , IgnoreInvalidFlexRatio , , FALSE , ()) \ _(BOOLEAN , IgnoreInvalidFlexRatio , , FALSE , ()) \
_(INT8 , ResizeGpuBars , , -1 , ()) \ _(INT8 , ResizeGpuBars , , -1 , ()) \
......
...@@ -289,6 +289,19 @@ OcCpuCorrectFlexRatio ( ...@@ -289,6 +289,19 @@ OcCpuCorrectFlexRatio (
IN OC_CPU_INFO *Cpu IN OC_CPU_INFO *Cpu
); );
/**
Enable VMX in FeatureControl MSR if supported and not already locked by BIOS.
Required to use virtualization in Windows on some Mac hardware.
REF: https://github.com/acidanthera/bugtracker/issues/1870
REF: https://www.thomas-krenn.com/en/wiki/Activating_the_Intel_VT_Virtualization_Feature (via rEFInd)
REF: 'Intel 64 and IA-32 Architectures Software Developer's Manual Volume 3', p.1296 etc.
**/
EFI_STATUS
OcCpuEnableVmx (
VOID
);
/** /**
Synchronise TSC on all cores (needed on server chipsets and some laptops). Synchronise TSC on all cores (needed on server chipsets and some laptops).
This does not fully replace VoodooTscSync or TSCAdjustReset due to This does not fully replace VoodooTscSync or TSCAdjustReset due to
......
...@@ -686,6 +686,7 @@ mUefiQuirksSchema[] = { ...@@ -686,6 +686,7 @@ mUefiQuirksSchema[] = {
OC_SCHEMA_BOOLEAN_IN ("ActivateHpetSupport", OC_GLOBAL_CONFIG, Uefi.Quirks.ActivateHpetSupport), OC_SCHEMA_BOOLEAN_IN ("ActivateHpetSupport", OC_GLOBAL_CONFIG, Uefi.Quirks.ActivateHpetSupport),
OC_SCHEMA_BOOLEAN_IN ("DisableSecurityPolicy", OC_GLOBAL_CONFIG, Uefi.Quirks.DisableSecurityPolicy), OC_SCHEMA_BOOLEAN_IN ("DisableSecurityPolicy", OC_GLOBAL_CONFIG, Uefi.Quirks.DisableSecurityPolicy),
OC_SCHEMA_BOOLEAN_IN ("EnableVectorAcceleration", OC_GLOBAL_CONFIG, Uefi.Quirks.EnableVectorAcceleration), OC_SCHEMA_BOOLEAN_IN ("EnableVectorAcceleration", OC_GLOBAL_CONFIG, Uefi.Quirks.EnableVectorAcceleration),
OC_SCHEMA_BOOLEAN_IN ("EnableVmx", OC_GLOBAL_CONFIG, Uefi.Quirks.EnableVmx),
OC_SCHEMA_INTEGER_IN ("ExitBootServicesDelay", OC_GLOBAL_CONFIG, Uefi.Quirks.ExitBootServicesDelay), OC_SCHEMA_INTEGER_IN ("ExitBootServicesDelay", OC_GLOBAL_CONFIG, Uefi.Quirks.ExitBootServicesDelay),
OC_SCHEMA_BOOLEAN_IN ("ForceOcWriteFlash", OC_GLOBAL_CONFIG, Uefi.Quirks.ForceOcWriteFlash), OC_SCHEMA_BOOLEAN_IN ("ForceOcWriteFlash", OC_GLOBAL_CONFIG, Uefi.Quirks.ForceOcWriteFlash),
OC_SCHEMA_BOOLEAN_IN ("ForgeUefiSupport", OC_GLOBAL_CONFIG, Uefi.Quirks.ForgeUefiSupport), OC_SCHEMA_BOOLEAN_IN ("ForgeUefiSupport", OC_GLOBAL_CONFIG, Uefi.Quirks.ForgeUefiSupport),
......
...@@ -1163,6 +1163,34 @@ OcCpuCorrectFlexRatio ( ...@@ -1163,6 +1163,34 @@ OcCpuCorrectFlexRatio (
} }
} }
EFI_STATUS
OcCpuEnableVmx (
VOID
)
{
CPUID_VERSION_INFO_ECX RegEcx;
MSR_IA32_FEATURE_CONTROL_REGISTER Msr;
AsmCpuid (1, 0, 0, &RegEcx.Uint32, 0);
if (RegEcx.Bits.VMX == 0) {
return EFI_UNSUPPORTED;
}
Msr.Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL);
if (Msr.Bits.Lock != 0) {
return EFI_WRITE_PROTECTED;
}
//
// Unclear if pre-existing valid bits should ever be present if register is unlocked.
//
Msr.Bits.Lock = 1;
Msr.Bits.EnableVmxOutsideSmx = 1;
AsmWriteMsr64 (MSR_IA32_FEATURE_CONTROL, Msr.Uint64);
return EFI_SUCCESS;
}
STATIC STATIC
VOID VOID
EFIAPI EFIAPI
......
...@@ -816,6 +816,7 @@ OcLoadUefiSupport ( ...@@ -816,6 +816,7 @@ OcLoadUefiSupport (
IN UINT8 *Signature IN UINT8 *Signature
) )
{ {
EFI_STATUS Status;
EFI_HANDLE *DriversToConnect; EFI_HANDLE *DriversToConnect;
EFI_EVENT Event; EFI_EVENT Event;
BOOLEAN AvxEnabled; BOOLEAN AvxEnabled;
...@@ -841,6 +842,11 @@ OcLoadUefiSupport ( ...@@ -841,6 +842,11 @@ OcLoadUefiSupport (
OcCpuCorrectFlexRatio (CpuInfo); OcCpuCorrectFlexRatio (CpuInfo);
} }
if (Config->Uefi.Quirks.EnableVmx) {
Status = OcCpuEnableVmx ();
DEBUG ((EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO, "OC: Enable VMX - %r\n", Status));
}
if (Config->Uefi.Quirks.TscSyncTimeout > 0) { if (Config->Uefi.Quirks.TscSyncTimeout > 0) {
OcCpuCorrectTscSync (CpuInfo, Config->Uefi.Quirks.TscSyncTimeout); OcCpuCorrectTscSync (CpuInfo, Config->Uefi.Quirks.TscSyncTimeout);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册