From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web11.386.1686191344244208222 for ; Wed, 07 Jun 2023 19:29:16 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=bTEh8qxl; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: dun.tan@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686191356; x=1717727356; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tKftqN46br2i6HvjdETh0Lzv0J6jIzZlkp0a3V7o4dI=; b=bTEh8qxlS5u1msF0eXbOTH9zEuNh7lPTZ/nqRo+0apEfP6zr+lLCFGsu U4v4E8NNzW5V2Gc8Akr6IQXwwt3M75i9zWrkgqvkEAsuUuG7Hlgo0j8GO v60rJdgCgoqy1DGc6UxOrqZelIHB0rnyFos+dLK584cim5dVO6MlWoQag HUiJEwvHSmbKBi3dDSHBrrVHo8wVWtqh7ZKJE1tjNGPtP2+dsclv0dpWV GUgBK6BpuCgkYHQbK1Z19xBhHSnG2rWQ4dOHvBs0SojvclpDrVmXoIB7M TKVlXWeMS6nZho7qJIODtau0AO5twTyRI8knt51tpqpCIEvrMDdh1KsLe g==; X-IronPort-AV: E=McAfee;i="6600,9927,10734"; a="357184479" X-IronPort-AV: E=Sophos;i="6.00,225,1681196400"; d="scan'208";a="357184479" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2023 19:29:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10734"; a="774877968" X-IronPort-AV: E=Sophos;i="6.00,225,1681196400"; d="scan'208";a="774877968" Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.55.158]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2023 19:29:14 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [Patch V5 14/14] UefiCpuPkg/PiSmmCpuDxeSmm: Remove unnecessary function Date: Thu, 8 Jun 2023 10:27:42 +0800 Message-Id: <20230608022742.1292-15-dun.tan@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20230608022742.1292-1-dun.tan@intel.com> References: <20230608022742.1292-1-dun.tan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Remove unnecessary function SetNotPresentPage(). We can directly use ConvertMemoryPageAttributes to set a range to non-present. Signed-off-by: Dun Tan Cc: Eric Dong Reviewed-by: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 8 ++++++-- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 16 ---------------- UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 22 ---------------------- 3 files changed, 6 insertions(+), 40 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 2568ffd677..c2452e6a29 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -1074,10 +1074,14 @@ PiCpuSmmEntry ( mSmmShadowStackSize ); if (FeaturePcdGet (PcdCpuSmmStackGuard)) { - SetNotPresentPage ( + ConvertMemoryPageAttributes ( Cr3, + mPagingMode, (EFI_PHYSICAL_ADDRESS)(UINTN)Stacks + mSmmStackSize + EFI_PAGES_TO_SIZE (1) + (mSmmStackSize + mSmmShadowStackSize) * Index, - EFI_PAGES_TO_SIZE (1) + EFI_PAGES_TO_SIZE (1), + EFI_MEMORY_RP, + TRUE, + NULL ); } } diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h index 12ad86028e..0dc4d758cc 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h @@ -1247,22 +1247,6 @@ SetShadowStack ( IN UINT64 Length ); -/** - Set not present memory. - - @param[in] Cr3 The page table base address. - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - - @retval EFI_SUCCESS The not present memory is set. -**/ -EFI_STATUS -SetNotPresentPage ( - IN UINTN Cr3, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length - ); - /** Initialize the shadow stack related data structure. diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c index 4e93d26eb4..ab502b800b 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c @@ -768,28 +768,6 @@ SetShadowStack ( return Status; } -/** - Set not present memory. - - @param[in] Cr3 The page table base address. - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - - @retval EFI_SUCCESS The not present memory is set. -**/ -EFI_STATUS -SetNotPresentPage ( - IN UINTN Cr3, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length - ) -{ - EFI_STATUS Status; - - Status = SmmSetMemoryAttributesEx (Cr3, mPagingMode, BaseAddress, Length, EFI_MEMORY_RP); - return Status; -} - /** Retrieves a pointer to the system configuration table from the SMM System Table based on a specified GUID. -- 2.31.1.windows.1