提交 0bb426d3 编写于 作者: V vit9696

OcAppleKernelLib: Added `PatchAppleRtcChecksum` kernel quirk

上级 4ec0e4e1
......@@ -13,6 +13,7 @@ OpenCore Changelog
- Added mouse drivers to the package as OVMF needs one
- Added memory region reservation support
- Added RtcRw tool to manipulate RTC memory
- Added `PatchAppleRtcChecksum` kernel quirk
#### v0.5.7
- Added TimeMachine detection to picker
......
......@@ -1975,6 +1975,21 @@ blocking.
ACPI table and disabling VT-d in firmware preferences, which does not break
VT-d support in other systems in case they need it.
\item
\texttt{DisableRtcChecksum}\\
\textbf{Type}: \texttt{plist\ boolean}\\
\textbf{Failsafe}: \texttt{false}\\
\textbf{Description}: Disables primary checksum (\texttt{0x58}-\texttt{0x59})
writing in AppleRTC.
\emph{Note 1}: This option will not protect other areas from being overwritten,
see \href{https://github.com/acidanthera/RTCMemoryFixup}{RTCMemoryFixup}
kernel extension if this is desired.
\emph{Note 2}: This option will not protect areas from being overwritten
at firmware stage (e.g. macOS bootloader), see \texttt{RTC} (FIXME) section
if this is desired.
\item
\texttt{DummyPowerManagement}\\
\textbf{Type}: \texttt{plist\ boolean}\\
......
\documentclass[]{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL PreviousConfiguration.tex Tue Apr 7 19:32:13 2020
%DIF ADD ../Configuration.tex Sat Apr 18 13:12:30 2020
%DIF ADD ../Configuration.tex Sat Apr 18 15:39:07 2020
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
......@@ -2037,7 +2037,25 @@ blocking.
VT-d support in other systems in case they need it.
\item
\texttt{DummyPowerManagement}\\
\DIFaddbegin \texttt{\DIFadd{DisableRtcChecksum}}\\
\textbf{\DIFadd{Type}}\DIFadd{: }\texttt{\DIFadd{plist\ boolean}}\\
\textbf{\DIFadd{Failsafe}}\DIFadd{: }\texttt{\DIFadd{false}}\\
\textbf{\DIFadd{Description}}\DIFadd{: Disables primary checksum (}\texttt{\DIFadd{0x58}}\DIFadd{-}\texttt{\DIFadd{0x59}}\DIFadd{)
writing in AppleRTC.
}
\emph{\DIFadd{Note 1}}\DIFadd{: This option will not protect other areas from being overwritten,
see }\href{https://github.com/acidanthera/RTCMemoryFixup}{RTCMemoryFixup}
\DIFadd{kernel extension if this is desired.
}
\emph{\DIFadd{Note 2}}\DIFadd{: This option will not protect areas from being overwritten
at firmware stage (e.g. macOS bootloader), see }\texttt{\DIFadd{RTC}} \DIFadd{(FIXME) section
if this is desired.
}
\item
\DIFaddend \texttt{DummyPowerManagement}\\
\textbf{Type}: \texttt{plist\ boolean}\\
\textbf{Failsafe}: \texttt{false}\\
\textbf{Description}: Disables \texttt{AppleIntelCpuPowerManagement}.
......
......@@ -462,34 +462,6 @@
<key>Skip</key>
<integer>0</integer>
</dict>
<dict>
<key>Base</key>
<string>__ZN8AppleRTC14updateChecksumEv</string>
<key>Comment</key>
<string>Disable RTC checksum update on poweroff</string>
<key>Count</key>
<integer>1</integer>
<key>Enabled</key>
<false/>
<key>Find</key>
<data></data>
<key>Identifier</key>
<string>com.apple.driver.AppleRTC</string>
<key>Limit</key>
<integer>0</integer>
<key>Mask</key>
<data></data>
<key>MaxKernel</key>
<string></string>
<key>MinKernel</key>
<string></string>
<key>Replace</key>
<data>ww==</data>
<key>ReplaceMask</key>
<data></data>
<key>Skip</key>
<integer>0</integer>
</dict>
<dict>
<key>Base</key>
<string>_AcpiOsVprintf</string>
......@@ -561,6 +533,8 @@
<false/>
<key>DisableIoMapper</key>
<false/>
<key>DisableRtcChecksum</key>
<false/>
<key>DummyPowerManagement</key>
<false/>
<key>ExternalDiskIcons</key>
......
......@@ -462,34 +462,6 @@
<key>Skip</key>
<integer>0</integer>
</dict>
<dict>
<key>Base</key>
<string>__ZN8AppleRTC14updateChecksumEv</string>
<key>Comment</key>
<string>Disable RTC checksum update on poweroff</string>
<key>Count</key>
<integer>1</integer>
<key>Enabled</key>
<false/>
<key>Find</key>
<data></data>
<key>Identifier</key>
<string>com.apple.driver.AppleRTC</string>
<key>Limit</key>
<integer>0</integer>
<key>Mask</key>
<data></data>
<key>MaxKernel</key>
<string></string>
<key>MinKernel</key>
<string></string>
<key>Replace</key>
<data>ww==</data>
<key>ReplaceMask</key>
<data></data>
<key>Skip</key>
<integer>0</integer>
</dict>
<dict>
<key>Base</key>
<string>_AcpiOsVprintf</string>
......@@ -561,6 +533,8 @@
<false/>
<key>DisableIoMapper</key>
<false/>
<key>DisableRtcChecksum</key>
<false/>
<key>DummyPowerManagement</key>
<false/>
<key>ExternalDiskIcons</key>
......
......@@ -586,4 +586,16 @@ PatchPowerStateTimeout (
IN OUT PATCHER_CONTEXT *Patcher
);
/**
Disable AppleRTC checksum writing.
@param Patcher Patcher context.
@return RETURN_SUCCESS on success.
**/
EFI_STATUS
PatchAppleRtcChecksum (
IN OUT PRELINKED_CONTEXT *Context
);
#endif // OC_APPLE_KERNEL_LIB_H
......@@ -243,6 +243,7 @@
_(BOOLEAN , AppleXcpmForceBoost , , FALSE , ()) \
_(BOOLEAN , CustomSmbiosGuid , , FALSE , ()) \
_(BOOLEAN , DisableIoMapper , , FALSE , ()) \
_(BOOLEAN , DisableRtcChecksum , , FALSE , ()) \
_(BOOLEAN , DummyPowerManagement , , FALSE , ()) \
_(BOOLEAN , ExternalDiskIcons , , FALSE , ()) \
_(BOOLEAN , IncreasePciBarSize , , FALSE , ()) \
......
......@@ -1484,3 +1484,72 @@ PatchPowerStateTimeout (
return Status;
}
//
// There currently are 2 places main RTC checksum is calculated in AppleRTC.kext
// __ZN8AppleRTC14updateChecksumEv and __ZN8AppleRTC19rtcRecordTracePointEjjj.
// Since we do not want to completely break RTC and/or saving tracepoints to RTC
// we patch-out __ZN8AppleRTC8rtcWriteEjh call arguments (0x58 and 0x59) with
// invalid (out of range) value 0xFFFF in 4 places.
//
STATIC
UINT8
mAppleRtcChecksumPatchFind[] = {
0xBE, 0x58, 0x00, 0x00, 0x00
};
STATIC
UINT8
mAppleRtcChecksumPatchMask[] = {
0xFF, 0xFE, 0xFF, 0xFF, 0xFF
};
STATIC
UINT8
mAppleRtcChecksumPatchReplace[] = {
0xBE, 0xFF, 0xFF, 0x00, 0x00
};
STATIC
PATCHER_GENERIC_PATCH
mAppleRtcChecksumPatch = {
.Comment = DEBUG_POINTER ("DisableRtcChecksum"),
.Base = NULL,
.Find = mAppleRtcChecksumPatchFind,
.Mask = mAppleRtcChecksumPatchMask,
.Replace = mAppleRtcChecksumPatchReplace,
.ReplaceMask = NULL,
.Size = sizeof (mAppleRtcChecksumPatchFind),
.Count = 4,
.Skip = 0,
.Limit = 0
};
EFI_STATUS
PatchAppleRtcChecksum (
IN OUT PRELINKED_CONTEXT *Context
)
{
RETURN_STATUS Status;
PATCHER_CONTEXT Patcher;
Status = PatcherInitContextFromPrelinked (
&Patcher,
Context,
"com.apple.driver.AppleRTC"
);
if (!EFI_ERROR (Status)) {
Status = PatcherApplyGenericPatch (&Patcher, &mAppleRtcChecksumPatch);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OCAK: Failed to apply patch com.apple.driver.AppleRTC DisableRtcChecksum - %r\n", Status));
} else {
DEBUG ((DEBUG_INFO, "OCAK: Patch success com.apple.driver.AppleRTC DisableRtcChecksum\n"));
}
} else {
DEBUG ((DEBUG_INFO, "OCAK: Failed to find com.apple.driver.AppleRTC for DisableRtcChecksum - %r\n", Status));
}
return Status;
}
......@@ -293,6 +293,7 @@ mKernelQuirksSchema[] = {
OC_SCHEMA_BOOLEAN_IN ("AppleXcpmForceBoost", OC_GLOBAL_CONFIG, Kernel.Quirks.AppleXcpmForceBoost),
OC_SCHEMA_BOOLEAN_IN ("CustomSMBIOSGuid", OC_GLOBAL_CONFIG, Kernel.Quirks.CustomSmbiosGuid),
OC_SCHEMA_BOOLEAN_IN ("DisableIoMapper", OC_GLOBAL_CONFIG, Kernel.Quirks.DisableIoMapper),
OC_SCHEMA_BOOLEAN_IN ("DisableRtcChecksum", OC_GLOBAL_CONFIG, Kernel.Quirks.DisableRtcChecksum),
OC_SCHEMA_BOOLEAN_IN ("DummyPowerManagement", OC_GLOBAL_CONFIG, Kernel.Quirks.DummyPowerManagement),
OC_SCHEMA_BOOLEAN_IN ("ExternalDiskIcons", OC_GLOBAL_CONFIG, Kernel.Quirks.ExternalDiskIcons),
OC_SCHEMA_BOOLEAN_IN ("IncreasePciBarSize", OC_GLOBAL_CONFIG, Kernel.Quirks.IncreasePciBarSize),
......
......@@ -457,6 +457,10 @@ OcKernelApplyPatches (
PatchAppleIoMapperSupport (Context);
}
if (Config->Kernel.Quirks.DisableRtcChecksum) {
PatchAppleRtcChecksum (Context);
}
if (Config->Kernel.Quirks.IncreasePciBarSize) {
PatchIncreasePciBarSize (Context);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册