From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3DDD4220757F6 for ; Mon, 13 Nov 2017 19:07:22 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2017 19:11:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,392,1505804400"; d="scan'208";a="1603327" Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.194.33]) by FMSMGA003.fm.intel.com with ESMTP; 13 Nov 2017 19:11:27 -0800 From: Jian J Wang To: edk2-devel@lists.01.org Date: Tue, 14 Nov 2017 11:11:19 +0800 Message-Id: <20171114031126.23340-1-jian.j.wang@intel.com> X-Mailer: git-send-email 2.14.1.windows.1 Subject: [PATCH v6 0/7] Implement heap guard feature X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Nov 2017 03:07:22 -0000 > Patch V6 changes: > Add sanity check and comments for the use of heap guard and memory > protection because heap guard might overwrite memory attributes set > by memory protection. > Patch V5 changes: > a. Remove EFI from comment for SMM memory attribute protocol. > b. Change parameter modifier of GetAttribute from IN to OUT > c. Add ASSERT to make sure static paging and heap guard are not enabled > at the same time > d. Remove lib and pcd no longer needed from PiSmmCore.inf > e. Fix duplicate pcd token number > Pacth V4 changes: > a. Change names of gEdkiiSmmMemoryAttributeProtocolGuid related > definitions from EFI_ to EDKII_ > b. Coding style cleanup > c. Split patches in a more reasonable order and groups > Patch V3 changes: > a. Add new protocol gEdkiiSmmMemoryAttributeProtocolGuid to do > memory attributes update instead of doing it directly in SmmCore > b. Fix GCC build error > Patch V2 changes: > a. Remove local variable initializer with memory copy from globals > b. Change map table dump code to use DEBUG_PAGE|DEBUG_POOL level > message > c. Fix malfunction in 32-bit boot mode > d. Add comment for the use of mOnGuarding > e. Change name of function InitializePageTableLib to > InitializePageTableGlobals > f. Add code in 32-bit code to bypass setting page table to read-only > g. Coding style clean-up > This feature makes use of paging mechanism to add a hidden (not present) page just before and after the allocated memory block. If the code tries to access memory outside of the allocated part, page fault exception will be triggered. This feature is disabled by default and is not recommended to enable it in production build of BIOS. This patch has passed following validations: a. Boot to shell (OVMF, Intel real platform)(32/64) b. Boot to Fedora 25 (64) NT32 emulation platform was not validated with this feature enabled due to the fact that it doesn't support paging which is needed for this feature to work. But all are validated with feature is disabled. Suggested-by: Ayellet Wolman Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang Jian J Wang (7): MdeModulePkg/MdeModulePkg.dec,.uni: Add Protocol, PCDs and string tokens MdeModulePkg/SmmMemoryAttribute.h: Add new protocol definitions UefiCpuPkg/CpuDxe: Reduce debug message MdeModulePkg/DxeIpl: Enable paging for heap guard MdeModulePkg/DxeCore: Implement heap guard feature for UEFI UefiCpuPkg/PiSmmCpuDxeSmm: Add SmmMemoryAttribute protocol MdeModulePkg/PiSmmCore: Implement heap guard feature for SMM mode MdeModulePkg/Core/Dxe/DxeMain.inf | 4 + MdeModulePkg/Core/Dxe/Mem/HeapGuard.c | 1192 ++++++++++++++++ MdeModulePkg/Core/Dxe/Mem/HeapGuard.h | 394 ++++++ MdeModulePkg/Core/Dxe/Mem/Imem.h | 38 +- MdeModulePkg/Core/Dxe/Mem/Page.c | 130 +- MdeModulePkg/Core/Dxe/Mem/Pool.c | 154 +- MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 3 + MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 1 + MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c | 36 +- MdeModulePkg/Core/PiSmmCore/HeapGuard.c | 1467 ++++++++++++++++++++ MdeModulePkg/Core/PiSmmCore/HeapGuard.h | 398 ++++++ MdeModulePkg/Core/PiSmmCore/Page.c | 52 +- MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 7 +- MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 81 +- MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 6 + MdeModulePkg/Core/PiSmmCore/Pool.c | 81 +- MdeModulePkg/Include/Protocol/SmmMemoryAttribute.h | 136 ++ MdeModulePkg/MdeModulePkg.dec | 60 + MdeModulePkg/MdeModulePkg.uni | 58 + UefiCpuPkg/CpuDxe/CpuPageTable.c | 5 +- UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c | 10 + UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 20 + UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 98 ++ UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf | 2 + UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 163 +++ UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 15 +- 26 files changed, 4512 insertions(+), 99 deletions(-) create mode 100644 MdeModulePkg/Core/Dxe/Mem/HeapGuard.c create mode 100644 MdeModulePkg/Core/Dxe/Mem/HeapGuard.h create mode 100644 MdeModulePkg/Core/PiSmmCore/HeapGuard.c create mode 100644 MdeModulePkg/Core/PiSmmCore/HeapGuard.h create mode 100644 MdeModulePkg/Include/Protocol/SmmMemoryAttribute.h -- 2.14.1.windows.1