From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 A35BF20945C1C for ; Fri, 8 Sep 2017 00:26:16 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Sep 2017 00:29:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,360,1500966000"; d="scan'208";a="309387411" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga004.fm.intel.com with ESMTP; 08 Sep 2017 00:29:08 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 8 Sep 2017 00:29:08 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 8 Sep 2017 00:29:07 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.39]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.219]) with mapi id 14.03.0319.002; Fri, 8 Sep 2017 15:29:06 +0800 From: "Zeng, Star" To: Laszlo Ersek , edk2-devel-01 CC: Ard Biesheuvel , Brijesh Singh , "Dong, Eric" , "Yao, Jiewen" , "Justen, Jordan L" , "Zeng, Star" Thread-Topic: [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at ExitBootServices Thread-Index: AQHTKCpw/10DR9lo5UqtGiYznIlniKKqj1eg Date: Fri, 8 Sep 2017 07:29:05 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B93EC08@shsmsx102.ccr.corp.intel.com> References: <20170907224116.895-1-lersek@redhat.com> In-Reply-To: <20170907224116.895-1-lersek@redhat.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 Subject: Re: [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at ExitBootServices 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 07:26:16 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng to MdeModulePkg changes. -----Original Message----- From: Laszlo Ersek [mailto:lersek@redhat.com]=20 Sent: Friday, September 8, 2017 6:41 AM To: edk2-devel-01 Cc: Ard Biesheuvel ; Brijesh Singh ; Dong, Eric ; Yao, Jiewen ; Justen, Jordan L ; Zeng, Star Subject: [PATCH 00/10] MdeModulePkg, OvmfPkg: unmap DMA buffers at ExitBoot= Services Repo: https://github.com/lersek/edk2.git Branch: iommu_exit_boot This series is the result of the discussion under [edk2] [PATCH 0/4] MdeModulePkg: some PCI HC drivers: unmap common buffers at ExitBootServices() https://lists.01.org/pipermail/edk2-devel/2017-September/014099.html At ExitBootServices(), PCI and VirtIo drivers should only care about aborti= ng pending DMA on the devices. Cleaning up PciIo mappings (which ultimately= boil down to IOMMU mappings) for those aborted DMA operations should be th= e job of the IOMMU driver. Patches 01 through 03 clean up the AtaAtapiPassThru driver in MdeModulePkg = a little bit, because at present, (a) it unmaps the buffers and disables BM= DMA in the wrong order in its DriverBindingStop() function, (b) it doesn't = abort pending DMA at ExitBootServices(). This subset can be treated separately from the rest of the series, but I th= ought they belonged loosely together (given that AtaAtapiPassThru is used o= n QEMU's Q35 machine type). Patches 04 through 07 remove VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer() calls from the VirtIo drivers' ExitBootServices() handlers. (The conversion of VirtioNetDxe to device addresses is still in progress -- Brijesh, when you submit v2 of that, under this approach, there is no ne= ed to change VirtioNetExitBoot() relative to current upstream, and you can = use VirtioOperationBusMasterRead to map outgoing packets.) Patches 08 through 10 make OvmfPkg/IoMmuDxe track all mappings, and unmap a= ll mappings (Read, Write, CommonBuffer) that are in effect when ExitBootServices() is called. It is ensured that PCI and VirtIo drivers abo= rt pending DMA first, and IoMmuDxe clean up the mappings last. Cc: Ard Biesheuvel Cc: Brijesh Singh Cc: Eric Dong Cc: Jiewen Yao Cc: Jordan Justen Cc: Star Zeng Thanks Laszlo Laszlo Ersek (10): MdeModulePkg/AtaAtapiPassThru: cache EnabledPciAttributes MdeModulePkg/AtaAtapiPassThru: unmap DMA buffers after disabling BM DMA MdeModulePkg/AtaAtapiPassThru: disable the device at ExitBootServices() OvmfPkg/VirtioBlkDxe: don't unmap VRING at ExitBootServices() OvmfPkg/VirtioGpuDxe: don't unmap VRING & BackingStore at ExitBootServices OvmfPkg/VirtioRngDxe: don't unmap VRING at ExitBootServices() OvmfPkg/VirtioScsiDxe: don't unmap VRING at ExitBootServices() OvmfPkg/IoMmuDxe: track all mappings OvmfPkg/IoMmuDxe: generalize IoMmuUnmap() to IoMmuUnmapWorker() OvmfPkg/IoMmuDxe: unmap all IOMMU mappings at ExitBootServices() MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 103 +++++--- MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h | 7 + OvmfPkg/IoMmuDxe/AmdSevIoMmu.c | 246 +++++++++++= ++++++--- OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 7 +- OvmfPkg/VirtioGpuDxe/Commands.c | 23 +- OvmfPkg/VirtioRngDxe/VirtioRng.c | 7 +- OvmfPkg/VirtioScsiDxe/VirtioScsi.c | 7 +- 7 files changed, 299 insertions(+), 101 deletions(-) -- 2.14.1.3.gb7cf6e02401b