public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"abdattar@amd.com" <abdattar@amd.com>
Cc: Paul Grimes <paul.grimes@amd.com>,
	Garrett Kirkendall <garrett.kirkendall@amd.com>,
	Abner Chang <abner.chang@amd.com>,
	"Dong, Eric" <eric.dong@intel.com>,
	"Kumar, Rahul R" <rahul.r.kumar@intel.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>
Subject: Re: [edk2-devel] [PATCH v8 7/9] UefiCpuPkg: Implements SmmSmramSaveStateLib for Intel
Date: Tue, 11 Apr 2023 08:54:10 +0000	[thread overview]
Message-ID: <MN6PR11MB8244AC9AAF51F48C3A13DD1B8C9A9@MN6PR11MB8244.namprd11.prod.outlook.com> (raw)
In-Reply-To: <67da7e065711b9ad299c21031ba3b3eae8bb9231.1681121324.git.abdattar@amd.com>

> +
> SmmSmramSaveStateLib|UefiCpuPkg/Library/SmmSmramSaveStateLib/Intel
> SmmSmramSaveStateLib.inf

1. Can you rename it to "IntelMmSaveStateLib"?


> +  INF_VERSION                    = 1.29
> +  BASE_NAME                      = IntelSmmSmramSaveStateLib
> +  FILE_GUID                      = 37E8137B-9F74-4250-8951-7A970A3C39C0
> +  MODULE_TYPE                    = DXE_SMM_DRIVER
> +  VERSION_STRING                 = 1.0
> +  LIBRARY_CLASS                  = SmmSmramSaveStateLib

2. Can you check back the comments I left for AMD instance and apply similar changes here?

>  **/
>  EFI_STATUS
> -EFIAPI

3. Why remove "EFIAPI"?


