From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 9DDE221A18AAA for ; Mon, 27 Mar 2017 18:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490666088; x=1522202088; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version; bh=NqwRvDnUjQ/KyZAtIyoMxV0EWVu+erIPl4K8UbPMql8=; b=UPoPOpZiq5qEiLrkPv17KiqJ3mwOQJPgAxUcLq0CxOuQp6/JzWqK4g52 sTipraSZVCkBR/2cJo6YzrWp6UVmfw==; Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2017 18:54:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,234,1486454400"; d="scan'208,217";a="81675730" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga006.fm.intel.com with ESMTP; 27 Mar 2017 18:54:48 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 27 Mar 2017 18:54:48 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 27 Mar 2017 18:54:47 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.212]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.42]) with mapi id 14.03.0248.002; Tue, 28 Mar 2017 09:54:45 +0800 From: "Yao, Jiewen" To: "Yao, Jiewen" , "Duran, Leo" , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" , "Singh, Brijesh" Thread-Topic: [RFC] [PATCH 0/3] Add IOMMU support. Thread-Index: AQHSpzNqnOYLD0s+1UWqSZtZeyjIoqGpePFAgAACubA= Date: Tue, 28 Mar 2017 01:54:45 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503A914CA1@shsmsx102.ccr.corp.intel.com> References: <1490434122-16200-1-git-send-email-jiewen.yao@intel.com> <74D8A39837DF1E4DA445A8C0B3885C503A914BF3@shsmsx102.ccr.corp.intel.com> In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503A914BF3@shsmsx102.ccr.corp.intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 Subject: Re: [RFC] [PATCH 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: Tue, 28 Mar 2017 01:54:48 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I forget mentioning that I have to do it in PciIo instead of PciRootBridgeI= o. The reason is that Intel VTd solution need know which PCI device submit the= DMA access request, so that it can only modify the IOMMU paging for this s= pecific device. I believe AMD IOMMU has similar requirement. However, this info is not needed, if you just want to enable AMD SEV soluti= on. In that case, you can ignore the DeviceHandle, and just update SEV clea= r/set bit for that memory. BTW: I just realize I miss one thing. I call gIoMmuProtocol->SetAttribute, = after it is returned from PciRootBridgeIo. For AMD SEC, I think we need do CopyMem again, if this is DMA read request.= I will update my patch for that. Thank you Yao Jiewen From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yao,= Jiewen Sent: Tuesday, March 28, 2017 9:41 AM To: Duran, Leo ; edk2-devel@lists.01.org Cc: Ni, Ruiyu ; Singh, Brijesh Subject: Re: [edk2] [RFC] [PATCH 0/3] Add IOMMU support. Hi Leo I do intercept 4 I/O operation in *PciIo*, instead of *PciRootBridgeIo*. See: https://lists.01.org/pipermail/edk2-devel/2017-March/009021.html There are 4 gIoMmuProtocol->SetAttribute() I believe you can clear/set SEV = action there. Would you please double check that? Thank you Yao Jiewen From: Duran, Leo [mailto:leo.duran@amd.com] Sent: Tuesday, March 28, 2017 3:51 AM To: Yao, Jiewen >; edk2-d= evel@lists.01.org Cc: Ni, Ruiyu >; Singh, Brije= sh > Subject: RE: [RFC] [PATCH 0/3] Add IOMMU support. Hi Yao, This patch-set, in its current form, does not address all of the required S= EV functionality for PcIHostBridgeIo. Basically, we need to intercept all 4 I/O Operations: - IoMap() - IoUnmap() - IoAllocateBuffer() - IoFreeBuffer() SEV I/O intercepts would do this: 1) IoMap() - Allocate an accessible bounce buffer (AllocateType depends on consumer's = capabilities). - Clear SEV mask on retuned mapped DMA buffer - On DMA Read: CopyMem() from consumer buffer to mapped buffer (bounce oper= ation) 2) IoUnmap() - On DMA Write: CopyMem() from mapped buffer to consumer buffer (bounce ope= ration) - Restore SEV mask on mapped DMA buffer 3) IoAllocateBuffer() - Allocate an accessible buffer (AllocateType depends on consumer's capabil= ities). - Clear SEV mask on allocated buffer - return allocated buffer 4) IoFreeBuffer() - Restore SEV mask on allocated buffer - Free allocated buffer For an sample on how we've intercepted BmDmaLib operations, please refer to= the patch-sets posted by Brijesh: https://lists.01.org/pipermail/edk2-devel/2017-March/008838.html https://lists.01.org/pipermail/edk2-devel/2017-March/008840.html Thanks, Leo > -----Original Message----- > From: Jiewen Yao [mailto:jiewen.yao@intel.com] > Sent: Saturday, March 25, 2017 4:29 AM > To: edk2-devel@lists.01.org> > Cc: Ruiyu Ni >>; Duran, Leo >>; > Singh, Brijesh >> > Subject: [RFC] [PATCH 0/3] Add IOMMU support. > > This patch series adds IOMMU protocol and updates the consumer to > support IOMMU based DMA access in UEFI. > > 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(). > > 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(). > > This patch series does not provide a full Intel VTd driver, which will be > provide in other patch in the future. > > The purpose of this patch series to review if this IOMMU protocol design = can > meet all DMA access and management requirement. > > Cc: Ruiyu Ni >> > Cc: Leo Duran >> > Cc: Brijesh Singh >> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jiewen Yao >> > > > Jiewen Yao (3): > MdeModulePkg/Include: Add IOMMU protocol definition. > MdeModulePkg/PciHostBridge: Add IOMMU support. > MdeModulePkg/PciBus: Add IOMMU support. > > MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c | 12 ++ > MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h | 10 ++ > MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf | 1 + > MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c | 100 +++++++= +++++ > MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c | 3 + > MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf | 1 + > MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h | 7 + > MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c | 172 > +++++++++++++++++++- > MdeModulePkg/Include/Protocol/IoMmu.h | 132 > +++++++++++++++ > MdeModulePkg/MdeModulePkg.dec | 3 + > 10 files changed, 436 insertions(+), 5 deletions(-) create mode 100644 > MdeModulePkg/Include/Protocol/IoMmu.h > > -- > 2.7.4.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel