From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 0F48D21191729 for ; Mon, 11 Jun 2018 00:08:48 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jun 2018 00:08:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,500,1520924400"; d="scan'208";a="207007648" Received: from shwdeopenpsi777.ccr.corp.intel.com ([10.239.158.27]) by orsmga004.jf.intel.com with ESMTP; 11 Jun 2018 00:08:46 -0700 From: Jian J Wang To: edk2-devel@lists.01.org Date: Mon, 11 Jun 2018 15:08:31 +0800 Message-Id: <20180611070833.5440-1-jian.j.wang@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Subject: [PATCH 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: Mon, 11 Jun 2018 07:08:48 -0000 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.c | 2 +- UefiCpuPkg/CpuDxe/CpuDxe.inf | 1 + UefiCpuPkg/CpuDxe/CpuPageTable.c | 108 +++++++++++++++++++++++----------- 4 files changed, 75 insertions(+), 46 deletions(-) -- 2.16.2.windows.1