diff --git a/AppleSupportPkg.dsc b/AppleSupportPkg.dsc index 7426866..4bd36f9 100644 --- a/AppleSupportPkg.dsc +++ b/AppleSupportPkg.dsc @@ -35,6 +35,7 @@ ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf + FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf @@ -64,10 +65,17 @@ PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf OcTimerLib|OcSupportPkg/Library/OcTimerLib/OcTimerLib.inf OcMiscLib|OcSupportPkg/Library/OcMiscLib/OcMiscLib.inf + OcAppleBootPolicyLib|OcSupportPkg/Library/OcAppleBootPolicyLib/OcAppleBootPolicyLib.inf + OcAppleChunklistLib|OcSupportPkg/Library/OcAppleChunklistLib/OcAppleChunklistLib.inf + OcAppleDiskImageLib|OcSupportPkg/Library/OcAppleDiskImageLib/OcAppleDiskImageLib.inf + OcAppleRamDiskLib|OcSupportPkg/Library/OcAppleRamDiskLib/OcAppleRamDiskLib.inf + OcBootManagementLib|OcSupportPkg/Library/OcBootManagementLib/OcBootManagementLib.inf + OcCompressionLib|OcSupportPkg/Library/OcCompressionLib/OcCompressionLib.inf + OcDataHubLib|OcSupportPkg/Library/OcDataHubLib/OcDataHubLib.inf OcDevicePathLib|OcSupportPkg/Library/OcDevicePathLib/OcDevicePathLib.inf OcDevicePropertyLib|OcSupportPkg/Library/OcDevicePropertyLib/OcDevicePropertyLib.inf OcStringLib|OcSupportPkg/Library/OcStringLib/OcStringLib.inf - OcDataHubLib|OcSupportPkg/Library/OcDataHubLib/OcDataHubLib.inf + OcXmlLib|OcSupportPkg/Library/OcXmlLib/OcXmlLib.inf SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf diff --git a/Changelog.md b/Changelog.md index ae46108..56b7ccf 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,9 @@ AppleSupport Changelog ====================== +#### v2.0.8 +- Respect OpenCore scan policy during apfs driver loading + #### v2.0.7 - Added bless-compatible VBoxHfs driver (by @nms42) - Added compatibility with OpenCore logging protocols diff --git a/Include/AppleSupportPkgVersion.h b/Include/AppleSupportPkgVersion.h index 516f03c..8ec3f59 100644 --- a/Include/AppleSupportPkgVersion.h +++ b/Include/AppleSupportPkgVersion.h @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef APPLE_SUPPORT_VERSION_H #define APPLE_SUPPORT_VERSION_H -#define APPLE_SUPPORT_VERSION L"2.0.7" +#define APPLE_SUPPORT_VERSION L"2.0.8" #endif // APPLE_SUPPORT_VERSION_H diff --git a/Platform/ApfsDriverLoader/ApfsDriverLoader.c b/Platform/ApfsDriverLoader/ApfsDriverLoader.c index 3d745b8..4188b34 100755 --- a/Platform/ApfsDriverLoader/ApfsDriverLoader.c +++ b/Platform/ApfsDriverLoader/ApfsDriverLoader.c @@ -18,6 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include #include +#include #include #include #include @@ -26,6 +27,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include #include @@ -427,6 +429,56 @@ LegacyApfsContainerScan ( } +STATIC +EFI_STATUS +CheckOpenCoreScanPolicy ( + IN EFI_HANDLE Handle + ) +{ + EFI_STATUS Status; + UINT32 ScanPolicy; + UINT32 OcScanPolicy; + UINTN OcScanPolicySize; + + // + // If scan policy is missing, just ignore. + // + OcScanPolicy = 0; + OcScanPolicySize = sizeof (OcScanPolicy); + Status = gRT->GetVariable ( + OC_SCAN_POLICY_VARIABLE_NAME, + &gOcVendorVariableGuid, + NULL, + &OcScanPolicySize, + &OcScanPolicy + ); + if (EFI_ERROR (Status)) { + return EFI_SUCCESS; + } + + // + // If filesystem limitations are set and APFS is not allowed, + // report failure. + // + if ((OcScanPolicy & OC_SCAN_FILE_SYSTEM_LOCK) != 0 + && (OcScanPolicy & OC_SCAN_ALLOW_FS_APFS) == 0) { + return EFI_UNSUPPORTED; + } + + // + // If device type locking is set and this device is not allowed, + // report failure. + // + if ((OcScanPolicy & OC_SCAN_DEVICE_LOCK) != 0) { + ScanPolicy = OcGetDevicePolicyType (Handle, NULL); + if ((ScanPolicy & OcScanPolicy) == 0) { + return EFI_UNSUPPORTED; + } + } + + return EFI_SUCCESS; +} + /** Routine Description: @@ -459,6 +511,11 @@ ApfsDriverLoaderSupported ( APPLE_PARTITION_INFO_PROTOCOL *ApplePartitionInfo = NULL; EFI_PARTITION_INFO_PROTOCOL *Edk2PartitionInfo = NULL; + Status = CheckOpenCoreScanPolicy (ControllerHandle); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + Status = gBS->OpenProtocol ( ControllerHandle, &gApfsEfiBootRecordInfoProtocolGuid, diff --git a/Platform/ApfsDriverLoader/ApfsDriverLoader.inf b/Platform/ApfsDriverLoader/ApfsDriverLoader.inf index decb0dd..f344c57 100644 --- a/Platform/ApfsDriverLoader/ApfsDriverLoader.inf +++ b/Platform/ApfsDriverLoader/ApfsDriverLoader.inf @@ -48,6 +48,7 @@ DebugLib PcdLib OcAppleImageVerificationLib + OcBootManagementLib OcMiscLib OcGuardLib