MdeModulePkg/Core: fix guard page missing issue
This issue is a regression one caused by a patch at425d25699b
That fix didn't take the 0 page to free into account, which still needs to call UnsetGuardPage() even no memory needs to free. The fix is just moving the calling of UnsetGuardPage() to the place right after calling AdjustMemoryF(). Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> (cherry picked from commit1263ecf2ff
)
This commit is contained in:
@ -642,15 +642,15 @@ CoreFreePoolPagesWithGuard (
|
||||
NoPagesGuarded = NoPages;
|
||||
|
||||
AdjustMemoryF (&Memory, &NoPages);
|
||||
//
|
||||
// It's safe to unset Guard page inside memory lock because there should
|
||||
// be no memory allocation occurred in updating memory page attribute at
|
||||
// this point. And unsetting Guard page before free will prevent Guard
|
||||
// page just freed back to pool from being allocated right away before
|
||||
// marking it usable (from non-present to present).
|
||||
//
|
||||
UnsetGuardForMemory (MemoryGuarded, NoPagesGuarded);
|
||||
if (NoPages > 0) {
|
||||
//
|
||||
// It's safe to unset Guard page inside memory lock because there should
|
||||
// be no memory allocation occurred in updating memory page attribute at
|
||||
// this point. And unsetting Guard page before free will prevent Guard
|
||||
// page just freed back to pool from being allocated right away before
|
||||
// marking it usable (from non-present to present).
|
||||
//
|
||||
UnsetGuardForMemory (MemoryGuarded, NoPagesGuarded);
|
||||
CoreFreePoolPagesI (PoolType, Memory, NoPages);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user