From: "Zeng, Star" <star.zeng@intel.com>
To: "Yao, Jiewen" <jiewen.yao@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH 3/3] IntelSiliconPkg/VTdPmrPei: Add EndOfPei callback for S3
Date: Fri, 22 Sep 2017 04:22:20 +0000 [thread overview]
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9788FC@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1506051885-21008-4-git-send-email-jiewen.yao@intel.com>
Is the code comment correct?
+ //
+ // Register EndOfPei Notify for S3 to run FSP NotifyPhase
+ //
Should the "VTdPrm" be "VTdPmr"?
If checking the bootmode in entrypoint, should add gEfiPeiMasterBootModePpiGuid in the depex or not?
Thanks,
Star
-----Original Message-----
From: Yao, Jiewen
Sent: Friday, September 22, 2017 11:45 AM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>
Subject: [PATCH 3/3] IntelSiliconPkg/VTdPmrPei: Add EndOfPei callback for S3
In S3 resume, before system transfer to waking vector,
the VTdPrm 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>
---
IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c | 59 +++++++++++++++++++-
IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.inf | 1 +
2 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c
index e768274..3fe6d65 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 86cd7d1..e1aa980 100644
--- a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.inf
+++ b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.inf
@@ -46,6 +46,7 @@
[Ppis]
gEdkiiIoMmuPpiGuid ## PRODUCES
gEdkiiVTdInfoPpiGuid ## CONSUMES
+ gEfiEndOfPeiSignalPpiGuid ## CONSUMES
[Pcd]
gIntelSiliconPkgTokenSpaceGuid.PcdVTdPolicyPropertyMask ## CONSUMES
--
2.7.4.windows.1
next prev parent reply other threads:[~2017-09-22 4:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-22 3:44 [PATCH 0/3] IntelVTd fix Jiewen Yao
2017-09-22 3:44 ` [PATCH 1/3] IntelSiliconPkg/VTdDxe: Clean up DXE flush memory Jiewen Yao
2017-09-22 3:44 ` [PATCH 2/3] IntelSiliconPkg/dec: Clarify VTdPolicy Jiewen Yao
2017-09-22 3:44 ` [PATCH 3/3] IntelSiliconPkg/VTdPmrPei: Add EndOfPei callback for S3 Jiewen Yao
2017-09-22 4:22 ` Zeng, Star [this message]
2017-09-22 4:42 ` Yao, Jiewen
2017-09-22 5:47 ` Zeng, Star
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=0C09AFA07DD0434D9E2A0C6AEB0483103B9788FC@shsmsx102.ccr.corp.intel.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