public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ard.biesheuvel@linaro.org>
To: edk2-devel-groups-io <devel@edk2.groups.io>,
	"Wu, Hao A" <hao.a.wu@intel.com>,
	 Jian J Wang <jian.j.wang@intel.com>,
	Zhichao Gao <zhichao.gao@intel.com>,
	 "Ni, Ray" <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>,
	Leif Lindholm <leif@nuviainc.com>,
	 "Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: [PATCH v3 5/6] MdeModulePkg/DxeCore: defer PE/COFF emulator registration to StartImage
Date: Thu, 27 Feb 2020 18:10:42 +0100	[thread overview]
Message-ID: <CAKv+Gu8UYxLi_0gBUFszV3BXF=99g9X_3kspAr+-acFLUz8zPA@mail.gmail.com> (raw)
In-Reply-To: <20200226194343.2985-6-ard.biesheuvel@linaro.org>

On Wed, 26 Feb 2020 at 20:43, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
> EDK2's implementation of the LoadImage() boot service permits non-native
> binaries to be loaded (i.e., X64 images on IA32 firmware), but any
> attempts to start such an image using StartImage() will return
> EFI_UNSUPPORTED.
>
> The integration of the PE/COFF emulator protocol into the DXE core
> deviates slightly from this paradigm, given that its IsImageSupported
> hook as well as its RegisterImage hook are invoked from LoadImage,
> and by the time StartImage is called, no opportunity is given to the
> provider of the PE/COFF emulator protocol to prevent an image from
> being started if it only supports loading it.
>
> To address this disparity, let's move the invocation of RegisterImage()
> to the implementation of the StartImage() boot service, allowing the
> emulator to permit LoadImage() but reject StartImage() on images that
> turn out not to meet the requirements of the emulator as it is being
> started.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

@MdeModulePkg maintainers: do you have any comments on this patch?


> ---
>  MdeModulePkg/Core/Dxe/Image/Image.c | 24 +++++++++++---------
>  1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c
> index 22a87ecf6d7c..d86da89ee704 100644
> --- a/MdeModulePkg/Core/Dxe/Image/Image.c
> +++ b/MdeModulePkg/Core/Dxe/Image/Image.c
> @@ -756,17 +756,6 @@ CoreLoadPeImage (
>    // Get the image entry point.
>    //
>    Image->EntryPoint   = (EFI_IMAGE_ENTRY_POINT)(UINTN)Image->ImageContext.EntryPoint;
> -  if (Image->PeCoffEmu != NULL) {
> -    Status = Image->PeCoffEmu->RegisterImage (Image->PeCoffEmu,
> -                                 Image->ImageBasePage,
> -                                 EFI_PAGES_TO_SIZE (Image->NumberOfPages),
> -                                 &Image->EntryPoint);
> -    if (EFI_ERROR (Status)) {
> -      DEBUG ((DEBUG_LOAD | DEBUG_ERROR,
> -        "CoreLoadPeImage: Failed to register foreign image with emulator.\n"));
> -      goto Done;
> -    }
> -  }
>
>    //
>    // Fill in the image information for the Loaded Image Protocol
> @@ -1603,6 +1592,19 @@ CoreStartImage (
>      return EFI_UNSUPPORTED;
>    }
>
> +  if (Image->PeCoffEmu != NULL) {
> +    Status = Image->PeCoffEmu->RegisterImage (Image->PeCoffEmu,
> +                                 Image->ImageBasePage,
> +                                 EFI_PAGES_TO_SIZE (Image->NumberOfPages),
> +                                 &Image->EntryPoint);
> +    if (EFI_ERROR (Status)) {
> +      DEBUG ((DEBUG_LOAD | DEBUG_ERROR,
> +        "CoreLoadPeImage: Failed to register foreign image with emulator - %r\n",
> +          Status));
> +      return Status;
> +    }
> +  }
> +
>    PERF_START_IMAGE_BEGIN (Handle);
>
>
> --
> 2.17.1
>

  reply	other threads:[~2020-02-27 17:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 19:43 [PATCH v3 0/6] OvmfPkg: implement initrd shell command and mixed mode loader Ard Biesheuvel
2020-02-26 19:43 ` [PATCH v3 1/6] OvmfPkg: add definition of LINUX_EFI_INITRD_MEDIA_GUID Ard Biesheuvel
2020-02-26 19:43 ` [PATCH v3 2/6] OvmfPkg: add 'initrd' shell command to expose Linux initrd via device path Ard Biesheuvel
2020-02-27 10:59   ` [edk2-devel] " Laszlo Ersek
2020-02-26 19:43 ` [PATCH v3 3/6] ArmVirtPkg: add the 'initrd' dynamic shell command Ard Biesheuvel
2020-02-26 19:43 ` [PATCH v3 4/6] OvmfPkg: " Ard Biesheuvel
2020-02-27 11:06   ` [edk2-devel] " Laszlo Ersek
2020-02-27 11:07     ` Ard Biesheuvel
2020-02-26 19:43 ` [PATCH v3 5/6] MdeModulePkg/DxeCore: defer PE/COFF emulator registration to StartImage Ard Biesheuvel
2020-02-27 17:10   ` Ard Biesheuvel [this message]
2020-02-28 12:02     ` [edk2-devel] " Liming Gao
2020-02-26 19:43 ` [PATCH v3 6/6] OvmfPkg IA32: add support for loading X64 images Ard Biesheuvel
2020-02-26 20:32   ` [edk2-devel] " Brian J. Johnson
2020-02-26 21:40     ` Ard Biesheuvel
2020-02-27 11:10       ` Laszlo Ersek
2020-02-27 19:40 ` [PATCH v3 0/6] OvmfPkg: implement initrd shell command and mixed mode loader Ard Biesheuvel

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='CAKv+Gu8UYxLi_0gBUFszV3BXF=99g9X_3kspAr+-acFLUz8zPA@mail.gmail.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