audk/UefiCpuPkg/Library
Ray Ni f4c845e46b CpuPageTableLib: Fix parent attributes are not inherited properly
With the following paging structure that maps [0, 2G] with ReadWrite
bit set.
PML4[0] --> PDPTE[0] --> PDE[0-255]
              \-> PDPTE[1] --> PDE[0-255]

If ReadWrite bit is cleared in PML4[0] and PageTableMap() is called
to change [0, 2M] as writable, today's logic doesn't inherit the
parent entry's attributes when determining the child entry's
attributes. It just sets the PDPTE[0].PDE[0].ReadWrite bit.
But since the PML4[0].ReadWrite is 0, [0, 2M] is still read-only.

The change fixes the bug.
If the inheritable attributes in ParentPagingEntry conflicts with the
requested attributes, let the child entries take the parent attributes
and loosen the attribute in the parent entry.

E.g.: when PDPTE[0].ReadWrite = 0 but caller wants to map [0-2MB as
ReadWrite = 1 (PDE[0].ReadWrite = 1), we need to change
PDPTE[0].ReadWrite = 1 and let all PDE[0-255].ReadWrite = 0 first.
Then change PDE[0].ReadWrite = 1.

Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
2022-08-09 07:08:05 +00:00
..
BaseUefiCpuLib UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
BaseXApicLib UefiCpuPkg: Add CpuLib to module INFs that depend on UefiCpuLib. 2022-05-06 07:48:15 +00:00
BaseXApicX2ApicLib UefiCpuPkg: Add CpuLib to module INFs that depend on UefiCpuLib. 2022-05-06 07:48:15 +00:00
CpuCacheInfoLib UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
CpuCommonFeaturesLib UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
CpuExceptionHandlerLib UefiCpuPkg: Simplify the struct definition of CPU_EXCEPTION_INIT_DATA 2022-08-09 04:12:28 +00:00
CpuPageTableLib CpuPageTableLib: Fix parent attributes are not inherited properly 2022-08-09 07:08:05 +00:00
CpuTimerLib UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
MicrocodeLib UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
MpInitLib MpInitLib: Move the Above1Mb vector allocation to MpInitLibInitialize 2022-06-10 12:15:49 +00:00
MpInitLibUp UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
MtrrLib UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
PlatformSecLibNull UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
RegisterCpuFeaturesLib UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
SecPeiDxeTimerLibUefiCpu UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
SmmCpuFeaturesLib UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
SmmCpuPlatformHookLibNull UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
SmmCpuRendezvousLib UefiCpuPkg: Extend SMM CPU Service with rendezvous support. 2022-03-04 05:44:42 +00:00
VmgExitLibNull UefiCpuPkg: Extend VmgExitLibNull to handle #VE exception 2022-04-02 08:15:12 +00:00