From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (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 7E80C202E5401 for ; Fri, 6 Jul 2018 04:24:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 25C2C81A4EA8; Fri, 6 Jul 2018 11:24:35 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-154.rdu2.redhat.com [10.10.120.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AE842166BA9; Fri, 6 Jul 2018 11:24:33 +0000 (UTC) To: Brijesh Singh , edk2-devel@lists.01.org Cc: Lendacky Thomas , Ard Biesheuvel , Anthony Perard , Julien Grall , Justen Jordan L References: <1530817945-8030-1-git-send-email-brijesh.singh@amd.com> <1530817945-8030-2-git-send-email-brijesh.singh@amd.com> From: Laszlo Ersek Message-ID: <0f0736f4-d52c-6184-968e-32b59e030fde@redhat.com> Date: Fri, 6 Jul 2018 13:24:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1530817945-8030-2-git-send-email-brijesh.singh@amd.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 06 Jul 2018 11:24:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 06 Jul 2018 11:24:35 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: Re: [PATCH v3 1/3] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: mark Flash memory range as MMIO X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jul 2018 11:24:36 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 07/05/18 21:12, Brijesh Singh wrote: > The flash memory range is an IO address and should be presented as Memory > Mapped IO in EFI Runtime mapping. This information can be used by OS > when mapping the flash memory range. > > It is especially helpful in SEV guest case, in which IO addresses should > be mapped as unencrypted. If memory region is not marked as MMIO then OS > maps the range as encrypted. > > Cc: Ard Biesheuvel > Cc: Anthony Perard > Cc: Julien Grall > Cc: Justen Jordan L > Cc: Laszlo Ersek > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Brijesh Singh > --- > .../FwBlockService.c | 28 ++++++++++++++++------ > 1 file changed, 21 insertions(+), 7 deletions(-) > > diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c > index 558b395dff4a..28499991a43c 100644 > --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c > +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c > @@ -831,12 +831,13 @@ ValidateFvHeader ( > > STATIC > EFI_STATUS > -MarkMemoryRangeForRuntimeAccess ( > +MarkIoMemoryRangeForRuntimeAccess ( > EFI_PHYSICAL_ADDRESS BaseAddress, > UINTN Length > ) > { > EFI_STATUS Status; > + EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor; > > // > // Mark flash region as runtime memory > @@ -847,18 +848,31 @@ MarkMemoryRangeForRuntimeAccess ( > ); > > Status = gDS->AddMemorySpace ( > - EfiGcdMemoryTypeSystemMemory, > + EfiGcdMemoryTypeMemoryMappedIo, > BaseAddress, > Length, > EFI_MEMORY_UC | EFI_MEMORY_RUNTIME > ); > ASSERT_EFI_ERROR (Status); > > - Status = gBS->AllocatePages ( > + Status = gDS->AllocateMemorySpace ( > AllocateAddress, (1) This should be changed to "EfiGcdAllocateAddress". (I didn't notice this in your previous submission; however, to my excuse, I did suggest it correctly in :) ) Note that this omission does not invalidate your testing, because "AllocateAddress" (from "MdePkg/Include/Uefi/UefiSpec.h") has value 2, and "EfiGcdAllocateAddress" (from "MdePkg/Include/Pi/PiDxeCis.h") has value 2 as well. > - EfiRuntimeServicesData, > - EFI_SIZE_TO_PAGES (Length), > - &BaseAddress > + EfiGcdMemoryTypeMemoryMappedIo, > + 0, > + Length, > + &BaseAddress, > + gImageHandle, > + NULL > + ); > + ASSERT_EFI_ERROR (Status); > + > + Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor); (2) The extra space before the equal sign (=) looks uncalled for. > + ASSERT_EFI_ERROR (Status); > + > + Status = gDS->SetMemorySpaceAttributes ( > + BaseAddress, > + Length, > + GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME > ); > ASSERT_EFI_ERROR (Status); > > @@ -1091,7 +1105,7 @@ FvbInitialize ( > // > InstallProtocolInterfaces (FvbDevice); > > - MarkMemoryRangeForRuntimeAccess (BaseAddress, Length); > + MarkIoMemoryRangeForRuntimeAccess (BaseAddress, Length); > > // > // Set several PCD values to point to flash > Thanks! Laszlo