From nobody Tue Feb 10 02:28:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1523435939996204.95497917828334; Wed, 11 Apr 2018 01:38:59 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C3D352265A34B; Wed, 11 Apr 2018 01:38:57 -0700 (PDT) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 7F2452265A347 for ; Wed, 11 Apr 2018 01:38:56 -0700 (PDT) Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2018 01:38:56 -0700 Received: from shwdeopenpsi777.ccr.corp.intel.com ([10.239.158.27]) by orsmga007.jf.intel.com with ESMTP; 11 Apr 2018 01:38:55 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,435,1517904000"; d="scan'208";a="32503853" From: Jian J Wang To: edk2-devel@lists.01.org Date: Wed, 11 Apr 2018 16:38:46 +0800 Message-Id: <20180411083846.7300-3-jian.j.wang@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20180411083846.7300-1-jian.j.wang@intel.com> References: <20180411083846.7300-1-jian.j.wang@intel.com> Subject: [edk2] [PATCH 2/2] MdeModulePkg/SmmCore: add sanity check for SetMemoryAttributes 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: , Cc: Ruiyu Ni , Jiewen Yao , Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Heap Guard feature needs enough memory and paging to work. Otherwise calling SetMemoryAttributes to change page attribute will fail. This patch add necessary check of result of calling SetMemoryAttributes. This can help users to debug their problem in enabling this feature. Cc: Star Zeng Cc: Eric Dong Cc: Jiewen Yao Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang --- MdeModulePkg/Core/PiSmmCore/HeapGuard.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c b/MdeModulePkg/Core/Pi= SmmCore/HeapGuard.c index d5556eb79c..d9e54b96cb 100644 --- a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c +++ b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c @@ -592,14 +592,17 @@ SetGuardPage ( IN EFI_PHYSICAL_ADDRESS BaseAddress ) { + EFI_STATUS Status; + if (mSmmMemoryAttribute !=3D NULL) { mOnGuarding =3D TRUE; - mSmmMemoryAttribute->SetMemoryAttributes ( - mSmmMemoryAttribute, - BaseAddress, - EFI_PAGE_SIZE, - EFI_MEMORY_RP - ); + Status =3D mSmmMemoryAttribute->SetMemoryAttributes ( + mSmmMemoryAttribute, + BaseAddress, + EFI_PAGE_SIZE, + EFI_MEMORY_RP + ); + ASSERT_EFI_ERROR (Status); mOnGuarding =3D FALSE; } } @@ -619,14 +622,17 @@ UnsetGuardPage ( IN EFI_PHYSICAL_ADDRESS BaseAddress ) { + EFI_STATUS Status; + if (mSmmMemoryAttribute !=3D NULL) { mOnGuarding =3D TRUE; - mSmmMemoryAttribute->ClearMemoryAttributes ( - mSmmMemoryAttribute, - BaseAddress, - EFI_PAGE_SIZE, - EFI_MEMORY_RP - ); + Status =3D mSmmMemoryAttribute->ClearMemoryAttributes ( + mSmmMemoryAttribute, + BaseAddress, + EFI_PAGE_SIZE, + EFI_MEMORY_RP + ); + ASSERT_EFI_ERROR (Status); mOnGuarding =3D FALSE; } } --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel