From nobody Mon Sep 16 19:04:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+104935+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+104935+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1684231247; cv=none; d=zohomail.com; s=zohoarc; b=O0chVRLhbTLucDPvPv0FrxZc85jNnz6y4N4LzF+3zv7h8jtSc8fwxZmpE1itw/LvD5xGBc4pSTT0L9wQegb/nYPa75jScZcGgmo++efu7YjjfRbyCO219hBi2Ix/FQXqurkcuNxIaNz/0sLOJwBQskzGWXKh/9H74HeeebfYMGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684231247; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ev64I4xwe7Rjjw3ppCC8EaGhSynff7gQLtVIHviNkBs=; b=b2OCI5JtQ0NU0qSOjt333wVB/XbRgYWOPAk4kCeg8LAViQPkaSl1ZZf+igUnJ+Ga+JWWBwkz4kn1JDjWU3Vf6pNiFCx1QK9dbhGvJFAmMvWyXxPz6272087q3m5KJr5ss0TCWzG+FHKtDtFsw0JBXwAuj1m46mHoOpiBpabc87I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+104935+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1684231247652771.0301968361816; Tue, 16 May 2023 03:00:47 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id JlMVYY1788612xendWsSCuJX; Tue, 16 May 2023 03:00:47 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web11.17915.1684231210780691710 for ; Tue, 16 May 2023 03:00:46 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10711"; a="417093436" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="417093436" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2023 03:00:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10711"; a="791019782" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="791019782" X-Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.55.158]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2023 03:00:45 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [Patch V4 15/15] UefiCpuPkg/PiSmmCpuDxeSmm: Remove unnecessary function Date: Tue, 16 May 2023 17:59:32 +0800 Message-Id: <20230516095932.1525-16-dun.tan@intel.com> In-Reply-To: <20230516095932.1525-1-dun.tan@intel.com> References: <20230516095932.1525-1-dun.tan@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dun.tan@intel.com X-Gm-Message-State: oBGE74AbkGzG6fHZdzyvxNoxx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1684231247; bh=Ifh1vDlBWtn3Q9y/QeBiT/ld2QFw+L3iM/u/QsvABcU=; h=Cc:Date:From:Reply-To:Subject:To; b=anpmp0x5clrS4iduX+6u7ZyzR9vjfQOm/rafbVUkLLjerTEjzut565Oku8AnrlHSvhH xpDB8fbh8E6sxNdITbjIxZPNhwPavQAY+qYk6cViflSH7+EuGctqYpnRRApnRLIgH1zxK w/ztCcpdASjV1j5WHYs6LiY8/TmbzGsm92I= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1684231249170100047 Content-Type: text/plain; charset="utf-8" Remove unnecessary function SetNotPresentPage(). We can directly use ConvertMemoryPageAttributes to set a range to non-present. Signed-off-by: Dun Tan Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Reviewed-by: Ray Ni --- 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/PiSmmC= puDxeSmm/PiSmmCpuDxeSmm.c index d69e976269..7fa1867b63 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/PiSmmC= puDxeSmm/PiSmmCpuDxeSmm.h index 12ad86028e..0dc4d758cc 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h @@ -1247,22 +1247,6 @@ SetShadowStack ( IN UINT64 Length ); =20 -/** - Set not present memory. - - @param[in] Cr3 The page table base address. - @param[in] BaseAddress The physical address that is the start addr= ess 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. =20 diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPk= g/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c index 138ff43c9d..95de472ebf 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c @@ -752,28 +752,6 @@ SetShadowStack ( return Status; } =20 -/** - Set not present memory. - - @param[in] Cr3 The page table base address. - @param[in] BaseAddress The physical address that is the start addr= ess 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 =3D SmmSetMemoryAttributesEx (Cr3, mPagingMode, BaseAddress, Leng= th, EFI_MEMORY_RP); - return Status; -} - /** Retrieves a pointer to the system configuration table from the SMM Syste= m Table based on a specified GUID. --=20 2.31.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#104935): https://edk2.groups.io/g/devel/message/104935 Mute This Topic: https://groups.io/mt/98922944/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-