]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: fix issue in wakeup buffer initialization
authorJian J Wang <jian.j.wang@intel.com>
Wed, 24 Jan 2018 01:36:01 +0000 (09:36 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Thu, 25 Jan 2018 02:24:21 +0000 (10:24 +0800)
To fix an issue in which enabling NX feature will mark the AP wakeup
buffer as non-executable and fail the AP init, the buffer was split
into two part: the lower part in memory within 1MB and the higher part
within allocated executable memory (EfiBootServicesCode). But the
address of higher part memory was stored in lower part memory, which
is actually shared with legacy components and will be overwritten by
LegacyBiosDxe driver if CSM is enabled.

This patch fixes this issue by storing the address of higher part
memory in CpuMpData instead of ExchangeInfo.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
UefiCpuPkg/Library/MpInitLib/MpLib.c
UefiCpuPkg/Library/MpInitLib/MpLib.h

index 6231968c7483249caf270faf5418a1573b209136..42011d6231a234613f31524fb5383608fb5511da 100644 (file)
@@ -823,19 +823,20 @@ FillExchangeInfoData (
   // Copy all 32-bit code and 64-bit code into memory with type of\r
   // EfiBootServicesCode to avoid page fault if NX memory protection is enabled.\r
   //\r
-  if (ExchangeInfo->ModeTransitionMemory != 0) {\r
+  if (CpuMpData->WakeupBufferHigh != 0) {\r
     Size = CpuMpData->AddressMap.RendezvousFunnelSize -\r
            CpuMpData->AddressMap.ModeTransitionOffset;\r
     CopyMem (\r
-      (VOID *)(UINTN)ExchangeInfo->ModeTransitionMemory,\r
+      (VOID *)CpuMpData->WakeupBufferHigh,\r
       CpuMpData->AddressMap.RendezvousFunnelAddress +\r
       CpuMpData->AddressMap.ModeTransitionOffset,\r
       Size\r
       );\r
 \r
-    ExchangeInfo->ModeHighMemory = ExchangeInfo->ModeTransitionMemory;\r
-    ExchangeInfo->ModeHighMemory += (UINT32)ExchangeInfo->ModeOffset -\r
-               (UINT32)CpuMpData->AddressMap.ModeTransitionOffset;\r
+    ExchangeInfo->ModeTransitionMemory = (UINT32)CpuMpData->WakeupBufferHigh;\r
+    ExchangeInfo->ModeHighMemory = (UINT32)CpuMpData->WakeupBufferHigh +\r
+                                   (UINT32)ExchangeInfo->ModeOffset -\r
+                                   (UINT32)CpuMpData->AddressMap.ModeTransitionOffset;\r
     ExchangeInfo->ModeHighSegment = (UINT16)ExchangeInfo->CodeSegment;\r
   } else {\r
     ExchangeInfo->ModeTransitionMemory = (UINT32)\r
@@ -916,11 +917,10 @@ AllocateResetVector (
     CpuMpData->WakeupBuffer      = GetWakeupBuffer (ApResetVectorSize);\r
     CpuMpData->MpCpuExchangeInfo = (MP_CPU_EXCHANGE_INFO *) (UINTN)\r
                     (CpuMpData->WakeupBuffer + CpuMpData->AddressMap.RendezvousFunnelSize);\r
-    CpuMpData->MpCpuExchangeInfo->ModeTransitionMemory = (UINT32)\r
-                    GetModeTransitionBuffer (\r
-                      CpuMpData->AddressMap.RendezvousFunnelSize -\r
-                      CpuMpData->AddressMap.ModeTransitionOffset\r
-                      );\r
+    CpuMpData->WakeupBufferHigh  = GetModeTransitionBuffer (\r
+                                    CpuMpData->AddressMap.RendezvousFunnelSize -\r
+                                    CpuMpData->AddressMap.ModeTransitionOffset\r
+                                    );\r
   }\r
   BackupAndPrepareWakeupBuffer (CpuMpData);\r
 }\r
index 0232fe896ab553621282d84c7fc3d0b2b274e65b..e7f9a4de0aa0b14054acd9613d44332166a7c57f 100644 (file)
@@ -208,6 +208,7 @@ struct _CPU_MP_DATA {
   UINTN                          CpuApStackSize;\r
   MP_ASSEMBLY_ADDRESS_MAP        AddressMap;\r
   UINTN                          WakeupBuffer;\r
+  UINTN                          WakeupBufferHigh;\r
   UINTN                          BackupBuffer;\r
   UINTN                          BackupBufferSize;\r
 \r