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 17CBC21DFA917 for ; Mon, 27 Mar 2017 03:29:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7664713A5D; Mon, 27 Mar 2017 10:29:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7664713A5D Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7664713A5D Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-77.phx2.redhat.com [10.3.116.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97D2C17961; Mon, 27 Mar 2017 10:29:16 +0000 (UTC) To: Brijesh Singh , michael.d.kinney@intel.com, jordan.l.justen@intel.com, edk2-devel@ml01.01.org, liming.gao@intel.com References: <149013076154.27235.10725020825643505862.stgit@brijesh-build-machine> <149013082409.27235.9271750185308365336.stgit@brijesh-build-machine> Cc: brijesh.singh@amd.com, leo.duran@amd.com, Thomas.Lendacky@amd.com From: Laszlo Ersek Message-ID: <06f627fd-d6f5-9764-4656-20df7bc286d9@redhat.com> Date: Mon, 27 Mar 2017 12:29:15 +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: <149013082409.27235.9271750185308365336.stgit@brijesh-build-machine> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 27 Mar 2017 10:29:18 +0000 (UTC) Subject: Re: [RFC PATCH v2 10/10] OvmfPkg/QemuVideoDxe: Clear the C-bit from framebuffer region when SEV is enabled 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: Mon, 27 Mar 2017 10:29:19 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 03/21/17 22:13, Brijesh Singh wrote: > Since the framebuffer memory region is shared between the guest and hypervisor > hence we must clear the memory encryption bit from this memory region when SEV > is enabled. > > Signed-off-by: Brijesh Singh > --- > OvmfPkg/QemuVideoDxe/Gop.c | 15 +++++++++++++++ > OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf | 1 + > 2 files changed, 16 insertions(+) > > diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c > index 359e921..96661d1 100644 > --- a/OvmfPkg/QemuVideoDxe/Gop.c > +++ b/OvmfPkg/QemuVideoDxe/Gop.c > @@ -13,6 +13,8 @@ > > **/ > > +#include > + > #include "Qemu.h" > > STATIC > @@ -65,6 +67,19 @@ QemuVideoCompleteModeData ( > (VOID**) &FrameBufDesc > ); > > + // > + // Framebuffer memory region is shared between hypervisor and guest, > + // Clear the memory encryption mask when SEV is active. > + // > + if (MemEncryptSevIsEnabled ()) { > + EFI_STATUS Status; > + > + Status = MemEncryptSevClearPageEncMask (FrameBufDesc->AddrRangeMin, EFI_SIZE_TO_PAGES (FrameBufDesc->AddrLen)); > + if (EFI_ERROR(Status)) { > + DEBUG ((EFI_D_WARN, "Failed to clear memory encryption mask 0x%#Lx+0x%x\n", FrameBufDesc->AddrRangeMin, FrameBufDesc->AddrLen)); > + } > + } > + > Mode->FrameBufferBase = FrameBufDesc->AddrRangeMin; > Mode->FrameBufferSize = Info->HorizontalResolution * Info->VerticalResolution; > Mode->FrameBufferSize = Mode->FrameBufferSize * ((ModeData->ColorDepth + 7) / 8); This way the above logic is executed on every GOP->SetMode() call. Instead, I think it should occur in QemuVideoControllerDriverStart(). And, likely, undone / rolled back in QemuVideoControllerDriverStop(). Thanks Laszlo > diff --git a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf > index affb6ff..83ea86c 100644 > --- a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf > +++ b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf > @@ -60,6 +60,7 @@ > UefiBootServicesTableLib > UefiDriverEntryPoint > UefiLib > + MemEncryptSevLib > > [Protocols] > gEfiDriverSupportedEfiVersionProtocolGuid # PROTOCOL ALWAYS_PRODUCED > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel >