audk/UefiCpuPkg/Library/CpuPageTableLib
Ray Ni 9f53fd4ba7 CpuPageTableLib: Fix a bug to avoid unnecessary changing to page table
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 read-only, today's logic unnecessarily changes
the paging structure in 2 aspects:
1. When setting PageTableBaseAddress in the entry, the code clears
    all attributes.
2. Even the ReadWrite bit in parent entry is not set, the code clears
    the ReadWrite bit in the leaf entry.

First change is wrong. It should not change other attributes when
setting the PA.
Second change is unnecessary. Because the parent entry already
declares the whole region as read-only, there is no need to clear
ReadWrite bit in the leaf entry again.

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
..
CpuPageTable.h CpuPageTableLib: Fix parent attributes are not inherited properly 2022-08-09 07:08:05 +00:00
CpuPageTableLib.inf UefiCpuPkg: Create CpuPageTableLib for manipulating X86 paging structs 2022-08-09 07:08:05 +00:00
CpuPageTableMap.c CpuPageTableLib: Fix a bug to avoid unnecessary changing to page table 2022-08-09 07:08:05 +00:00
CpuPageTableParse.c UefiCpuPkg: Create CpuPageTableLib for manipulating X86 paging structs 2022-08-09 07:08:05 +00:00