IntelSiliconPkg VTdDxe: Option to force no early access attr request

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1272

To have high confidence in usage for platform, add option (BIT2 of
PcdVTdPolicyPropertyMask) to force no IOMMU access attribute request
recording before DMAR table is installed.

Check PcdVTdPolicyPropertyMask BIT2 before RequestAccessAttribute()
and ProcessRequestedAccessAttribute(), then RequestAccessAttribute(),
ProcessRequestedAccessAttribute() and mAccessRequestXXX variables
could be optimized by compiler when PcdVTdPolicyPropertyMask BIT2 = 1.

Test done:
1: Created case that has IOMMU access attribute request before DMAR
   table is installed, ASSERT was triggered after setting
   PcdVTdPolicyPropertyMask BIT2 to 1.

2. Confirmed RequestAccessAttribute(), ProcessRequestedAccessAttribute()
   and mAccessRequestXXX variables were optimized by compiler after
   setting PcdVTdPolicyPropertyMask BIT2 to 1.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
Star Zeng 2018-10-17 17:43:28 +08:00
parent 0bc7448ad2
commit 8c09f30010
3 changed files with 15 additions and 1 deletions

View File

@ -515,7 +515,13 @@ SetupVtd (
ParseDmarAcpiTableRmrr (); ParseDmarAcpiTableRmrr ();
ProcessRequestedAccessAttribute (); if ((PcdGet8 (PcdVTdPolicyPropertyMask) & BIT2) == 0) {
//
// Support IOMMU access attribute request recording before DMAR table is installed.
// Here is to process the requests.
//
ProcessRequestedAccessAttribute ();
}
for (Index = 0; Index < mVtdUnitNumber; Index++) { for (Index = 0; Index < mVtdUnitNumber; Index++) {
DEBUG ((DEBUG_INFO,"VTD Unit %d (Segment: %04x)\n", Index, mVtdUnitInformation[Index].Segment)); DEBUG ((DEBUG_INFO,"VTD Unit %d (Segment: %04x)\n", Index, mVtdUnitInformation[Index].Segment));

View File

@ -254,6 +254,13 @@ VTdSetAttribute (
// Record the entry to driver global variable. // Record the entry to driver global variable.
// As such once VTd is activated, the setting can be adopted. // As such once VTd is activated, the setting can be adopted.
// //
if ((PcdGet8 (PcdVTdPolicyPropertyMask) & BIT2) != 0) {
//
// Force no IOMMU access attribute request recording before DMAR table is installed.
//
ASSERT_EFI_ERROR (EFI_NOT_READY);
return EFI_NOT_READY;
}
Status = RequestAccessAttribute (Segment, SourceId, DeviceAddress, Length, IoMmuAccess); Status = RequestAccessAttribute (Segment, SourceId, DeviceAddress, Length, IoMmuAccess);
} else { } else {
PERF_CODE ( PERF_CODE (

View File

@ -58,6 +58,7 @@
## The mask is used to control VTd behavior.<BR><BR> ## The mask is used to control VTd behavior.<BR><BR>
# BIT0: Enable IOMMU during boot (If DMAR table is installed in DXE. If VTD_INFO_PPI is installed in PEI.) # BIT0: Enable IOMMU during boot (If DMAR table is installed in DXE. If VTD_INFO_PPI is installed in PEI.)
# BIT1: Enable IOMMU when transfer control to OS (ExitBootService in normal boot. EndOfPEI in S3) # BIT1: Enable IOMMU when transfer control to OS (ExitBootService in normal boot. EndOfPEI in S3)
# BIT2: Force no IOMMU access attribute request recording before DMAR table is installed.
# @Prompt The policy for VTd driver behavior. # @Prompt The policy for VTd driver behavior.
gIntelSiliconPkgTokenSpaceGuid.PcdVTdPolicyPropertyMask|1|UINT8|0x00000002 gIntelSiliconPkgTokenSpaceGuid.PcdVTdPolicyPropertyMask|1|UINT8|0x00000002