[edk2-devel] [Patch V4 15/15] UefiCpuPkg/PiSmmCpuDxeSmm: Remove unnecessary function

Ni, Ray ray.ni at intel.com
Fri Jun 2 03:55:39 UTC 2023


Reviewed-by: Ray Ni <ray.ni at intel.com>

> -----Original Message-----
> From: Tan, Dun <dun.tan at intel.com>
> Sent: Tuesday, May 16, 2023 6:00 PM
> To: devel at edk2.groups.io
> Cc: Dong, Eric <eric.dong at intel.com>; Ni, Ray <ray.ni at intel.com>; Kumar, Rahul
> R <rahul.r.kumar at intel.com>; Gerd Hoffmann <kraxel at redhat.com>
> Subject: [Patch V4 15/15] UefiCpuPkg/PiSmmCpuDxeSmm: Remove unnecessary
> function
> 
> Remove unnecessary function SetNotPresentPage(). We can directly
> use ConvertMemoryPageAttributes to set a range to non-present.
> 
> Signed-off-by: Dun Tan <dun.tan at intel.com>
> Cc: Eric Dong <eric.dong at intel.com>
> Cc: Ray Ni <ray.ni at intel.com>
> Cc: Rahul Kumar <rahul1.kumar at intel.com>
> Cc: Gerd Hoffmann <kraxel at redhat.com>
> ---
>  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 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/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 138ff43c9d..95de472ebf 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> @@ -752,28 +752,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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105633): https://edk2.groups.io/g/devel/message/105633
Mute This Topic: https://groups.io/mt/98922944/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3943202/1813853/130120423/xyzzy [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list