public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v3 0/5] Enhanced SMM support for AMD-based x86 systems.
@ 2017-10-04 18:55 Leo Duran
  2017-10-04 18:55 ` [PATCH v3 1/5] UefiCpuPkg/UefiCpuPkg.dec: Create FixedPCDs for SMM support Leo Duran
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Leo Duran @ 2017-10-04 18:55 UTC (permalink / raw)
  To: edk2-devel

This patch-set introduces a couple of FixedPCDs to replace
Intel-specific macros, and better support AMD-based x86 systems.
    
1) PcdCpuSmmSmramSaveStateMapOffset - SMRAM Save State Map Offset.
2) PcdCpuSmmPSDOffset - Processor SMM Descriptor Offset in SMRAM.

OvmfPkg and QuarkSocPkg:

Changes since v2:
The intent of this revision is to maintain compatibility with existing
packages. To that end, changes to OvmgfPkg and QuarkSocPkg are reverted.
Moreover, pertinent macros are replaced in the C code, rather than on
header files that are shared globally.

Leo Duran (5):
  UefiCpuPkg/UefiCpuPkg.dec: Create FixedPCDs for SMM support
  UefiCpuPkg/PiSmmCpuDxeSmm: Consume FixedPCDs to enhance SMM support
  UefiCpuPkg/PiSmmCpuDxeSmm: Use FixedPCDs to enhance SMM support
  UefiCpuPkg/SmmCpuFeaturesLib: Consume FixedPCD to enhance SMM support
  UefiCpuPkg/SmmCpuFeaturesLib: Use FixedPCD on non-STM library

 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c      |  4 +++-
 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf    |  5 +++++
 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf |  5 +++++
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c                    |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S                     |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm                   |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm                  |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c                    | 10 +++++-----
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h                    |  2 --
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf                  |  4 ++++
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c            |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c                    |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c                     |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S                      |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm                    |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm                   |  4 +++-
 UefiCpuPkg/UefiCpuPkg.dec                                     |  9 +++++++++
 17 files changed, 61 insertions(+), 18 deletions(-)

-- 
2.7.4



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 1/5] UefiCpuPkg/UefiCpuPkg.dec: Create FixedPCDs for SMM support
  2017-10-04 18:55 [PATCH v3 0/5] Enhanced SMM support for AMD-based x86 systems Leo Duran
@ 2017-10-04 18:55 ` Leo Duran
  2017-10-04 18:55 ` [PATCH v3 2/5] UefiCpuPkg/PiSmmCpuDxeSmm: Consume FixedPCDs to enhance " Leo Duran
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Leo Duran @ 2017-10-04 18:55 UTC (permalink / raw)
  To: edk2-devel
  Cc: Leo Duran, Jiewen Yao, Ruiyu Ni, Michael D Kinney, Jordan Justen,
	Liming Gao

Introduce a couple of FixedPCDs to replace Intel-specific macros.
The new PCDs will allow SMM support on AMD-based x86 systems.

1) PcdCpuSmmSmramSaveStateMapOffset - SMRAM Save State Map Offset.
2) PcdCpuSmmPSDOffset - Processor SMM Descriptor Offset in SMRAM.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Leo Duran <leo.duran@amd.com>
---
 UefiCpuPkg/UefiCpuPkg.dec | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index 3bd8740..c92c56e 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 - 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
 #
 # This program and the accompanying materials are licensed and made available under
 # the terms and conditions of the BSD License which accompanies this distribution.
@@ -204,6 +205,14 @@
   # @Prompt If CPU features will be initialized during S3 resume.
   gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume|FALSE|BOOLEAN|0x0000001D
 
+  ## Specifies the Offset of SMRAM Save State Map from SMBASE.
+  # @Prompt SMRAM Save State Map Offset.
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSmramSaveStateMapOffset|0xFC00|UINT16|0x32132113
+
+  ## Specifies the PROCESSOR SMM DESCRIPTOR Offset in SMRAM.
+  # @Prompt SMRAM PSD Offset.
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmPSDOffset|0xFB00|UINT16|0x32132114
+
 [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
   ## Specifies max supported number of Logical Processors.
   # @Prompt Configure max supported number of Logical Processors
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 2/5] UefiCpuPkg/PiSmmCpuDxeSmm: Consume FixedPCDs to enhance SMM support
  2017-10-04 18:55 [PATCH v3 0/5] Enhanced SMM support for AMD-based x86 systems Leo Duran
  2017-10-04 18:55 ` [PATCH v3 1/5] UefiCpuPkg/UefiCpuPkg.dec: Create FixedPCDs for SMM support Leo Duran
