From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0609.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe45::609]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A93CB21A134B8 for ; Sat, 13 May 2017 12:28:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=QUZ42zAfSEc+gcu60d2So9W8klZcCyhe3Aa3Q2OgPwY=; b=5XVm2gdwqzEMJ0RxJimerPh8Hs4SoGMRSO/QNkftXMmAF/gPjCZpIGxyfwQ9bviMrvmHj5g1LQMUpcD/4mtkXwr48hdekmt/3/vWuLUyifX8WD5vvk/muKUYmH5U3JAXRlmrmAz6q25LA8EYB4ncYoFRHpgITmAkyT1yo5Zlewk= Received: from DM5PR12MB1243.namprd12.prod.outlook.com (10.168.237.22) by BY2PR12MB0146.namprd12.prod.outlook.com (10.162.82.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1084.16; Sat, 13 May 2017 19:27:59 +0000 Received: from DM5PR12MB1243.namprd12.prod.outlook.com ([10.168.237.22]) by DM5PR12MB1243.namprd12.prod.outlook.com ([10.168.237.22]) with mapi id 15.01.1084.025; Sat, 13 May 2017 19:27:57 +0000 From: "Duran, Leo" To: Jiewen Yao , "edk2-devel@lists.01.org" CC: Ruiyu Ni , "Singh, Brijesh" , Ard Biesheuvel Thread-Topic: [PATCH V5 0/3] Add IOMMU support. Thread-Index: AQHSxPRFdNEGY2ewY02uvCoTT/Upv6Hys/pg Date: Sat, 13 May 2017 19:27:57 +0000 Message-ID: References: <1493915561-8500-1-git-send-email-jiewen.yao@intel.com> In-Reply-To: <1493915561-8500-1-git-send-email-jiewen.yao@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=amd.com; x-originating-ip: [2605:6000:e7cd:8500:2c64:8fff:33f3:884b] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BY2PR12MB0146; 7:I7020A34vEhVfAzt5YeKo4MK2Y79FHXEqRlUmXL/q/d3V6EVzvNvIbhjlBWwReyP3pk7xuQAx4+rbNPu65/AEbJqhoS8Y7/qSUfR1BlGF6aALiqUM5HhJjwU+wgMtI/2JX5r+33yAZyO+XDt3rRd7/PzCqFpYjoaw3kqbDttJ44FU0Ka201/ZTPtLcNCigCyWjnu+dLKdYT2FYqzZIqU21OoLz905xNY2uXFNzXtmUDoZ6kmjcyDJyRtPWB0+mLqj6U/w0631s3fyR0fdMlzJWAoBLxVioWBONuahiSS7MB5aeK4WOOBCW4nSSx7wXonlzCOlP+0en1wAcgUu23qdQ==; 20:9CTuqizIL+Wdn24P2U1pzozKI/YDg056JiHFY99keSqbw1Iy0n8MSzdD55IZwpA5+pOqzZsDemFj0oWXgq0wMr8behZqV+ETGQu28EoDf8wviKD2l+eE+WY4A3m46whup1X6ucMAGhJDL21cf5RXzf3FzIp/Kz6khjr+f7GwymxMLUcJnLMXzoVTuoxBCoptmqrjYAn9kAki+KsnuKW9SLWJKhBx4fJLK43/gkGXJ6jRniyB9YExTkzLBiG0qXHf x-forefront-antispam-report: SFV:SKI; SCL:-1SFV:NSPM; SFS:(10009020)(6009001)(39400400002)(39850400002)(39450400003)(39840400002)(39410400002)(13464003)(377454003)(33656002)(189998001)(478600001)(122556002)(6306002)(8936002)(9686003)(54906002)(8676002)(55016002)(81166006)(99286003)(53546009)(25786009)(6506006)(6436002)(54356999)(76176999)(50986999)(2950100002)(7696004)(86362001)(305945005)(77096006)(2501003)(2900100001)(229853002)(5660300001)(4326008)(38730400002)(3280700002)(7736002)(53936002)(102836003)(6116002)(2906002)(3660700001)(74316002)(6246003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0146; H:DM5PR12MB1243.namprd12.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; x-ms-office365-filtering-correlation-id: f68798af-7f14-4285-439d-08d49a362923 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081)(201702281549075); SRVR:BY2PR12MB0146; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(166708455590820)(767451399110)(162533806227266)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123560025)(20161123558100)(20161123555025)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148); SRVR:BY2PR12MB0146; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0146; x-forefront-prvs: 0306EE2ED4 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-originalarrivaltime: 13 May 2017 19:27:57.2989 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0146 Subject: Re: [PATCH V5 0/3] Add IOMMU 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: Sat, 13 May 2017 19:28:02 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Leo Duran Thanks, Leo. > -----Original Message----- > From: Jiewen Yao [mailto:jiewen.yao@intel.com] > Sent: Thursday, May 04, 2017 11:33 AM > To: edk2-devel@lists.01.org > Cc: Ruiyu Ni ; Duran, Leo ; > Singh, Brijesh ; Ard Biesheuvel > > Subject: [PATCH V5 0/3] Add IOMMU support. >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D V5 =3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D > Minor update from V4. >=20 > 1) Remove unused SetAttribute() API in IOMMU protocol. > (Feedback from Ruiyu and Ard) > 2) Rename SetMappingAttribute() to SetAttribute(). > (Feedback from Ruiyu) > 3) Fix the bug in PciBus driver for Operation (Thanks to Ard to catch it) >=20 > V4: > Tested-by: Brijesh Singh With the issue in 3/3 > addressed: > Tested-by: Ard Biesheuvel >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D V4 =3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D > Refine the EDKII_IOMMU_PROTOCOL. >=20 > 1) Add AllocateBuffer/FreeBuffer/Map/Unmap() API. > They are similar to DmaLib in EmbeddedPkg and similar to the previous > BmDmaLib (by leo.duran@amd.com). >=20 > These APIs are invoked by PciHostBridge driver to allocate DMA memory. >=20 > The PciHostBridge driver (IOMMU consumer) is simplified: > It uses IOMMU, if IOMMU protocol is present. > Else it uses original logic. >=20 > 2) Add SetMappingAttribute() API. > It is similar to SetAttribute() API in V1. >=20 > This API is invoked by PciBus driver to set DMA access attribute (read/wr= ite) > for device. >=20 > The PciBus driver (IOMMU consumer) is simplified: > It sets access attribute in Map/Unmap, > if IOMMU protocol is present. >=20 > 3) Remove SetRemapAddress/GetRemapAddress() API. > Because PciHostBridge/PciBus can call the APIs defined above, there is no > need to provide remap capability. >=20 > -- Sample producer drivers: > 1) The sample VTd driver (IOMMU producer) is at > https://github.com/jyao1/edk2/tree/dma_v4/IntelSiliconPkg/IntelVTdDxe >=20 > It is added to show the concept. It is not fully implemented yet. > It will not be checked in in this patch. >=20 > 2) The sample AMD SEV driver (IOMMU producer) is at > https://github.com/jyao1/edk2/tree/dma_v4/IntelSiliconPkg/SampleAmdSe > vDxe > (code is borrowed from leo.duran@amd.com and brijesh.singh@amd.com) >=20 > This is not a right place to put this driver. >=20 > It is added to show the concept. > It is not fully implemented. It will not be checked in. > Please do not use it directly. >=20 > 3) The sample STYX driver (IOMMU producer) is at > https://github.com/jyao1/edk2/tree/dma_v4/IntelSiliconPkg/SampleStyxDx > e > (code is borrowed from ard.biesheuvel@linaro.org) >=20 > This is not a right place to put this driver. >=20 > It is added to show the concept. > It is not fully implemented. It will not be checked in. > Please do not use it directly. >=20 >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D V3 =3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D > 1) Add Remap capability (from Ard Biesheuvel) Add > EDKII_IOMMU_REMAP_ADDRESS API in IOMMU_PROTOCOL. >=20 > NOTE: The code is not fully validated yet. > The purpose is to collect feedback to decide the next step. >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D V2 =3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D > 1) Enhance Unmap() in PciIo (From Ruiyu Ni) Maintain a local list of MapI= nfo > and match it in Unmap. >=20 > 2) CopyMem for ReadOperation in PciIo after SetAttribute (Leo Duran) Fix = a > bug in V1 that copy mem for read happen before SetAttribute, which will > break AMD SEV solution. >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D V1 =3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D >=20 > This patch series adds IOMMU protocol and updates the consumer to > support IOMMU based DMA access in UEFI. >=20 > This patch series can support the BmDmaLib request for AMD SEV. > submitted by Duran, Leo and Brijesh Singh > . > https://lists.01.org/pipermail/edk2-devel/2017-March/008109.html, and > https://lists.01.org/pipermail/edk2-devel/2017-March/008820.html. > We can have an AMD SEV specific IOMMU driver to produce IOMMU > protocol, and clear SEV in IOMMU->SetAttribute(). >=20 > This patch series can also support Intel VTd based DMA protection, > requested by Jiewen Yao , discussed in > https://lists.01.org/pipermail/edk2-devel/2017-March/008157.html. > We can have an Intel VTd specific IOMMU driver to produce IOMMU > protocol, and update VTd engine to grant or deny access in IOMMU- > >SetAttribute(). >=20 > This patch series does not provide a full Intel VTd driver, which will be > provide in other patch in the future. >=20 > The purpose of this patch series to review if this IOMMU protocol design = can > meet all DMA access and management requirement. >=20 > Cc: Ruiyu Ni > Cc: Leo Duran > Cc: Brijesh Singh > Cc: Ard Biesheuvel > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jiewen Yao >=20 > Jiewen Yao (3): > MdeModulePkg/Include: Add IOMMU protocol definition. > MdeModulePkg/PciHostBridge: Add IOMMU support. > MdeModulePkg/PciBus: Add IOMMU support. >=20 > MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c | 9 + > MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h | 1 + > MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf | 1 + > MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c | 47 +++- > MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c | 37 +++ > MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf | 2 + > MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h | 2 + > MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c | 61 +++++ > MdeModulePkg/Include/Protocol/IoMmu.h | 259 > ++++++++++++++++++++ > MdeModulePkg/MdeModulePkg.dec | 3 + > 10 files changed, 418 insertions(+), 4 deletions(-) create mode 100644 > MdeModulePkg/Include/Protocol/IoMmu.h >=20 > -- > 2.7.4.windows.1