From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 F270921E1DADA for ; Wed, 2 Aug 2017 01:39:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 970F4539FA; Wed, 2 Aug 2017 08:41:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 970F4539FA Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-47.phx2.redhat.com [10.3.116.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6CFAD757A7; Wed, 2 Aug 2017 08:41:36 +0000 (UTC) To: Brijesh Singh , edk2-devel@lists.01.org Cc: Tom Lendacky , Jordan Justen , Ard Biesheuvel References: <1501529474-20550-1-git-send-email-brijesh.singh@amd.com> <1501529474-20550-3-git-send-email-brijesh.singh@amd.com> <89e1553a-1630-87a5-cffd-99174a380d41@redhat.com> From: Laszlo Ersek Message-ID: Date: Wed, 2 Aug 2017 10:41:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 02 Aug 2017 08:41:37 +0000 (UTC) Subject: Re: [PATCH v1 2/4] OvmfPkg: IommuDxe: Provide support for mapping BusMasterCommonBuffer operation 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, 02 Aug 2017 08:39:28 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 08/02/17 01:51, Brijesh Singh wrote: > On 8/1/17 4:59 PM, Laszlo Ersek wrote: >> Please implement the free-list idea that I outlined earlier. Unmap() >> must not call FreePool() on the MAP_INFO structures. > > Sorry it was my bad. I missed implementing that feedback. I will fix it > in next rev. As you have outlined in previous feedback that Unmap() can > be called from ExitBootService() hence i will refrain from using > FreePool() or MemEncryptSev*() functions in this sequence (except when > freeing the actual bounce buffer). No, you have to distinguish the C-bit's management and memory releasing. Unmap must restore the C bit on the bounce buffer, for all of BusMasterRead, BusMasterWrite, and BusMasterCommonBuffer. This is required regardless of whether the bounce buffer was allocated implicitly (for BusMasterRead and BusMasterWrite) or explicitly (for BusMasterCommonBuffer, in AllocateBuffer()). Unmap must zero and release the implicitly allocated bounce buffer for BusMasterRead, BusMasterWrite. Unmap must neither zero nor release the explicitly allocated buffer for BusMasterCommonBuffer. For that operation, FreeBuffer() must do both steps. Unmap must put MAP_INFO back on the internal free list for BusMasterCommonBuffer. For BusMasterRead and BusMasterWrite, Unmap can release MAP_INFO with FreePool(). Thanks Laszlo