audk/MdeModulePkg
Jian J Wang 2ac1730bf2 MdeModulePkg/DxeIpl: Mark page table as read-only
This patch will set the memory pages used for page table as read-only
memory after the paging is setup. CR0.WP must set to let it take into
effect.

A simple page table memory management mechanism, page table pool concept,
is introduced to simplify the page table memory allocation and protection.
It will also help to reduce the potential recursive "split" action during
updating memory paging attributes.

The basic idea is to allocate a bunch of continuous pages of memory in
advance as one or more page table pools, and all future page tables
consumption will happen in those pool instead of system memory. If the page
pool is reserved at the boundary of 2MB page and with same size of 2MB page,
there's no page granularity "split" operation will be needed, because the
memory of new page tables (if needed) will be usually in the same page as
target page table you're working on.

And since we have centralized page tables (a few 2MB pages), it's easier
to protect them by changing their attributes to be read-only once and for
all. There's no need to apply the protection for new page tables any more
as long as the pool has free pages available.

Once current page table pool has been used up, one can allocate another 2MB
memory pool and just set this new 2MB memory block to be read-only instead of
setting the new page tables one page by one page.

Two new PCDs PcdPageTablePoolUnitSize and PcdPageTablePoolAlignment are used
to specify the size and alignment for page table pool. For IA32 processor
0x200000 (2MB) is the only choice for both of them to meet the requirement of
page table pool.

Laszlo (lersek@redhat.com) did a regression test on QEMU virtual platform with
one middle version of this series patch. The details can be found at

 https://lists.01.org/pipermail/edk2-devel/2017-December/018625.html

There're a few changes after his work.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2017-12-12 10:14:51 +08:00
..
Application MdeModulePkg: Fix misuses of AllocateCopyPool 2017-11-08 17:13:03 +08:00
Bus MdeModulePkg: Correct function description for AllocateBuffer 2017-12-12 09:31:54 +08:00
Core MdeModulePkg/DxeIpl: Mark page table as read-only 2017-12-12 10:14:51 +08:00
Include MdeModulePkg: Correct function description for AllocateBuffer 2017-12-12 09:31:54 +08:00
Library MdeModulePkg/CpuExceptionHandlerLibNull: Add new API implementation 2017-12-08 14:38:49 +08:00
Logo MdeModulePkg/LogoDxe: Return error if HII Package not present 2017-05-22 16:30:11 -07:00
Universal MdeModulePkg: loose VA_COPY with no matching VA_END on a return path 2017-12-11 09:07:40 +08:00
MdeModulePkg.dec MdeModulePkg/metafile: Add PCD PcdCpuStackGuard 2017-12-08 14:38:46 +08:00
MdeModulePkg.dsc MdeModulePkg: Add UdfDxe to the dsc file 2017-09-13 18:24:40 +08:00
MdeModulePkg.uni MdeModulePkg/metafile: Add PCD PcdCpuStackGuard 2017-12-08 14:38:46 +08:00
MdeModulePkgExtra.uni MdeModulePkg: Convert all .uni files to utf-8 2015-12-15 04:56:23 +00:00