From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0610.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe49::610]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CAF3C21A134BB for ; Wed, 3 May 2017 07:11:39 -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=U25IEZL3aEBohTMTlXYJo7B7gCsJhP1eh1OPHHyy9qc=; b=SO5i6cGo3eLDH2+gnMfwfEmLd/ukCPknAxoHT/oGTY5wv0jjgluU0tKAqQMlMPK6PIrPIYZbiUaa57FMffauKxZe6KVegveWRg7wsD7Z5C70drI0F3DFyXtqS6gRHcrlo0TrjaIGdgjoLoLfLWWvz3J7mpHDgk7QAzVeUxMJBeM= Received: from DM5PR12MB1243.namprd12.prod.outlook.com (10.168.237.22) by SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1061.12; Wed, 3 May 2017 14:11:37 +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.1061.021; Wed, 3 May 2017 14:11:36 +0000 From: "Duran, Leo" To: "'Yao, Jiewen'" , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" , "Singh, Brijesh" , Ard Biesheuvel Thread-Topic: [RFC] [PATCH V4 0/3] Add IOMMU support. Thread-Index: AQHSwO/C7MxdwjPBX0OTPcF/W8YHhaHhYzaAgAB1TgCAANOxYA== Date: Wed, 3 May 2017 14:11:36 +0000 Message-ID: References: <1493473882-7336-1-git-send-email-jiewen.yao@intel.com> <74D8A39837DF1E4DA445A8C0B3885C503A936E0B@shsmsx102.ccr.corp.intel.com> In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503A936E0B@shsmsx102.ccr.corp.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: [165.204.77.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; SN1PR12MB0158; 7:DjwfoaI+cJLO3XV9hMEB0+npgllo4dXr/nLdrMUZAFoGCyvFrP82v9pSI+vQiYo+PRndI5P9kHog5uAJlqsI4hqMXKYcZPdN72zPRmoQfOqLIi9ZKTG/p1GynAxvkA7oyw6+jWj+3vPpu+aA+KUgdSlXK4g5iTrI9E+QkyNmaPFX0e9oXNGSlvWxxSp11nKXsheEw7i6rTuylgRPCBNgaiGIvwk1v49gslp2UshWdUhmhbh1tYjf1V/dcsNWHwpgk7xC7eoxRl6bLZkFqKN5EkmCpsqtrtLTN2zReBi4son5T5KsW8yWfDPnTffKD+1ytFruWugsq8WQOo3873dzIg==; 20:GMpbHeQymy7/ztBxvpZuHAJhRzY3l8SZGcoyW0ezKExWT+e6hhHf957Eh+2oJfsQexeA2OvQcF4ou+IVIRI6A9AbzflcVqKJkDNcD/X9M0/gBIZo8GOoCH8Auf6F4bJa5U8bZ7J7rXKjsyVoA2ZH5jUoJqzgzzlTJzwJjsSuuVQeXa1YVH5QmsNjsA9QnGErl7LB6bil4H8HFbMR6OY7nKGQF8E9eUfq+v3HVqJ4iZ1UKJ7G+qS7o3F8ivD/nMWR x-forefront-antispam-report: SFV:SKI; SCL:-1SFV:NSPM; SFS:(10009020)(39400400002)(39850400002)(39840400002)(39450400003)(39860400002)(13464003)(377454003)(76176999)(50986999)(2906002)(33656002)(122556002)(3660700001)(3280700002)(229853002)(4326008)(86362001)(102836003)(54356999)(9326002)(3846002)(7696004)(25786009)(8676002)(7906003)(81166006)(2950100002)(6506006)(790700001)(6116002)(74316002)(77096006)(8936002)(2501003)(6246003)(55016002)(66066001)(189998001)(9686003)(6306002)(236005)(5660300001)(38730400002)(54896002)(6436002)(53936002)(54906002)(99286003)(478600001)(7736002)(606005); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0158; H:DM5PR12MB1243.namprd12.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; x-ms-office365-filtering-correlation-id: 233350c7-a595-4415-9b34-08d4922e4f87 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081); SRVR:SN1PR12MB0158; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(166708455590820)(767451399110)(162533806227266)(21748063052155)(228905959029699)(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123558100)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(6072148); SRVR:SN1PR12MB0158; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0158; x-forefront-prvs: 029651C7A1 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-originalarrivaltime: 03 May 2017 14:11:36.4929 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0158 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 Subject: Re: [RFC] [PATCH V4 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: Wed, 03 May 2017 14:11:40 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Yao, We're OK so far (as noted below). Leo From: Yao, Jiewen [mailto:jiewen.yao@intel.com] Sent: Tuesday, May 02, 2017 8:33 PM To: Duran, Leo ; edk2-devel@lists.01.org Cc: Ni, Ruiyu ; Singh, Brijesh ;= Ard Biesheuvel Subject: RE: [RFC] [PATCH V4 0/3] Add IOMMU support. It is a good question. I did consider that before. In our scenario, we need support VTd dynamic opt-in/opt-out. I hope to keep= all these logic inside of VTd driver. If we need a default path-through driver, a platform need more complex logi= c to decide when to run the default pass-through and when to run the real V= Td driver. It is a burden. I think we do use optional protocols in PciBus driver (such as EFI_INCOMPAT= IBLE_PCI_DEVICE_SUPPORT_PROTOCOL, EFI_PCI_PLATFORM_PROTOCOL, EFI_PCI_OVERRI= DE_PROTOCOL) In V4, I am using protocol notification for PciHostBridge, so that we do no= t need locate IOMMU protocol at each function call. Do you run into any issue on using protocol notification? [Duran, Leo] Nope, no issues found as of yet. Thank you Yao Jiewen From: Duran, Leo [mailto:leo.duran@amd.com] Sent: Wednesday, May 3, 2017 2:42 AM To: Yao, Jiewen >; edk2-d= evel@lists.01.org Cc: Ni, Ruiyu >; Singh, Brije= sh >; Ard Biesheuvel > Subject: RE: [RFC] [PATCH V4 0/3] Add IOMMU support. Hi Yao, Would it make sense to have a default protocol producer driver that provide= s pass-thru functionality? This way consumers of the protocol may add a dependency on it, ensuring tha= t the protocol provider always run first. (In the SEV sample driver we run first because we added the driver to the A= PRIORI list, but it seems like a Depex would be more elegant) Leo. > -----Original Message----- > From: Jiewen Yao [mailto:jiewen.yao@intel.com] > Sent: Saturday, April 29, 2017 8:51 AM > To: edk2-devel@lists.01.org > Cc: Ruiyu Ni >; Duran, Leo = >; > Singh, Brijesh >; Ard= Biesheuvel > > > Subject: [RFC] [PATCH V4 0/3] Add IOMMU support. > > =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. > > 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). > > These APIs are invoked by PciHostBridge driver to allocate DMA memory. > > The PciHostBridge driver (IOMMU consumer) is simplified: > It uses IOMMU, if IOMMU protocol is present. > Else it uses original logic. > > 2) Add SetMappingAttribute() API. > It is similar to SetAttribute() API in V1. > > This API is invoked by PciBus driver to set DMA access attribute (read/wr= ite) > for device. > > The PciBus driver (IOMMU consumer) is simplified: > It sets access attribute in Map/Unmap, > if IOMMU protocol is present. > > 3) Remove SetRemapAddress/GetRemapAddress() API. > Because PciHostBridge/PciBus can call the APIs defined above, there is no > need to provide remap capability. > > -- Sample producer drivers: > 1) The sample VTd driver (IOMMU producer) is at > https://github.com/jyao1/edk2/tree/dma_v4/IntelSiliconPkg/IntelVTdDxe > > It is added to show the concept. It is not fully implemented yet. > It will not be checked in in this patch. > > 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 br= ijesh.singh@amd.com) > > This is not a right place to put this driver. > > It is added to show the concept. > It is not fully implemented. It will not be checked in. > Please do not use it directly. > > 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) > > This is not a right place to put this driver. > > It is added to show the concept. > It is not fully implemented. It will not be checked in. > Please do not use it directly. > > > =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. > > NOTE: The code is not fully validated yet. > The purpose is to collect feedback to decide the next step. > > =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. > > 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. > > =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 > > 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 > > Cc: Ard Biesheuvel > > 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 | 9 + > MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h | 1 + > MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf | 1 + > MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c | 37 +++ > 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 | 310 > ++++++++++++++++++++ > MdeModulePkg/MdeModulePkg.dec | 3 + > 10 files changed, 463 insertions(+) > create mode 100644 MdeModulePkg/Include/Protocol/IoMmu.h > > -- > 2.7.4.windows.1