Skip to content

Commit

Permalink
OcAppleKernelLib: Fix CPUID patching on 10.4.10 and 10.4.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldfish64 committed Oct 14, 2020
1 parent 857bfb7 commit 9ecb761
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ OpenCore Changelog
- Fixed `BOOTx64.efi` and `BOOTIA32.efi` convention
- Fixed SMBIOS handling with multiple memory arrays
- Fixed memory array handle assignment on empty slots
- Fixed CPUID patching on certain versions of macOS 10.4.10 and 10.4.11.

#### v0.6.2
- Updated builtin firmware versions for SMBIOS and the rest
Expand Down
12 changes: 11 additions & 1 deletion Library/OcAppleKernelLib/CpuidPatches.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ PatchKernelCpuIdLegacy (
UINT8 *LocationSnow32;
UINT32 Signature[3];
BOOLEAN IsTiger;
BOOLEAN IsTigerOld;
BOOLEAN IsLeopard;
BOOLEAN IsSnow;
BOOLEAN IsLion;
Expand All @@ -168,7 +169,11 @@ PatchKernelCpuIdLegacy (
INT32 Delta;
INTERNAL_CPUID_PATCH Patch;

//
// XNU 8.10.1 and older require an additional patch to _tsc_init.
//
IsTiger = OcMatchDarwinVersion (KernelVersion, KERNEL_VERSION_TIGER_MIN, KERNEL_VERSION_TIGER_MAX);
IsTigerOld = OcMatchDarwinVersion (KernelVersion, KERNEL_VERSION_TIGER_MIN, KERNEL_VERSION (8, 10, 1));
IsLeopard = OcMatchDarwinVersion (KernelVersion, KERNEL_VERSION_LEOPARD_MIN, KERNEL_VERSION_LEOPARD_MAX);
IsSnow = OcMatchDarwinVersion (KernelVersion, KERNEL_VERSION_SNOW_LEOPARD_MIN, KERNEL_VERSION_SNOW_LEOPARD_MAX);
IsLion = OcMatchDarwinVersion (KernelVersion, KERNEL_VERSION_LION_MIN, KERNEL_VERSION_LION_MAX);
Expand Down Expand Up @@ -509,8 +514,13 @@ PatchKernelCpuIdLegacy (

//
// Locate _tsc_init on 10.4, as there is a CPUID (1) call that needs to be patched.
// This only applies to XNU 8.10.1 and older. Some recovery versions of
// 10.4.10 have a newer XNU 8.10.3 kernel with code changes to _tsc_init.
//
if (IsTiger) {
// It's possible 8.10.2 may require the patch, but there is no sources or kernels
// available to verify.
//
if (IsTigerOld) {
Status = PatcherGetSymbolAddress (Patcher, "_tsc_init", (UINT8 **) &Record);
if (EFI_ERROR (Status) || Record >= Last) {
DEBUG ((DEBUG_WARN, "OCAK: Failed to locate _tsc_init (%p) - %r\n", Record, Status));
Expand Down

0 comments on commit 9ecb761

Please sign in to comment.