audk/UefiCpuPkg/CpuDxe
Jian J Wang 2a93cccc24 UefiCpuPkg: restore strict page attributes via #DB in nonstop mode only
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1576

The root cause of this issue is that non-stop mode of Heap Guard and
NULL Detection set TF bit (single-step) in EFLAG unconditionally in
the common handler in CpuExceptionLib.

If PcdCpuSmmStaticPageTable is FALSE, the SMM will only create page
table for memory below 4G. If SMM tries to access memory beyond 4G,
a page fault exception will be triggered and the memory to access
will be added to page table so that SMM code can continue the access.

Because of above issue, the TF bit is set after the page fault is
handled and then fall into another DEBUG exception. Since non-stop
mode of Heap Guard and NULL Detection are not enabled, no special
DEBUG exception handler is registered. The default handler just
prints exception context and go into dead loop.

Actually EFLAGS can be changed in any standard exception handler.
There's no need to do single-step setup in assembly code. So the fix
is to move the logic to C code part of page fault exception handler
so that we can fully validate the configuration and prevent TF bit
from being set unexpectedly.

Fixes: dcc026217f
       16b918bbaf
Test:
 - Pass special test of accessing memory beyond 4G in SMM mode
 - Boot to OS with Qemu emulator platform (Fedora27, Ubuntu18.04,
   Windows7, Windows10)

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
2019-03-01 11:17:17 +08:00
..
Ia32 UefiCpuPkg: Remove X86 ASM and S files 2018-06-07 15:27:36 +08:00
X64 UefiCpuPkg: Remove X86 ASM and S files 2018-06-07 15:27:36 +08:00
CpuDxe.c UefiCpuPkg/CpuDxe: change level of DEBUG message 2018-08-30 07:43:56 +08:00
CpuDxe.h UefiCpuPkg/CpuDxe: consider freed-memory guard in non-stop mode 2018-10-26 10:27:21 +08:00
CpuDxe.inf UefiCpuPkg/CpuDxe: implement non-stop mode for uefi 2018-08-30 07:22:30 +08:00
CpuDxe.uni UefiCpuPkg: Clean up source files 2018-06-28 11:19:53 +08:00
CpuDxeExtra.uni UefiCpuPkg: Clean up source files 2018-06-28 11:19:53 +08:00
CpuGdt.c UefiCpuPkg: CpuDxe: Update GDT to be consistent with DxeIplPeim 2015-10-30 17:32:27 +00:00
CpuGdt.h UefiCpuPkg: CpuDxe: Update GDT to be consistent with DxeIplPeim 2015-10-30 17:32:27 +00:00
CpuMp.c UefiCpuPkg/CpuDxe: implement non-stop mode for uefi 2018-08-30 07:22:30 +08:00
CpuMp.h UefiCpuPkg CpuDxe: Update return status to follow spec. 2017-07-07 08:54:10 +08:00
CpuPageTable.c UefiCpuPkg: restore strict page attributes via #DB in nonstop mode only 2019-03-01 11:17:17 +08:00
CpuPageTable.h UefiCpuPkg/CpuDxe: Enable protection for newly added page table 2017-12-12 10:14:51 +08:00