mirror of
https://github.com/utmapp/edk2.git
synced 2026-12-01 14:00:40 -10:00
This patch fixes an issue introduced by commit5b91bf82c6and0c9f2cb10bThis issue will only happen if PcdDxeNxMemoryProtectionPolicy is enabled for reserved memory, which will mark SMM RAM as NX (non- executable) during DXE core initialization. SMM IPL driver will unset the NX attribute for SMM RAM to allow loading and running SMM core/drivers. But above commit will fail the unset operation of the NX attribute due to a fact that SMM RAM has zero cache attribute (MRC code always sets 0 attribute to reserved memory), which will cause GCD internal method ConverToCpuArchAttributes() to return 0 attribute, which is taken as invalid CPU paging attribute and skip the calling of gCpu->SetMemoryAttributes(). The solution is to make use of existing functionality in PiSmmIpl to make sure one cache attribute is set for SMM RAM. For performance consideration, PiSmmIpl will always try to set SMM RAM to write-back. But there's a hole in the code which will fail the setting write-back attribute because of no corresponding cache capabilities. This patch will add necessary cache capabilities before setting corresponding attributes. Cc: Star Zeng <[email protected]> Cc: Eric Dong <[email protected]> Cc: Jiewen Yao <[email protected]> Cc: Ruiyu Ni <[email protected]> Cc: Michael D Kinney <[email protected]> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <[email protected]> Reviewed-by: Star Zeng <[email protected]> (cherry picked from commit54ec85dd29)