audk/MdeModulePkg
Jian J Wang 425d25699b MdeModulePkg/Core: fix a logic hole in page free
This hole will cause page fault randomly. The root cause is that Guard
page, which is just freed back to page pool but not yet cleared not-
present attribute, will be allocated right away by internal function
CoreFreeMemoryMapStack(). The solution to this issue is to clear the
not-present attribute for freed Guard page before doing any free
operation, instead of after those operation.

The reason we didn't do this before is due to the fact that manipulating
page attributes might cause memory allocation action which would cause a
dead lock inside a memory allocation/free operation. So we always set or
unset Guard page outside the memory lock. After a thorough analysis, we
believe clearing a Guard page will not cause memory allocation because
memory we're to manipulate was already manipulated before for sure.
Therefore there should be no memory allocation occurring in this
situation.

Since we cleared Guard page not-present attribute before freeing instead
of after freeing, the debug code to clear freed memory can now be restored
to its original way (aka no checking and bypassing Guard page).

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
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>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-01-19 14:16:11 +08:00
..
Application MdeModulePkg: Fix misuses of AllocateCopyPool 2017-11-08 17:13:03 +08:00
Bus MdeModulePkg/EhciDxe: call EhcFreeUrb when int-transfer completes 2018-01-16 10:58:02 +08:00
Core MdeModulePkg/Core: fix a logic hole in page free 2018-01-19 14:16:11 +08:00
Include MdeModulePkg: Did some code enhancement for DxeIpIoLib. 2018-01-16 11:10:05 +08:00
Library MdeModulePkg/DxeIpIoLib: Fixed the error ASSERT incorrectly used in IpIoAddIp(). 2018-01-17 08:29:48 +08:00
Logo MdeModulePkg/LogoDxe: Return error if HII Package not present 2017-05-22 16:30:11 -07:00
Universal MdeModulePkg SectionExtractionPei: remove the hard code alignment adjustment 2018-01-19 13:20:20 +08:00
MdeModulePkg.dec MdeModulePkg/MdeModulePkg.dec: clarify Heap Guard usage 2018-01-10 09:52:38 +08:00
MdeModulePkg.dsc MdeModulePkg: Add UdfDxe to the dsc file 2017-09-13 18:24:40 +08:00
MdeModulePkg.uni MdeModulePkg/MdeModulePkg.uni: clarify Heap Guard usage 2018-01-10 09:52:39 +08:00
MdeModulePkgExtra.uni