From: Laszlo Ersek <lersek@redhat.com>
To: Brijesh Singh <brijesh.singh@amd.com>, edk2-devel@lists.01.org
Cc: Lendacky Thomas <Thomas.Lendacky@amd.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Anthony Perard <anthony.perard@citrix.com>,
Julien Grall <julien.grall@linaro.org>,
Justen Jordan L <jordan.l.justen@intel.com>
Subject: Re: [PATCH v3 2/3] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Do not expose MMIO in SMM build
Date: Fri, 6 Jul 2018 13:35:06 +0200 [thread overview]
Message-ID: <dcdd2682-edca-3996-3a03-d81c74aab0f3@redhat.com> (raw)
In-Reply-To: <1530817945-8030-3-git-send-email-brijesh.singh@amd.com>
On 07/05/18 21:12, Brijesh Singh wrote:
> In the SMM build, only an SMM driver is using the address range hence we
> do not need to expose the flash MMIO range in EFI runtime mapping.
>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Julien Grall <julien.grall@linaro.org>
> Cc: Justen Jordan L <jordan.l.justen@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
> ---
> .../FwBlockService.c | 50 ---------------------
> .../FwBlockService.h | 7 +++
> .../FwBlockServiceDxe.c | 51 ++++++++++++++++++++++
> .../FwBlockServiceSmm.c | 13 ++++++
> 4 files changed, 71 insertions(+), 50 deletions(-)
>
> diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
> index 28499991a43c..eec8b1b1ae9d 100644
> --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
> +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
> @@ -831,56 +831,6 @@ ValidateFvHeader (
>
> STATIC
> EFI_STATUS
> -MarkIoMemoryRangeForRuntimeAccess (
> - EFI_PHYSICAL_ADDRESS BaseAddress,
> - UINTN Length
> - )
> -{
> - EFI_STATUS Status;
> - EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
> -
> - //
> - // Mark flash region as runtime memory
> - //
> - Status = gDS->RemoveMemorySpace (
> - BaseAddress,
> - Length
> - );
> -
> - Status = gDS->AddMemorySpace (
> - EfiGcdMemoryTypeMemoryMappedIo,
> - BaseAddress,
> - Length,
> - EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
> - );
> - ASSERT_EFI_ERROR (Status);
> -
> - Status = gDS->AllocateMemorySpace (
> - AllocateAddress,
> - EfiGcdMemoryTypeMemoryMappedIo,
> - 0,
> - Length,
> - &BaseAddress,
> - gImageHandle,
> - NULL
> - );
> - ASSERT_EFI_ERROR (Status);
> -
> - Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);
> - ASSERT_EFI_ERROR (Status);
> -
> - Status = gDS->SetMemorySpaceAttributes (
> - BaseAddress,
> - Length,
> - GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME
> - );
> - ASSERT_EFI_ERROR (Status);
> -
> - return Status;
> -}
> -
> -STATIC
> -EFI_STATUS
> InitializeVariableFvHeader (
> VOID
> )
> diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h
> index 1f9287b08769..178f578d49f0 100644
> --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h
> +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h
> @@ -189,4 +189,11 @@ VOID
> InstallVirtualAddressChangeHandler (
> VOID
> );
> +
> +EFI_STATUS
> +MarkIoMemoryRangeForRuntimeAccess (
> + IN EFI_PHYSICAL_ADDRESS BaseAddress,
> + IN UINTN Length
> + );
> +
> #endif
> diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c
> index 63b308658e36..646427bf4e2c 100644
> --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c
> +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c
> @@ -22,6 +22,8 @@
> #include <Library/UefiRuntimeLib.h>
> #include <Protocol/DevicePath.h>
> #include <Protocol/FirmwareVolumeBlock.h>
> +#include <Library/DxeServicesTableLib.h>
> +#include <Library/MemoryAllocationLib.h>
(1) Can you drop "MemoryAllocationLib.h"? I don't think it is needed.
(2) Also, can you add the "DxeServicesTableLib.h" include directive so
that the Library #include list remains sorted?
>
> #include "FwBlockService.h"
> #include "QemuFlash.h"
> @@ -155,3 +157,52 @@ InstallVirtualAddressChangeHandler (
> );
> ASSERT_EFI_ERROR (Status);
> }
> +
> +EFI_STATUS
> +MarkIoMemoryRangeForRuntimeAccess (
> + EFI_PHYSICAL_ADDRESS BaseAddress,
> + UINTN Length
> + )
> +{
> + EFI_STATUS Status;
> + EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
> +
> + //
> + // Mark flash region as runtime memory
> + //
> + Status = gDS->RemoveMemorySpace (
> + BaseAddress,
> + Length
> + );
> +
> + Status = gDS->AddMemorySpace (
> + EfiGcdMemoryTypeMemoryMappedIo,
> + BaseAddress,
> + Length,
> + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = gDS->AllocateMemorySpace (
> + AllocateAddress,
> + EfiGcdMemoryTypeMemoryMappedIo,
> + 0,
> + Length,
> + &BaseAddress,
> + gImageHandle,
> + NULL
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = gDS->SetMemorySpaceAttributes (
> + BaseAddress,
> + Length,
> + GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + return Status;
> +}
(3) Please don't forget to update this function (post-move) as I
requested for patch #1.
> diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c
> index e0617f2503a2..cdb073348158 100644
> --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c
> +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c
> @@ -67,3 +67,16 @@ InstallVirtualAddressChangeHandler (
> // Nothing.
> //
> }
> +
> +EFI_STATUS
> +MarkIoMemoryRangeForRuntimeAccess (
> + EFI_PHYSICAL_ADDRESS BaseAddress,
> + UINTN Length
> + )
> +{
> + //
> + // Nothing
> + //
> +
> + return EFI_SUCCESS;
> +}
>
Looks OK to me otherwise.
Thanks
Laszlo
next prev parent reply other threads:[~2018-07-06 11:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-05 19:12 [PATCH v3 0/3] OvmfPkg: mark flash memory range as MMIO Brijesh Singh
2018-07-05 19:12 ` [PATCH v3 1/3] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: mark Flash " Brijesh Singh
2018-07-06 11:24 ` Laszlo Ersek
2018-07-05 19:12 ` [PATCH v3 2/3] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Do not expose MMIO in SMM build Brijesh Singh
2018-07-06 11:35 ` Laszlo Ersek [this message]
2018-07-06 11:48 ` Laszlo Ersek
2018-07-05 19:12 ` [PATCH v3 3/3] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Restore C-bit when SEV is active Brijesh Singh
2018-07-06 12:08 ` Laszlo Ersek
2018-07-06 14:01 ` [PATCH v3 0/3] OvmfPkg: mark flash memory range as MMIO Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dcdd2682-edca-3996-3a03-d81c74aab0f3@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox