Branch: refs/heads/master
  Home:   https://github.com/tianocore/edk2
  Commit: af9b8517322bb246cbfbf90f9624871fb5c54fad
      
https://github.com/tianocore/edk2/commit/af9b8517322bb246cbfbf90f9624871fb5c54fad
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    A UefiCpuPkg/Include/Library/SmmRelocationLib.h
    M UefiCpuPkg/UefiCpuPkg.dec

  Log Message:
  -----------
  UefiCpuPkg: Add SmmRelocationLib class

Intel plans to separate the smbase relocation logic from
PiSmmCpuDxeSmm driver, and the related behavior will be
moved to the new interface defined by the SmmRelocationLib
class.

The SmmRelocationLib class provides the SmmRelocationInit()
interface for platform to do the smbase relocation, which
shall provide below 2 functionalities:
1. Relocate smbases for each processor.
2. Create the gSmmBaseHobGuid HOB.

With SmmRelocationLib, PiSmmCpuDxeSmm driver (which runs at
a later phase) shall:
1. Consume the gSmmBaseHobGuid HOB for the relocated smbases
for each Processor.
2. Execute the early SMM Init.

This patch just provides the SmmRelocationLib class.

Cc: Ray Ni <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>


  Commit: 51fcd2023b84f1122c894a74c78fbafb893ae040
      
https://github.com/tianocore/edk2/commit/51fcd2023b84f1122c894a74c78fbafb893ae040
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    A UefiCpuPkg/Library/SmmRelocationLib/Ia32/Semaphore.c
    A UefiCpuPkg/Library/SmmRelocationLib/Ia32/SmmInit.nasm
    A UefiCpuPkg/Library/SmmRelocationLib/InternalSmmRelocationLib.h
    A UefiCpuPkg/Library/SmmRelocationLib/SmmRelocationLib.c
    A UefiCpuPkg/Library/SmmRelocationLib/SmmRelocationLib.inf
    A UefiCpuPkg/Library/SmmRelocationLib/SmramSaveStateConfig.c
    A UefiCpuPkg/Library/SmmRelocationLib/X64/Semaphore.c
    A UefiCpuPkg/Library/SmmRelocationLib/X64/SmmInit.nasm
    M UefiCpuPkg/UefiCpuPkg.dsc

  Log Message:
  -----------
  UefiCpuPkg/SmmRelocationLib: Add SmmRelocationLib library instance

This patch just separates the smbase relocation logic from
PiSmmCpuDxeSmm driver, and moves to the SmmRelocationInit
interface. It maintains the original implementation of most
functions and leaves the definitions of global variables
intact. Further refinements to the code are planned for
subsequent patches.

Platform shall consume the interface for the smbase
relocation if need SMM support.

Note:
Before using SmmRelocationLib, the PiSmmCpuDxeSmm driver
allocates the SMRAM to be used for SMI handler and Save
state area of each processor from Smst->AllocatePages().
With SmmRelocationLib, the SMRAM allocation for SMI
handlers and Save state areas is moved to early PEI
phase (Smst->AllocatePages() service is not available).
So, the allocation is done by splitting the SMRAM out of
the SMRAM regions reported from gEfiSmmSMramMemoryGuid.

So, Platform must produce the gEfiSmmSMramMemoryGuid HOB
for SmmRelocationLib usage.

Cc: Ray Ni <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>


  Commit: 42e8fa84f782d79cd18cd10493375d5b71bcc71b
      
https://github.com/tianocore/edk2/commit/42e8fa84f782d79cd18cd10493375d5b71bcc71b
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    M UefiCpuPkg/Library/SmmRelocationLib/Ia32/SmmInit.nasm
    M UefiCpuPkg/Library/SmmRelocationLib/InternalSmmRelocationLib.h
    M UefiCpuPkg/Library/SmmRelocationLib/SmmRelocationLib.c
    M UefiCpuPkg/Library/SmmRelocationLib/X64/SmmInit.nasm

  Log Message:
  -----------
  UefiCpuPkg/SmmRelocationLib: Rename global variables

This patch aims to rename global variables for clearer
association with Smm Init, ensuring their names are
distinct from those used in the PiSmmCpuDxeSmm Driver.

Cc: Ray Ni <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>


  Commit: 7421094136989fe53c73efd9c90eefd289a28a01
      
https://github.com/tianocore/edk2/commit/7421094136989fe53c73efd9c90eefd289a28a01
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    M UefiCpuPkg/Library/SmmRelocationLib/SmmRelocationLib.c

  Log Message:
  -----------
  UefiCpuPkg/SmmRelocationLib: Avoid unnecessary memory allocation

