From nobody Mon Dec 23 12:57:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516168785363210.37524186508233; Tue, 16 Jan 2018 21:59:45 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 87AFD2232BE12; Tue, 16 Jan 2018 21:54:23 -0800 (PST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 345E42232BE0A for ; Tue, 16 Jan 2018 21:54:21 -0800 (PST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2018 21:59:41 -0800 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by fmsmga005.fm.intel.com with ESMTP; 16 Jan 2018 21:59:40 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,371,1511856000"; d="scan'208";a="196177891" From: Star Zeng To: edk2-devel@lists.01.org Date: Wed, 17 Jan 2018 13:59:38 +0800 Message-Id: <1516168778-16308-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [edk2] [PATCH] IntelSiliconPkg IntelVTdPmrPei: Get high top by host address width X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Get high top by host address width instead of resource HOB. Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng Reviewed-by: Jiewen.yao@intel.com --- .../Feature/VTd/IntelVTdPmrPei/DmarTable.c | 4 +- .../Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c | 167 +----------------= ---- .../Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.h | 12 +- 3 files changed, 5 insertions(+), 178 deletions(-) diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/DmarTable.c b/Intel= SiliconPkg/Feature/VTd/IntelVTdPmrPei/DmarTable.c index 891efa65468d..ea853bd6bc70 100644 --- a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/DmarTable.c +++ b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/DmarTable.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -528,7 +528,7 @@ ProcessRmrr ( LowBottom =3D 0; LowTop =3D (UINTN)DmarRmrr->ReservedMemoryRegionBaseAddress; HighBottom =3D (UINTN)DmarRmrr->ReservedMemoryRegionLimitAddress + 1; - HighTop =3D GetTopMemory (); + HighTop =3D LShiftU64 (1, VTdInfo->HostAddressWidth + 1); =20 SetDmaProtectedRange ( VTdInfo, diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c b/= IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c index bb7ace4ca557..63ba94d62b7e 100644 --- a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c +++ b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c @@ -60,7 +60,7 @@ typedef struct { =20 PEI Memory Layout: =20 - +------------------+ <=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D PHMR.Limit (+ alignment) (Top of memory) + +------------------+ <=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D PHMR.Limit (+ alignment) (1 << (HostAddressWidth + 1)) | Mem Resource | | | =20 @@ -377,159 +377,6 @@ CONST EFI_PEI_PPI_DESCRIPTOR mIoMmuPpiList =3D { (VOID *) &mIoMmuPpi }; =20 -#define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT | \ - EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \ - EFI_RESOURCE_ATTRIBUTE_TESTED | \ - EFI_RESOURCE_ATTRIBUTE_16_BIT_IO | \ - EFI_RESOURCE_ATTRIBUTE_32_BIT_IO | \ - EFI_RESOURCE_ATTRIBUTE_64_BIT_IO \ - ) - -#define TESTED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | EF= I_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_TESTED) - -#define INITIALIZED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | EF= I_RESOURCE_ATTRIBUTE_INITIALIZED) - -#define PRESENT_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT) - -GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *mResourceTypeShortName[] =3D { - "Mem", - "MMIO", - "I/O", - "FD", - "MM Port I/O", - "Reserved Mem", - "Reserved I/O", -}; - -/** - Return the short name of resource type. - - @param Type resource type. - - @return the short name of resource type. -**/ -CHAR8 * -ShortNameOfResourceType ( - IN UINT32 Type - ) -{ - if (Type < sizeof(mResourceTypeShortName) / sizeof(mResourceTypeShortNam= e[0])) { - return mResourceTypeShortName[Type]; - } else { - return "Unknown"; - } -} - -/** - Dump resource hob. - - @param HobList the HOB list. -**/ -VOID -DumpResourceHob ( - IN VOID *HobList - ) -{ - EFI_PEI_HOB_POINTERS Hob; - EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob; - - DEBUG ((DEBUG_VERBOSE, "Resource Descriptor HOBs\n")); - for (Hob.Raw =3D HobList; !END_OF_HOB_LIST (Hob); Hob.Raw =3D GET_NEXT_H= OB (Hob)) { - if (GET_HOB_TYPE (Hob) =3D=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { - ResourceHob =3D Hob.ResourceDescriptor; - DEBUG ((DEBUG_VERBOSE, - " BA=3D%016lx L=3D%016lx Attr=3D%08x ", - ResourceHob->PhysicalStart, - ResourceHob->ResourceLength, - ResourceHob->ResourceAttribute - )); - DEBUG ((DEBUG_VERBOSE, ShortNameOfResourceType(ResourceHob->Resource= Type))); - switch (ResourceHob->ResourceType) { - case EFI_RESOURCE_SYSTEM_MEMORY: - if ((ResourceHob->ResourceAttribute & EFI_RESOURCE_ATTRIBUTE_PERSI= STENT) !=3D 0) { - DEBUG ((DEBUG_VERBOSE, " (Persistent)")); - } else if ((ResourceHob->ResourceAttribute & EFI_RESOURCE_ATTRIBUT= E_MORE_RELIABLE) !=3D 0) { - DEBUG ((DEBUG_VERBOSE, " (MoreReliable)")); - } else if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK= ) =3D=3D TESTED_MEMORY_ATTRIBUTES) { - DEBUG ((DEBUG_VERBOSE, " (Tested)")); - } else if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK= ) =3D=3D INITIALIZED_MEMORY_ATTRIBUTES) { - DEBUG ((DEBUG_VERBOSE, " (Init)")); - } else if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK= ) =3D=3D PRESENT_MEMORY_ATTRIBUTES) { - DEBUG ((DEBUG_VERBOSE, " (Present)")); - } else { - DEBUG ((DEBUG_VERBOSE, " (Unknown)")); - } - break; - default: - break; - } - DEBUG ((DEBUG_VERBOSE, "\n")); - } - } -} - -/** - Dump PHIT hob. - - @param HobList the HOB list. -**/ -VOID -DumpPhitHob ( - IN VOID *HobList - ) -{ - EFI_HOB_HANDOFF_INFO_TABLE *PhitHob; - - PhitHob =3D HobList; - ASSERT(GET_HOB_TYPE(HobList) =3D=3D EFI_HOB_TYPE_HANDOFF); - DEBUG ((DEBUG_VERBOSE, "PHIT HOB\n")); - DEBUG ((DEBUG_VERBOSE, " PhitHob - 0x%x\n", PhitHob)); - DEBUG ((DEBUG_VERBOSE, " BootMode - 0x%x\n", PhitHob->BootMo= de)); - DEBUG ((DEBUG_VERBOSE, " EfiMemoryTop - 0x%016lx\n", PhitHob->Ef= iMemoryTop)); - DEBUG ((DEBUG_VERBOSE, " EfiMemoryBottom - 0x%016lx\n", PhitHob->Ef= iMemoryBottom)); - DEBUG ((DEBUG_VERBOSE, " EfiFreeMemoryTop - 0x%016lx\n", PhitHob->Ef= iFreeMemoryTop)); - DEBUG ((DEBUG_VERBOSE, " EfiFreeMemoryBottom - 0x%016lx\n", PhitHob->Ef= iFreeMemoryBottom)); - DEBUG ((DEBUG_VERBOSE, " EfiEndOfHobList - 0x%lx\n", PhitHob->EfiEn= dOfHobList)); -} - -/** - Get the highest memory. - - @return the highest memory. -**/ -UINT64 -GetTopMemory ( - VOID - ) -{ - VOID *HobList; - EFI_PEI_HOB_POINTERS Hob; - EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob; - UINT64 TopMemory; - UINT64 ResourceTop; - - HobList =3D GetHobList (); - - TopMemory =3D 0; - for (Hob.Raw =3D HobList; !END_OF_HOB_LIST (Hob); Hob.Raw =3D GET_NEXT_H= OB (Hob)) { - if (GET_HOB_TYPE (Hob) =3D=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { - ResourceHob =3D Hob.ResourceDescriptor; - switch (ResourceHob->ResourceType) { - case EFI_RESOURCE_SYSTEM_MEMORY: - ResourceTop =3D ResourceHob->PhysicalStart + ResourceHob->Resource= Length; - if (TopMemory < ResourceTop) { - TopMemory =3D ResourceTop; - } - break; - default: - break; - } - DEBUG ((DEBUG_VERBOSE, "\n")); - } - } - return TopMemory; -} - /** Initialize DMA protection. =20 @@ -548,8 +395,6 @@ InitDmaProtection ( ) { EFI_STATUS Status; - VOID *HobList; - EFI_HOB_HANDOFF_INFO_TABLE *PhitHob; UINT32 LowMemoryAlignment; UINT64 HighMemoryAlignment; UINTN MemoryAlignment; @@ -558,14 +403,6 @@ InitDmaProtection ( UINTN HighBottom; UINT64 HighTop; =20 - HobList =3D GetHobList (); - DumpPhitHob (HobList); - DumpResourceHob (HobList); - - PhitHob =3D HobList; - - ASSERT (PhitHob->EfiMemoryBottom < PhitHob->EfiMemoryTop); - LowMemoryAlignment =3D GetLowMemoryAlignment (VTdInfo, VTdInfo->EngineMa= sk); HighMemoryAlignment =3D GetHighMemoryAlignment (VTdInfo, VTdInfo->Engine= Mask); if (LowMemoryAlignment < HighMemoryAlignment) { @@ -584,7 +421,7 @@ InitDmaProtection ( LowBottom =3D 0; LowTop =3D *DmaBufferBase; HighBottom =3D *DmaBufferBase + DmaBufferSize; - HighTop =3D GetTopMemory (); + HighTop =3D LShiftU64 (1, VTdInfo->HostAddressWidth + 1); =20 Status =3D SetDmaProtectedRange ( VTdInfo, diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.h b/= IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.h index 499119d3ff19..c53f69cb3465 100644 --- a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.h +++ b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.h @@ -1,7 +1,7 @@ /** @file The definition for DMA access Library. =20 - Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -159,16 +159,6 @@ DumpAcpiDMAR ( IN EFI_ACPI_DMAR_HEADER *Dmar ); =20 -/** - Get the highest memory. - - @return the highest memory. -**/ -UINT64 -GetTopMemory ( - VOID - ); - extern EFI_GUID mVTdInfoGuid; =20 #endif --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel