]> git.proxmox.com Git - mirror_edk2.git/commit
UefiCpuPkg: restore strict page attributes via #DB in nonstop mode only
authorJian J Wang <jian.j.wang@intel.com>
Thu, 28 Feb 2019 07:16:25 +0000 (15:16 +0800)
committerJian J Wang <jian.j.wang@intel.com>
Fri, 1 Mar 2019 03:17:17 +0000 (11:17 +0800)
commit2a93cccc24cfca12c66f13a41d52fb0a82fb924e
tree981504ec526e8d28f97d19adf03c2b0928065dfc
parenta6c63ee6d5d842bb8c4663c5140ae2c8e7360cac
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: dcc026217fdc363f55c217039fc43d344f69fed6
       16b918bbaf51211a32ae04d9d8a5ba6ccca25a6a
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>
UefiCpuPkg/CpuDxe/CpuPageTable.c
UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm