audk/MdeModulePkg/Core/Dxe
Jian J Wang 0adc6eae94 MdeModulePkg/Core: fix ineffective guard page issue
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1295

This issue originates from following patch which allows to enable
paging if PcdImageProtectionPolicy and PcdDxeNxMemoryProtectionPolicy
(in addition to PcdSetNxForStack) are set to enable related features.

  5267926134

Due to above change, PcdImageProtectionPolicy will be set to 0 by
default in many platforms, which, in turn, cause following code in
MdeModulePkg\Core\Dxe\Misc\MemoryProtection.c fail the creation of
notify event of CpuArchProtocol.

1138:  if (mImageProtectionPolicy != 0 ||
           PcdGet64 (PcdDxeNxMemoryProtectionPolicy) != 0) {
1139:  Status = CoreCreateEvent (
...
1142:             MemoryProtectionCpuArchProtocolNotify,
...
1145:             );

Then following call flow won't be done and Guard pages will not be
set as not-present in SetAllGuardPages() eventually.

   MemoryProtectionCpuArchProtocolNotify()
=> HeapGuardCpuArchProtocolNotify()
=> SetAllGuardPages()

The solution is removing the if(...) statement so that the notify
event will always be created and registered. This won't cause
unnecessary code execution because, in the notify event handler,
the related PCDs like

    PcdImageProtectionPolicy and
    PcdDxeNxMemoryProtectionPolicy

will be checked again before doing related jobs.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-11-07 23:08:27 +08:00
..
Dispatcher MdeModulePkg DxeCore: Handle multiple FV images in one FV file 2018-09-03 17:04:58 +08:00
DxeMain MdeModulePkg Core/Dxe: Remove redundant functions 2018-08-21 16:29:04 +08:00
Event MdeModulePkg: Clean up source files 2018-06-28 11:19:45 +08:00
FwVol MdeModulePkg: Clean up source files 2018-06-28 11:19:45 +08:00
FwVolBlock MdeModulePkg: Clean up source files 2018-06-28 11:19:45 +08:00
Gcd MdeModulePkg/Core: fix an issue of potential NULL pointer access 2018-10-30 10:16:03 +08:00
Hand MdeModulePkg: Clean up source files 2018-06-28 11:19:45 +08:00
Image MdeModulePkg: Clean up source files 2018-06-28 11:19:45 +08:00
Library Update the copyright notice format 2010-04-24 09:49:11 +00:00
Mem MdeModulePkg/Core: correct one coding style 2018-10-27 21:33:13 +08:00
Misc MdeModulePkg/Core: fix ineffective guard page issue 2018-11-07 23:08:27 +08:00
SectionExtraction MdeModulePkg: Clean up source files 2018-06-28 11:19:45 +08:00
DxeCore.uni MdeModulePkg: Clean up source files 2018-06-28 11:19:45 +08:00
DxeCoreExtra.uni MdeModulePkg: Clean up source files 2018-06-28 11:19:45 +08:00
DxeMain.h MdeModulePkg Core/Dxe: Remove redundant functions 2018-08-21 16:29:04 +08:00
DxeMain.inf MdeModulePkg: Removing ipf which is no longer supported from edk2. 2018-09-06 15:25:16 +08:00