[edk2-devel] [PATCH v2 3/6] UefiCpuPkg: Adds SmmSmramSaveStateLib library class

Chang, Abner via groups.io abner.chang=amd.com at groups.io
Sun Jan 15 04:26:07 UTC 2023


[AMD Official Use Only - General]

Comments in line.

> -----Original Message-----
> From: devel at edk2.groups.io <devel at edk2.groups.io> On Behalf Of Abdul
> Lateef Attar via groups.io
> Sent: Wednesday, January 11, 2023 2:16 PM
> To: devel at edk2.groups.io
> Cc: Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar at amd.com>;
> Grimes, Paul <Paul.Grimes at amd.com>; Kirkendall, Garrett
> <Garrett.Kirkendall at amd.com>; Chang, Abner <Abner.Chang at amd.com>;
> Eric Dong <eric.dong at intel.com>; Ray Ni <ray.ni at intel.com>; Rahul Kumar
> <rahul1.kumar at intel.com>; Gerd Hoffmann <kraxel at redhat.com>
> Subject: [edk2-devel] [PATCH v2 3/6] UefiCpuPkg: Adds
> SmmSmramSaveStateLib library class
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> BZ:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugz
> illa.tianocore.org%2Fshow_bug.cgi%3Fid%3D4182&data=05%7C01%7Cabner.
> chang%40amd.com%7C90493fee40864523f7d508daf39b7e40%7C3dd8961fe4
> 884e608e11a82d994e183d%7C0%7C0%7C638090146447645457%7CUnknown
> %7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1ha
> WwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=E1WQL7%2F65L1K%2F6S
> uvA0EKpQ55V1J36Ofe3NklDf3Cqw%3D&reserved=0
> 
> Adds SmmSmramSaveStateLib Library class in UefiCpuPkg.dec.
> Adds function declaration header file.
> 
> Cc: Paul Grimes <paul.grimes at amd.com>
> Cc: Garrett Kirkendall <garrett.kirkendall at amd.com>
> Cc: Abner Chang <abner.chang at amd.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>
> 
> Signed-off-by: Abdul Lateef Attar <abdattar at amd.com>
> ---
>  UefiCpuPkg/UefiCpuPkg.dec                     |  4 ++
>  .../Include/Library/SmmSmramSaveStateLib.h    | 69
> +++++++++++++++++++
>  2 files changed, 73 insertions(+)
>  create mode 100644 UefiCpuPkg/Include/Library/SmmSmramSaveStateLib.h
> 
> diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
> index cff239d5283e..1de90b677828 100644
> --- a/UefiCpuPkg/UefiCpuPkg.dec
> +++ b/UefiCpuPkg/UefiCpuPkg.dec
> @@ -2,6 +2,7 @@
>  # This Package provides UEFI compatible CPU modules and libraries.
> 
>  #
> 
>  # Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.<BR>
> 
> +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
> +reserved.<BR>
> 
>  #
> 
>  # SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  #
> 
> @@ -65,6 +66,9 @@ [LibraryClasses.IA32, LibraryClasses.X64]
>    ##  @libraryclass  Provides function for manipulating x86 paging structures.
> 
>    CpuPageTableLib|Include/Library/CpuPageTableLib.h
> 
> 
> 
> +  ## @libraryclass   Provides functions for manipulating Smram savestate
> registers.
> 
> +  SmmSmramSaveSateLib|Include/Library/SmmSmramSaveStateLib.h
> 
> +
> 
>  [Guids]
> 
>    gUefiCpuPkgTokenSpaceGuid      = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa,
> 0xb8, 0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }}
> 
>    gMsegSmramGuid                 = { 0x5802bce4, 0xeeee, 0x4e33, { 0xa1, 0x30,
> 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }}
> 
> diff --git a/UefiCpuPkg/Include/Library/SmmSmramSaveStateLib.h
> b/UefiCpuPkg/Include/Library/SmmSmramSaveStateLib.h
> new file mode 100644
> index 000000000000..d10eb064ceac
> --- /dev/null
> +++ b/UefiCpuPkg/Include/Library/SmmSmramSaveStateLib.h
> @@ -0,0 +1,69 @@
> +/** @file
> 
> +Library that provides service to read/write CPU specific smram save state
> registers.
> 
> +
> 
> +Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
> 
> +Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
> +reserved.<BR>
> 
> +
> 
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> +
> 
> +**/
> 
> +
> 
> +#ifndef SMM_SMRAM_SAVE_STATE_LIB_H_
> 
> +#define SMM_SMRAM_SAVE_STATE_LIB_H_
> 
> +
> 
> +#include <Protocol/SmmCpu.h>
> 
> +#include <Uefi/UefiBaseType.h>
> 
> +
> 
> +/**
> 
> +  Read an SMM Save State register on the target processor.  If this
> + function
> 
> +  returns EFI_UNSUPPORTED, then the caller is responsible for reading
> + the
> 
> +  SMM Save Sate register.
> 
> +
> 
> +  @param[in]  CpuIndex  The index of the CPU to read the SMM Save
> + State.  The
> 
> +                        value must be between 0 and the NumberOfCpus
> + field in
> 
> +                        the System Management System Table (SMST).
> 
> +  @param[in]  Register  The SMM Save State register to read.
> 
> +  @param[in]  Width     The number of bytes to read from the CPU save
> state.
> 
> +  @param[out] Buffer    Upon return, this holds the CPU register value read
> 
> +                        from the save state.
> 
> +
> 
> +  @retval EFI_SUCCESS           The register was read from Save State.
> 
> +  @retval EFI_INVALID_PARAMTER  Buffer is NULL.
> 
> +  @retval EFI_UNSUPPORTED       This function does not support reading
[Chang, Abner] 
EFI_NOT_FOUND is missed in @retval.

> Register.
> 
> +
> 
> +**/
> 
> +EFI_STATUS
> 
> +EFIAPI
> 
> +SmramSaveStateReadRegister (
> 
> +  IN  UINTN                        CpuIndex,
> 
> +  IN  EFI_SMM_SAVE_STATE_REGISTER  Register,
> 
> +  IN  UINTN                        Width,
> 
> +  OUT VOID                         *Buffer
> 
> +  );
> 
> +
> 
> +/**
> 
> +  Writes an SMM Save State register on the target processor.  If this
> + function
> 
> +  returns EFI_UNSUPPORTED, then the caller is responsible for writing
> + the
> 
> +  SMM Save Sate register.
> 
> +
> 
> +  @param[in] CpuIndex  The index of the CPU to write the SMM Save
> + State.  The
> 
> +                       value must be between 0 and the NumberOfCpus
> + field in
> 
> +                       the System Management System Table (SMST).
> 
> +  @param[in] Register  The SMM Save State register to write.
> 
> +  @param[in] Width     The number of bytes to write to the CPU save state.
> 
> +  @param[in] Buffer    Upon entry, this holds the new CPU register value.
> 
> +
> 
> +  @retval EFI_SUCCESS           The register was written to Save State.
> 
> +  @retval EFI_INVALID_PARAMTER  Buffer is NULL.
> 
> +  @retval EFI_UNSUPPORTED       This function does not support writing
[Chang, Abner] 
EFI_NOT_FOUND is missed in @retval.

Thanks
Abner

> Register.
> 
> +**/
> 
> +EFI_STATUS
> 
> +EFIAPI
> 
> +SmramSaveStateWriteRegister (
> 
> +  IN UINTN                        CpuIndex,
> 
> +  IN EFI_SMM_SAVE_STATE_REGISTER  Register,
> 
> +  IN UINTN                        Width,
> 
> +  IN CONST VOID                   *Buffer
> 
> +  );
> 
> +
> 
> +#endif
> 
> --
> 2.25.1
> 
> 
> 
> 
> 


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




More information about the edk2-devel-archive mailing list