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.126; helo=mga18.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 1E6D8212BFB61 for ; Tue, 12 Jun 2018 22:35:18 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jun 2018 22:35:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,217,1526367600"; d="scan'208";a="56794832" Received: from shwdeopenpsi777.ccr.corp.intel.com ([10.239.158.27]) by fmsmga002.fm.intel.com with ESMTP; 12 Jun 2018 22:35:06 -0700 From: Jian J Wang To: edk2-devel@lists.01.org Date: Wed, 13 Jun 2018 13:34:59 +0800 Message-Id: <20180613053501.4604-1-jian.j.wang@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Subject: [PATCH v2 0/2] fix DXE memory free issue in SMM mode X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 05:35:19 -0000 > v2: > a. add more specific explanations in commit message > b. add more comments in code > c. remove redundant logic in code > d. fix logic hole in code > e. replace meanless constant macro with meaning ones > f. remove irrelated changes This patch series try to fix an issue caused by trying to free memory allocated in DXE but freed in SMM mode. This happens only if Heap Guard feature is enabled, which needs to update page table. The root cause is that DXE and SMM don't share the same paging configuration but CpuDxe driver still tries to access page table through current processor registers (CR3) in SMM mode, during memory free opration in DXE core. This will cause DXE core got the incorrect paging attributes of memory to be freed, and then fail the free operation. The solution is let CpuDxe store the paging configuration in a global variable and use it to access DXE page table if in SMM mode. Jian J Wang (2): UefiCpuPkg/CpuDxe: allow accessing (DXE) page table in SMM mode MdeModulePkg/Core: remove SMM check for Heap Guard feature detection MdeModulePkg/Core/Dxe/Mem/HeapGuard.c | 10 --- UefiCpuPkg/CpuDxe/CpuDxe.inf | 1 + UefiCpuPkg/CpuDxe/CpuPageTable.c | 159 ++++++++++++++++++++++++++-------- 3 files changed, 123 insertions(+), 47 deletions(-) -- 2.16.2.windows.1