Since SMM relocation is performed serially for each CPU, there is
no need to allocate buffers for all CPUs to store the SmBase
address in mSmBase and the Rebased flag in mRebased. A defined
global variable is sufficient.

This patch focuses on the mSmBase and mRebased global variables
to prevent unnecessary memory allocation for these variables.

Cc: Ray Ni <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>


  Commit: 9783dc01cccf557e6955dfc938f8b4acd7b16c88
      
https://github.com/tianocore/edk2/commit/9783dc01cccf557e6955dfc938f8b4acd7b16c88
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    M UefiCpuPkg/Library/SmmRelocationLib/SmmRelocationLib.c

  Log Message:
  -----------
  UefiCpuPkg/SmmRelocationLib: Remove unnecessary global variable

This patch aims on mProcessorInfo global variable, which can be
defined as local variable in SmmRelocateBases(). With this patch,
no need to allocate the memory for all CPUs to store the
Processor Info.

Cc: Ray Ni <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>


  Commit: c56ea95b2845d2846eda8ceb740586fe936627c9
      
https://github.com/tianocore/edk2/commit/c56ea95b2845d2846eda8ceb740586fe936627c9
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    M UefiCpuPkg/Library/SmmRelocationLib/Ia32/Semaphore.c
    M UefiCpuPkg/Library/SmmRelocationLib/InternalSmmRelocationLib.h
    M UefiCpuPkg/Library/SmmRelocationLib/SmmRelocationLib.c
    M UefiCpuPkg/Library/SmmRelocationLib/SmramSaveStateConfig.c
    M UefiCpuPkg/Library/SmmRelocationLib/X64/Semaphore.c

  Log Message:
  -----------
  UefiCpuPkg/SmmRelocationLib: Remove unnecessary CpuIndex

This patch is to remove unnecessary CpuIndex.

Cc: Ray Ni <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>


  Commit: 47f212295f17ef2473b37e3e8cfbddd411ad85ea
      
https://github.com/tianocore/edk2/commit/47f212295f17ef2473b37e3e8cfbddd411ad85ea
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    A UefiCpuPkg/Library/SmmRelocationLib/AmdSmmRelocationLib.inf
    A UefiCpuPkg/Library/SmmRelocationLib/AmdSmramSaveStateConfig.c
    M UefiCpuPkg/UefiCpuPkg.dsc

  Log Message:
  -----------
  UefiCpuPkg/SmmRelocationLib: Add library instance for AMD

Due to the definition difference of SMRAM Save State,
SmmBase config in SMRAM Save State for AMD is also different.

This patch provides the AmdSmmRelocationLib library instance
to handle the SMRAM Save State difference.

Cc: Abdul Lateef Attar <[email protected]>
Cc: Abner Chang <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Acked-by: Ray Ni <[email protected]>
Reviewed-by: Abdul Lateef Attar <[email protected]>


  Commit: 3dfd64305b7f46da6f98ae15c87227b0fb55f726
      
https://github.com/tianocore/edk2/commit/3dfd64305b7f46da6f98ae15c87227b0fb55f726
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    M OvmfPkg/AmdSev/AmdSevX64.dsc
    M OvmfPkg/CloudHv/CloudHvX64.dsc
    A OvmfPkg/Library/SmmRelocationLib/Ia32/Semaphore.c
    A OvmfPkg/Library/SmmRelocationLib/Ia32/SmmInit.nasm
    A OvmfPkg/Library/SmmRelocationLib/InternalSmmRelocationLib.h
    A OvmfPkg/Library/SmmRelocationLib/SmmRelocationLib.c
    A OvmfPkg/Library/SmmRelocationLib/SmmRelocationLib.inf
    A OvmfPkg/Library/SmmRelocationLib/SmramSaveStateConfig.c
    A OvmfPkg/Library/SmmRelocationLib/X64/Semaphore.c
    A OvmfPkg/Library/SmmRelocationLib/X64/SmmInit.nasm
    M OvmfPkg/Microvm/MicrovmX64.dsc
    M OvmfPkg/OvmfPkgIa32.dsc
    M OvmfPkg/OvmfPkgIa32X64.dsc
    M OvmfPkg/OvmfPkgX64.dsc

  Log Message:
  -----------
  OvmfPkg/SmmRelocationLib: Add library instance for OVMF