@ 2017-10-04 18:55 ` Leo Duran
  2017-10-04 18:55 ` [PATCH v3 3/5] UefiCpuPkg/PiSmmCpuDxeSmm: Use " Leo Duran
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Leo Duran @ 2017-10-04 18:55 UTC (permalink / raw)
  To: edk2-devel
  Cc: Leo Duran, Jiewen Yao, Ruiyu Ni, Michael D Kinney, Jordan Justen,
	Liming Gao

Consume a couple of FixedPCDs to replace Intel-specific macros.
The new PCDs will allow SMM support on AMD-based x86 systems.

1) PcdCpuSmmSmramSaveStateMapOffset - SMRAM Save State Map Offset.
2) PcdCpuSmmPSDOffset - Processor SMM Descriptor Offset in SMRAM.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Leo Duran <leo.duran@amd.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
index 099792e..bf237f7 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
@@ -147,6 +147,10 @@
   gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileRingBuffer             ## CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmFeatureControlMsrLock         ## CONSUMES
 
+[FixedPcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSmramSaveStateMapOffset       ## CONSUMES
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmPSDOffset                     ## CONSUMES
+
 [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber        ## SOMETIMES_CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileSize                   ## SOMETIMES_CONSUMES
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 3/5] UefiCpuPkg/PiSmmCpuDxeSmm: Use FixedPCDs to enhance SMM support
  2017-10-04 18:55 [PATCH v3 0/5] Enhanced SMM support for AMD-based x86 systems Leo Duran
  2017-10-04 18:55 ` [PATCH v3 1/5] UefiCpuPkg/UefiCpuPkg.dec: Create FixedPCDs for SMM support Leo Duran
  2017-10-04 18:55 ` [PATCH v3 2/5] UefiCpuPkg/PiSmmCpuDxeSmm: Consume FixedPCDs to enhance " Leo Duran
@ 2017-10-04 18:55 ` Leo Duran
  2017-10-04 18:55 ` [PATCH v3 4/5] UefiCpuPkg/SmmCpuFeaturesLib: Consume FixedPCD " Leo Duran
  2017-10-04 18:55 ` [PATCH v3 5/5] UefiCpuPkg/SmmCpuFeaturesLib: Use FixedPCD on non-STM library Leo Duran
  4 siblings, 0 replies; 6+ messages in thread
From: Leo Duran @ 2017-10-04 18:55 UTC (permalink / raw)
  To: edk2-devel
  Cc: Leo Duran, Jiewen Yao, Ruiyu Ni, Michael D Kinney, Jordan Justen,
	Liming Gao

Consume a couple of FixedPCDs to replace Intel-specific macros.
The new PCDs will allow SMM support on AMD-based x86 systems.

1) PcdCpuSmmSmramSaveStateMapOffset - SMRAM Save State Map Offset.
2) PcdCpuSmmPSDOffset - Processor SMM Descriptor Offset in SMRAM.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Leo Duran <leo.duran@amd.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c         |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S          |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm        |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm       |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c         | 10 +++++-----
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h         |  2 --
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c         |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c          |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S           |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm         |  4 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm        |  4 +++-
 12 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c
index 02a866b..cc2624e 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Semaphore.c
@@ -3,6 +3,8 @@ Semaphore mechanism to indicate to the BSP that an AP has exited SMM
 after SMBASE relocation.
 
 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -38,7 +40,7 @@ SemaphoreHook (
 
   mRebasedFlag = RebasedFlag;
 
-  CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);
+  CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + FixedPcdGet16 (PcdCpuSmmSmramSaveStateMapOffset));
   mSmmRelocationOriginalAddress = (UINTN)HookReturnFromSmm (
                                            CpuIndex,
                                            CpuState,
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
index 3243a91..25af6e7 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
@@ -1,6 +1,8 @@
 #------------------------------------------------------------------------------
 #
 # Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+#
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
 # which accompanies this distribution.  The full text of the license may be found at
@@ -35,7 +37,7 @@ ASM_GLOBAL  ASM_PFX(gSmiHandlerIdtr)
 #
 # Constants relating to PROCESSOR_SMM_DESCRIPTOR
 #
-.equ            DSC_OFFSET, 0xfb00
+.equ            DSC_OFFSET, (FixedPcdGet16 (PcdCpuSmmPSDOffset))
 .equ            DSC_GDTPTR, 0x30
 .equ            DSC_GDTSIZ, 0x38
 .equ            DSC_CS, 14
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
index 8296f36..f526778 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
@@ -1,5 +1,7 @@
 ;------------------------------------------------------------------------------ ;
 ; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+;
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD License
 ; which accompanies this distribution.  The full text of the license may be found at
@@ -29,7 +31,7 @@ MSR_EFER_XD   EQU     0800h
 ;
 ; Constants relating to PROCESSOR_SMM_DESCRIPTOR
 ;
-DSC_OFFSET    EQU     0fb00h
+DSC_OFFSET    EQU     (FixedPcdGet16 (PcdCpuSmmPSDOffset))
 DSC_GDTPTR    EQU     30h
 DSC_GDTSIZ    EQU     38h
 DSC_CS        EQU     14
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm
index 4d2383f..9092dcc 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm
@@ -1,5 +1,7 @@
 ;------------------------------------------------------------------------------ ;
 ; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+;
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD License
 ; which accompanies this distribution.  The full text of the license may be found at
@@ -25,7 +27,7 @@
 ;
 ; Constants relating to PROCESSOR_SMM_DESCRIPTOR
 ;
-%define DSC_OFFSET 0xfb00
+%define DSC_OFFSET (FixedPcdGet16 (PcdCpuSmmPSDOffset))
 %define DSC_GDTPTR 0x30
 %define DSC_GDTSIZ 0x38
 %define DSC_CS 14
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
index 282d2e6..b2a941e 100755
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
@@ -407,7 +407,7 @@ SmmRelocateBases (
   gcSmiInitGdtr.Limit = gcSmiGdtr.Limit;
 
   U8Ptr = (UINT8*)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET);
-  CpuStatePtr = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);
+  CpuStatePtr = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + FixedPcdGet16 (PcdCpuSmmSmramSaveStateMapOffset));
 
   //
   // Backup original contents at address 0x38000
@@ -707,12 +707,12 @@ PiCpuSmmEntry (
 
   //
   // Compute tile size of buffer required to hold the CPU SMRAM Save State Map, extra CPU
-  // specific context start starts at SMBASE + SMM_PSD_OFFSET, and the SMI entry point.
+  // specific context start starts at SMBASE + PcdCpuSmmPSDOffset, and the SMI entry point.
   // This size is rounded up to nearest power of 2.
   //
   TileCodeSize = GetSmiHandlerSize ();
   TileCodeSize = ALIGN_VALUE(TileCodeSize, SIZE_4KB);
-  TileDataSize = (SMRAM_SAVE_STATE_MAP_OFFSET - SMM_PSD_OFFSET) + sizeof (SMRAM_SAVE_STATE_MAP);
+  TileDataSize = (FixedPcdGet16 (PcdCpuSmmSmramSaveStateMapOffset) - FixedPcdGet16 (PcdCpuSmmPSDOffset)) + sizeof (SMRAM_SAVE_STATE_MAP);
   TileDataSize = ALIGN_VALUE(TileDataSize, SIZE_4KB);
   TileSize = TileDataSize + TileCodeSize - 1;
   TileSize = 2 * GetPowerOfTwo32 ((UINT32)TileSize);
@@ -725,7 +725,7 @@ PiCpuSmmEntry (
   // the SMI Handler size must be reduced or the size of the extra CPU specific
   // context must be reduced.
   //
-  ASSERT (TileSize <= (SMRAM_SAVE_STATE_MAP_OFFSET + sizeof (SMRAM_SAVE_STATE_MAP) - SMM_HANDLER_OFFSET));
+  ASSERT (TileSize <= (FixedPcdGet16 (PcdCpuSmmSmramSaveStateMapOffset) + sizeof (SMRAM_SAVE_STATE_MAP) - SMM_HANDLER_OFFSET));
 
   //
   // Allocate buffer for all of the tiles.
@@ -783,7 +783,7 @@ PiCpuSmmEntry (
   for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
     mCpuHotPlugData.SmBase[Index]          = (UINTN)Buffer + Index * TileSize - SMM_HANDLER_OFFSET;
     gSmmCpuPrivate->CpuSaveStateSize[Index] = sizeof(SMRAM_SAVE_STATE_MAP);
-    gSmmCpuPrivate->CpuSaveState[Index]     = (VOID *)(mCpuHotPlugData.SmBase[Index] + SMRAM_SAVE_STATE_MAP_OFFSET);
+    gSmmCpuPrivate->CpuSaveState[Index]     = (VOID *)(mCpuHotPlugData.SmBase[Index] + FixedPcdGet16 (PcdCpuSmmSmramSaveStateMapOffset));
     gSmmCpuPrivate->Operation[Index] = SmmCpuNone;
 
     if (Index < mNumberOfCpus) {
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index 1cf85c1..31e4f53 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -360,8 +360,6 @@ typedef struct {
   UINT32       MsrIndex;
 } MP_MSR_LOCK;
 
-#define SMM_PSD_OFFSET              0xfb00
-
 ///
 /// All global semaphores' pointer
 ///
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
index 3ad5256..147b694 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
@@ -1,6 +1,8 @@
 /** @file
 
 Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -703,7 +705,7 @@ PatchSmmSaveStateMap (
 
   TileCodeSize = GetSmiHandlerSize ();
   TileCodeSize = ALIGN_VALUE(TileCodeSize, SIZE_4KB);
-  TileDataSize = (SMRAM_SAVE_STATE_MAP_OFFSET - SMM_PSD_OFFSET) + sizeof (SMRAM_SAVE_STATE_MAP);
+  TileDataSize = (FixedPcdGet16 (PcdCpuSmmSmramSaveStateMapOffset) - FixedPcdGet16 (PcdCpuSmmPSDOffset)) + sizeof (SMRAM_SAVE_STATE_MAP);
   TileDataSize = ALIGN_VALUE(TileDataSize, SIZE_4KB);
   TileSize = TileDataSize + TileCodeSize - 1;
   TileSize = 2 * GetPowerOfTwo32 ((UINT32)TileSize);
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c
index 3188d43..d59b9a0 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c
@@ -2,6 +2,8 @@
 Provides services to access SMRAM Save State Map
 
 Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -690,7 +692,7 @@ InstallSmiHandler (
   //
   // Initialize PROCESSOR_SMM_DESCRIPTOR
   //
-  Psd = (PROCESSOR_SMM_DESCRIPTOR *)(VOID *)((UINTN)SmBase + SMM_PSD_OFFSET);
+  Psd = (PROCESSOR_SMM_DESCRIPTOR *)(VOID *)((UINTN)SmBase + FixedPcdGet16 (PcdCpuSmmPSDOffset));
   CopyMem (Psd, &gcPsd, sizeof (gcPsd));
   Psd->SmmGdtPtr = (UINT64)GdtBase;
   Psd->SmmGdtSize = (UINT32)GdtSize;
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c
index 6dbcb08..e74bb69 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c
@@ -3,6 +3,8 @@ Semaphore mechanism to indicate to the BSP that an AP has exited SMM
 after SMBASE relocation.
 
 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -51,7 +53,7 @@ SemaphoreHook (
   mRebasedFlag       = RebasedFlag;
   mRebasedFlagAddr32 = (UINT32)(UINTN)mRebasedFlag;
 
-  CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);
+  CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + FixedPcdGet16 (PcdCpuSmmSmramSaveStateMapOffset));
   mSmmRelocationOriginalAddress = HookReturnFromSmm (
                                     CpuIndex,
                                     CpuState,
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
index 600d862..ebea477 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
@@ -1,6 +1,8 @@
 #------------------------------------------------------------------------------
 #
 # Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+#
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
 # which accompanies this distribution.  The full text of the license may be found at
@@ -34,7 +36,7 @@ ASM_GLOBAL  ASM_PFX(gSmiHandlerIdtr)
 #
 # Constants relating to PROCESSOR_SMM_DESCRIPTOR
 #
-.equ            DSC_OFFSET, 0xfb00
+.equ            DSC_OFFSET, (FixedPcdGet16 (PcdCpuSmmPSDOffset))
 .equ            DSC_GDTPTR, 0x30
 .equ            DSC_GDTSIZ, 0x38
 .equ            DSC_CS, 14
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
index c74f82a..ff46838 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
@@ -1,5 +1,7 @@
 ;------------------------------------------------------------------------------ ;
 ; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+;
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD License
 ; which accompanies this distribution.  The full text of the license may be found at
@@ -39,7 +41,7 @@ MSR_EFER_XD   EQU     0800h
 ;
 ; Constants relating to PROCESSOR_SMM_DESCRIPTOR
 ;
-DSC_OFFSET    EQU     0fb00h
+DSC_OFFSET    EQU     (FixedPcdGet16 (PcdCpuSmmPSDOffset))
 DSC_GDTPTR    EQU     30h
 DSC_GDTSIZ    EQU     38h
 DSC_CS        EQU     14
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm
index c3c094f..f55da9b 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm
@@ -1,5 +1,7 @@
 ;------------------------------------------------------------------------------ ;
 ; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+;
 ; This program and the accompanying materials
 ; are licensed and made available under the terms and conditions of the BSD License
 ; which accompanies this distribution.  The full text of the license may be found at
@@ -29,7 +31,7 @@
 ;
 ; Constants relating to PROCESSOR_SMM_DESCRIPTOR
 ;
-%define DSC_OFFSET 0xfb00
+%define DSC_OFFSET (FixedPcdGet16 (PcdCpuSmmPSDOffset))
 %define DSC_GDTPTR 0x30
 %define DSC_GDTSIZ 0x38
 %define DSC_CS 14
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 4/5] UefiCpuPkg/SmmCpuFeaturesLib: Consume FixedPCD to enhance SMM support
  2017-10-04 18:55 [PATCH v3 0/5] Enhanced SMM support for AMD-based x86 systems Leo Duran
                   ` (2 preceding siblings ...)
  2017-10-04 18:55 ` [PATCH v3 3/5] UefiCpuPkg/PiSmmCpuDxeSmm: Use " Leo Duran
@ 2017-10-04 18:55 ` Leo Duran
  2017-10-04 18:55 ` [PATCH v3 5/5] UefiCpuPkg/SmmCpuFeaturesLib: Use FixedPCD on non-STM library Leo Duran
  4 siblings, 0 replies; 6+ messages in thread
From: Leo Duran @ 2017-10-04 18:55 UTC (permalink / raw)
  To: edk2-devel
  Cc: Leo Duran, Jiewen Yao, Ruiyu Ni, Michael D Kinney, Jordan Justen,
	Liming Gao

Consume a FixedPCD to replace Intel-specific macro.
The new PCD will allow SMM support on AMD-based x86 systems.

PcdCpuSmmSmramSaveStateMapOffset - SMRAM Save State Map Offset.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Leo Duran <leo.duran@amd.com>
---
 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf    | 5 +++++
 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
index 77908b0..1be2671 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
@@ -2,6 +2,8 @@
 #  The CPU specific programming for PiSmmCpuDxeSmm module.
 #
 #  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+#
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
@@ -36,5 +38,8 @@
   MemoryAllocationLib
   DebugLib
 
+[FixedPcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSmramSaveStateMapOffset       ## CONSUMES
+
 [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber        ## SOMETIMES_CONSUMES
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
index db8dcdc..a91e9ed 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
@@ -3,6 +3,8 @@
 #  is included.
 #
 #  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+#
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
@@ -78,6 +80,9 @@
   gEfiAcpi20TableGuid                      ## SOMETIMES_CONSUMES ## SystemTable
   gEfiAcpi10TableGuid                      ## SOMETIMES_CONSUMES ## SystemTable
 
+[FixedPcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSmramSaveStateMapOffset       ## CONSUMES
+
 [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber        ## SOMETIMES_CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuMsegSize                         ## SOMETIMES_CONSUMES
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 5/5] UefiCpuPkg/SmmCpuFeaturesLib: Use FixedPCD on non-STM library
  2017-10-04 18:55 [PATCH v3 0/5] Enhanced SMM support for AMD-based x86 systems Leo Duran
                   ` (3 preceding siblings ...)
  2017-10-04 18:55 ` [PATCH v3 4/5] UefiCpuPkg/SmmCpuFeaturesLib: Consume FixedPCD " Leo Duran
@ 2017-10-04 18:55 ` Leo Duran
  4 siblings, 0 replies; 6+ messages in thread
From: Leo Duran @ 2017-10-04 18:55 UTC (permalink / raw)
  To: edk2-devel
  Cc: Leo Duran, Jiewen Yao, Ruiyu Ni, Michael D Kinney, Jordan Justen,
	Liming Gao

Consume a FixedPCD to replace Intel-specific macro.
The new PCD will allow SMM support on AMD-based x86 systems.

PcdCpuSmmSmramSaveStateMapOffset - SMRAM Save State Map Offset.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Leo Duran <leo.duran@amd.com>
---
 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
index 2d2bc6d..88f43b4 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
@@ -2,6 +2,8 @@
 The CPU specific programming for PiSmmCpuDxeSmm module.
 
 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -224,7 +226,7 @@ SmmCpuFeaturesInitializeProcessor (
   //
   // Configure SMBASE.
   //
-  CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);
+  CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + FixedPcdGet16 (PcdCpuSmmSmramSaveStateMapOffset));
   CpuState->x86.SMBASE = (UINT32)CpuHotPlugData->SmBase[CpuIndex];
 
   //
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-10-04 18:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-04 18:55 [PATCH v3 0/5] Enhanced SMM support for AMD-based x86 systems Leo Duran
2017-10-04 18:55 ` [PATCH v3 1/5] UefiCpuPkg/UefiCpuPkg.dec: Create FixedPCDs for SMM support Leo Duran
2017-10-04 18:55 ` [PATCH v3 2/5] UefiCpuPkg/PiSmmCpuDxeSmm: Consume FixedPCDs to enhance " Leo Duran
2017-10-04 18:55 ` [PATCH v3 3/5] UefiCpuPkg/PiSmmCpuDxeSmm: Use " Leo Duran
2017-10-04 18:55 ` [PATCH v3 4/5] UefiCpuPkg/SmmCpuFeaturesLib: Consume FixedPCD " Leo Duran
2017-10-04 18:55 ` [PATCH v3 5/5] UefiCpuPkg/SmmCpuFeaturesLib: Use FixedPCD on non-STM library Leo Duran

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox