From b34239fb8e704f2995ef8231db8b95e15346884a Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Tue, 21 Sep 2021 21:25:49 -0600 Subject: [PATCH] Add Kepler Acceleration for Monterey Beta 7 --- CHANGELOG.md | 1 + OCLP-CLI.command | 36 +++++++++++++++++--------------- OpenCore-Patcher.command | 33 ++++++++++++++++-------------- Resources/Constants.py | 3 ++- Resources/ModelArray.py | 5 +++++ Resources/SysPatch.py | 44 +++++++++++++++++++++++++++++++++------- 6 files changed, 83 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdff8dfef..8a709fcd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ - Applicable for BRCM2046 and BRCM2070 chipsets - Disable Library Validation allowing for AMFI usage - Remove reliance on amfi_get_out_of_my_way=1 +- Add Kepler Accleration Patches for Monterey Beta 7 and newer ## 0.2.4 diff --git a/OCLP-CLI.command b/OCLP-CLI.command index bb033900c..698afe1cb 100755 --- a/OCLP-CLI.command +++ b/OCLP-CLI.command @@ -20,6 +20,9 @@ class OpenCoreLegacyPatcher: self.constants.computer = device_probe.Computer.probe() self.computer = self.constants.computer self.constants.detected_os = int(platform.uname().release.partition(".")[0]) + self.constants.detected_os_minor = int(platform.uname().release.partition(".")[2].partition(".")[0]) + detected_os_build: str = subprocess.run("sw_vers -buildVersion".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode() + self.constants.detected_os_build = detected_os_build custom_cpu_model_value = Utilities.get_nvram("revcpuname", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) if custom_cpu_model_value is not None: @@ -200,33 +203,34 @@ If you plan to create the USB for another machine, please select the "Change Mod elif model in ModelArray.LegacyGPU: self.constants.disable_cs_lv = True if model in ModelArray.LegacyGPU: - if Utilities.check_metal_support(device_probe, self.computer) is True: - print("- Detected Metal GPU, overriding default configuration") + if host_is_target and Utilities.check_metal_support(device_probe, self.computer) is True: # Building on device and we have a native, supported GPU - self.constants.sip_status = True - # self.constants.secure_status = True # Monterey - self.constants.amfi_status = True - elif host_is_target: + if self.computer.dgpu and self.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler: + self.constants.sip_status = False + # self.constants.secure_status = True # Monterey + self.constants.amfi_status = True + self.constants.allow_fv_root = True # Allow FileVault on broken seal + else: + self.constants.sip_status = True + # self.constants.secure_status = True # Monterey + self.constants.amfi_status = True + else: self.constants.sip_status = False # Unsigned kexts self.constants.secure_status = False # Root volume modified self.constants.amfi_status = False # Unsigned binaries - if model in ModelArray.ModernGPU: - if host_is_target and model in ["iMac13,1", "iMac13,3"] and self.computer.dgpu: - # Some models have a supported dGPU, others don't - print("- Detected Metal dGPU, overriding default configuration") - self.constants.sip_status = True - elif host_is_target: - self.constants.sip_status = False # Unsigned kexts - self.constants.secure_status = False # Modified root volume self.constants.allow_fv_root = True # Allow FileVault on broken seal - # self.constants.amfi_status = True # Signed bundles, Don't need to explicitly set currently + if model in ModelArray.ModernGPU: + self.constants.sip_status = False # Unsigned kexts + self.constants.secure_status = False # Modified root volume + self.constants.allow_fv_root = True # Allow FileVault on broken seal + # self.constants.amfi_status = True # Signed bundles, Don't need to explicitly set currently if model == "MacBook8,1": # MacBook8,1 has an odd bug where it cannot install Monterey with Minimal spoofing self.constants.serial_settings == "Moderate" if self.constants.latebloom_delay == 0: self.constants.latebloom_delay, self.constants.latebloom_range, self.constants.latebloom_debug = Utilities.latebloom_detection(model) - + if Utilities.get_nvram("gpu-power-prefs", "FA4CE28D-B62F-4C99-9CC3-6815686E30F9", decode=True): self.constants.allow_ts2_accel = False diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command index ca95a31eb..80eebdc25 100755 --- a/OpenCore-Patcher.command +++ b/OpenCore-Patcher.command @@ -18,6 +18,8 @@ class OpenCoreLegacyPatcher: self.computer = self.constants.computer self.constants.detected_os = int(platform.uname().release.partition(".")[0]) self.constants.detected_os_minor = int(platform.uname().release.partition(".")[2].partition(".")[0]) + detected_os_build: str = subprocess.run("sw_vers -buildVersion".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode() + self.constants.detected_os_build = detected_os_build self.set_defaults(self.computer.real_model, True) def set_defaults(self, model, host_is_target): @@ -35,25 +37,25 @@ class OpenCoreLegacyPatcher: if model in ModelArray.LegacyGPU: if host_is_target and Utilities.check_metal_support(device_probe, self.computer) is True: # Building on device and we have a native, supported GPU - self.constants.sip_status = True - # self.constants.secure_status = True # Monterey - self.constants.amfi_status = True + if self.computer.dgpu and self.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler: + self.constants.sip_status = False + # self.constants.secure_status = True # Monterey + self.constants.amfi_status = True + self.constants.allow_fv_root = True # Allow FileVault on broken seal + else: + self.constants.sip_status = True + # self.constants.secure_status = True # Monterey + self.constants.amfi_status = True else: self.constants.sip_status = False # Unsigned kexts self.constants.secure_status = False # Root volume modified self.constants.amfi_status = False # Unsigned binaries self.constants.allow_fv_root = True # Allow FileVault on broken seal if model in ModelArray.ModernGPU: - if host_is_target and model in ["iMac13,1", "iMac13,3"] and self.computer.dgpu: - # Some models have a supported dGPU, others don't - self.constants.sip_status = True - # self.constants.secure_status = True # Monterey - # self.constants.amfi_status = True # Signed bundles, Don't need to explicitly set currently - else: - self.constants.sip_status = False # Unsigned kexts - self.constants.secure_status = False # Modified root volume - self.constants.allow_fv_root = True # Allow FileVault on broken seal - # self.constants.amfi_status = True # Signed bundles, Don't need to explicitly set currently + self.constants.sip_status = False # Unsigned kexts + self.constants.secure_status = False # Modified root volume + self.constants.allow_fv_root = True # Allow FileVault on broken seal + # self.constants.amfi_status = True # Signed bundles, Don't need to explicitly set currently if model == "MacBook8,1": # MacBook8,1 has an odd bug where it cannot install Monterey with Minimal spoofing self.constants.serial_settings = "Moderate" @@ -69,13 +71,13 @@ class OpenCoreLegacyPatcher: if Utilities.amfi_status() is False: self.constants.amfi_status = False - + if Utilities.get_nvram("gpu-power-prefs", "FA4CE28D-B62F-4C99-9CC3-6815686E30F9", decode=True): self.constants.allow_ts2_accel = False if self.constants.latebloom_delay == 0: self.constants.latebloom_delay, self.constants.latebloom_range, self.constants.latebloom_debug = Utilities.latebloom_detection(model) - + if Utilities.get_nvram("gpu-power-prefs", "FA4CE28D-B62F-4C99-9CC3-6815686E30F9", decode=True): self.constants.allow_ts2_accel = False @@ -305,6 +307,7 @@ B. Exit - Metal Graphics Acceleration - Intel: Ivy Bridge (4000 series iGPUs) + - Nvidia: Kepler (600-700) - Non-Metal Graphics Accelertation - Intel: Ironlake - Sandy Bridge - Nvidia: Tesla - Fermi (8000-500 series) diff --git a/Resources/Constants.py b/Resources/Constants.py index fb19565fe..1ad560ef6 100644 --- a/Resources/Constants.py +++ b/Resources/Constants.py @@ -14,7 +14,7 @@ class Constants: def __init__(self): # Patcher Versioning self.patcher_version = "0.2.5" # OpenCore-Legacy-Patcher - self.patcher_support_pkg_version = "0.1.2" # PatcherSupportPkg + self.patcher_support_pkg_version = "0.1.3" # PatcherSupportPkg # OpenCore Versioning # https://github.com/acidanthera/OpenCorePkg @@ -121,6 +121,7 @@ class Constants: self.os_support = 12.0 self.detected_os = 0 # Major Kernel Version self.detected_os_minor = 0 # Minor Kernel Version + self.detected_os_build = "" # OS Build self.allow_fv_root = False # Allow FileVault on broken sealed snapshots ## Boot Volume Settings diff --git a/Resources/ModelArray.py b/Resources/ModelArray.py index 45dacf0d0..157f51b13 100644 --- a/Resources/ModelArray.py +++ b/Resources/ModelArray.py @@ -271,10 +271,15 @@ ModernGPU = [ "MacBookPro9,2", # Intel 4000 "MacBookPro10,1", # Intel 4000 + Nvidia 650M "MacBookPro10,2", # Intel 4000 + "MacBookPro11,3", # Intel 5000 + Nvidia Kepler "Macmini6,1", # Intel 4000 "Macmini6,2", # Intel 4000 "iMac13,1", # Intel 4000 + "iMac13,2", # Intel 4000 + Nvidia Kepler "iMac13,3", # Intel 4000 + "iMac14,1", # Intel 5000 + Nvidia Kepler + "iMac14,2", # Intel 5000 + Nvidia Kepler + "iMac14,3", # Intel 5000 + Nvidia Kepler ] LegacyGPU = [ diff --git a/Resources/SysPatch.py b/Resources/SysPatch.py index bd3f3b4f0..bc21327e0 100644 --- a/Resources/SysPatch.py +++ b/Resources/SysPatch.py @@ -26,6 +26,7 @@ class PatchSysVolume: self.fv_enabled = True self.dosdude_patched = True self.nvidia_legacy = False + self.kepler_gpu = False self.amd_ts1 = False self.amd_ts2 = False self.iron_gpu = False @@ -406,6 +407,14 @@ set million colour before rebooting""" print("- Installing basic Ivy Bridge Kext patches for generic OS") self.add_new_binaries(SysPatchArray.AddIntelGen3Accel, self.constants.legacy_intel_gen3_path) + def gpu_franevuffer_kepler_master(self): + if self.constants.detected_os == self.constants.monterey: + print("- Installing Kepler Acceleration Kext patches for Monterey") + self.add_new_binaries(SysPatchArray.AddNvidiaKeplerAccel11, self.constants.legacy_nvidia_kepler_path) + else: + print("- Installing Kepler Kext patches for generic OS") + self.add_new_binaries(SysPatchArray.AddNvidiaKeplerAccel11, self.constants.legacy_nvidia_kepler_path) + def gpu_accel_legacy_extended(self): print("- Merging general legacy Frameworks") self.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_frameworks_path_accel}/", self.mount_frameworks], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) @@ -426,7 +435,11 @@ set million colour before rebooting""" # Assume non-OCLP Macs don't have _cs_require_lv print("- Disabling Library Validation") Utilities.process_status( - self.elevated(["defaults", "write", "/Library/Preferences/com.apple.security.libraryvalidation.plist", "DisableLibraryValidation", "-bool", "true"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + self.elevated( + ["defaults", "write", "/Library/Preferences/com.apple.security.libraryvalidation.plist", "DisableLibraryValidation", "-bool", "true"], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + ) ) def gpu_accel_legacy_extended_ts2(self): @@ -451,6 +464,14 @@ set million colour before rebooting""" print("- Detected unsupported OS, installing Basic Framebuffer") self.gpu_accel_legacy_nvidia_master() + elif self.kepler_gpu is True: + print("- Installing Kepler Patches") + if self.constants.detected_os == self.constants.monterey: + print("- Detected supported OS, installing Acceleration Patches") + else: + print("- Detected unsupported OS, installing Basic Framebuffer") + self.gpu_franevuffer_kepler_master() + elif self.amd_ts1 is True: print("- Installing legacy TeraScale 1 Patches") if self.constants.detected_os in self.constants.legacy_accel_support: @@ -495,11 +516,7 @@ set million colour before rebooting""" print("- Detected unsupported OS, installing Basic Framebuffer") self.gpu_framebuffer_ivybridge_master() - if ( - self.amd_ts2 is True - and self.constants.detected_os in self.constants.legacy_accel_support - and self.constants.allow_ts2_accel is True - ): + if self.amd_ts2 is True and self.constants.detected_os in self.constants.legacy_accel_support and self.constants.allow_ts2_accel is True: # TeraScale 2 patches must be installed after Intel HD3000 self.add_new_binaries(SysPatchArray.AddAMDAccel11TS2, self.constants.legacy_amd_path_ts2) @@ -599,6 +616,15 @@ set million colour before rebooting""" if self.constants.detected_os > non_metal_os: self.nvidia_legacy = True self.amfi_must_disable = True + elif dgpu.arch == device_probe.NVIDIA.Archs.Kepler: + if self.constants.detected_os > self.constants.big_sur: + # Kepler drivers were dropped with Beta 7 + # 12.0 Beta 5: 21.0.0 - 21A5304g + # 12.0 Beta 6: 21.1.0 - 21A5506j + # 12.0 Beta 7: 21.1.0 - 21A5522h + if self.constants.detected_os == self.constants.monterey and self.constants.detected_os_minor > 0: + if "21A5506j" not in self.constants.detected_os_build: + self.kepler_gpu = True elif dgpu.arch == device_probe.AMD.Archs.TeraScale_1: if self.constants.detected_os > non_metal_os: self.amd_ts1 = True @@ -647,6 +673,8 @@ set million colour before rebooting""" print("The following patches will be applied:") if self.nvidia_legacy is True: print("- Add Legacy Nvidia Tesla Graphics Patch") + elif self.kepler_gpu is True: + print("- Add Legacy Nvidia Kepler Graphics Patch") elif self.amd_ts1 is True: print("- Add Legacy ATI TeraScale 1 Graphics Patch") elif self.amd_ts2 is True: @@ -667,6 +695,7 @@ set million colour before rebooting""" self.no_patch = not any( [ self.nvidia_legacy, + self.kepler_gpu, self.amd_ts1, self.amd_ts2, self.iron_gpu, @@ -701,7 +730,8 @@ set million colour before rebooting""" if self.fv_enabled is True: print("\nCannot patch! Please disable FileVault.") - print("Go to System Preferences -> Security and disable FileVault") + print("For OCLP Macs, please rebuild your config with 0.2.5 or newer") + print("For others, Go to System Preferences -> Security and disable FileVault") if self.amfi_enabled is True and self.amfi_must_disable is True: print("\nCannot patch! Please disable AMFI.")