> +/**
> +  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
> Register.
> +  @retval EFI_NOT_FOUND         If desired Register not found.
> +**/
> +EFI_STATUS
> +EFIAPI
> +SmramSaveStateReadRegister (
> +  IN  UINTN                        CpuIndex,
> +  IN  EFI_SMM_SAVE_STATE_REGISTER  Register,
> +  IN  UINTN                        Width,
> +  OUT VOID                         *Buffer
> +  )
> +{
> +  UINT32                      SmmRevId;
> +  SMRAM_SAVE_STATE_IOMISC     IoMisc;
> +  EFI_SMM_SAVE_STATE_IO_INFO  *IoInfo;
> +
> +  //
> +  // Check for special EFI_SMM_SAVE_STATE_REGISTER_LMA
> +  //
> +  if (Register == EFI_SMM_SAVE_STATE_REGISTER_LMA) {
> +    //
> +    // Only byte access is supported for this register
> +    //
> +    if (Width != 1) {
> +      return EFI_INVALID_PARAMETER;
> +    }
> +
> +    *(UINT8 *)Buffer = SmramSaveStateGetRegisterLma ();

4. It's Intel specific flow. I am curious how AMD flow handles the LMA read.

> +
> +    return EFI_SUCCESS;
> +  }
> +
> +  //
> +  // Check for special EFI_SMM_SAVE_STATE_REGISTER_IO
> +  //
> +  if (Register == EFI_SMM_SAVE_STATE_REGISTER_IO) {

5. Similar question here: how AMD flow handles the IO read?


> +
> +  //
> +  // Convert Register to a register lookup table index
> +  //
> +  return SmramSaveStateReadRegisterByIndex (CpuIndex,
> SmramSaveStateGetRegisterIndex (Register), Width, Buffer);

6. Can you double check here? The mSmmSmramCpuWidthOffset[] of Intel/AMD version don't put the GdtBase in the same location.
SMM_SAVE_STATE_REGISTER_MAX_INDEX is 2 for AMD but should be 4 for Intel.
How about define a "CONST UINTN gSmmSaveStateRegisterMaxIndex" with different values in Intel/AmdSmramSaveState.c?



>  EFI_STATUS
> -EFIAPI

7. Why remove "EFIAPI"?

> +UINT8
> +IntelSmramSaveStateGetRegisterLma (

8. Can you implement the SmramSaveStateGetRegisterLma() in Intel/Amd C files?


  reply	other threads:[~2023-04-11  8:54 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-10 11:09 [PATCH v8 0/9] Adds AmdSmmCpuFeaturesLib and SmmSmramSaveStateLib Abdul Lateef Attar
2023-04-10 11:09 ` [PATCH v8 1/9] MdePkg: Adds AMD SMRAM save state map Abdul Lateef Attar
2023-04-11  7:38   ` [edk2-devel] " Ni, Ray
2023-04-11 18:49     ` Michael D Kinney
2023-04-12  6:44     ` Attar, AbdulLateef (Abdul Lateef)
2023-04-10 11:09 ` [PATCH v8 2/9] UefiCpuPkg: Adds SmmSmramSaveStateLib library class Abdul Lateef Attar
2023-04-11  7:50   ` [edk2-devel] " Ni, Ray
2023-04-17  8:46     ` Attar, AbdulLateef (Abdul Lateef)
2023-04-10 11:09 ` [PATCH v8 3/9] UefiCpuPkg: Implements " Abdul Lateef Attar
2023-04-11  8:30   ` [edk2-devel] " Ni, Ray
2023-04-10 11:09 ` [PATCH v8 4/9] UefiCpuPkg/SmmCpuFeaturesLib: Restructure arch-dependent code Abdul Lateef Attar
2023-04-10 11:09 ` [PATCH v8 5/9] UefiCpuPkg: Initial implementation of AMD's SmmCpuFeaturesLib Abdul Lateef Attar
2023-04-11  8:32   ` [edk2-devel] " Ni, Ray
2023-04-10 11:09 ` [PATCH v8 6/9] UefiCpuPkg: Implements SmmCpuFeaturesLib for AMD Family Abdul Lateef Attar
2023-04-11  8:35   ` [edk2-devel] " Ni, Ray
2023-04-10 11:09 ` [PATCH v8 7/9] UefiCpuPkg: Implements SmmSmramSaveStateLib for Intel Abdul Lateef Attar
2023-04-11  8:54   ` Ni, Ray [this message]
2023-04-10 11:09 ` [PATCH v8 8/9] UefiCpuPkg: Uses SmmSmramSaveStateLib library Abdul Lateef Attar
2023-04-10 11:48   ` [edk2-devel] " Chang, Abner
2023-04-11  9:00   ` Ni, Ray
2023-04-10 11:09 ` [PATCH v8 9/9] OvmfPkg: " Abdul Lateef Attar
2023-04-11  9:42   ` Gerd Hoffmann
2023-04-11 10:09     ` [edk2-devel] " Ni, Ray
2023-04-11 10:48       ` Gerd Hoffmann
2023-04-11 11:17       ` Attar, AbdulLateef (Abdul Lateef)
2023-04-11 12:49         ` Ni, Ray
2023-04-18  5:22           ` Attar, AbdulLateef (Abdul Lateef)
2023-04-18  5:38             ` Ni, Ray
2023-04-18  6:42               ` Gerd Hoffmann
2023-04-11 11:12     ` Attar, AbdulLateef (Abdul Lateef)
2023-04-10 16:29 ` [PATCH v8 0/9] Adds AmdSmmCpuFeaturesLib and SmmSmramSaveStateLib Michael D Kinney
2023-04-11  1:07   ` Chang, Abner
2023-04-11  4:16     ` Attar, AbdulLateef (Abdul Lateef)
2023-04-11 18:48       ` Michael D Kinney
2023-04-12  2:21         ` Attar, AbdulLateef (Abdul Lateef)
2023-04-11 18:45     ` [edk2-devel] " Michael D Kinney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MN6PR11MB8244AC9AAF51F48C3A13DD1B8C9A9@MN6PR11MB8244.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox