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 BD33021A16E49 for ; Thu, 11 May 2017 09:38:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 05A8481127; Thu, 11 May 2017 16:38:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 05A8481127 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=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 05A8481127 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 7BBD217B80; Thu, 11 May 2017 16:38:23 +0000 (UTC) To: Brijesh Singh , edk2-devel@lists.01.org References: <1494454162-9940-1-git-send-email-brijesh.singh@amd.com> <1494454162-9940-11-git-send-email-brijesh.singh@amd.com> Cc: Thomas.Lendacky@amd.com, leo.duran@amd.com, Jordan Justen From: Laszlo Ersek Message-ID: Date: Thu, 11 May 2017 18:38:22 +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-11-git-send-email-brijesh.singh@amd.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 May 2017 16:38:25 +0000 (UTC) Subject: Re: [RFC v4 10/13] OvmfPkg/QemuFwCfgLib: Implement SEV internal functions for PEI phase 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 16:38:26 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 05/11/17 00:09, Brijesh Singh wrote: > Cc: Jordan Justen > Cc: Laszlo Ersek > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Brijesh Singh > --- > OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf | 1 + > OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c | 72 +++++++++++++++++++- > 2 files changed, 71 insertions(+), 2 deletions(-) Reviewed-by: Laszlo Ersek Thanks, Laszlo > diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf > index 4f966a85088a..b97b475c7cad 100644 > --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf > +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf > @@ -47,4 +47,5 @@ [LibraryClasses] > DebugLib > IoLib > MemoryAllocationLib > + MemEncryptSevLib > > diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c > index ac05f4c347f3..1696512bccaf 100644 > --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c > +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c > @@ -4,6 +4,7 @@ > > Copyright (C) 2013, Red Hat, Inc. > Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.
> + Copyright (c) 2017, Advanced Micro Devices. All rights reserved.
> > This program and the accompanying materials are licensed and made available > under the terms and conditions of the BSD License which accompanies this > @@ -14,8 +15,10 @@ > WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > **/ > > +#include > #include > #include > +#include > > #include "QemuFwCfgLibInternal.h" > > @@ -76,8 +79,18 @@ QemuFwCfgInitialize ( > if ((Revision & FW_CFG_F_DMA) == 0) { > DEBUG ((DEBUG_INFO, "QemuFwCfg interface (IO Port) is supported.\n")); > } else { > - mQemuFwCfgDmaSupported = TRUE; > - DEBUG ((DEBUG_INFO, "QemuFwCfg interface (DMA) is supported.\n")); > + // > + // If SEV is enabled then we do not support DMA operations in PEI phase. > + // This is mainly because DMA in SEV guest requires using bounce buffer > + // (which need to allocate dynamic memory and allocating a PAGE size'd > + // buffer can be challenge in PEI phase) > + // > + if (InternalQemuFwCfgSevIsEnabled ()) { > + DEBUG ((DEBUG_INFO, "SEV: QemuFwCfg fallback to IO Port interface.\n")); > + } else { > + mQemuFwCfgDmaSupported = TRUE; > + DEBUG ((DEBUG_INFO, "QemuFwCfg interface (DMA) is supported.\n")); > + } > } > return RETURN_SUCCESS; > } > @@ -114,3 +127,58 @@ InternalQemuFwCfgDmaIsAvailable ( > { > return mQemuFwCfgDmaSupported; > } > + > +/** > + > + Returns a boolean indicating whether SEV is enabled > + > + @retval TRUE SEV is enabled > + @retval FALSE SEV is disabled > +**/ > +BOOLEAN > +InternalQemuFwCfgSevIsEnabled ( > + VOID > + ) > +{ > + return MemEncryptSevIsEnabled (); > +} > + > +/** > + Allocate a bounce buffer for SEV DMA. > + > + @param[in] NumPage Number of pages. > + @param[out] Buffer Allocated DMA Buffer pointer > + > +**/ > +VOID > +InternalQemuFwCfgSevDmaAllocateBuffer ( > + IN UINT32 NumPages, > + OUT VOID **Buffer > + ) > +{ > + // > + // We should never reach here > + // > + ASSERT (FALSE); > + CpuDeadLoop (); > +} > + > +/** > + Free the DMA buffer allocated using InternalQemuFwCfgSevDmaAllocateBuffer > + > + @param[in] NumPage Number of pages. > + @param[in] Buffer DMA Buffer pointer > + > +**/ > +VOID > +InternalQemuFwCfgSevDmaFreeBuffer ( > + IN VOID *Buffer, > + IN UINT32 NumPages > + ) > +{ > + // > + // We should never reach here > + // > + ASSERT (FALSE); > + CpuDeadLoop (); > +} >