From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 C38B320945BFC for ; Fri, 8 Sep 2017 08:01:09 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Sep 2017 08:04:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,361,1500966000"; d="scan'208";a="309511549" Received: from jyao1-mobl.ccr.corp.intel.com ([10.254.209.82]) by fmsmga004.fm.intel.com with ESMTP; 08 Sep 2017 08:04:01 -0700 From: Jiewen Yao To: edk2-devel@lists.01.org Date: Fri, 8 Sep 2017 23:03:43 +0800 Message-Id: <1504883034-22060-1-git-send-email-jiewen.yao@intel.com> X-Mailer: git-send-email 2.7.4.windows.1 Subject: [PATCH 00/11] Add IOMMU PEI support. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Sep 2017 15:01:10 -0000 This series patch added IOMMU PEI support. It is also posted to https://github.com/jyao1/edk2/tree/IoMmuPpi. 1) Patch 1 and 2 add EDKII_IOMMU_PPI. It is similar to EDKII_IOMMU_PROTOCOL. 2) Patch 3 and 4 add Intel VTD PMR register support for DXE phase IntelVTdDxe. This is to prepare handle PMR usage in PEI phase. 3) Patch 5 and 6 add EDKII_VTD_INFO_PPI. This PPI is to provide Intel VTD information in PEI. In DXE, the VTd driver can get VTD info from ACPI DMAR table. But in PEI, there is no way to get VTD info before. VTD_INFO_PPI is added to resolve the problem. 4) Patch 7 and 8 add IntelVTdPmrPei driver. This driver consumes EDKII_VTD_INFO_PPI and produces IOMMU_PPI. It enables VTD PMR register to provide DMA protection. The PMR based DMA protection is a simple solution to mark 2 regions can be DMA protected. The IntelVTdPmrPei allocates a small chunk buffer for DMA and protect the rest memory. 5) Patch 9 and 10 add a sample VTdInfo PEI driver. It provides a sample to show how to report VTd info in PEI phase. 6) Patch 11 updates XhciPei driver to consume IOMMU_PPI. If the IOMMU_PPI is present, XhciPei will use IOMMU_PPI to allocate DMA buffer. Or the XhciPei will still use old way - PeiServiceAllocatePage to allocate DRAM as DMA buffer. This is the first PEI device driver consuming IOMMU_PPI to show the concept. The rest PEI device drivers will be updated in separated patches. This series patch is validated on Intel Kabylake Platform. 1) We can use XHCI to do file transfer in PEI phase, 2) We can still use XHCI in DXE phase, such as shell environment. 3) If the device driver does not consume IOMMU_PPI, the DMA fails. Jiewen Yao (11): MdeModulePkg/Include: Add IOMMU_PPI. MdeModulePkg/Dec: Add IOMMU_PPI GUID. IntelSiliconPkg/Vtd.h: Add definition for PMR. IntelSiliconPkg/VTdDxe: Disable PMR IntelSiliconPkg/include: Add VTD_INFO PPI. IntelSiliconPkg/dec: Add VTD_INFO PPI GUID IntelSiliconPkg: Add IntelVTdPmrPei. IntelSiliconPkg/dsc: Add IntelVTdPmrPeim. IntelSiliconPkg: Add PlatformVTdInfoSamplePei. IntelSiliconPkg/dsc: Add PlatformVTdInfoSamplePei. MdeModulePkg/XhciPei: Support IoMmu. IntelSiliconPkg/Include/IndustryStandard/Vtd.h | 6 + IntelSiliconPkg/Include/Ppi/VtdInfo.h | 40 ++ IntelSiliconPkg/IntelSiliconPkg.dec | 3 + IntelSiliconPkg/IntelSiliconPkg.dsc | 10 + IntelSiliconPkg/IntelVTdDxe/VtdReg.c | 51 +- IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmr.c | 314 ++++++++++ IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.c | 615 ++++++++++++++++++++ IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.h | 68 +++ IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.inf | 59 ++ IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.uni | 20 + IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPeiExtra.uni | 20 + IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.c | 65 +++ IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.inf | 51 ++ IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.uni | 20 + IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePeiExtra.uni | 20 + MdeModulePkg/Bus/Pci/XhciPei/DmaMem.c | 249 ++++++++ MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c | 55 +- MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.h | 9 +- MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.c | 55 +- MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.h | 107 ++++ MdeModulePkg/Bus/Pci/XhciPei/XhciPei.inf | 3 + MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c | 47 +- MdeModulePkg/Bus/Pci/XhciPei/XhciSched.h | 1 + MdeModulePkg/Include/Ppi/IoMmu.h | 196 +++++++ MdeModulePkg/MdeModulePkg.dec | 3 + 25 files changed, 2052 insertions(+), 35 deletions(-) create mode 100644 IntelSiliconPkg/Include/Ppi/VtdInfo.h create mode 100644 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmr.c create mode 100644 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.c create mode 100644 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.h create mode 100644 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.inf create mode 100644 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.uni create mode 100644 IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPeiExtra.uni create mode 100644 IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.c create mode 100644 IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.inf create mode 100644 IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.uni create mode 100644 IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePeiExtra.uni create mode 100644 MdeModulePkg/Bus/Pci/XhciPei/DmaMem.c create mode 100644 MdeModulePkg/Include/Ppi/IoMmu.h -- 2.7.4.windows.1