There are below 2 differences between AMD & OVMF according
existing implementation:
1.The mode of the CPU check is different between the AMD & OVMF.
OVMF:
CpuSaveState->x86.SMMRevId & 0Xffff

AMD:
 LMAValue = (UINT32)AsmReadMsr64 (EFER_ADDRESS) & LMA

2.Existing SmBase configuration is different between the
AMD & OVMF.
OVMF:
 if ((CpuSaveState->x86.SMMRevId & 0xFFFF) == 0) {
   CpuSaveState->x86.SMBASE = mSmBaseForAllCpus[CpuIndex];
 } else {
   CpuSaveState->x64.SMBASE = mSmBaseForAllCpus[CpuIndex];
 }

AMD:
 AmdCpuState->x64.SMBASE = mSmBaseForAllCpus[CpuIndex];

This patch provides the SmmRelocationLib library instance
for OVMF to handle the logic difference, and it won't change
the existing implementation code logic.

Cc: Ray Ni <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Tested-by: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>


  Commit: 6a468a8b55e99d6999a61131aa057411aae73310
      
https://github.com/tianocore/edk2/commit/6a468a8b55e99d6999a61131aa057411aae73310
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    M OvmfPkg/Library/PlatformInitLib/MemDetect.c
    M OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf

  Log Message:
  -----------
  OvmfPkg/PlatformInitLib: Create gEfiSmmSmramMemoryGuid

In the PiSmmCpuDxeSmm driver, SMRAM allocation for SMI
handlers and processor Save State areas was traditionally
performed using the Smst->AllocatePages() function during
the DXE phase. The introduction of SmmRelocationLib
changes this process by moving the allocation to the PEI
phase, where Smst->AllocatePages() is not accessible.
Instead, the allocation is now handled by partitioning
the SMRAM based on the information provided by a GUID HOB
(identified by gEfiSmmSMramMemoryGuid).

This patch is to ensure that OVMF produces the
gEfiSmmSMramMemoryGuid HOB, allowing SmmRelocationLib to
reserve the necessary memory for SMBASE relocation.

More info for the change:
1. The EFI_SMM_SMRAM_MEMORY_GUID HOB, as defined in the PI
specification, vol.3, section 5, which is used to describe
the SMRAM memory regions supported by the platform. This HOB
should be produced during the memory detection phase to
align with the PI spec.

2. In addition to the memory reserved for ACPI S3 resume,
an increasing number of features require reserving SMRAM
for specific purposes, such as SmmRelocation. Other
advanced features in Intel platforms also necessitate
this. The implementation of these features varies and is
entirely dependent on the platform. This is why an
increasing number of platforms are adopting the
EFI_SMM_SMRAM_MEMORY_GUID HOB for SMRAM description.

3. It is crucial that the SMRAM information remains
consistent when retrieved from the platform, whether
through the SMM ACCESS PPI/Protocol or the
EFI_SMM_SMRAM_MEMORY_GUID HOB. Inconsistencies can lead
to unexpected issues, most commonly memory region conflicts.

4. The SMM ACCESS PPI/Protocol can be naturally
implemented for general use. The common approach is to
utilize the EFI_SMM_SMRAM_MEMORY_GUID HOB. For reference,
see the existing implementation in the EDK2 repository at
edk2/UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.inf and
edk2-platforms/Silicon/Intel/IntelSiliconPkg/Feature/
SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.inf.

Next patch will refine the OVMF SMM Access to consume
the EFI_SMM_SMRAM_MEMORY_GUID HOB.

Cc: Ard Biesheuvel <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Ray Ni <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Tested-by: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>


  Commit: 04c36d5a1b6cf17de62e2526c968661883567d1f
      
https://github.com/tianocore/edk2/commit/04c36d5a1b6cf17de62e2526c968661883567d1f
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    M OvmfPkg/Library/PlatformInitLib/MemDetect.c
    M OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf
    M OvmfPkg/SmmAccess/SmmAccess2Dxe.c
    M OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
    M OvmfPkg/SmmAccess/SmmAccessPei.c
    M OvmfPkg/SmmAccess/SmmAccessPei.inf
    M OvmfPkg/SmmAccess/SmramInternal.c
    M OvmfPkg/SmmAccess/SmramInternal.h

  Log Message:
  -----------
  OvmfPkg: Refine SmmAccess implementation

This patch refines the SmmAccess implementation:
1. SmramMap will be retrieved from the
gEfiSmmSmramMemoryGuid instead of original from
the TSEG Memory Base register.
2. Remove the gEfiAcpiVariableGuid creation, thus
the DESCRIPTOR_INDEX definition can be also cleaned.
3. The gEfiAcpiVariableGuid HOB is moved to the
OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf.

Cc: Ard Biesheuvel <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Ray Ni <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Tested-by: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>


  Commit: 4a6400b084d98bea6182a17769049e4f6b6c5627
      
https://github.com/tianocore/edk2/commit/4a6400b084d98bea6182a17769049e4f6b6c5627
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    M OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c

  Log Message:
  -----------
  OvmfPkg/SmmCpuFeaturesLib: Check Smbase Relocation is done or not

Based on gSmmBaseHobGuid:
If gSmmBaseHobGuid found, means SmBase info has been relocated
and recorded in the SmBase array.
So, this patch check smbase relocation is done or not in
SmmCpuFeaturesInitializeProcessor().

With SmmRelocationLib, gSmmBaseHobGuid will be always created.
Here this patch just makes the function/logic correct. The SMM
Relocation logic can be totally cleaned from the
SmmCpuFeaturesLib. But it will happen in the future patch set,
this patch does not target to the cleanup work.

Cc: Ard Biesheuvel <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Ray Ni <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>
Tested-by: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>


  Commit: 6b3a89a9fdb5003e1b6a511fd4c09429e19b4b2f
      
https://github.com/tianocore/edk2/commit/6b3a89a9fdb5003e1b6a511fd4c09429e19b4b2f
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    M OvmfPkg/PlatformPei/Platform.c
    M OvmfPkg/PlatformPei/Platform.h
    M OvmfPkg/PlatformPei/PlatformPei.inf
    A OvmfPkg/PlatformPei/SmmRelocation.c

  Log Message:
  -----------
  OvmfPkg/PlatformPei: Relocate SmBases in PEI phase

This patch is to consume SmmRelocationInit for SmBase
Relocation.

Cc: Ard Biesheuvel <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Ray Ni <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Tested-by: Gerd Hoffmann <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
Acked-by: Jiewen Yao <[email protected]>


  Commit: 23ed7f209c122b5f9d8c1b35b2b01ece2b716e54
      
https://github.com/tianocore/edk2/commit/23ed7f209c122b5f9d8c1b35b2b01ece2b716e54
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    M UefiPayloadPkg/UefiPayloadPkg.dsc

  Log Message:
  -----------
  UefiPayloadPkg/UefiPayloadPkg.dsc: Include SmmRelocationLib

This patch just includes SmmRelocationLib in UefiPayloadPkg.

Cc: Guo Dong <[email protected]>
Cc: Sean Rhodes <[email protected]>
Cc: James Lu <[email protected]>
Cc: Gua Guo <[email protected]>
Cc: Ray Ni <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Gua Guo <[email protected]>
Reviewed-by: Guo Dong <[email protected]>


  Commit: 2727231b0a6fb4c043479d132df4d36cf9f751c2
      
https://github.com/tianocore/edk2/commit/2727231b0a6fb4c043479d132df4d36cf9f751c2
  Author: Jiaxin Wu <[email protected]>
  Date:   2024-05-08 (Wed, 08 May 2024)

  Changed paths:
    M UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
    R UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c
    R UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm
    M UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
    M UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
    M UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
    M UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
    M UefiCpuPkg/PiSmmCpuDxeSmm/SmmMpPerf.h
    M UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c
    R UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c
    R UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmInit.nasm

  Log Message:
  -----------
  UefiCpuPkg/PiSmmCpuDxeSmm: Remove SmBases relocation logic

This patch is to remove legacy SmBase relocation in
PiSmmCpuDxeSmm Driver. The responsibility for SmBase
relocation has been transferred to the SmmRelocationInit
interface, which now handles the following tasks:
1. Relocates the SmBase for each processor.
2. Generates the gSmmBaseHobGuid HOB.

As a result of this change, the PiSmmCpuDxeSmm driver's
role in SMM environment setup is simplified to:
1. Utilize the gSmmBaseHobGuid to determine the SmBase.
2. Perform the ExecuteFirstSmiInit() to do early SMM
initialization.

Cc: Ray Ni <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Rahul Kumar <[email protected]>
Signed-off-by: Jiaxin Wu <[email protected]>
Reviewed-by: Ray Ni <[email protected]>


Compare: https://github.com/tianocore/edk2/compare/987bea6525d7...2727231b0a6f

To unsubscribe from these emails, change your notification settings at 
https://github.com/tianocore/edk2/settings/notifications


_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to