]> git.proxmox.com Git - mirror_edk2.git/commit
CpuPageTableLib: Fix bug that wrongly requires extra size for mapping
authorRay Ni <ray.ni@intel.com>
Mon, 18 Jul 2022 08:41:37 +0000 (16:41 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 9 Aug 2022 07:08:05 +0000 (07:08 +0000)
commit927113c83b4106aedf57fd1c8dc6dad5f1fe6a69
treebb181ab175024bad4ef8cec139f890ebab1c8ee0
parent9f53fd4ba7ac4abe82365f310e0a4bcccc4448b3
CpuPageTableLib: Fix bug that wrongly requires extra size for mapping

With following paging structure to map
  [2M-4K, 2M] as P = 1, RW = 0,
  [2M, 4M]    as P = 1, RW = 1:

PML4[0] -> PDPTE[0] -> PDE[0](RW = 0) -> PTE[255](P = 0, RW = 0)
                    -> PDE[1](RW = 1)

When a new request to map [2M-4K, 2M+4K] as P = 1, RW = 1,
CpuPageTableMap() wrongly requests 4K buffer size for the new mapping
request.

But in fact, for [2M-4K, 2M] request, PTE[255] can be changed in place,
for [2M, 2M+4K], no change is needed because PDE[1].RW = 1 already.

The change fixes the bug.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c