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 A517321A04E11 for ; Thu, 11 May 2017 10:10:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 19012C04B94F; Thu, 11 May 2017 17:10:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 19012C04B94F Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 19012C04B94F Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-15.phx2.redhat.com [10.3.116.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16A3E18B53; Thu, 11 May 2017 17:10:00 +0000 (UTC) To: Brijesh Singh , edk2-devel@lists.01.org References: <1494454162-9940-1-git-send-email-brijesh.singh@amd.com> <1494454162-9940-13-git-send-email-brijesh.singh@amd.com> Cc: Thomas.Lendacky@amd.com, leo.duran@amd.com From: Laszlo Ersek Message-ID: Date: Thu, 11 May 2017 19:10:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1494454162-9940-13-git-send-email-brijesh.singh@amd.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 11 May 2017 17:10:02 +0000 (UTC) Subject: Re: [RFC v4 12/13] OvmfPkg/QemuFwCfgLib: Add option to dynamic alloc FW_CFG_DMA Access 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: Thu, 11 May 2017 17:10:02 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 05/11/17 00:09, Brijesh Singh wrote: > Update InternalQemuFwCfgDmaBytes() to work with DMA Access pointer. > The change provides the flexibility to dynamically allocate the "Access" > when SEV is enabled. > > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Brijesh Singh > --- > OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) Reviewed-by: Laszlo Ersek Thanks, Laszlo > diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c > index 1bf725d8b7ae..73a19772bee1 100644 > --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c > +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c > @@ -68,7 +68,8 @@ InternalQemuFwCfgDmaBytes ( > IN UINT32 Control > ) > { > - volatile FW_CFG_DMA_ACCESS Access; > + volatile FW_CFG_DMA_ACCESS LocalAccess; > + volatile FW_CFG_DMA_ACCESS *Access; > UINT32 AccessHigh, AccessLow; > UINT32 Status; > > @@ -79,9 +80,11 @@ InternalQemuFwCfgDmaBytes ( > return; > } > > - Access.Control = SwapBytes32 (Control); > - Access.Length = SwapBytes32 (Size); > - Access.Address = SwapBytes64 ((UINTN)Buffer); > + Access = &LocalAccess; > + > + Access->Control = SwapBytes32 (Control); > + Access->Length = SwapBytes32 (Size); > + Access->Address = SwapBytes64 ((UINTN)Buffer); > > // > // Delimit the transfer from (a) modifications to Access, (b) in case of a > @@ -92,8 +95,8 @@ InternalQemuFwCfgDmaBytes ( > // > // Start the transfer. > // > - AccessHigh = (UINT32)RShiftU64 ((UINTN)&Access, 32); > - AccessLow = (UINT32)(UINTN)&Access; > + AccessHigh = (UINT32)RShiftU64 ((UINTN)Access, 32); > + AccessLow = (UINT32)(UINTN)Access; > IoWrite32 (FW_CFG_IO_DMA_ADDRESS, SwapBytes32 (AccessHigh)); > IoWrite32 (FW_CFG_IO_DMA_ADDRESS + 4, SwapBytes32 (AccessLow)); > > @@ -106,7 +109,7 @@ InternalQemuFwCfgDmaBytes ( > // Wait for the transfer to complete. > // > do { > - Status = SwapBytes32 (Access.Control); > + Status = SwapBytes32 (Access->Control); > ASSERT ((Status & FW_CFG_DMA_CTL_ERROR) == 0); > } while (Status != 0); > >