From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web10.1876.1591055374297572877 for ; Mon, 01 Jun 2020 16:49:34 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: iwen.evelyn.wang@intel.com) IronPort-SDR: r70WP85xgzGWs2ZCQImFbHNfKfgo2c2Btt7FHnDuZOXUjLsXf3jNwpudSwgFpsX9Xa6bm922GV l0+ZmlhW2vpg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2020 16:49:33 -0700 IronPort-SDR: xlz+Y96kZTOG2dgDUMBvq/lyORQN2lCAUHDrkrLjjNu6O0XvO4VYomkynvqmZO0uXQnY15l+R4 x9xo7X5WosVA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,462,1583222400"; d="scan'208";a="347213748" Received: from iwenevel-dev01.amr.corp.intel.com ([10.9.70.66]) by orsmga001.jf.intel.com with ESMTP; 01 Jun 2020 16:49:33 -0700 From: "Evelyn Wang" To: devel@edk2.groups.io Cc: Jenny Huang , More Shih , Ray Ni , Rangasai V Chaganty , Jiewen Yao , W Sheng Subject: [PATCH] IntelSiliconPkg-Vtd: Set all IOMMU PMR to same range Date: Mon, 1 Jun 2020 16:49:25 -0700 Message-Id: <20200601234925.11108-1-iwen.evelyn.wang@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2775 Signed-off-by: Evelyn Wang Cc: Jenny Huang Cc: More Shih Cc: Ray Ni Cc: Rangasai V Chaganty Cc: Jiewen Yao Cc: W Sheng --- .../Feature/VTd/IntelVTdPmrPei/DmarTable.c | 38 +++++++++++++++------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/DmarTable.c b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/DmarTable.c index d920d136f1..fd64051032 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/DmarTable.c +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/DmarTable.c @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -13,7 +13,7 @@ #include #include #include - +#include #include "IntelVTdPmrPei.h" /** @@ -502,19 +502,17 @@ ProcessRmrr ( UINT64 RmrrMask; UINTN LowBottom; UINTN LowTop; - UINTN HighBottom; + UINT64 HighBottom; UINT64 HighTop; EFI_ACPI_DMAR_HEADER *AcpiDmarTable; + VTD_PMR_INFO_HOB *VtdPmrHob; + VOID *VtdPmrHobPtr; + VtdPmrHobPtr = GetFirstGuidHob (&gVtdPmrInfoDataHobGuid); AcpiDmarTable = VTdInfo->AcpiDmarTable; DEBUG ((DEBUG_INFO," RMRR (Base 0x%016lx, Limit 0x%016lx)\n", DmarRmrr->ReservedMemoryRegionBaseAddress, DmarRmrr->ReservedMemoryRegionLimitAddress)); - if ((DmarRmrr->ReservedMemoryRegionBaseAddress == 0) || - (DmarRmrr->ReservedMemoryRegionLimitAddress == 0)) { - return ; - } - DmarDevScopeEntry = (EFI_ACPI_DMAR_DEVICE_SCOPE_STRUCTURE_HEADER *)((UINTN)(DmarRmrr + 1)); while ((UINTN)DmarDevScopeEntry < (UINTN)DmarRmrr + DmarRmrr->Header.Length) { ASSERT (DmarDevScopeEntry->Type == EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_ENDPOINT); @@ -523,10 +521,26 @@ ProcessRmrr ( if (VTdIndex != (UINTN)-1) { RmrrMask = LShiftU64 (1, VTdIndex); - LowBottom = 0; - LowTop = (UINTN)DmarRmrr->ReservedMemoryRegionBaseAddress; - HighBottom = (UINTN)DmarRmrr->ReservedMemoryRegionLimitAddress + 1; - HighTop = LShiftU64 (1, VTdInfo->HostAddressWidth + 1); + if (VtdPmrHobPtr == NULL) { + LowBottom = 0; + LowTop = (UINTN)DmarRmrr->ReservedMemoryRegionBaseAddress; + HighBottom = DmarRmrr->ReservedMemoryRegionLimitAddress + 1; + HighTop = LShiftU64 (1, VTdInfo->HostAddressWidth + 1); + } else { + /** + When gVtdPmrInfoDataHobGuid exists, it means: + 1. Dma buffer is reserved by memory initialize code + 2. PeiGetVtdPmrAlignmentLib is used to get alignment + 3. PMR ranges are determined by the system memory map + 4. PMR ranges will be conveyed through VTD_PMR_INFO_HOB + 5. All IOMMU PMR should have the same ranges + **/ + VtdPmrHob = GET_GUID_HOB_DATA (VtdPmrHobPtr); + LowBottom = VtdPmrHob->ProtectedLowBase; + LowTop = VtdPmrHob->ProtectedLowLimit; + HighBottom = VtdPmrHob->ProtectedHighBase; + HighTop = VtdPmrHob->ProtectedHighLimit; + } SetDmaProtectedRange ( VTdInfo, -- 2.16.2.windows.1