summaryrefslogtreecommitdiffstats
path: root/IntelSiliconPkg
diff options
context:
space:
mode:
authorJiewen Yao <jiewen.yao@intel.com>2017-09-21 15:07:38 +0800
committerStar Zeng <star.zeng@intel.com>2018-05-10 14:23:34 +0800
commit1c8bdffe4f7297bad7a91678e0b486d64f6df505 (patch)
tree93c9912658d7b818e8ee5271058c6dee122b2b01 /IntelSiliconPkg
parent864f8a3217ea24f119cf89669f68818c5234c486 (diff)
downloadedk2-1c8bdffe4f7297bad7a91678e0b486d64f6df505.tar.gz
edk2-1c8bdffe4f7297bad7a91678e0b486d64f6df505.tar.bz2
edk2-1c8bdffe4f7297bad7a91678e0b486d64f6df505.zip
IntelSiliconPkg/VTdPmrPei: Add EndOfPei callback for S3
In S3 resume, before system transfer to waking vector, the VTdPmr need turn off VTd protection based upon VTdPolicy. Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> (cherry picked from commit fc8be1ad9ab310b1c7752985c982b66a5a377f1a)
Diffstat (limited to 'IntelSiliconPkg')
-rw-r--r--IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c59
-rw-r--r--IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.inf2
2 files changed, 59 insertions, 2 deletions
diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c
index e7682749a6..3fe6d654cd 100644
--- a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c
+++ b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c
@@ -24,16 +24,18 @@
#include <IndustryStandard/Vtd.h>
#include <Ppi/IoMmu.h>
#include <Ppi/VtdInfo.h>
+#include <Ppi/EndOfPeiPhase.h>
#include "IntelVTdPmrPei.h"
#define TOTAL_DMA_BUFFER_SIZE SIZE_4MB
+#define TOTAL_DMA_BUFFER_SIZE_S3 SIZE_1MB
EFI_ACPI_DMAR_HEADER *mAcpiDmarTable;
VTD_INFO *mVTdInfo;
UINT64 mEngineMask;
UINTN mDmaBufferBase;
-UINTN mDmaBufferSize = TOTAL_DMA_BUFFER_SIZE;
+UINTN mDmaBufferSize;
UINTN mDmaBufferCurrentTop;
UINTN mDmaBufferCurrentBottom;
@@ -544,6 +546,7 @@ InitDmaProtection (
}
ASSERT (DmaBufferSize == ALIGN_VALUE(DmaBufferSize, MemoryAlignment));
*DmaBufferBase = (UINTN)AllocateAlignedPages (EFI_SIZE_TO_PAGES(DmaBufferSize), MemoryAlignment);
+ ASSERT (*DmaBufferBase != 0);
if (*DmaBufferBase == 0) {
DEBUG ((DEBUG_INFO, " InitDmaProtection : OutOfResource\n"));
return EFI_OUT_OF_RESOURCES;
@@ -1105,6 +1108,41 @@ ParseDmarAcpiTableRmrr (
}
/**
+ This function handles S3 resume task at the end of PEI
+
+ @param[in] PeiServices Pointer to PEI Services Table.
+ @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
+ caused this function to execute.
+ @param[in] Ppi Pointer to the PPI data associated with this function.
+
+ @retval EFI_STATUS Always return EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+S3EndOfPeiNotify(
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
+ )
+{
+ UINT64 EngineMask;
+
+ DEBUG((DEBUG_INFO, "VTdPmr S3EndOfPeiNotify\n"));
+
+ if ((PcdGet8(PcdVTdPolicyPropertyMask) & BIT1) == 0) {
+ EngineMask = LShiftU64 (1, mVTdInfo->VTdEngineCount) - 1;
+ DisableDmaProtection (EngineMask);
+ }
+ return EFI_SUCCESS;
+}
+
+EFI_PEI_NOTIFY_DESCRIPTOR mS3EndOfPeiNotifyDesc = {
+ (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEfiEndOfPeiSignalPpiGuid,
+ S3EndOfPeiNotify
+};
+
+/**
Initializes the Intel VTd PMR PEIM.
@param FileHandle Handle of the file being invoked.
@@ -1122,11 +1160,14 @@ IntelVTdPmrInitialize (
)
{
EFI_STATUS Status;
+ EFI_BOOT_MODE BootMode;
if ((PcdGet8(PcdVTdPolicyPropertyMask) & BIT0) == 0) {
return EFI_UNSUPPORTED;
}
+ PeiServicesGetBootMode (&BootMode);
+
Status = PeiServicesLocatePpi (
&gEdkiiVTdInfoPpiGuid,
0,
@@ -1150,6 +1191,13 @@ IntelVTdPmrInitialize (
//
ParseDmarAcpiTableRmrr ();
+ if (BootMode == BOOT_ON_S3_RESUME) {
+ mDmaBufferSize = TOTAL_DMA_BUFFER_SIZE_S3;
+ } else {
+ mDmaBufferSize = TOTAL_DMA_BUFFER_SIZE;
+ }
+ DEBUG ((DEBUG_INFO, " DmaBufferSize : 0x%x\n", mDmaBufferSize));
+
//
// Find a pre-memory in resource hob as DMA buffer
// Mark PEI memory to be DMA protected.
@@ -1160,7 +1208,6 @@ IntelVTdPmrInitialize (
}
DEBUG ((DEBUG_INFO, " DmaBufferBase : 0x%x\n", mDmaBufferBase));
- DEBUG ((DEBUG_INFO, " DmaBufferSize : 0x%x\n", mDmaBufferSize));
mDmaBufferCurrentTop = mDmaBufferBase + mDmaBufferSize;
mDmaBufferCurrentBottom = mDmaBufferBase;
@@ -1171,6 +1218,14 @@ IntelVTdPmrInitialize (
Status = PeiServicesInstallPpi (&mIoMmuPpiList);
ASSERT_EFI_ERROR(Status);
+ //
+ // Register EndOfPei Notify for S3 to run FSP NotifyPhase
+ //
+ if (BootMode == BOOT_ON_S3_RESUME) {
+ Status = PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc);
+ ASSERT_EFI_ERROR (Status);
+ }
+
return Status;
}
diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.inf b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.inf
index 86cd7d1618..4d0e187dc3 100644
--- a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.inf
+++ b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.inf
@@ -46,12 +46,14 @@
[Ppis]
gEdkiiIoMmuPpiGuid ## PRODUCES
gEdkiiVTdInfoPpiGuid ## CONSUMES
+ gEfiEndOfPeiSignalPpiGuid ## CONSUMES
[Pcd]
gIntelSiliconPkgTokenSpaceGuid.PcdVTdPolicyPropertyMask ## CONSUMES
[Depex]
gEfiPeiMemoryDiscoveredPpiGuid AND
+ gEfiPeiMasterBootModePpiGuid AND
gEdkiiVTdInfoPpiGuid
[UserExtensions.TianoCore."ExtraFiles"]