Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
OpenCorePKG_MOD
提交
6d61426d
O
OpenCorePKG_MOD
项目概览
btwise
/
OpenCorePKG_MOD
通知
26
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OpenCorePKG_MOD
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6d61426d
编写于
3月 12, 2020
作者:
V
vit9696
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OcAppleBootCompatLib: Implement ProtectUefiServices quirk
上级
c4344487
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
205 addition
and
142 deletion
+205
-142
Changelog.md
Changelog.md
+1
-0
Docs/Configuration.pdf
Docs/Configuration.pdf
+0
-0
Docs/Configuration.tex
Docs/Configuration.tex
+15
-0
Docs/Differences/Differences.pdf
Docs/Differences/Differences.pdf
+0
-0
Docs/Differences/Differences.tex
Docs/Differences/Differences.tex
+20
-2
Docs/Sample.plist
Docs/Sample.plist
+2
-0
Docs/SampleFull.plist
Docs/SampleFull.plist
+2
-0
Include/Library/OcAppleBootCompatLib.h
Include/Library/OcAppleBootCompatLib.h
+11
-0
Include/Library/OcConfigurationLib.h
Include/Library/OcConfigurationLib.h
+2
-1
Library/OcAppleBootCompatLib/ServiceOverrides.c
Library/OcAppleBootCompatLib/ServiceOverrides.c
+150
-139
Library/OcConfigurationLib/OcConfigurationLib.c
Library/OcConfigurationLib/OcConfigurationLib.c
+1
-0
Platform/OpenCore/OpenCoreUefi.c
Platform/OpenCore/OpenCoreUefi.c
+1
-0
未找到文件。
Changelog.md
浏览文件 @
6d61426d
...
...
@@ -11,6 +11,7 @@ OpenCore Changelog
-
Added
`FwProtect`
tool to configure full NVRAM access from Shell
-
Added
`boot.efi`
debug protocol support for 10.15.4+
-
Added
`boot.efi`
performance logging for 10.15.4+
-
Added
`ProtectUefiServices`
quirk to fix
`DevirtualiseMmio`
on Z390
#### v0.5.6
-
Various improvements to builtin text renderer
...
...
Docs/Configuration.pdf
浏览文件 @
6d61426d
无法预览此类型文件
Docs/Configuration.tex
浏览文件 @
6d61426d
...
...
@@ -1328,6 +1328,21 @@ To view their current state use \texttt{pmset -g} command in Terminal.
\emph
{
Note
}
: This quirk mainly attempts to avoid issues with NVRAM implementations
with problematic defragmentation, such as select Insyde or
\texttt
{
MacPro5,1
}
.
\item
\texttt
{
ProtectUefiServices
}
\\
\textbf
{
Type
}
:
\texttt
{
plist
\
boolean
}
\\
\textbf
{
Failsafe
}
:
\texttt
{
false
}
\\
\textbf
{
Description
}
: Protect UEFI services from being overridden by the firmware.
Some modern firmwares including both hardware and virtual machines, like VMware,
may update pointers to UEFI services during driver loading and related actions.
Consequentially this directly breaks other quirks that affect memory management,
like
\texttt
{
DevirtualiseMmio
}
,
\texttt
{
ProtectCsmRegion
}
, or
\texttt
{
ShrinkMemoryMap
}
,
and may also break other quirks depending on the effects of these.
\emph
{
Note
}
: On VMware the need for this quirk may be diagnosed by ``Your Mac OS guest
might run unreliably with more than one virtual core.'' message.
\item
\texttt
{
ProvideCustomSlide
}
\\
\textbf
{
Type
}
:
\texttt
{
plist
\
boolean
}
\\
...
...
Docs/Differences/Differences.pdf
浏览文件 @
6d61426d
无法预览此类型文件
Docs/Differences/Differences.tex
浏览文件 @
6d61426d
\documentclass
[]
{
article
}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL PreviousConfiguration.tex Fri Mar 6 09:43:05 2020
%DIF ADD ../Configuration.tex T
ue Mar 10 00:51:02
2020
%DIF ADD ../Configuration.tex T
hu Mar 12 02:08:30
2020
\usepackage
{
lmodern
}
\usepackage
{
amssymb,amsmath
}
...
...
@@ -1391,7 +1391,25 @@ To view their current state use \texttt{pmset -g} command in Terminal.
with problematic defragmentation, such as select Insyde or
\texttt
{
MacPro5,1
}
.
\item
\texttt
{
ProvideCustomSlide
}
\\
\DIFaddbegin
\texttt
{
\DIFadd
{
ProtectUefiServices
}}
\\
\textbf
{
\DIFadd
{
Type
}}
\DIFadd
{
:
}
\texttt
{
\DIFadd
{
plist
\
boolean
}}
\\
\textbf
{
\DIFadd
{
Failsafe
}}
\DIFadd
{
:
}
\texttt
{
\DIFadd
{
false
}}
\\
\textbf
{
\DIFadd
{
Description
}}
\DIFadd
{
: Protect UEFI services from being overridden by the firmware.
}
\DIFadd
{
Some modern firmwares including both hardware and virtual machines, like VMware,
may update pointers to UEFI services during driver loading and related actions.
Consequentially this directly breaks other quirks that affect memory management,
like
}
\texttt
{
\DIFadd
{
DevirtualiseMmio
}}
\DIFadd
{
,
}
\texttt
{
\DIFadd
{
ProtectCsmRegion
}}
\DIFadd
{
, or
}
\texttt
{
\DIFadd
{
ShrinkMemoryMap
}}
\DIFadd
{
,
and may also break other quirks depending on the effects of these.
}
\emph
{
\DIFadd
{
Note
}}
\DIFadd
{
: On VMware the need for this quirk may be diagnosed by ``Your Mac OS guest
might run unreliably with more than one virtual core.'' message.
}
\item
\DIFaddend
\texttt
{
ProvideCustomSlide
}
\\
\textbf
{
Type
}
:
\texttt
{
plist
\
boolean
}
\\
\textbf
{
Failsafe
}
:
\texttt
{
false
}
\\
\textbf
{
Description
}
: Provide custom KASLR slide on low memory.
...
...
Docs/Sample.plist
浏览文件 @
6d61426d
...
...
@@ -256,6 +256,8 @@
<false/>
<key>
ProtectSecureBoot
</key>
<false/>
<key>
ProtectUefiServices
</key>
<false/>
<key>
ProvideCustomSlide
</key>
<true/>
<key>
SetupVirtualMap
</key>
...
...
Docs/SampleFull.plist
浏览文件 @
6d61426d
...
...
@@ -256,6 +256,8 @@
<false/>
<key>
ProtectSecureBoot
</key>
<false/>
<key>
ProtectUefiServices
</key>
<false/>
<key>
ProvideCustomSlide
</key>
<true/>
<key>
SetupVirtualMap
</key>
...
...
Include/Library/OcAppleBootCompatLib.h
浏览文件 @
6d61426d
...
...
@@ -87,6 +87,17 @@ typedef struct OC_ABC_SETTINGS_ {
///
BOOLEAN
SignalAppleOS
;
///
/// CoreImage may update and restore GetMemoryMap during loading (see InsertImageRecord)
/// as it needs this for segment splitting. Unfortunately it assumes nobody else
/// changes GetMemoryMap, and thus restores to its own CoreGetMemoryMap instead of
/// the previous value. Fix it here.
/// To make it worse VMware also replaces GetMemoryMap pointer in MacMisc, which CoreDxe
/// effectively trashes when we load drivers. As a result without this hack VMware Fusion
/// may show "Your Mac OS guest might run unreliably with more than one virtual core."
/// message when running OpenCore.
///
BOOLEAN
ProtectUefiServices
;
///
/// List of physical addresses to not be devirtualised by DevirtualiseMmio.
///
EFI_PHYSICAL_ADDRESS
*
MmioWhitelist
;
...
...
Include/Library/OcConfigurationLib.h
浏览文件 @
6d61426d
...
...
@@ -116,12 +116,13 @@
_(BOOLEAN , DevirtualiseMmio , , FALSE , ()) \
_(BOOLEAN , DisableSingleUser , , FALSE , ()) \
_(BOOLEAN , DisableVariableWrite , , FALSE , ()) \
_(BOOLEAN , ProtectSecureBoot , , FALSE , ()) \
_(BOOLEAN , DiscardHibernateMap , , FALSE , ()) \
_(BOOLEAN , EnableSafeModeSlide , , FALSE , ()) \
_(BOOLEAN , EnableWriteUnprotector , , FALSE , ()) \
_(BOOLEAN , ForceExitBootServices , , FALSE , ()) \
_(BOOLEAN , ProtectCsmRegion , , FALSE , ()) \
_(BOOLEAN , ProtectSecureBoot , , FALSE , ()) \
_(BOOLEAN , ProtectUefiServices , , FALSE , ()) \
_(BOOLEAN , ProvideCustomSlide , , FALSE , ()) \
_(BOOLEAN , SetupVirtualMap , , FALSE , ()) \
_(BOOLEAN , ShrinkMemoryMap , , FALSE , ()) \
...
...
Library/OcAppleBootCompatLib/ServiceOverrides.c
浏览文件 @
6d61426d
...
...
@@ -259,145 +259,6 @@ DevirtualiseMmio (
}
}
/**
UEFI Boot Services StartImage override. Called to start an efi image.
If this is boot.efi, then our overrides are enabled.
**/
STATIC
EFI_STATUS
EFIAPI
OcStartImage
(
IN
EFI_HANDLE
ImageHandle
,
OUT
UINTN
*
ExitDataSize
,
OUT
CHAR16
**
ExitData
OPTIONAL
)
{
EFI_STATUS
Status
;
EFI_LOADED_IMAGE_PROTOCOL
*
AppleLoadedImage
;
EFI_OS_INFO_PROTOCOL
*
OSInfo
;
BOOT_COMPAT_CONTEXT
*
BootCompat
;
OC_FWRT_CONFIG
Config
;
UINTN
DataSize
;
BootCompat
=
GetBootCompatContext
();
AppleLoadedImage
=
OcGetAppleBootLoadedImage
(
ImageHandle
);
//
// Clear monitoring vars
//
BootCompat
->
ServiceState
.
MinAllocatedAddr
=
0
;
if
(
AppleLoadedImage
!=
NULL
)
{
//
// Report about macOS being loaded.
//
++
BootCompat
->
ServiceState
.
AppleBootNestedCount
;
BootCompat
->
ServiceState
.
AppleHibernateWake
=
OcIsAppleHibernateWake
();
BootCompat
->
ServiceState
.
AppleCustomSlide
=
OcCheckArgumentFromEnv
(
AppleLoadedImage
,
BootCompat
->
ServicePtrs
.
GetVariable
,
"slide="
,
L_STR_LEN
(
"slide="
)
);
if
(
BootCompat
->
Settings
.
EnableSafeModeSlide
)
{
ASSERT
(
AppleLoadedImage
->
ImageSize
<=
MAX_UINTN
);
AppleSlideUnlockForSafeMode
(
(
UINT8
*
)
AppleLoadedImage
->
ImageBase
,
(
UINTN
)
AppleLoadedImage
->
ImageSize
);
}
AppleMapPrepareBooterState
(
BootCompat
,
AppleLoadedImage
,
BootCompat
->
ServicePtrs
.
GetMemoryMap
);
}
else
if
(
BootCompat
->
Settings
.
SignalAppleOS
)
{
Status
=
gBS
->
LocateProtocol
(
&
gEfiOSInfoProtocolGuid
,
NULL
,
(
VOID
*
)
&
OSInfo
);
if
(
!
EFI_ERROR
(
Status
))
{
OSInfo
->
OSVendor
(
EFI_OS_INFO_APPLE_VENDOR_NAME
);
OSInfo
->
OSName
(
"Mac OS X 10.15"
);
}
}
if
(
BootCompat
->
ServiceState
.
FwRuntime
!=
NULL
)
{
BootCompat
->
ServiceState
.
FwRuntime
->
GetCurrent
(
&
Config
);
//
// Support for ReadOnly and WriteOnly variables is OpenCore & Lilu security basics.
// For now always enable it.
//
Config
.
RestrictedVariables
=
TRUE
;
//
// Restrict secure boot variables and never let them slip unless once restricted.
//
Config
.
ProtectSecureBoot
=
BootCompat
->
Settings
.
ProtectSecureBoot
;
//
// Enable Boot#### variable redirection if OpenCore requested it.
// Do NOT disable it once enabled for stability reasons.
//
DataSize
=
sizeof
(
Config
.
BootVariableRedirect
);
BootCompat
->
ServicePtrs
.
GetVariable
(
OC_BOOT_REDIRECT_VARIABLE_NAME
,
&
gOcVendorVariableGuid
,
NULL
,
&
DataSize
,
&
Config
.
BootVariableRedirect
);
//
// Do the same thing for Boot#### variable fallback.
//
DataSize
=
sizeof
(
Config
.
BootVariableFallback
);
BootCompat
->
ServicePtrs
.
GetVariable
(
OC_BOOT_FALLBACK_VARIABLE_NAME
,
&
gOcVendorVariableGuid
,
NULL
,
&
DataSize
,
&
Config
.
BootVariableFallback
);
//
// Enable Apple-specific changes if requested.
// Disable them when this is no longer Apple.
//
if
(
BootCompat
->
ServiceState
.
AppleBootNestedCount
>
0
)
{
Config
.
WriteProtection
=
BootCompat
->
Settings
.
DisableVariableWrite
;
Config
.
WriteUnprotector
=
BootCompat
->
Settings
.
EnableWriteUnprotector
;
}
else
{
Config
.
WriteProtection
=
FALSE
;
Config
.
WriteUnprotector
=
FALSE
;
}
BootCompat
->
ServiceState
.
FwRuntime
->
SetMain
(
&
Config
);
}
Status
=
BootCompat
->
ServicePtrs
.
StartImage
(
ImageHandle
,
ExitDataSize
,
ExitData
);
if
(
AppleLoadedImage
!=
NULL
)
{
//
// We failed but other operating systems should be loadable.
//
--
BootCompat
->
ServiceState
.
AppleBootNestedCount
;
}
return
Status
;
}
/**
UEFI Boot Services AllocatePages override.
Returns pages from free memory block to boot.efi for kernel boot image.
...
...
@@ -537,6 +398,156 @@ OcGetMemoryMap (
return
Status
;
}
/**
UEFI Boot Services StartImage override. Called to start an efi image.
If this is boot.efi, then our overrides are enabled.
**/
STATIC
EFI_STATUS
EFIAPI
OcStartImage
(
IN
EFI_HANDLE
ImageHandle
,
OUT
UINTN
*
ExitDataSize
,
OUT
CHAR16
**
ExitData
OPTIONAL
)
{
EFI_STATUS
Status
;
EFI_LOADED_IMAGE_PROTOCOL
*
AppleLoadedImage
;
EFI_OS_INFO_PROTOCOL
*
OSInfo
;
BOOT_COMPAT_CONTEXT
*
BootCompat
;
OC_FWRT_CONFIG
Config
;
UINTN
DataSize
;
BootCompat
=
GetBootCompatContext
();
AppleLoadedImage
=
OcGetAppleBootLoadedImage
(
ImageHandle
);
//
// Recover firmware-replaced GetMemoryMap pointer.
//
if
(
BootCompat
->
Settings
.
ProtectUefiServices
&&
BootCompat
->
ServicePtrs
.
GetMemoryMap
!=
OcGetMemoryMap
)
{
DEBUG
((
DEBUG_INFO
,
"OCABC: Recovering trashed GetMemoryMap pointer
\n
"
));
gBS
->
GetMemoryMap
=
OcGetMemoryMap
;
gBS
->
Hdr
.
CRC32
=
0
;
gBS
->
CalculateCrc32
(
gBS
,
gBS
->
Hdr
.
HeaderSize
,
&
gBS
->
Hdr
.
CRC32
);
}
//
// Clear monitoring vars
//
BootCompat
->
ServiceState
.
MinAllocatedAddr
=
0
;
if
(
AppleLoadedImage
!=
NULL
)
{
//
// Report about macOS being loaded.
//
++
BootCompat
->
ServiceState
.
AppleBootNestedCount
;
BootCompat
->
ServiceState
.
AppleHibernateWake
=
OcIsAppleHibernateWake
();
BootCompat
->
ServiceState
.
AppleCustomSlide
=
OcCheckArgumentFromEnv
(
AppleLoadedImage
,
BootCompat
->
ServicePtrs
.
GetVariable
,
"slide="
,
L_STR_LEN
(
"slide="
)
);
if
(
BootCompat
->
Settings
.
EnableSafeModeSlide
)
{
ASSERT
(
AppleLoadedImage
->
ImageSize
<=
MAX_UINTN
);
AppleSlideUnlockForSafeMode
(
(
UINT8
*
)
AppleLoadedImage
->
ImageBase
,
(
UINTN
)
AppleLoadedImage
->
ImageSize
);
}
AppleMapPrepareBooterState
(
BootCompat
,
AppleLoadedImage
,
BootCompat
->
ServicePtrs
.
GetMemoryMap
);
}
else
if
(
BootCompat
->
Settings
.
SignalAppleOS
)
{
Status
=
gBS
->
LocateProtocol
(
&
gEfiOSInfoProtocolGuid
,
NULL
,
(
VOID
*
)
&
OSInfo
);
if
(
!
EFI_ERROR
(
Status
))
{
OSInfo
->
OSVendor
(
EFI_OS_INFO_APPLE_VENDOR_NAME
);
OSInfo
->
OSName
(
"Mac OS X 10.15"
);
}
}
if
(
BootCompat
->
ServiceState
.
FwRuntime
!=
NULL
)
{
BootCompat
->
ServiceState
.
FwRuntime
->
GetCurrent
(
&
Config
);
//
// Support for ReadOnly and WriteOnly variables is OpenCore & Lilu security basics.
// For now always enable it.
//
Config
.
RestrictedVariables
=
TRUE
;
//
// Restrict secure boot variables and never let them slip unless once restricted.
//
Config
.
ProtectSecureBoot
=
BootCompat
->
Settings
.
ProtectSecureBoot
;
//
// Enable Boot#### variable redirection if OpenCore requested it.
// Do NOT disable it once enabled for stability reasons.
//
DataSize
=
sizeof
(
Config
.
BootVariableRedirect
);
BootCompat
->
ServicePtrs
.
GetVariable
(
OC_BOOT_REDIRECT_VARIABLE_NAME
,
&
gOcVendorVariableGuid
,
NULL
,
&
DataSize
,
&
Config
.
BootVariableRedirect
);
//
// Do the same thing for Boot#### variable fallback.
//
DataSize
=
sizeof
(
Config
.
BootVariableFallback
);
BootCompat
->
ServicePtrs
.
GetVariable
(
OC_BOOT_FALLBACK_VARIABLE_NAME
,
&
gOcVendorVariableGuid
,
NULL
,
&
DataSize
,
&
Config
.
BootVariableFallback
);
//
// Enable Apple-specific changes if requested.
// Disable them when this is no longer Apple.
//
if
(
BootCompat
->
ServiceState
.
AppleBootNestedCount
>
0
)
{
Config
.
WriteProtection
=
BootCompat
->
Settings
.
DisableVariableWrite
;
Config
.
WriteUnprotector
=
BootCompat
->
Settings
.
EnableWriteUnprotector
;
}
else
{
Config
.
WriteProtection
=
FALSE
;
Config
.
WriteUnprotector
=
FALSE
;
}
BootCompat
->
ServiceState
.
FwRuntime
->
SetMain
(
&
Config
);
}
Status
=
BootCompat
->
ServicePtrs
.
StartImage
(
ImageHandle
,
ExitDataSize
,
ExitData
);
if
(
AppleLoadedImage
!=
NULL
)
{
//
// We failed but other operating systems should be loadable.
//
--
BootCompat
->
ServiceState
.
AppleBootNestedCount
;
}
return
Status
;
}
/**
UEFI Boot Services ExitBootServices override.
Patches kernel entry point with jump to our KernelEntryPatchJumpBack().
...
...
Library/OcConfigurationLib/OcConfigurationLib.c
浏览文件 @
6d61426d
...
...
@@ -174,6 +174,7 @@ mBooterQuirksSchema[] = {
OC_SCHEMA_BOOLEAN_IN
(
"ForceExitBootServices"
,
OC_GLOBAL_CONFIG
,
Booter
.
Quirks
.
ForceExitBootServices
),
OC_SCHEMA_BOOLEAN_IN
(
"ProtectCsmRegion"
,
OC_GLOBAL_CONFIG
,
Booter
.
Quirks
.
ProtectCsmRegion
),
OC_SCHEMA_BOOLEAN_IN
(
"ProtectSecureBoot"
,
OC_GLOBAL_CONFIG
,
Booter
.
Quirks
.
ProtectSecureBoot
),
OC_SCHEMA_BOOLEAN_IN
(
"ProtectUefiServices"
,
OC_GLOBAL_CONFIG
,
Booter
.
Quirks
.
ProtectUefiServices
),
OC_SCHEMA_BOOLEAN_IN
(
"ProvideCustomSlide"
,
OC_GLOBAL_CONFIG
,
Booter
.
Quirks
.
ProvideCustomSlide
),
OC_SCHEMA_BOOLEAN_IN
(
"SetupVirtualMap"
,
OC_GLOBAL_CONFIG
,
Booter
.
Quirks
.
SetupVirtualMap
),
OC_SCHEMA_BOOLEAN_IN
(
"ShrinkMemoryMap"
,
OC_GLOBAL_CONFIG
,
Booter
.
Quirks
.
ShrinkMemoryMap
),
...
...
Platform/OpenCore/OpenCoreUefi.c
浏览文件 @
6d61426d
...
...
@@ -356,6 +356,7 @@ OcLoadBooterUefiSupport (
AbcSettings
.
SetupVirtualMap
=
Config
->
Booter
.
Quirks
.
SetupVirtualMap
;
AbcSettings
.
ShrinkMemoryMap
=
Config
->
Booter
.
Quirks
.
ShrinkMemoryMap
;
AbcSettings
.
SignalAppleOS
=
Config
->
Booter
.
Quirks
.
SignalAppleOS
;
AbcSettings
.
ProtectUefiServices
=
Config
->
Booter
.
Quirks
.
ProtectUefiServices
;
if
(
AbcSettings
.
DevirtualiseMmio
&&
Config
->
Booter
.
MmioWhitelist
.
Count
>
0
)
{
AbcSettings
.
MmioWhitelist
=
AllocatePool
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录