* [PATCH v2 1/9] MdeModulePkg/SecurityStubDxe: Defer 3rd party image before EndOfDxe
2016-11-08 12:29 [PATCH v2 0/9] Defer 3rd party images loading to after EndOfDxe Ruiyu Ni
@ 2016-11-08 12:29 ` Ruiyu Ni
2016-11-10 7:24 ` Gao, Liming
2016-11-08 12:29 ` [PATCH v2 2/9] MdeModulePkg/UefiBootManager: Add EfiBootManagerDispatchDeferredImages Ruiyu Ni
` (8 subsequent siblings)
9 siblings, 1 reply; 25+ messages in thread
From: Ruiyu Ni @ 2016-11-08 12:29 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Jiewen Yao, Chao B Zhang
The images not from FV are treated as 3rd party images. They will
be deferred to dispatch when they are dispatched before EndOfDxe
event.
It's a new feature in the BS.LoadImage() path which can disallow
executing 3rd party images before EndOfDxe and re-execute them
after EndOfDxe (through EfiBootManagerDispatchDeferredImages
introduced in next commit).
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
---
.../SecurityStubDxe/Defer3rdPartyImageLoad.c | 356 +++++++++++++++++++++
.../SecurityStubDxe/Defer3rdPartyImageLoad.h | 92 ++++++
.../Universal/SecurityStubDxe/SecurityStub.c | 14 +-
.../Universal/SecurityStubDxe/SecurityStubDxe.inf | 8 +-
4 files changed, 468 insertions(+), 2 deletions(-)
create mode 100644 MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c
create mode 100644 MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.h
diff --git a/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c
new file mode 100644
index 0000000..ca45d56
--- /dev/null
+++ b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c
@@ -0,0 +1,356 @@
+/** @file
+ Implement defer image load services for user identification in UEFI2.2.
+
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#include "Defer3rdPartyImageLoad.h"
+
+//
+// The structure to save the deferred 3rd party image information.
+//
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
+ BOOLEAN BootOption;
+ BOOLEAN Loaded;
+} DEFERRED_3RD_PARTY_IMAGE_INFO;
+
+//
+// The table to save the deferred 3rd party image item.
+//
+typedef struct {
+ UINTN Count; ///< deferred 3rd party image count
+ DEFERRED_3RD_PARTY_IMAGE_INFO *ImageInfo; ///< deferred 3rd party image item
+} DEFERRED_3RD_PARTY_IMAGE_TABLE;
+
+BOOLEAN mEndOfDxe = FALSE;
+DEFERRED_3RD_PARTY_IMAGE_TABLE mDeferred3rdPartyImage = {
+ 0, // Deferred image count
+ NULL // The deferred image info
+};
+
+EFI_DEFERRED_IMAGE_LOAD_PROTOCOL mDeferredImageLoad = {
+ GetDefferedImageInfo
+};
+
+/**
+ Return whether the file comes from FV.
+
+ @param[in] File This is a pointer to the device path of the file
+ that is being dispatched.
+
+ @retval TRUE File comes from FV.
+ @retval FALSE File doesn't come from FV.
+**/
+BOOLEAN
+FileFromFv (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *File
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE DeviceHandle;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+
+ //
+ // First check to see if File is from a Firmware Volume
+ //
+ DeviceHandle = NULL;
+ TempDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) File;
+ Status = gBS->LocateDevicePath (
+ &gEfiFirmwareVolume2ProtocolGuid,
+ &TempDevicePath,
+ &DeviceHandle
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol (
+ DeviceHandle,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ NULL,
+ NULL,
+ NULL,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
+ if (!EFI_ERROR (Status)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+/**
+ Find the deferred image which matches the device path.
+
+ @param[in] ImageDevicePath A pointer to the device path of a image.
+ @param[in] BootOption Whether the image is a boot option.
+
+ @return Pointer to the found deferred image or NULL if not found.
+**/
+DEFERRED_3RD_PARTY_IMAGE_INFO *
+LookupImage (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath,
+ IN BOOLEAN BootOption
+ )
+{
+ UINTN Index;
+ UINTN DevicePathSize;
+
+ DevicePathSize = GetDevicePathSize (ImageDevicePath);
+
+ for (Index = 0; Index < mDeferred3rdPartyImage.Count; Index++) {
+ if (CompareMem (ImageDevicePath, mDeferred3rdPartyImage.ImageInfo[Index].ImageDevicePath, DevicePathSize) == 0) {
+ ASSERT (mDeferred3rdPartyImage.ImageInfo[Index].BootOption == BootOption);
+ return &mDeferred3rdPartyImage.ImageInfo[Index];
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ Add the image info to a deferred image list.
+
+ @param[in] ImageDevicePath A pointer to the device path of a image.
+ @param[in] BootOption Whether the image is a boot option.
+
+**/
+VOID
+QueueImage (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath,
+ IN BOOLEAN BootOption
+ )
+{
+ DEFERRED_3RD_PARTY_IMAGE_INFO *ImageInfo;
+
+ //
+ // Expand memory for the new deferred image.
+ //
+ ImageInfo = ReallocatePool (
+ mDeferred3rdPartyImage.Count * sizeof (DEFERRED_3RD_PARTY_IMAGE_INFO),
+ (mDeferred3rdPartyImage.Count + 1) * sizeof (DEFERRED_3RD_PARTY_IMAGE_INFO),
+ mDeferred3rdPartyImage.ImageInfo
+ );
+ if (ImageInfo == NULL) {
+ return;
+ }
+ mDeferred3rdPartyImage.ImageInfo = ImageInfo;
+
+ //
+ // Save the deferred image information.
+ //
+ ImageInfo = &mDeferred3rdPartyImage.ImageInfo[mDeferred3rdPartyImage.Count];
+ ImageInfo->ImageDevicePath = DuplicateDevicePath (ImageDevicePath);
+ if (ImageInfo->ImageDevicePath == NULL) {
+ return;
+ }
+ ImageInfo->BootOption = BootOption;
+ ImageInfo->Loaded = FALSE;
+ mDeferred3rdPartyImage.Count++;
+}
+
+
+/**
+ Returns information about a deferred image.
+
+ This function returns information about a single deferred image. The deferred images are
+ numbered consecutively, starting with 0. If there is no image which corresponds to
+ ImageIndex, then EFI_NOT_FOUND is returned. All deferred images may be returned by
+ iteratively calling this function until EFI_NOT_FOUND is returned.
+ Image may be NULL and ImageSize set to 0 if the decision to defer execution was made
+ because of the location of the executable image, rather than its actual contents.
+
+ @param[in] This Points to this instance of the EFI_DEFERRED_IMAGE_LOAD_PROTOCOL.
+ @param[in] ImageIndex Zero-based index of the deferred index.
+ @param[out] ImageDevicePath On return, points to a pointer to the device path of the image.
+ The device path should not be freed by the caller.
+ @param[out] Image On return, points to the first byte of the image or NULL if the
+ image is not available. The image should not be freed by the caller
+ unless LoadImage() has been successfully called.
+ @param[out] ImageSize On return, the size of the image, or 0 if the image is not available.
+ @param[out] BootOption On return, points to TRUE if the image was intended as a boot option
+ or FALSE if it was not intended as a boot option.
+
+ @retval EFI_SUCCESS Image information returned successfully.
+ @retval EFI_NOT_FOUND ImageIndex does not refer to a valid image.
+ @retval EFI_INVALID_PARAMETER ImageDevicePath is NULL or Image is NULL or ImageSize is NULL or
+ BootOption is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+GetDefferedImageInfo (
+ IN EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *This,
+ IN UINTN ImageIndex,
+ OUT EFI_DEVICE_PATH_PROTOCOL **ImageDevicePath,
+ OUT VOID **Image,
+ OUT UINTN *ImageSize,
+ OUT BOOLEAN *BootOption
+ )
+{
+ UINTN Index;
+ UINTN NewCount;
+
+ if ((This == NULL) || (ImageSize == NULL) || (Image == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((ImageDevicePath == NULL) || (BootOption == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Remove the loaded images from the defer list in the first call.
+ //
+ if (ImageIndex == 0) {
+ NewCount = 0;
+ for (Index = 0; Index < mDeferred3rdPartyImage.Count; Index++) {
+ if (!mDeferred3rdPartyImage.ImageInfo[Index].Loaded) {
+ CopyMem (
+ &mDeferred3rdPartyImage.ImageInfo[NewCount],
+ &mDeferred3rdPartyImage.ImageInfo[Index],
+ sizeof (DEFERRED_3RD_PARTY_IMAGE_INFO)
+ );
+ NewCount++;
+ }
+ }
+
+ mDeferred3rdPartyImage.Count = NewCount;
+ }
+
+ if (ImageIndex >= mDeferred3rdPartyImage.Count) {
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Get the request deferred image.
+ //
+ *ImageDevicePath = mDeferred3rdPartyImage.ImageInfo[ImageIndex].ImageDevicePath;
+ *BootOption = mDeferred3rdPartyImage.ImageInfo[ImageIndex].BootOption;
+ *Image = NULL;
+ *ImageSize = 0;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Callback function executed when the EndOfDxe event group is signaled.
+
+ @param[in] Event Event whose notification function is being invoked.
+ @param[in] Context The pointer to the notification function's context, which
+ is implementation-dependent.
+**/
+VOID
+EFIAPI
+EndOfDxe (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ mEndOfDxe = TRUE;
+}
+
+/**
+ Defer the 3rd party image load and installs Deferred Image Load Protocol.
+
+ @param[in] File This is a pointer to the device path of the file that
+ is being dispatched. This will optionally be used for
+ logging.
+ @param[in] BootPolicy A boot policy that was used to call LoadImage() UEFI service.
+
+ @retval EFI_SUCCESS The file is not 3rd party image and can be loaded immediately.
+ @retval EFI_ACCESS_DENIED The file is 3rd party image and needs deferred.
+**/
+EFI_STATUS
+Defer3rdPartyImageLoad (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *File,
+ IN BOOLEAN BootPolicy
+ )
+{
+ DEFERRED_3RD_PARTY_IMAGE_INFO *ImageInfo;
+
+ //
+ // Ignore if File is NULL.
+ //
+ if (File == NULL) {
+ return EFI_SUCCESS;
+ }
+
+ if (FileFromFv (File)) {
+ return EFI_SUCCESS;
+ }
+
+ ImageInfo = LookupImage (File, BootPolicy);
+
+ DEBUG_CODE (
+ CHAR16 *DevicePathStr;
+ DevicePathStr = ConvertDevicePathToText (File, FALSE, FALSE);
+ DEBUG ((
+ DEBUG_INFO,
+ "[Security] 3rd party image[%p] %s EndOfDxe: %s.\n", ImageInfo,
+ mEndOfDxe ? L"can be loaded after": L"is deferred to load before",
+ DevicePathStr
+ ));
+ if (DevicePathStr != NULL) {
+ FreePool (DevicePathStr);
+ }
+ );
+
+ if (mEndOfDxe) {
+ //
+ // The image might be first time loaded after EndOfDxe,
+ // So ImageInfo can be NULL.
+ //
+ if (ImageInfo != NULL) {
+ ImageInfo->Loaded = TRUE;
+ }
+ return EFI_SUCCESS;
+ } else {
+ //
+ // The image might be second time loaded before EndOfDxe,
+ // So ImageInfo can be non-NULL.
+ //
+ if (ImageInfo == NULL) {
+ QueueImage (File, BootPolicy);
+ }
+ return EFI_ACCESS_DENIED;
+ }
+}
+
+/**
+ Installs DeferredImageLoad Protocol and listens EndOfDxe event.
+**/
+VOID
+Defer3rdPartyImageLoadInitialize (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ EFI_EVENT Event;
+
+ Handle = NULL;
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Handle,
+ &gEfiDeferredImageLoadProtocolGuid,
+ &mDeferredImageLoad,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ EndOfDxe,
+ NULL,
+ &gEfiEndOfDxeEventGroupGuid,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+}
diff --git a/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.h b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.h
new file mode 100644
index 0000000..3fab258
--- /dev/null
+++ b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.h
@@ -0,0 +1,92 @@
+/** @file
+ Implement defer image load services for user identification in UEFI2.2.
+
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _DEFER_3RD_PARTY_IMAGE_LOAD_H_
+#define _DEFER_3RD_PARTY_IMAGE_LOAD_H_
+
+#include <Uefi.h>
+#include <Guid/EventGroup.h>
+#include <Protocol/DeferredImageLoad.h>
+#include <Protocol/FirmwareVolume2.h>
+
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/DebugLib.h>
+
+/**
+ Returns information about a deferred image.
+
+ This function returns information about a single deferred image. The deferred images are
+ numbered consecutively, starting with 0. If there is no image which corresponds to
+ ImageIndex, then EFI_NOT_FOUND is returned. All deferred images may be returned by
+ iteratively calling this function until EFI_NOT_FOUND is returned.
+ Image may be NULL and ImageSize set to 0 if the decision to defer execution was made
+ because of the location of the executable image, rather than its actual contents.
+
+ @param[in] This Points to this instance of the EFI_DEFERRED_IMAGE_LOAD_PROTOCOL.
+ @param[in] ImageIndex Zero-based index of the deferred index.
+ @param[out] ImageDevicePath On return, points to a pointer to the device path of the image.
+ The device path should not be freed by the caller.
+ @param[out] Image On return, points to the first byte of the image or NULL if the
+ image is not available. The image should not be freed by the caller
+ unless LoadImage() has been successfully called.
+ @param[out] ImageSize On return, the size of the image, or 0 if the image is not available.
+ @param[out] BootOption On return, points to TRUE if the image was intended as a boot option
+ or FALSE if it was not intended as a boot option.
+
+ @retval EFI_SUCCESS Image information returned successfully.
+ @retval EFI_NOT_FOUND ImageIndex does not refer to a valid image.
+ @retval EFI_INVALID_PARAMETER ImageDevicePath is NULL or Image is NULL or ImageSize is NULL or
+ BootOption is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+GetDefferedImageInfo (
+ IN EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *This,
+ IN UINTN ImageIndex,
+ OUT EFI_DEVICE_PATH_PROTOCOL **ImageDevicePath,
+ OUT VOID **Image,
+ OUT UINTN *ImageSize,
+ OUT BOOLEAN *BootOption
+ );
+
+/**
+ Defer the 3rd party image load and installs Deferred Image Load Protocol.
+
+ @param[in] File This is a pointer to the device path of the file that
+ is being dispatched. This will optionally be used for
+ logging.
+ @param[in] BootPolicy A boot policy that was used to call LoadImage() UEFI service.
+
+ @retval EFI_SUCCESS The file is not 3rd party image and can be loaded immediately.
+ @retval EFI_ACCESS_DENIED The file is 3rd party image and needs deferred.
+**/
+EFI_STATUS
+Defer3rdPartyImageLoad (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *File,
+ IN BOOLEAN BootPolicy
+ );
+
+/**
+ Installs DeferredImageLoad Protocol and listens EndOfDxe event.
+**/
+VOID
+Defer3rdPartyImageLoadInitialize (
+ VOID
+ );
+
+#endif
diff --git a/MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.c b/MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.c
index 22e6c7f..a75d8dc 100644
--- a/MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.c
+++ b/MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.c
@@ -1,7 +1,7 @@
/** @file
This driver produces Security2 and Security architectural protocol based on SecurityManagementLib.
- Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -20,6 +20,7 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/SecurityManagementLib.h>
+#include "Defer3rdPartyImageLoad.h"
//
// Handle for the Security Architectural Protocol instance produced by this driver
@@ -140,6 +141,15 @@ Security2StubAuthenticate (
IN BOOLEAN BootPolicy
)
{
+ EFI_STATUS Status;
+
+ if (FileBuffer != NULL) {
+ Status = Defer3rdPartyImageLoad (File, BootPolicy);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
return ExecuteSecurity2Handlers (EFI_AUTH_OPERATION_VERIFY_IMAGE |
EFI_AUTH_OPERATION_DEFER_IMAGE_LOAD |
EFI_AUTH_OPERATION_MEASURE_IMAGE |
@@ -200,5 +210,7 @@ SecurityStubInitialize (
);
ASSERT_EFI_ERROR (Status);
+ Defer3rdPartyImageLoadInitialize ();
+
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf b/MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
index 9d1c7b8..be6ce6c 100644
--- a/MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
+++ b/MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
@@ -1,7 +1,7 @@
## @file
# This driver produces security2 and security architectural protocol based on SecurityManagementLib.
#
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -29,6 +29,8 @@ [Defines]
[Sources]
SecurityStub.c
+ Defer3rdPartyImageLoad.c
+ Defer3rdPartyImageLoad.h
[Packages]
MdePkg/MdePkg.dec
@@ -40,9 +42,13 @@ [LibraryClasses]
DebugLib
SecurityManagementLib
+[Guids]
+ gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event
+
[Protocols]
gEfiSecurityArchProtocolGuid ## PRODUCES
gEfiSecurity2ArchProtocolGuid ## PRODUCES
+ gEfiDeferredImageLoadProtocolGuid ## PRODUCES
[Depex]
TRUE
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v2 1/9] MdeModulePkg/SecurityStubDxe: Defer 3rd party image before EndOfDxe
2016-11-08 12:29 ` [PATCH v2 1/9] MdeModulePkg/SecurityStubDxe: Defer 3rd party image before EndOfDxe Ruiyu Ni
@ 2016-11-10 7:24 ` Gao, Liming
0 siblings, 0 replies; 25+ messages in thread
From: Gao, Liming @ 2016-11-10 7:24 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Yao, Jiewen, Zhang, Chao B
Reviewed-by: Liming Gao <liming.gao@intel.com>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Tuesday, November 08, 2016 8:29 PM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Zhang, Chao B
> <chao.b.zhang@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [edk2] [PATCH v2 1/9] MdeModulePkg/SecurityStubDxe: Defer 3rd
> party image before EndOfDxe
>
> The images not from FV are treated as 3rd party images. They will
> be deferred to dispatch when they are dispatched before EndOfDxe
> event.
> It's a new feature in the BS.LoadImage() path which can disallow
> executing 3rd party images before EndOfDxe and re-execute them
> after EndOfDxe (through EfiBootManagerDispatchDeferredImages
> introduced in next commit).
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Chao B Zhang <chao.b.zhang@intel.com>
> ---
> .../SecurityStubDxe/Defer3rdPartyImageLoad.c | 356
> +++++++++++++++++++++
> .../SecurityStubDxe/Defer3rdPartyImageLoad.h | 92 ++++++
> .../Universal/SecurityStubDxe/SecurityStub.c | 14 +-
> .../Universal/SecurityStubDxe/SecurityStubDxe.inf | 8 +-
> 4 files changed, 468 insertions(+), 2 deletions(-)
> create mode 100644
> MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c
> create mode 100644
> MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.h
>
> diff --git
> a/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c
> b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c
> new file mode 100644
> index 0000000..ca45d56
> --- /dev/null
> +++
> b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c
> @@ -0,0 +1,356 @@
> +/** @file
> + Implement defer image load services for user identification in UEFI2.2.
> +
> +Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> +This program and the accompanying materials
> +are licensed and made available under the terms and conditions of the BSD
> License
> +which accompanies this distribution. The full text of the license may be
> found at
> +http://opensource.org/licenses/bsd-license.php
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +#include "Defer3rdPartyImageLoad.h"
> +
> +//
> +// The structure to save the deferred 3rd party image information.
> +//
> +typedef struct {
> + EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
> + BOOLEAN BootOption;
> + BOOLEAN Loaded;
> +} DEFERRED_3RD_PARTY_IMAGE_INFO;
> +
> +//
> +// The table to save the deferred 3rd party image item.
> +//
> +typedef struct {
> + UINTN Count; ///< deferred 3rd party image count
> + DEFERRED_3RD_PARTY_IMAGE_INFO *ImageInfo; ///< deferred 3rd
> party image item
> +} DEFERRED_3RD_PARTY_IMAGE_TABLE;
> +
> +BOOLEAN mEndOfDxe = FALSE;
> +DEFERRED_3RD_PARTY_IMAGE_TABLE mDeferred3rdPartyImage = {
> + 0, // Deferred image count
> + NULL // The deferred image info
> +};
> +
> +EFI_DEFERRED_IMAGE_LOAD_PROTOCOL mDeferredImageLoad = {
> + GetDefferedImageInfo
> +};
> +
> +/**
> + Return whether the file comes from FV.
> +
> + @param[in] File This is a pointer to the device path of the file
> + that is being dispatched.
> +
> + @retval TRUE File comes from FV.
> + @retval FALSE File doesn't come from FV.
> +**/
> +BOOLEAN
> +FileFromFv (
> + IN CONST EFI_DEVICE_PATH_PROTOCOL *File
> + )
> +{
> + EFI_STATUS Status;
> + EFI_HANDLE DeviceHandle;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> +
> + //
> + // First check to see if File is from a Firmware Volume
> + //
> + DeviceHandle = NULL;
> + TempDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) File;
> + Status = gBS->LocateDevicePath (
> + &gEfiFirmwareVolume2ProtocolGuid,
> + &TempDevicePath,
> + &DeviceHandle
> + );
> + if (!EFI_ERROR (Status)) {
> + Status = gBS->OpenProtocol (
> + DeviceHandle,
> + &gEfiFirmwareVolume2ProtocolGuid,
> + NULL,
> + NULL,
> + NULL,
> + EFI_OPEN_PROTOCOL_TEST_PROTOCOL
> + );
> + if (!EFI_ERROR (Status)) {
> + return TRUE;
> + }
> + }
> +
> + return FALSE;
> +}
> +
> +/**
> + Find the deferred image which matches the device path.
> +
> + @param[in] ImageDevicePath A pointer to the device path of a image.
> + @param[in] BootOption Whether the image is a boot option.
> +
> + @return Pointer to the found deferred image or NULL if not found.
> +**/
> +DEFERRED_3RD_PARTY_IMAGE_INFO *
> +LookupImage (
> + IN CONST EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath,
> + IN BOOLEAN BootOption
> + )
> +{
> + UINTN Index;
> + UINTN DevicePathSize;
> +
> + DevicePathSize = GetDevicePathSize (ImageDevicePath);
> +
> + for (Index = 0; Index < mDeferred3rdPartyImage.Count; Index++) {
> + if (CompareMem (ImageDevicePath,
> mDeferred3rdPartyImage.ImageInfo[Index].ImageDevicePath,
> DevicePathSize) == 0) {
> + ASSERT (mDeferred3rdPartyImage.ImageInfo[Index].BootOption ==
> BootOption);
> + return &mDeferred3rdPartyImage.ImageInfo[Index];
> + }
> + }
> +
> + return NULL;
> +}
> +
> +/**
> + Add the image info to a deferred image list.
> +
> + @param[in] ImageDevicePath A pointer to the device path of a image.
> + @param[in] BootOption Whether the image is a boot option.
> +
> +**/
> +VOID
> +QueueImage (
> + IN CONST EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath,
> + IN BOOLEAN BootOption
> + )
> +{
> + DEFERRED_3RD_PARTY_IMAGE_INFO *ImageInfo;
> +
> + //
> + // Expand memory for the new deferred image.
> + //
> + ImageInfo = ReallocatePool (
> + mDeferred3rdPartyImage.Count * sizeof
> (DEFERRED_3RD_PARTY_IMAGE_INFO),
> + (mDeferred3rdPartyImage.Count + 1) * sizeof
> (DEFERRED_3RD_PARTY_IMAGE_INFO),
> + mDeferred3rdPartyImage.ImageInfo
> + );
> + if (ImageInfo == NULL) {
> + return;
> + }
> + mDeferred3rdPartyImage.ImageInfo = ImageInfo;
> +
> + //
> + // Save the deferred image information.
> + //
> + ImageInfo =
> &mDeferred3rdPartyImage.ImageInfo[mDeferred3rdPartyImage.Count];
> + ImageInfo->ImageDevicePath = DuplicateDevicePath (ImageDevicePath);
> + if (ImageInfo->ImageDevicePath == NULL) {
> + return;
> + }
> + ImageInfo->BootOption = BootOption;
> + ImageInfo->Loaded = FALSE;
> + mDeferred3rdPartyImage.Count++;
> +}
> +
> +
> +/**
> + Returns information about a deferred image.
> +
> + This function returns information about a single deferred image. The
> deferred images are
> + numbered consecutively, starting with 0. If there is no image which
> corresponds to
> + ImageIndex, then EFI_NOT_FOUND is returned. All deferred images may
> be returned by
> + iteratively calling this function until EFI_NOT_FOUND is returned.
> + Image may be NULL and ImageSize set to 0 if the decision to defer
> execution was made
> + because of the location of the executable image, rather than its actual
> contents.
> +
> + @param[in] This Points to this instance of the
> EFI_DEFERRED_IMAGE_LOAD_PROTOCOL.
> + @param[in] ImageIndex Zero-based index of the deferred index.
> + @param[out] ImageDevicePath On return, points to a pointer to the
> device path of the image.
> + The device path should not be freed by the caller.
> + @param[out] Image On return, points to the first byte of the image
> or NULL if the
> + image is not available. The image should not be freed by the
> caller
> + unless LoadImage() has been successfully called.
> + @param[out] ImageSize On return, the size of the image, or 0 if the
> image is not available.
> + @param[out] BootOption On return, points to TRUE if the image was
> intended as a boot option
> + or FALSE if it was not intended as a boot option.
> +
> + @retval EFI_SUCCESS Image information returned successfully.
> + @retval EFI_NOT_FOUND ImageIndex does not refer to a valid image.
> + @retval EFI_INVALID_PARAMETER ImageDevicePath is NULL or Image is
> NULL or ImageSize is NULL or
> + BootOption is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +GetDefferedImageInfo (
> + IN EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *This,
> + IN UINTN ImageIndex,
> + OUT EFI_DEVICE_PATH_PROTOCOL **ImageDevicePath,
> + OUT VOID **Image,
> + OUT UINTN *ImageSize,
> + OUT BOOLEAN *BootOption
> + )
> +{
> + UINTN Index;
> + UINTN NewCount;
> +
> + if ((This == NULL) || (ImageSize == NULL) || (Image == NULL)) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if ((ImageDevicePath == NULL) || (BootOption == NULL)) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + //
> + // Remove the loaded images from the defer list in the first call.
> + //
> + if (ImageIndex == 0) {
> + NewCount = 0;
> + for (Index = 0; Index < mDeferred3rdPartyImage.Count; Index++) {
> + if (!mDeferred3rdPartyImage.ImageInfo[Index].Loaded) {
> + CopyMem (
> + &mDeferred3rdPartyImage.ImageInfo[NewCount],
> + &mDeferred3rdPartyImage.ImageInfo[Index],
> + sizeof (DEFERRED_3RD_PARTY_IMAGE_INFO)
> + );
> + NewCount++;
> + }
> + }
> +
> + mDeferred3rdPartyImage.Count = NewCount;
> + }
> +
> + if (ImageIndex >= mDeferred3rdPartyImage.Count) {
> + return EFI_NOT_FOUND;
> + }
> +
> + //
> + // Get the request deferred image.
> + //
> + *ImageDevicePath =
> mDeferred3rdPartyImage.ImageInfo[ImageIndex].ImageDevicePath;
> + *BootOption =
> mDeferred3rdPartyImage.ImageInfo[ImageIndex].BootOption;
> + *Image = NULL;
> + *ImageSize = 0;
> +
> + return EFI_SUCCESS;
> +}
> +
> +/**
> + Callback function executed when the EndOfDxe event group is signaled.
> +
> + @param[in] Event Event whose notification function is being invoked.
> + @param[in] Context The pointer to the notification function's context,
> which
> + is implementation-dependent.
> +**/
> +VOID
> +EFIAPI
> +EndOfDxe (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + mEndOfDxe = TRUE;
> +}
> +
> +/**
> + Defer the 3rd party image load and installs Deferred Image Load Protocol.
> +
> + @param[in] File This is a pointer to the device path of the file that
> + is being dispatched. This will optionally be used for
> + logging.
> + @param[in] BootPolicy A boot policy that was used to call
> LoadImage() UEFI service.
> +
> + @retval EFI_SUCCESS The file is not 3rd party image and can be
> loaded immediately.
> + @retval EFI_ACCESS_DENIED The file is 3rd party image and needs
> deferred.
> +**/
> +EFI_STATUS
> +Defer3rdPartyImageLoad (
> + IN CONST EFI_DEVICE_PATH_PROTOCOL *File,
> + IN BOOLEAN BootPolicy
> + )
> +{
> + DEFERRED_3RD_PARTY_IMAGE_INFO *ImageInfo;
> +
> + //
> + // Ignore if File is NULL.
> + //
> + if (File == NULL) {
> + return EFI_SUCCESS;
> + }
> +
> + if (FileFromFv (File)) {
> + return EFI_SUCCESS;
> + }
> +
> + ImageInfo = LookupImage (File, BootPolicy);
> +
> + DEBUG_CODE (
> + CHAR16 *DevicePathStr;
> + DevicePathStr = ConvertDevicePathToText (File, FALSE, FALSE);
> + DEBUG ((
> + DEBUG_INFO,
> + "[Security] 3rd party image[%p] %s EndOfDxe: %s.\n", ImageInfo,
> + mEndOfDxe ? L"can be loaded after": L"is deferred to load before",
> + DevicePathStr
> + ));
> + if (DevicePathStr != NULL) {
> + FreePool (DevicePathStr);
> + }
> + );
> +
> + if (mEndOfDxe) {
> + //
> + // The image might be first time loaded after EndOfDxe,
> + // So ImageInfo can be NULL.
> + //
> + if (ImageInfo != NULL) {
> + ImageInfo->Loaded = TRUE;
> + }
> + return EFI_SUCCESS;
> + } else {
> + //
> + // The image might be second time loaded before EndOfDxe,
> + // So ImageInfo can be non-NULL.
> + //
> + if (ImageInfo == NULL) {
> + QueueImage (File, BootPolicy);
> + }
> + return EFI_ACCESS_DENIED;
> + }
> +}
> +
> +/**
> + Installs DeferredImageLoad Protocol and listens EndOfDxe event.
> +**/
> +VOID
> +Defer3rdPartyImageLoadInitialize (
> + VOID
> + )
> +{
> + EFI_STATUS Status;
> + EFI_HANDLE Handle;
> + EFI_EVENT Event;
> +
> + Handle = NULL;
> + Status = gBS->InstallMultipleProtocolInterfaces (
> + &Handle,
> + &gEfiDeferredImageLoadProtocolGuid,
> + &mDeferredImageLoad,
> + NULL
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + TPL_CALLBACK,
> + EndOfDxe,
> + NULL,
> + &gEfiEndOfDxeEventGroupGuid,
> + &Event
> + );
> + ASSERT_EFI_ERROR (Status);
> +}
> diff --git
> a/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.h
> b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.h
> new file mode 100644
> index 0000000..3fab258
> --- /dev/null
> +++
> b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.h
> @@ -0,0 +1,92 @@
> +/** @file
> + Implement defer image load services for user identification in UEFI2.2.
> +
> +Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> +This program and the accompanying materials
> +are licensed and made available under the terms and conditions of the BSD
> License
> +which accompanies this distribution. The full text of the license may be
> found at
> +http://opensource.org/licenses/bsd-license.php
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef _DEFER_3RD_PARTY_IMAGE_LOAD_H_
> +#define _DEFER_3RD_PARTY_IMAGE_LOAD_H_
> +
> +#include <Uefi.h>
> +#include <Guid/EventGroup.h>
> +#include <Protocol/DeferredImageLoad.h>
> +#include <Protocol/FirmwareVolume2.h>
> +
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/DevicePathLib.h>
> +#include <Library/DebugLib.h>
> +
> +/**
> + Returns information about a deferred image.
> +
> + This function returns information about a single deferred image. The
> deferred images are
> + numbered consecutively, starting with 0. If there is no image which
> corresponds to
> + ImageIndex, then EFI_NOT_FOUND is returned. All deferred images may
> be returned by
> + iteratively calling this function until EFI_NOT_FOUND is returned.
> + Image may be NULL and ImageSize set to 0 if the decision to defer
> execution was made
> + because of the location of the executable image, rather than its actual
> contents.
> +
> + @param[in] This Points to this instance of the
> EFI_DEFERRED_IMAGE_LOAD_PROTOCOL.
> + @param[in] ImageIndex Zero-based index of the deferred index.
> + @param[out] ImageDevicePath On return, points to a pointer to the
> device path of the image.
> + The device path should not be freed by the caller.
> + @param[out] Image On return, points to the first byte of the image
> or NULL if the
> + image is not available. The image should not be freed by the
> caller
> + unless LoadImage() has been successfully called.
> + @param[out] ImageSize On return, the size of the image, or 0 if the
> image is not available.
> + @param[out] BootOption On return, points to TRUE if the image was
> intended as a boot option
> + or FALSE if it was not intended as a boot option.
> +
> + @retval EFI_SUCCESS Image information returned successfully.
> + @retval EFI_NOT_FOUND ImageIndex does not refer to a valid image.
> + @retval EFI_INVALID_PARAMETER ImageDevicePath is NULL or Image is
> NULL or ImageSize is NULL or
> + BootOption is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +GetDefferedImageInfo (
> + IN EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *This,
> + IN UINTN ImageIndex,
> + OUT EFI_DEVICE_PATH_PROTOCOL **ImageDevicePath,
> + OUT VOID **Image,
> + OUT UINTN *ImageSize,
> + OUT BOOLEAN *BootOption
> + );
> +
> +/**
> + Defer the 3rd party image load and installs Deferred Image Load Protocol.
> +
> + @param[in] File This is a pointer to the device path of the file that
> + is being dispatched. This will optionally be used for
> + logging.
> + @param[in] BootPolicy A boot policy that was used to call
> LoadImage() UEFI service.
> +
> + @retval EFI_SUCCESS The file is not 3rd party image and can be
> loaded immediately.
> + @retval EFI_ACCESS_DENIED The file is 3rd party image and needs
> deferred.
> +**/
> +EFI_STATUS
> +Defer3rdPartyImageLoad (
> + IN CONST EFI_DEVICE_PATH_PROTOCOL *File,
> + IN BOOLEAN BootPolicy
> + );
> +
> +/**
> + Installs DeferredImageLoad Protocol and listens EndOfDxe event.
> +**/
> +VOID
> +Defer3rdPartyImageLoadInitialize (
> + VOID
> + );
> +
> +#endif
> diff --git a/MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.c
> b/MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.c
> index 22e6c7f..a75d8dc 100644
> --- a/MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.c
> +++ b/MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.c
> @@ -1,7 +1,7 @@
> /** @file
> This driver produces Security2 and Security architectural protocol based on
> SecurityManagementLib.
>
> - Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD
> License
> which accompanies this distribution. The full text of the license may be
> found at
> @@ -20,6 +20,7 @@
> #include <Library/UefiBootServicesTableLib.h>
> #include <Library/UefiDriverEntryPoint.h>
> #include <Library/SecurityManagementLib.h>
> +#include "Defer3rdPartyImageLoad.h"
>
> //
> // Handle for the Security Architectural Protocol instance produced by this
> driver
> @@ -140,6 +141,15 @@ Security2StubAuthenticate (
> IN BOOLEAN BootPolicy
> )
> {
> + EFI_STATUS Status;
> +
> + if (FileBuffer != NULL) {
> + Status = Defer3rdPartyImageLoad (File, BootPolicy);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> + }
> +
> return ExecuteSecurity2Handlers (EFI_AUTH_OPERATION_VERIFY_IMAGE
> |
> EFI_AUTH_OPERATION_DEFER_IMAGE_LOAD |
> EFI_AUTH_OPERATION_MEASURE_IMAGE |
> @@ -200,5 +210,7 @@ SecurityStubInitialize (
> );
> ASSERT_EFI_ERROR (Status);
>
> + Defer3rdPartyImageLoadInitialize ();
> +
> return EFI_SUCCESS;
> }
> diff --git a/MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
> b/MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
> index 9d1c7b8..be6ce6c 100644
> --- a/MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
> +++ b/MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
> @@ -1,7 +1,7 @@
> ## @file
> # This driver produces security2 and security architectural protocol based on
> SecurityManagementLib.
> #
> -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the
> BSD License
> # which accompanies this distribution. The full text of the license may be
> found at
> @@ -29,6 +29,8 @@ [Defines]
>
> [Sources]
> SecurityStub.c
> + Defer3rdPartyImageLoad.c
> + Defer3rdPartyImageLoad.h
>
> [Packages]
> MdePkg/MdePkg.dec
> @@ -40,9 +42,13 @@ [LibraryClasses]
> DebugLib
> SecurityManagementLib
>
> +[Guids]
> + gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event
> +
> [Protocols]
> gEfiSecurityArchProtocolGuid ## PRODUCES
> gEfiSecurity2ArchProtocolGuid ## PRODUCES
> + gEfiDeferredImageLoadProtocolGuid ## PRODUCES
>
> [Depex]
> TRUE
> --
> 2.9.0.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 2/9] MdeModulePkg/UefiBootManager: Add EfiBootManagerDispatchDeferredImages
2016-11-08 12:29 [PATCH v2 0/9] Defer 3rd party images loading to after EndOfDxe Ruiyu Ni
2016-11-08 12:29 ` [PATCH v2 1/9] MdeModulePkg/SecurityStubDxe: Defer 3rd party image before EndOfDxe Ruiyu Ni
@ 2016-11-08 12:29 ` Ruiyu Ni
2016-11-08 14:11 ` Zhang, Chao B
` (2 more replies)
2016-11-08 12:29 ` [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before booting to OS Ruiyu Ni
` (7 subsequent siblings)
9 siblings, 3 replies; 25+ messages in thread
From: Ruiyu Ni @ 2016-11-08 12:29 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Chao B Zhang
The API dispatches the deferred images that are returned from all
DeferredImageLoad instances.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
---
MdeModulePkg/Include/Library/UefiBootManagerLib.h | 13 +++
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 113 +++++++++++++++++++++
.../Library/UefiBootManagerLib/InternalBm.h | 1 +
.../UefiBootManagerLib/UefiBootManagerLib.inf | 1 +
4 files changed, 128 insertions(+)
diff --git a/MdeModulePkg/Include/Library/UefiBootManagerLib.h b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
index e333ffd..97ac1f2 100644
--- a/MdeModulePkg/Include/Library/UefiBootManagerLib.h
+++ b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
@@ -777,4 +777,17 @@ EfiBootManagerIsValidLoadOptionVariableName (
OUT UINT16 *OptionNumber OPTIONAL
);
+
+/**
+ Dispatch the deferred images that are returned from all DeferredImageLoad instances.
+
+ @retval EFI_SUCCESS At least one deferred image is loaded successfully and started.
+ @retval EFI_NOT_FOUND There is no deferred image.
+ @retval EFI_ACCESS_DENIED There are deferred images but all of them are failed to load.
+**/
+EFI_STATUS
+EFIAPI
+EfiBootManagerDispatchDeferredImages (
+ VOID
+ );
#endif
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
index 2a60f06..09e4211 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
@@ -417,3 +417,116 @@ BmCharToUint (
return (UINTN) -1;
}
+/**
+ Dispatch the deferred images that are returned from all DeferredImageLoad instances.
+
+ @retval EFI_SUCCESS At least one deferred image is loaded successfully and started.
+ @retval EFI_NOT_FOUND There is no deferred image.
+ @retval EFI_ACCESS_DENIED There are deferred images but all of them are failed to load.
+**/
+EFI_STATUS
+EFIAPI
+EfiBootManagerDispatchDeferredImages (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ UINTN Index;
+ UINTN ImageIndex;
+ EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
+ VOID *Image;
+ UINTN ImageSize;
+ BOOLEAN BootOption;
+ EFI_HANDLE ImageHandle;
+ UINTN ExitDataSize;
+ CHAR16 *ExitData;
+ UINTN ImageCount;
+ UINTN LoadCount;
+
+ //
+ // Find all the deferred image load protocols.
+ //
+ HandleCount = 0;
+ Handles = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiDeferredImageLoadProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_FOUND;
+ }
+
+ ImageCount = 0;
+ LoadCount = 0;
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->HandleProtocol (Handles[Index], &gEfiDeferredImageLoadProtocolGuid, (VOID **) &DeferredImage);
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ for (ImageIndex = 0; ;ImageIndex++) {
+ //
+ // Load all the deferred images in this protocol instance.
+ //
+ Status = DeferredImage->GetImageInfo (
+ DeferredImage,
+ ImageIndex,
+ &ImageDevicePath,
+ (VOID **) &Image,
+ &ImageSize,
+ &BootOption
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ ImageCount++;
+ //
+ // Load and start the image.
+ //
+ Status = gBS->LoadImage (
+ BootOption,
+ gImageHandle,
+ ImageDevicePath,
+ NULL,
+ 0,
+ &ImageHandle
+ );
+ if (!EFI_ERROR (Status)) {
+ LoadCount++;
+ //
+ // Before calling the image, enable the Watchdog Timer for
+ // a 5 Minute period
+ //
+ gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);
+ Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);
+ if (ExitData != NULL) {
+ FreePool (ExitData);
+ }
+
+ //
+ // Clear the Watchdog Timer after the image returns.
+ //
+ gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);
+ }
+ }
+ }
+ if (Handles != NULL) {
+ FreePool (Handles);
+ }
+
+ if (ImageCount == 0) {
+ return EFI_NOT_FOUND;
+ } else {
+ if (LoadCount == 0) {
+ return EFI_ACCESS_DENIED;
+ } else {
+ return EFI_SUCCESS;
+ }
+ }
+}
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
index cb719e9..444d4a5 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
+++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
@@ -44,6 +44,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/FormBrowser2.h>
#include <Protocol/VariableLock.h>
#include <Protocol/RamDisk.h>
+#include <Protocol/DeferredImageLoad.h>
#include <Guid/MemoryTypeInformation.h>
#include <Guid/FileInfo.h>
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
index 8c3fd7f..bb7c00d 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+++ b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
@@ -109,6 +109,7 @@ [Protocols]
gEfiDriverHealthProtocolGuid ## SOMETIMES_CONSUMES
gEfiFormBrowser2ProtocolGuid ## SOMETIMES_CONSUMES
gEfiRamDiskProtocolGuid ## SOMETIMES_CONSUMES
+ gEfiDeferredImageLoadProtocolGuid ## CONSUMES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange ## SOMETIMES_CONSUMES
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v2 2/9] MdeModulePkg/UefiBootManager: Add EfiBootManagerDispatchDeferredImages
2016-11-08 12:29 ` [PATCH v2 2/9] MdeModulePkg/UefiBootManager: Add EfiBootManagerDispatchDeferredImages Ruiyu Ni
@ 2016-11-08 14:11 ` Zhang, Chao B
2016-11-10 5:52 ` Wang, Sunny (HPS SW)
2016-11-10 6:01 ` Gao, Liming
2 siblings, 0 replies; 25+ messages in thread
From: Zhang, Chao B @ 2016-11-08 14:11 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Gao, Liming
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
Thanks & Best regards
Chao Zhang
-----Original Message-----
From: Ni, Ruiyu
Sent: Tuesday, November 08, 2016 8:29 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming; Zhang, Chao B
Subject: [PATCH v2 2/9] MdeModulePkg/UefiBootManager: Add EfiBootManagerDispatchDeferredImages
The API dispatches the deferred images that are returned from all
DeferredImageLoad instances.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
---
MdeModulePkg/Include/Library/UefiBootManagerLib.h | 13 +++
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 113 +++++++++++++++++++++
.../Library/UefiBootManagerLib/InternalBm.h | 1 +
.../UefiBootManagerLib/UefiBootManagerLib.inf | 1 +
4 files changed, 128 insertions(+)
diff --git a/MdeModulePkg/Include/Library/UefiBootManagerLib.h b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
index e333ffd..97ac1f2 100644
--- a/MdeModulePkg/Include/Library/UefiBootManagerLib.h
+++ b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
@@ -777,4 +777,17 @@ EfiBootManagerIsValidLoadOptionVariableName (
OUT UINT16 *OptionNumber OPTIONAL
);
+
+/**
+ Dispatch the deferred images that are returned from all DeferredImageLoad instances.
+
+ @retval EFI_SUCCESS At least one deferred image is loaded successfully and started.
+ @retval EFI_NOT_FOUND There is no deferred image.
+ @retval EFI_ACCESS_DENIED There are deferred images but all of them are failed to load.
+**/
+EFI_STATUS
+EFIAPI
+EfiBootManagerDispatchDeferredImages (
+ VOID
+ );
#endif
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
index 2a60f06..09e4211 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
@@ -417,3 +417,116 @@ BmCharToUint (
return (UINTN) -1;
}
+/**
+ Dispatch the deferred images that are returned from all DeferredImageLoad instances.
+
+ @retval EFI_SUCCESS At least one deferred image is loaded successfully and started.
+ @retval EFI_NOT_FOUND There is no deferred image.
+ @retval EFI_ACCESS_DENIED There are deferred images but all of them are failed to load.
+**/
+EFI_STATUS
+EFIAPI
+EfiBootManagerDispatchDeferredImages (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ UINTN Index;
+ UINTN ImageIndex;
+ EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
+ VOID *Image;
+ UINTN ImageSize;
+ BOOLEAN BootOption;
+ EFI_HANDLE ImageHandle;
+ UINTN ExitDataSize;
+ CHAR16 *ExitData;
+ UINTN ImageCount;
+ UINTN LoadCount;
+
+ //
+ // Find all the deferred image load protocols.
+ //
+ HandleCount = 0;
+ Handles = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiDeferredImageLoadProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_FOUND;
+ }
+
+ ImageCount = 0;
+ LoadCount = 0;
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->HandleProtocol (Handles[Index], &gEfiDeferredImageLoadProtocolGuid, (VOID **) &DeferredImage);
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ for (ImageIndex = 0; ;ImageIndex++) {
+ //
+ // Load all the deferred images in this protocol instance.
+ //
+ Status = DeferredImage->GetImageInfo (
+ DeferredImage,
+ ImageIndex,
+ &ImageDevicePath,
+ (VOID **) &Image,
+ &ImageSize,
+ &BootOption
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ ImageCount++;
+ //
+ // Load and start the image.
+ //
+ Status = gBS->LoadImage (
+ BootOption,
+ gImageHandle,
+ ImageDevicePath,
+ NULL,
+ 0,
+ &ImageHandle
+ );
+ if (!EFI_ERROR (Status)) {
+ LoadCount++;
+ //
+ // Before calling the image, enable the Watchdog Timer for
+ // a 5 Minute period
+ //
+ gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);
+ Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);
+ if (ExitData != NULL) {
+ FreePool (ExitData);
+ }
+
+ //
+ // Clear the Watchdog Timer after the image returns.
+ //
+ gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);
+ }
+ }
+ }
+ if (Handles != NULL) {
+ FreePool (Handles);
+ }
+
+ if (ImageCount == 0) {
+ return EFI_NOT_FOUND;
+ } else {
+ if (LoadCount == 0) {
+ return EFI_ACCESS_DENIED;
+ } else {
+ return EFI_SUCCESS;
+ }
+ }
+}
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
index cb719e9..444d4a5 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
+++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
@@ -44,6 +44,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/FormBrowser2.h>
#include <Protocol/VariableLock.h>
#include <Protocol/RamDisk.h>
+#include <Protocol/DeferredImageLoad.h>
#include <Guid/MemoryTypeInformation.h>
#include <Guid/FileInfo.h>
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
index 8c3fd7f..bb7c00d 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+++ b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
@@ -109,6 +109,7 @@ [Protocols]
gEfiDriverHealthProtocolGuid ## SOMETIMES_CONSUMES
gEfiFormBrowser2ProtocolGuid ## SOMETIMES_CONSUMES
gEfiRamDiskProtocolGuid ## SOMETIMES_CONSUMES
+ gEfiDeferredImageLoadProtocolGuid ## CONSUMES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange ## SOMETIMES_CONSUMES
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v2 2/9] MdeModulePkg/UefiBootManager: Add EfiBootManagerDispatchDeferredImages
2016-11-08 12:29 ` [PATCH v2 2/9] MdeModulePkg/UefiBootManager: Add EfiBootManagerDispatchDeferredImages Ruiyu Ni
2016-11-08 14:11 ` Zhang, Chao B
@ 2016-11-10 5:52 ` Wang, Sunny (HPS SW)
2016-11-10 6:01 ` Gao, Liming
2 siblings, 0 replies; 25+ messages in thread
From: Wang, Sunny (HPS SW) @ 2016-11-10 5:52 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel@lists.01.org
Cc: Chao B Zhang, Liming Gao, Wang, Sunny (HPS SW), Haskell, Darrell
[-- Attachment #1: Type: text/plain, Size: 7206 bytes --]
Thanks for addressing my offline comments. This patch looks good to me.
Reviewed-by: Sunny Wang <sunnywang@hpe.com>
Regards,
Sunny Wang
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Tuesday, November 08, 2016 8:29 PM
To: edk2-devel@lists.01.org
Cc: Chao B Zhang <chao.b.zhang@intel.com>; Liming Gao <liming.gao@intel.com>
Subject: [edk2] [PATCH v2 2/9] MdeModulePkg/UefiBootManager: Add EfiBootManagerDispatchDeferredImages
The API dispatches the deferred images that are returned from all DeferredImageLoad instances.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
---
MdeModulePkg/Include/Library/UefiBootManagerLib.h | 13 +++
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 113 +++++++++++++++++++++
.../Library/UefiBootManagerLib/InternalBm.h | 1 +
.../UefiBootManagerLib/UefiBootManagerLib.inf | 1 +
4 files changed, 128 insertions(+)
diff --git a/MdeModulePkg/Include/Library/UefiBootManagerLib.h b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
index e333ffd..97ac1f2 100644
--- a/MdeModulePkg/Include/Library/UefiBootManagerLib.h
+++ b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
@@ -777,4 +777,17 @@ EfiBootManagerIsValidLoadOptionVariableName (
OUT UINT16 *OptionNumber OPTIONAL
);
+
+/**
+ Dispatch the deferred images that are returned from all DeferredImageLoad instances.
+
+ @retval EFI_SUCCESS At least one deferred image is loaded successfully and started.
+ @retval EFI_NOT_FOUND There is no deferred image.
+ @retval EFI_ACCESS_DENIED There are deferred images but all of them are failed to load.
+**/
+EFI_STATUS
+EFIAPI
+EfiBootManagerDispatchDeferredImages (
+ VOID
+ );
#endif
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
index 2a60f06..09e4211 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
@@ -417,3 +417,116 @@ BmCharToUint (
return (UINTN) -1;
}
+/**
+ Dispatch the deferred images that are returned from all DeferredImageLoad instances.
+
+ @retval EFI_SUCCESS At least one deferred image is loaded successfully and started.
+ @retval EFI_NOT_FOUND There is no deferred image.
+ @retval EFI_ACCESS_DENIED There are deferred images but all of them are failed to load.
+**/
+EFI_STATUS
+EFIAPI
+EfiBootManagerDispatchDeferredImages (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ UINTN Index;
+ UINTN ImageIndex;
+ EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
+ VOID *Image;
+ UINTN ImageSize;
+ BOOLEAN BootOption;
+ EFI_HANDLE ImageHandle;
+ UINTN ExitDataSize;
+ CHAR16 *ExitData;
+ UINTN ImageCount;
+ UINTN LoadCount;
+
+ //
+ // Find all the deferred image load protocols.
+ //
+ HandleCount = 0;
+ Handles = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiDeferredImageLoadProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_FOUND;
+ }
+
+ ImageCount = 0;
+ LoadCount = 0;
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->HandleProtocol (Handles[Index], &gEfiDeferredImageLoadProtocolGuid, (VOID **) &DeferredImage);
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ for (ImageIndex = 0; ;ImageIndex++) {
+ //
+ // Load all the deferred images in this protocol instance.
+ //
+ Status = DeferredImage->GetImageInfo (
+ DeferredImage,
+ ImageIndex,
+ &ImageDevicePath,
+ (VOID **) &Image,
+ &ImageSize,
+ &BootOption
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ ImageCount++;
+ //
+ // Load and start the image.
+ //
+ Status = gBS->LoadImage (
+ BootOption,
+ gImageHandle,
+ ImageDevicePath,
+ NULL,
+ 0,
+ &ImageHandle
+ );
+ if (!EFI_ERROR (Status)) {
+ LoadCount++;
+ //
+ // Before calling the image, enable the Watchdog Timer for
+ // a 5 Minute period
+ //
+ gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);
+ Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);
+ if (ExitData != NULL) {
+ FreePool (ExitData);
+ }
+
+ //
+ // Clear the Watchdog Timer after the image returns.
+ //
+ gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);
+ }
+ }
+ }
+ if (Handles != NULL) {
+ FreePool (Handles);
+ }
+
+ if (ImageCount == 0) {
+ return EFI_NOT_FOUND;
+ } else {
+ if (LoadCount == 0) {
+ return EFI_ACCESS_DENIED;
+ } else {
+ return EFI_SUCCESS;
+ }
+ }
+}
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
index cb719e9..444d4a5 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
+++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
@@ -44,6 +44,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/FormBrowser2.h>
#include <Protocol/VariableLock.h>
#include <Protocol/RamDisk.h>
+#include <Protocol/DeferredImageLoad.h>
#include <Guid/MemoryTypeInformation.h> #include <Guid/FileInfo.h> diff --git a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
index 8c3fd7f..bb7c00d 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+++ b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
@@ -109,6 +109,7 @@ [Protocols]
gEfiDriverHealthProtocolGuid ## SOMETIMES_CONSUMES
gEfiFormBrowser2ProtocolGuid ## SOMETIMES_CONSUMES
gEfiRamDiskProtocolGuid ## SOMETIMES_CONSUMES
+ gEfiDeferredImageLoadProtocolGuid ## CONSUMES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange ## SOMETIMES_CONSUMES
--
2.9.0.windows.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
[-- Attachment #2: Type: message/rfc822, Size: 14762 bytes --]
From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: "Wang, Sunny (HPS SW)" <sunnywang@hpe.com>
Cc: "Haskell, Darrell" <darrell.haskell@hpe.com>
Subject: RE: [edk2] [PATCH 2/4] MdeModulePkg/UefiBootManager: Add EfiBootManagerDispatchDeferredImages
Date: Mon, 7 Nov 2016 02:37:59 +0000
Message-ID: <734D49CCEBEEF84792F5B80ED585239D58E5679E@SHSMSX104.ccr.corp.intel.com>
Thanks/Ray
> -----Original Message-----
> From: Wang, Sunny (HPS SW) [mailto:sunnywang@hpe.com]
> Sent: Friday, November 4, 2016 7:42 PM
> To: Ni, Ruiyu <ruiyu.ni@intel.com>
> Cc: Wang, Sunny (HPS SW) <sunnywang@hpe.com>; Haskell, Darrell
> <darrell.haskell@hpe.com>
> Subject: RE: [edk2] [PATCH 2/4] MdeModulePkg/UefiBootManager: Add
> EfiBootManagerDispatchDeferredImages
>
> Hi Ray,
> Remove others. Feel free to add some people back.
> EfiBootManagerDispatchDeferredImages () is almost the same as
> LoadDeferredImage () in UserIdentifyManagerDxe\LoadDeferredImage.c, so
> It looks good to me.
> However, I still have a question from my curiosity. Why don't you just simply
> call USER_MANAGER_PROTOCOL->Identify to trigger LoadDeferredImage()
> right after signaling EndOfDxe in platform BDS code instead of this patch
> series?
UID (User Identification) is a standalone feature and I don't think it is
actively used by the industry. I don't want to combine this feature with
the UID.
>
> By the way, besides the question above, I still have two minor questions
> below, but I think I will see the answer when you send your platform patch.
> 1. Will EfiBootManagerDispatchDeferredImages() only be consumed/called
> by BDS platform code? In other words, we will not call
> EfiBootManagerDispatchDeferredImages() in BdsDxe module, right?
Yes It has to be called from PlatformBDS because it should be called after
platform signals the EndOfDxe event (and Install ReadyToLock protocol).
> 2. Since EfiBootManagerDispatchDeferredImages() is almost the same as
> LoadDeferredImage(), will you remove LoadDeferredImage() from
> UserIdentifyManagerDxe module and call this new API right after calling
> USER_MANAGER_PROTOCOL->Identify in BDS platform code instead?
Sounds like a good idea. I will do it after this patches are committed.
>
> Regards,
> Sunny Wang
>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Friday, November 04, 2016 9:00 AM
> To: edk2-devel@lists.01.org
> Cc: Chao B Zhang <chao.b.zhang@intel.com>; Liming Gao
> <liming.gao@intel.com>
> Subject: [edk2] [PATCH 2/4] MdeModulePkg/UefiBootManager: Add
> EfiBootManagerDispatchDeferredImages
>
> The API dispatches the deferred images that are returned from all
> DeferredImageLoad instances.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Chao B Zhang <chao.b.zhang@intel.com>
> ---
> MdeModulePkg/Include/Library/UefiBootManagerLib.h | 13 +++
> MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 113
> +++++++++++++++++++++
> .../Library/UefiBootManagerLib/InternalBm.h | 1 +
> .../UefiBootManagerLib/UefiBootManagerLib.inf | 1 +
> 4 files changed, 128 insertions(+)
>
> diff --git a/MdeModulePkg/Include/Library/UefiBootManagerLib.h
> b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
> index e333ffd..97ac1f2 100644
> --- a/MdeModulePkg/Include/Library/UefiBootManagerLib.h
> +++ b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
> @@ -777,4 +777,17 @@ EfiBootManagerIsValidLoadOptionVariableName (
> OUT UINT16 *OptionNumber OPTIONAL
> );
>
> +
> +/**
> + Dispatch the deferred images that are returned from all
> DeferredImageLoad instances.
> +
> + @retval EFI_SUCCESS At least one deferred image is loaded successfully
> and started.
> + @retval EFI_NOT_FOUND There is no deferred image.
> + @retval EFI_ACCESS_DENIED There are deferred images but all of them
> are failed to load.
> +**/
> +EFI_STATUS
> +EFIAPI
> +EfiBootManagerDispatchDeferredImages (
> + VOID
> + );
> #endif
> diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
> b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
> index 2a60f06..09e4211 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
> +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
> @@ -417,3 +417,116 @@ BmCharToUint (
> return (UINTN) -1;
> }
>
> +/**
> + Dispatch the deferred images that are returned from all
> DeferredImageLoad instances.
> +
> + @retval EFI_SUCCESS At least one deferred image is loaded successfully
> and started.
> + @retval EFI_NOT_FOUND There is no deferred image.
> + @retval EFI_ACCESS_DENIED There are deferred images but all of them
> are failed to load.
> +**/
> +EFI_STATUS
> +EFIAPI
> +EfiBootManagerDispatchDeferredImages (
> + VOID
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;
> + UINTN HandleCount;
> + EFI_HANDLE *Handles;
> + UINTN Index;
> + UINTN ImageIndex;
> + EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
> + VOID *Image;
> + UINTN ImageSize;
> + BOOLEAN BootOption;
> + EFI_HANDLE ImageHandle;
> + UINTN ExitDataSize;
> + CHAR16 *ExitData;
> + UINTN ImageCount;
> + UINTN LoadCount;
> +
> + //
> + // Find all the deferred image load protocols.
> + //
> + HandleCount = 0;
> + Handles = NULL;
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiDeferredImageLoadProtocolGuid,
> + NULL,
> + &HandleCount,
> + &Handles
> + );
> + if (EFI_ERROR (Status)) {
> + return EFI_NOT_FOUND;
> + }
> +
> + ImageCount = 0;
> + LoadCount = 0;
> + for (Index = 0; Index < HandleCount; Index++) {
> + Status = gBS->HandleProtocol (Handles[Index],
> &gEfiDeferredImageLoadProtocolGuid, (VOID **) &DeferredImage);
> + if (EFI_ERROR (Status)) {
> + continue;
> + }
> +
> + for (ImageIndex = 0; ;ImageIndex++) {
> + //
> + // Load all the deferred images in this protocol instance.
> + //
> + Status = DeferredImage->GetImageInfo (
> + DeferredImage,
> + ImageIndex,
> + &ImageDevicePath,
> + (VOID **) &Image,
> + &ImageSize,
> + &BootOption
> + );
> + if (EFI_ERROR (Status)) {
> + break;
> + }
> + ImageCount++;
> + //
> + // Load and start the image.
> + //
> + Status = gBS->LoadImage (
> + BootOption,
> + gImageHandle,
> + ImageDevicePath,
> + NULL,
> + 0,
> + &ImageHandle
> + );
> + if (!EFI_ERROR (Status)) {
> + LoadCount++;
> + //
> + // Before calling the image, enable the Watchdog Timer for
> + // a 5 Minute period
> + //
> + gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);
> + Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);
> + if (ExitData != NULL) {
> + FreePool (ExitData);
> + }
> +
> + //
> + // Clear the Watchdog Timer after the image returns.
> + //
> + gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);
> + }
> + }
> + }
> + if (Handles != NULL) {
> + FreePool (Handles);
> + }
> +
> + if (ImageCount == 0) {
> + return EFI_NOT_FOUND;
> + } else {
> + if (LoadCount == 0) {
> + return EFI_ACCESS_DENIED;
> + } else {
> + return EFI_SUCCESS;
> + }
> + }
> +}
> diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
> b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
> index cb719e9..444d4a5 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
> +++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
> @@ -44,6 +44,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
> #include <Protocol/FormBrowser2.h>
> #include <Protocol/VariableLock.h>
> #include <Protocol/RamDisk.h>
> +#include <Protocol/DeferredImageLoad.h>
>
> #include <Guid/MemoryTypeInformation.h> #include <Guid/FileInfo.h>
> diff --git
> a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> index 8c3fd7f..bb7c00d 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> +++
> b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> @@ -109,6 +109,7 @@ [Protocols]
> gEfiDriverHealthProtocolGuid ## SOMETIMES_CONSUMES
> gEfiFormBrowser2ProtocolGuid ## SOMETIMES_CONSUMES
> gEfiRamDiskProtocolGuid ## SOMETIMES_CONSUMES
> + gEfiDeferredImageLoadProtocolGuid ## CONSUMES
>
> [Pcd]
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationC
> hange ## SOMETIMES_CONSUMES
> --
> 2.9.0.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v2 2/9] MdeModulePkg/UefiBootManager: Add EfiBootManagerDispatchDeferredImages
2016-11-08 12:29 ` [PATCH v2 2/9] MdeModulePkg/UefiBootManager: Add EfiBootManagerDispatchDeferredImages Ruiyu Ni
2016-11-08 14:11 ` Zhang, Chao B
2016-11-10 5:52 ` Wang, Sunny (HPS SW)
@ 2016-11-10 6:01 ` Gao, Liming
2 siblings, 0 replies; 25+ messages in thread
From: Gao, Liming @ 2016-11-10 6:01 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Zhang, Chao B
Reviewed-by: Liming Gao <liming.gao@intel.com>
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Tuesday, November 08, 2016 8:29 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Zhang, Chao B
> <chao.b.zhang@intel.com>
> Subject: [PATCH v2 2/9] MdeModulePkg/UefiBootManager: Add
> EfiBootManagerDispatchDeferredImages
>
> The API dispatches the deferred images that are returned from all
> DeferredImageLoad instances.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Chao B Zhang <chao.b.zhang@intel.com>
> ---
> MdeModulePkg/Include/Library/UefiBootManagerLib.h | 13 +++
> MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 113
> +++++++++++++++++++++
> .../Library/UefiBootManagerLib/InternalBm.h | 1 +
> .../UefiBootManagerLib/UefiBootManagerLib.inf | 1 +
> 4 files changed, 128 insertions(+)
>
> diff --git a/MdeModulePkg/Include/Library/UefiBootManagerLib.h
> b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
> index e333ffd..97ac1f2 100644
> --- a/MdeModulePkg/Include/Library/UefiBootManagerLib.h
> +++ b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
> @@ -777,4 +777,17 @@ EfiBootManagerIsValidLoadOptionVariableName (
> OUT UINT16 *OptionNumber OPTIONAL
> );
>
> +
> +/**
> + Dispatch the deferred images that are returned from all
> DeferredImageLoad instances.
> +
> + @retval EFI_SUCCESS At least one deferred image is loaded successfully
> and started.
> + @retval EFI_NOT_FOUND There is no deferred image.
> + @retval EFI_ACCESS_DENIED There are deferred images but all of them
> are failed to load.
> +**/
> +EFI_STATUS
> +EFIAPI
> +EfiBootManagerDispatchDeferredImages (
> + VOID
> + );
> #endif
> diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
> b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
> index 2a60f06..09e4211 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
> +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
> @@ -417,3 +417,116 @@ BmCharToUint (
> return (UINTN) -1;
> }
>
> +/**
> + Dispatch the deferred images that are returned from all
> DeferredImageLoad instances.
> +
> + @retval EFI_SUCCESS At least one deferred image is loaded successfully
> and started.
> + @retval EFI_NOT_FOUND There is no deferred image.
> + @retval EFI_ACCESS_DENIED There are deferred images but all of them
> are failed to load.
> +**/
> +EFI_STATUS
> +EFIAPI
> +EfiBootManagerDispatchDeferredImages (
> + VOID
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;
> + UINTN HandleCount;
> + EFI_HANDLE *Handles;
> + UINTN Index;
> + UINTN ImageIndex;
> + EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
> + VOID *Image;
> + UINTN ImageSize;
> + BOOLEAN BootOption;
> + EFI_HANDLE ImageHandle;
> + UINTN ExitDataSize;
> + CHAR16 *ExitData;
> + UINTN ImageCount;
> + UINTN LoadCount;
> +
> + //
> + // Find all the deferred image load protocols.
> + //
> + HandleCount = 0;
> + Handles = NULL;
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiDeferredImageLoadProtocolGuid,
> + NULL,
> + &HandleCount,
> + &Handles
> + );
> + if (EFI_ERROR (Status)) {
> + return EFI_NOT_FOUND;
> + }
> +
> + ImageCount = 0;
> + LoadCount = 0;
> + for (Index = 0; Index < HandleCount; Index++) {
> + Status = gBS->HandleProtocol (Handles[Index],
> &gEfiDeferredImageLoadProtocolGuid, (VOID **) &DeferredImage);
> + if (EFI_ERROR (Status)) {
> + continue;
> + }
> +
> + for (ImageIndex = 0; ;ImageIndex++) {
> + //
> + // Load all the deferred images in this protocol instance.
> + //
> + Status = DeferredImage->GetImageInfo (
> + DeferredImage,
> + ImageIndex,
> + &ImageDevicePath,
> + (VOID **) &Image,
> + &ImageSize,
> + &BootOption
> + );
> + if (EFI_ERROR (Status)) {
> + break;
> + }
> + ImageCount++;
> + //
> + // Load and start the image.
> + //
> + Status = gBS->LoadImage (
> + BootOption,
> + gImageHandle,
> + ImageDevicePath,
> + NULL,
> + 0,
> + &ImageHandle
> + );
> + if (!EFI_ERROR (Status)) {
> + LoadCount++;
> + //
> + // Before calling the image, enable the Watchdog Timer for
> + // a 5 Minute period
> + //
> + gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);
> + Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);
> + if (ExitData != NULL) {
> + FreePool (ExitData);
> + }
> +
> + //
> + // Clear the Watchdog Timer after the image returns.
> + //
> + gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);
> + }
> + }
> + }
> + if (Handles != NULL) {
> + FreePool (Handles);
> + }
> +
> + if (ImageCount == 0) {
> + return EFI_NOT_FOUND;
> + } else {
> + if (LoadCount == 0) {
> + return EFI_ACCESS_DENIED;
> + } else {
> + return EFI_SUCCESS;
> + }
> + }
> +}
> diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
> b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
> index cb719e9..444d4a5 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
> +++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
> @@ -44,6 +44,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
> #include <Protocol/FormBrowser2.h>
> #include <Protocol/VariableLock.h>
> #include <Protocol/RamDisk.h>
> +#include <Protocol/DeferredImageLoad.h>
>
> #include <Guid/MemoryTypeInformation.h>
> #include <Guid/FileInfo.h>
> diff --git
> a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> index 8c3fd7f..bb7c00d 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> +++
> b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> @@ -109,6 +109,7 @@ [Protocols]
> gEfiDriverHealthProtocolGuid ## SOMETIMES_CONSUMES
> gEfiFormBrowser2ProtocolGuid ## SOMETIMES_CONSUMES
> gEfiRamDiskProtocolGuid ## SOMETIMES_CONSUMES
> + gEfiDeferredImageLoadProtocolGuid ## CONSUMES
>
> [Pcd]
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationC
> hange ## SOMETIMES_CONSUMES
> --
> 2.9.0.windows.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before booting to OS
2016-11-08 12:29 [PATCH v2 0/9] Defer 3rd party images loading to after EndOfDxe Ruiyu Ni
2016-11-08 12:29 ` [PATCH v2 1/9] MdeModulePkg/SecurityStubDxe: Defer 3rd party image before EndOfDxe Ruiyu Ni
2016-11-08 12:29 ` [PATCH v2 2/9] MdeModulePkg/UefiBootManager: Add EfiBootManagerDispatchDeferredImages Ruiyu Ni
@ 2016-11-08 12:29 ` Ruiyu Ni
2016-11-08 14:08 ` Zhang, Chao B
` (2 more replies)
2016-11-08 12:29 ` [PATCH v2 4/9] MdeModulePkg/SecurityStubDxe: Report failure if image is load earlier Ruiyu Ni
` (6 subsequent siblings)
9 siblings, 3 replies; 25+ messages in thread
From: Ruiyu Ni @ 2016-11-08 12:29 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Chao B Zhang
The patch adds check of deferred images before booting to OS.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
---
MdeModulePkg/Universal/BdsDxe/Bds.h | 4 +-
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 2 +
MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 90 ++++++++++++++++++++++++++++++++
3 files changed, 95 insertions(+), 1 deletion(-)
diff --git a/MdeModulePkg/Universal/BdsDxe/Bds.h b/MdeModulePkg/Universal/BdsDxe/Bds.h
index d243932..1f8a192 100644
--- a/MdeModulePkg/Universal/BdsDxe/Bds.h
+++ b/MdeModulePkg/Universal/BdsDxe/Bds.h
@@ -1,7 +1,7 @@
/** @file
Head file for BDS Architectural Protocol implementation
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -20,10 +20,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/ConnectConInEvent.h>
#include <Guid/Performance.h>
#include <Guid/StatusCodeDataTypeVariable.h>
+#include <Guid/EventGroup.h>
#include <Protocol/Bds.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/VariableLock.h>
+#include <Protocol/DeferredImageLoad.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/DebugLib.h>
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
index e03cfde..a00b442 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
@@ -79,11 +79,13 @@ [Guids]
gConnectConInEventGuid ## SOMETIMES_CONSUMES ## Event
gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID
gPerformanceProtocolGuid ## SOMETIMES_PRODUCES ## Variable:L"PerfDataMemAddr" (The ACPI address of performance data)
+ gEfiEventReadyToBootGuid ## CONSUMES ## Event
[Protocols]
gEfiBdsArchProtocolGuid ## PRODUCES
gEfiSimpleTextInputExProtocolGuid ## CONSUMES
gEdkiiVariableLockProtocolGuid ## CONSUMES
+ gEfiDeferredImageLoadProtocolGuid ## CONSUMES
[FeaturePcd]
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate ## CONSUMES
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index aacc4a6..72adc51 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -86,6 +86,81 @@ BdsDxeOnConnectConInCallBack (
DEBUG ((EFI_D_WARN, "[Bds] Connect ConIn failed - %r!!!\n", Status));
}
}
+/**
+ Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is used to
+ check whether there is remaining deferred load images.
+
+ @param[in] Event The Event that is being processed.
+ @param[in] Context The Event Context.
+
+**/
+VOID
+EFIAPI
+CheckDeferredLoadImageOnReadyToBoot (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ UINTN Index;
+ UINTN ImageIndex;
+ EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
+ VOID *Image;
+ UINTN ImageSize;
+ BOOLEAN BootOption;
+ CHAR16 *DevicePathStr;
+
+ //
+ // Find all the deferred image load protocols.
+ //
+ HandleCount = 0;
+ Handles = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiDeferredImageLoadProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->HandleProtocol (Handles[Index], &gEfiDeferredImageLoadProtocolGuid, (VOID **) &DeferredImage);
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ for (ImageIndex = 0; ; ImageIndex++) {
+ //
+ // Load all the deferred images in this protocol instance.
+ //
+ Status = DeferredImage->GetImageInfo (
+ DeferredImage,
+ ImageIndex,
+ &ImageDevicePath,
+ (VOID **) &Image,
+ &ImageSize,
+ &BootOption
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ DevicePathStr = ConvertDevicePathToText (ImageDevicePath, FALSE, FALSE);
+ DEBUG ((DEBUG_LOAD, "[Bds] Image was deferred but not loaded: %s.\n", DevicePathStr));
+ if (DevicePathStr != NULL) {
+ FreePool (DevicePathStr);
+ }
+ }
+ }
+ if (Handles != NULL) {
+ FreePool (Handles);
+ }
+}
/**
@@ -119,6 +194,21 @@ BdsInitialize (
);
ASSERT_EFI_ERROR (Status);
+ DEBUG_CODE (
+ EFI_EVENT Event;
+ //
+ // Register notify function to check deferred images on ReadyToBoot Event.
+ //
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ CheckDeferredLoadImageOnReadyToBoot,
+ NULL,
+ &gEfiEventReadyToBootGuid,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+ );
return Status;
}
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before booting to OS
2016-11-08 12:29 ` [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before booting to OS Ruiyu Ni
@ 2016-11-08 14:08 ` Zhang, Chao B
2016-11-10 5:50 ` Wang, Sunny (HPS SW)
2016-11-10 6:01 ` Gao, Liming
2 siblings, 0 replies; 25+ messages in thread
From: Zhang, Chao B @ 2016-11-08 14:08 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Gao, Liming
Reviewed-by : Chao Zhang <chao.b.zhang@intel.com>
Thanks & Best regards
Chao Zhang
-----Original Message-----
From: Ni, Ruiyu
Sent: Tuesday, November 08, 2016 8:29 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming; Zhang, Chao B
Subject: [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before booting to OS
The patch adds check of deferred images before booting to OS.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
---
MdeModulePkg/Universal/BdsDxe/Bds.h | 4 +-
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 2 +
MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 90 ++++++++++++++++++++++++++++++++
3 files changed, 95 insertions(+), 1 deletion(-)
diff --git a/MdeModulePkg/Universal/BdsDxe/Bds.h b/MdeModulePkg/Universal/BdsDxe/Bds.h
index d243932..1f8a192 100644
--- a/MdeModulePkg/Universal/BdsDxe/Bds.h
+++ b/MdeModulePkg/Universal/BdsDxe/Bds.h
@@ -1,7 +1,7 @@
/** @file
Head file for BDS Architectural Protocol implementation
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -20,10 +20,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/ConnectConInEvent.h>
#include <Guid/Performance.h>
#include <Guid/StatusCodeDataTypeVariable.h>
+#include <Guid/EventGroup.h>
#include <Protocol/Bds.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/VariableLock.h>
+#include <Protocol/DeferredImageLoad.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/DebugLib.h>
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
index e03cfde..a00b442 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
@@ -79,11 +79,13 @@ [Guids]
gConnectConInEventGuid ## SOMETIMES_CONSUMES ## Event
gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID
gPerformanceProtocolGuid ## SOMETIMES_PRODUCES ## Variable:L"PerfDataMemAddr" (The ACPI address of performance data)
+ gEfiEventReadyToBootGuid ## CONSUMES ## Event
[Protocols]
gEfiBdsArchProtocolGuid ## PRODUCES
gEfiSimpleTextInputExProtocolGuid ## CONSUMES
gEdkiiVariableLockProtocolGuid ## CONSUMES
+ gEfiDeferredImageLoadProtocolGuid ## CONSUMES
[FeaturePcd]
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate ## CONSUMES
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index aacc4a6..72adc51 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -86,6 +86,81 @@ BdsDxeOnConnectConInCallBack (
DEBUG ((EFI_D_WARN, "[Bds] Connect ConIn failed - %r!!!\n", Status));
}
}
+/**
+ Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is used to
+ check whether there is remaining deferred load images.
+
+ @param[in] Event The Event that is being processed.
+ @param[in] Context The Event Context.
+
+**/
+VOID
+EFIAPI
+CheckDeferredLoadImageOnReadyToBoot (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ UINTN Index;
+ UINTN ImageIndex;
+ EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
+ VOID *Image;
+ UINTN ImageSize;
+ BOOLEAN BootOption;
+ CHAR16 *DevicePathStr;
+
+ //
+ // Find all the deferred image load protocols.
+ //
+ HandleCount = 0;
+ Handles = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiDeferredImageLoadProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->HandleProtocol (Handles[Index], &gEfiDeferredImageLoadProtocolGuid, (VOID **) &DeferredImage);
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ for (ImageIndex = 0; ; ImageIndex++) {
+ //
+ // Load all the deferred images in this protocol instance.
+ //
+ Status = DeferredImage->GetImageInfo (
+ DeferredImage,
+ ImageIndex,
+ &ImageDevicePath,
+ (VOID **) &Image,
+ &ImageSize,
+ &BootOption
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ DevicePathStr = ConvertDevicePathToText (ImageDevicePath, FALSE, FALSE);
+ DEBUG ((DEBUG_LOAD, "[Bds] Image was deferred but not loaded: %s.\n", DevicePathStr));
+ if (DevicePathStr != NULL) {
+ FreePool (DevicePathStr);
+ }
+ }
+ }
+ if (Handles != NULL) {
+ FreePool (Handles);
+ }
+}
/**
@@ -119,6 +194,21 @@ BdsInitialize (
);
ASSERT_EFI_ERROR (Status);
+ DEBUG_CODE (
+ EFI_EVENT Event;
+ //
+ // Register notify function to check deferred images on ReadyToBoot Event.
+ //
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ CheckDeferredLoadImageOnReadyToBoot,
+ NULL,
+ &gEfiEventReadyToBootGuid,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+ );
return Status;
}
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before booting to OS
2016-11-08 12:29 ` [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before booting to OS Ruiyu Ni
2016-11-08 14:08 ` Zhang, Chao B
@ 2016-11-10 5:50 ` Wang, Sunny (HPS SW)
2016-11-10 6:01 ` Gao, Liming
2 siblings, 0 replies; 25+ messages in thread
From: Wang, Sunny (HPS SW) @ 2016-11-10 5:50 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel@lists.01.org
Cc: Chao B Zhang, Liming Gao, Wang, Sunny (HPS SW), Haskell, Darrell
[-- Attachment #1: Type: text/plain, Size: 6485 bytes --]
Thanks for addressing my offline comments. This updated patch looks good to me.
Reviewed-by: Sunny Wang <sunnywang@hpe.com>
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Tuesday, November 08, 2016 8:29 PM
To: edk2-devel@lists.01.org
Cc: Chao B Zhang <chao.b.zhang@intel.com>; Liming Gao <liming.gao@intel.com>
Subject: [edk2] [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before booting to OS
The patch adds check of deferred images before booting to OS.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Chao B Zhang <chao.b.zhang@intel.com>
---
MdeModulePkg/Universal/BdsDxe/Bds.h | 4 +-
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 2 + MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 90 ++++++++++++++++++++++++++++++++
3 files changed, 95 insertions(+), 1 deletion(-)
diff --git a/MdeModulePkg/Universal/BdsDxe/Bds.h b/MdeModulePkg/Universal/BdsDxe/Bds.h
index d243932..1f8a192 100644
--- a/MdeModulePkg/Universal/BdsDxe/Bds.h
+++ b/MdeModulePkg/Universal/BdsDxe/Bds.h
@@ -1,7 +1,7 @@
/** @file
Head file for BDS Architectural Protocol implementation
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -20,10 +20,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/ConnectConInEvent.h>
#include <Guid/Performance.h>
#include <Guid/StatusCodeDataTypeVariable.h>
+#include <Guid/EventGroup.h>
#include <Protocol/Bds.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/VariableLock.h>
+#include <Protocol/DeferredImageLoad.h>
#include <Library/UefiDriverEntryPoint.h> #include <Library/DebugLib.h> diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
index e03cfde..a00b442 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
@@ -79,11 +79,13 @@ [Guids]
gConnectConInEventGuid ## SOMETIMES_CONSUMES ## Event
gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID
gPerformanceProtocolGuid ## SOMETIMES_PRODUCES ## Variable:L"PerfDataMemAddr" (The ACPI address of performance data)
+ gEfiEventReadyToBootGuid ## CONSUMES ## Event
[Protocols]
gEfiBdsArchProtocolGuid ## PRODUCES
gEfiSimpleTextInputExProtocolGuid ## CONSUMES
gEdkiiVariableLockProtocolGuid ## CONSUMES
+ gEfiDeferredImageLoadProtocolGuid ## CONSUMES
[FeaturePcd]
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate ## CONSUMES
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index aacc4a6..72adc51 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -86,6 +86,81 @@ BdsDxeOnConnectConInCallBack (
DEBUG ((EFI_D_WARN, "[Bds] Connect ConIn failed - %r!!!\n", Status));
}
}
+/**
+ Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This
+is used to
+ check whether there is remaining deferred load images.
+
+ @param[in] Event The Event that is being processed.
+ @param[in] Context The Event Context.
+
+**/
+VOID
+EFIAPI
+CheckDeferredLoadImageOnReadyToBoot (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ UINTN Index;
+ UINTN ImageIndex;
+ EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
+ VOID *Image;
+ UINTN ImageSize;
+ BOOLEAN BootOption;
+ CHAR16 *DevicePathStr;
+
+ //
+ // Find all the deferred image load protocols.
+ //
+ HandleCount = 0;
+ Handles = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiDeferredImageLoadProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->HandleProtocol (Handles[Index], &gEfiDeferredImageLoadProtocolGuid, (VOID **) &DeferredImage);
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ for (ImageIndex = 0; ; ImageIndex++) {
+ //
+ // Load all the deferred images in this protocol instance.
+ //
+ Status = DeferredImage->GetImageInfo (
+ DeferredImage,
+ ImageIndex,
+ &ImageDevicePath,
+ (VOID **) &Image,
+ &ImageSize,
+ &BootOption
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ DevicePathStr = ConvertDevicePathToText (ImageDevicePath, FALSE, FALSE);
+ DEBUG ((DEBUG_LOAD, "[Bds] Image was deferred but not loaded: %s.\n", DevicePathStr));
+ if (DevicePathStr != NULL) {
+ FreePool (DevicePathStr);
+ }
+ }
+ }
+ if (Handles != NULL) {
+ FreePool (Handles);
+ }
+}
/**
@@ -119,6 +194,21 @@ BdsInitialize (
);
ASSERT_EFI_ERROR (Status);
+ DEBUG_CODE (
+ EFI_EVENT Event;
+ //
+ // Register notify function to check deferred images on ReadyToBoot Event.
+ //
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ CheckDeferredLoadImageOnReadyToBoot,
+ NULL,
+ &gEfiEventReadyToBootGuid,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+ );
return Status;
}
--
2.9.0.windows.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
[-- Attachment #2: Type: message/rfc822, Size: 14173 bytes --]
From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: "Wang, Sunny (HPS SW)" <sunnywang@hpe.com>
Cc: "Haskell, Darrell" <darrell.haskell@hpe.com>
Subject: RE: [edk2] [PATCH 3/4] MdeModulePkg/BdsDxe: Check deferred images before booting to OS
Date: Mon, 7 Nov 2016 02:35:11 +0000
Message-ID: <734D49CCEBEEF84792F5B80ED585239D58E56773@SHSMSX104.ccr.corp.intel.com>
Thanks/Ray
> -----Original Message-----
> From: Wang, Sunny (HPS SW) [mailto:sunnywang@hpe.com]
> Sent: Friday, November 4, 2016 7:34 PM
> To: Ni, Ruiyu <ruiyu.ni@intel.com>
> Cc: Wang, Sunny (HPS SW) <sunnywang@hpe.com>; Haskell, Darrell
> <darrell.haskell@hpe.com>
> Subject: RE: [edk2] [PATCH 3/4] MdeModulePkg/BdsDxe: Check deferred
> images before booting to OS
>
> Hi Ray,
> Remove others. Feel free to add some people back.
> CheckDeferredLoadImageOnReadyToBoot() is almost the same as
> CheckDeferredImage() in Intel Central park reference code, so It looks good
> to me.
> However, I have a question and a suggestion below:
> Question:
> - ReadyToBoot event is possibly signaled more than once during a boot.
> Why do we need to call CheckDeferredLoadImageOnReadyToBoot() more
> than once during a boot? If it is related to use cases of deferred image, could
> you give more information? I'm not familiar with the use cases of the
> deferred image, but I would like to know if it is worth for HPE sever to take
> little additional boot time to call CheckDeferredLoadImageOnReadyToBoot()
> more than once during a boot. Thanks in advance.
Yes I agree calling this more than once is unnecessary. I will change the patch
to call it only once.
>
> Suggestions:
> - It looks like CheckDeferredLoadImageOnReadyToBoot() is only for
> printing DEBUG messages. Is there anything which I overlook? If not, is it a
> good idea to add this CheckDeferredLoadImage() as a UefiBootManagerLib
> API instead of adding this as a Notify function in BdsDxe? So that all the
> companies can decide whether/when they want to call
> CheckDeferredLoadImage() in BDS platform code instead of being forced
> calling it with ReadyToBoot event signaled in BDS core code.
I see your needs now. So how about I only register this callback in DEBUG
build, surrounding the code with DEBUG_CODE() macro?
Make this as an API requires platform manually register this callback, which
I think is not very convenient to platform.
>
> Regards,
> Sunny Wang
>
>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Friday, November 04, 2016 9:00 AM
> To: edk2-devel@lists.01.org
> Cc: Chao B Zhang <chao.b.zhang@intel.com>; Liming Gao
> <liming.gao@intel.com>
> Subject: [edk2] [PATCH 3/4] MdeModulePkg/BdsDxe: Check deferred
> images before booting to OS
>
> The patch adds check of deferred images before booting to OS.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Chao B Zhang <chao.b.zhang@intel.com>
> ---
> MdeModulePkg/Universal/BdsDxe/Bds.h | 4 +-
> MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 2 +
> MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 89
> ++++++++++++++++++++++++++++++++
> 3 files changed, 94 insertions(+), 1 deletion(-)
>
> diff --git a/MdeModulePkg/Universal/BdsDxe/Bds.h
> b/MdeModulePkg/Universal/BdsDxe/Bds.h
> index d243932..1f8a192 100644
> --- a/MdeModulePkg/Universal/BdsDxe/Bds.h
> +++ b/MdeModulePkg/Universal/BdsDxe/Bds.h
> @@ -1,7 +1,7 @@
> /** @file
> Head file for BDS Architectural Protocol implementation
>
> -Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
> This program and the accompanying materials are licensed and made
> available under the terms and conditions of the BSD License which
> accompanies this distribution. The full text of the license may be found at
> @@ -20,10 +20,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF
> ANY KIND, EITHER EXPRESS OR IMPLIED.
> #include <Guid/ConnectConInEvent.h>
> #include <Guid/Performance.h>
> #include <Guid/StatusCodeDataTypeVariable.h>
> +#include <Guid/EventGroup.h>
>
> #include <Protocol/Bds.h>
> #include <Protocol/LoadedImage.h>
> #include <Protocol/VariableLock.h>
> +#include <Protocol/DeferredImageLoad.h>
>
> #include <Library/UefiDriverEntryPoint.h> #include <Library/DebugLib.h>
> diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
> b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
> index e03cfde..a00b442 100644
> --- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
> +++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
> @@ -79,11 +79,13 @@ [Guids]
> gConnectConInEventGuid ## SOMETIMES_CONSUMES ## Event
> gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES
> ## GUID
> gPerformanceProtocolGuid ## SOMETIMES_PRODUCES ##
> Variable:L"PerfDataMemAddr" (The ACPI address of performance data)
> + gEfiEventReadyToBootGuid ## CONSUMES ## Event
>
> [Protocols]
> gEfiBdsArchProtocolGuid ## PRODUCES
> gEfiSimpleTextInputExProtocolGuid ## CONSUMES
> gEdkiiVariableLockProtocolGuid ## CONSUMES
> + gEfiDeferredImageLoadProtocolGuid ## CONSUMES
>
> [FeaturePcd]
> gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate ##
> CONSUMES
> diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> index aacc4a6..ffa884a 100644
> --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> @@ -86,7 +86,83 @@ BdsDxeOnConnectConInCallBack (
> DEBUG ((EFI_D_WARN, "[Bds] Connect ConIn failed - %r!!!\n", Status));
> }
> }
> +/**
> + Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT.
> This
> +is used to
> + check whether there is remaining deferred load images.
> +
> + @param[in] Event The Event that is being processed.
> + @param[in] Context The Event Context.
> +
> +**/
> +VOID
> +EFIAPI
> +CheckDeferredLoadImageOnReadyToBoot (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;
> + UINTN HandleCount;
> + EFI_HANDLE *Handles;
> + UINTN Index;
> + UINTN ImageIndex;
> + EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
> + VOID *Image;
> + UINTN ImageSize;
> + BOOLEAN BootOption;
> +
> + //
> + // Find all the deferred image load protocols.
> + //
> + HandleCount = 0;
> + Handles = NULL;
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiDeferredImageLoadProtocolGuid,
> + NULL,
> + &HandleCount,
> + &Handles
> + );
> + if (EFI_ERROR (Status)) {
> + return;
> + }
> +
> + for (Index = 0; Index < HandleCount; Index++) {
> + Status = gBS->HandleProtocol (Handles[Index],
> &gEfiDeferredImageLoadProtocolGuid, (VOID **) &DeferredImage);
> + if (EFI_ERROR (Status)) {
> + continue;
> + }
>
> + for (ImageIndex = 0; ; ImageIndex++) {
> + //
> + // Load all the deferred images in this protocol instance.
> + //
> + Status = DeferredImage->GetImageInfo (
> + DeferredImage,
> + ImageIndex,
> + &ImageDevicePath,
> + (VOID **) &Image,
> + &ImageSize,
> + &BootOption
> + );
> + if (EFI_ERROR (Status)) {
> + break;
> + }
> + DEBUG_CODE (
> + CHAR16 *DevicePathStr;
> + DevicePathStr = ConvertDevicePathToText (ImageDevicePath, FALSE,
> FALSE);
> + DEBUG ((DEBUG_LOAD, "[Bds] Image was deferred but not
> loaded: %s.\n", DevicePathStr));
> + if (DevicePathStr != NULL) {
> + FreePool (DevicePathStr);
> + }
> + );
> + }
> + }
> + if (Handles != NULL) {
> + FreePool (Handles);
> + }
> +}
> /**
>
> Install Boot Device Selection Protocol @@ -108,6 +184,7 @@ BdsInitialize ( {
> EFI_STATUS Status;
> EFI_HANDLE Handle;
> + EFI_EVENT Event;
> //
> // Install protocol interface
> //
> @@ -119,6 +196,18 @@ BdsInitialize (
> );
> ASSERT_EFI_ERROR (Status);
>
> + //
> + // Register notify function to check deferred images on ReadyToBoot
> Event.
> + //
> + Status = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + TPL_CALLBACK,
> + CheckDeferredLoadImageOnReadyToBoot,
> + NULL,
> + &gEfiEventReadyToBootGuid,
> + &Event
> + );
> + ASSERT_EFI_ERROR (Status);
> return Status;
> }
>
> --
> 2.9.0.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before booting to OS
2016-11-08 12:29 ` [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before booting to OS Ruiyu Ni
2016-11-08 14:08 ` Zhang, Chao B
2016-11-10 5:50 ` Wang, Sunny (HPS SW)
@ 2016-11-10 6:01 ` Gao, Liming
2 siblings, 0 replies; 25+ messages in thread
From: Gao, Liming @ 2016-11-10 6:01 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Zhang, Chao B
Reviewed-by: Liming Gao <liming.gao@intel.com>
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Tuesday, November 08, 2016 8:29 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Zhang, Chao B
> <chao.b.zhang@intel.com>
> Subject: [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images
> before booting to OS
>
> The patch adds check of deferred images before booting to OS.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Chao B Zhang <chao.b.zhang@intel.com>
> ---
> MdeModulePkg/Universal/BdsDxe/Bds.h | 4 +-
> MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 2 +
> MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 90
> ++++++++++++++++++++++++++++++++
> 3 files changed, 95 insertions(+), 1 deletion(-)
>
> diff --git a/MdeModulePkg/Universal/BdsDxe/Bds.h
> b/MdeModulePkg/Universal/BdsDxe/Bds.h
> index d243932..1f8a192 100644
> --- a/MdeModulePkg/Universal/BdsDxe/Bds.h
> +++ b/MdeModulePkg/Universal/BdsDxe/Bds.h
> @@ -1,7 +1,7 @@
> /** @file
> Head file for BDS Architectural Protocol implementation
>
> -Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD
> License
> which accompanies this distribution. The full text of the license may be
> found at
> @@ -20,10 +20,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF
> ANY KIND, EITHER EXPRESS OR IMPLIED.
> #include <Guid/ConnectConInEvent.h>
> #include <Guid/Performance.h>
> #include <Guid/StatusCodeDataTypeVariable.h>
> +#include <Guid/EventGroup.h>
>
> #include <Protocol/Bds.h>
> #include <Protocol/LoadedImage.h>
> #include <Protocol/VariableLock.h>
> +#include <Protocol/DeferredImageLoad.h>
>
> #include <Library/UefiDriverEntryPoint.h>
> #include <Library/DebugLib.h>
> diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
> b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
> index e03cfde..a00b442 100644
> --- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
> +++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
> @@ -79,11 +79,13 @@ [Guids]
> gConnectConInEventGuid ## SOMETIMES_CONSUMES ## Event
> gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES
> ## GUID
> gPerformanceProtocolGuid ## SOMETIMES_PRODUCES ##
> Variable:L"PerfDataMemAddr" (The ACPI address of performance data)
> + gEfiEventReadyToBootGuid ## CONSUMES ## Event
>
> [Protocols]
> gEfiBdsArchProtocolGuid ## PRODUCES
> gEfiSimpleTextInputExProtocolGuid ## CONSUMES
> gEdkiiVariableLockProtocolGuid ## CONSUMES
> + gEfiDeferredImageLoadProtocolGuid ## CONSUMES
>
> [FeaturePcd]
> gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate ##
> CONSUMES
> diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> index aacc4a6..72adc51 100644
> --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> @@ -86,6 +86,81 @@ BdsDxeOnConnectConInCallBack (
> DEBUG ((EFI_D_WARN, "[Bds] Connect ConIn failed - %r!!!\n", Status));
> }
> }
> +/**
> + Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT.
> This is used to
> + check whether there is remaining deferred load images.
> +
> + @param[in] Event The Event that is being processed.
> + @param[in] Context The Event Context.
> +
> +**/
> +VOID
> +EFIAPI
> +CheckDeferredLoadImageOnReadyToBoot (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;
> + UINTN HandleCount;
> + EFI_HANDLE *Handles;
> + UINTN Index;
> + UINTN ImageIndex;
> + EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
> + VOID *Image;
> + UINTN ImageSize;
> + BOOLEAN BootOption;
> + CHAR16 *DevicePathStr;
> +
> + //
> + // Find all the deferred image load protocols.
> + //
> + HandleCount = 0;
> + Handles = NULL;
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiDeferredImageLoadProtocolGuid,
> + NULL,
> + &HandleCount,
> + &Handles
> + );
> + if (EFI_ERROR (Status)) {
> + return;
> + }
> +
> + for (Index = 0; Index < HandleCount; Index++) {
> + Status = gBS->HandleProtocol (Handles[Index],
> &gEfiDeferredImageLoadProtocolGuid, (VOID **) &DeferredImage);
> + if (EFI_ERROR (Status)) {
> + continue;
> + }
> +
> + for (ImageIndex = 0; ; ImageIndex++) {
> + //
> + // Load all the deferred images in this protocol instance.
> + //
> + Status = DeferredImage->GetImageInfo (
> + DeferredImage,
> + ImageIndex,
> + &ImageDevicePath,
> + (VOID **) &Image,
> + &ImageSize,
> + &BootOption
> + );
> + if (EFI_ERROR (Status)) {
> + break;
> + }
> + DevicePathStr = ConvertDevicePathToText (ImageDevicePath, FALSE,
> FALSE);
> + DEBUG ((DEBUG_LOAD, "[Bds] Image was deferred but not
> loaded: %s.\n", DevicePathStr));
> + if (DevicePathStr != NULL) {
> + FreePool (DevicePathStr);
> + }
> + }
> + }
> + if (Handles != NULL) {
> + FreePool (Handles);
> + }
> +}
>
> /**
>
> @@ -119,6 +194,21 @@ BdsInitialize (
> );
> ASSERT_EFI_ERROR (Status);
>
> + DEBUG_CODE (
> + EFI_EVENT Event;
> + //
> + // Register notify function to check deferred images on ReadyToBoot
> Event.
> + //
> + Status = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + TPL_CALLBACK,
> + CheckDeferredLoadImageOnReadyToBoot,
> + NULL,
> + &gEfiEventReadyToBootGuid,
> + &Event
> + );
> + ASSERT_EFI_ERROR (Status);
> + );
> return Status;
> }
>
> --
> 2.9.0.windows.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 4/9] MdeModulePkg/SecurityStubDxe: Report failure if image is load earlier
2016-11-08 12:29 [PATCH v2 0/9] Defer 3rd party images loading to after EndOfDxe Ruiyu Ni
` (2 preceding siblings ...)
2016-11-08 12:29 ` [PATCH v2 3/9] MdeModulePkg/BdsDxe: Check deferred images before booting to OS Ruiyu Ni
@ 2016-11-08 12:29 ` Ruiyu Ni
2016-11-08 12:29 ` [PATCH v2 5/9] ArmVirPkg/PlatformBds: Dispatch deferred images after EndOfDxe Ruiyu Ni
` (5 subsequent siblings)
9 siblings, 0 replies; 25+ messages in thread
From: Ruiyu Ni @ 2016-11-08 12:29 UTC (permalink / raw)
To: edk2-devel; +Cc: Jiewen Yao
The 3rd party image should be loaded after EndOfDxe event signal and
DxeSmmReadyToLock protocol installation. But non-SMM platform doesn't
published DxeSmmReadyToLock protocol.
So the SecurityStubDxe can only depend on EndOfDxe event.
This patch enhances the SecurityStubDxe to listen on
DxeSmmReadyToLock protocol installation and if any 3rd party image
is loaded before DxeSmmReadyToLock, it reports failure.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
---
.../SecurityStubDxe/Defer3rdPartyImageLoad.c | 58 ++++++++++++++++++++++
.../SecurityStubDxe/Defer3rdPartyImageLoad.h | 5 +-
.../Universal/SecurityStubDxe/SecurityStubDxe.inf | 3 ++
3 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c
index ca45d56..7135a9d 100644
--- a/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c
+++ b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c
@@ -30,6 +30,7 @@ typedef struct {
DEFERRED_3RD_PARTY_IMAGE_INFO *ImageInfo; ///< deferred 3rd party image item
} DEFERRED_3RD_PARTY_IMAGE_TABLE;
+BOOLEAN mImageLoadedAfterEndOfDxe = FALSE;
BOOLEAN mEndOfDxe = FALSE;
DEFERRED_3RD_PARTY_IMAGE_TABLE mDeferred3rdPartyImage = {
0, // Deferred image count
@@ -257,6 +258,53 @@ EndOfDxe (
}
/**
+ Event notification for gEfiDxeSmmReadyToLockProtocolGuid event.
+
+ This function reports failure if any deferred image is loaded before
+ this callback.
+ Platform should publish ReadyToLock protocol immediately after signaling
+ of the End of DXE Event.
+
+ @param Event The Event that is being processed, not used.
+ @param Context Event Context, not used.
+
+**/
+VOID
+EFIAPI
+DxeSmmReadyToLock (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ VOID *Interface;
+
+ Status = gBS->LocateProtocol (&gEfiDxeSmmReadyToLockProtocolGuid, NULL, &Interface);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ gBS->CloseEvent (Event);
+
+ if (mImageLoadedAfterEndOfDxe) {
+ //
+ // Platform should not dispatch the 3rd party images after signaling EndOfDxe event
+ // but before publishing DxeSmmReadyToLock protocol.
+ //
+ DEBUG ((
+ DEBUG_ERROR,
+ "[Security] 3rd party images must be dispatched after DxeSmmReadyToLock Protocol installation!\n"
+ ));
+ REPORT_STATUS_CODE (
+ EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED,
+ (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)
+ );
+ ASSERT (FALSE);
+ CpuDeadLoop ();
+ }
+}
+
+/**
Defer the 3rd party image load and installs Deferred Image Load Protocol.
@param[in] File This is a pointer to the device path of the file that
@@ -303,6 +351,7 @@ Defer3rdPartyImageLoad (
);
if (mEndOfDxe) {
+ mImageLoadedAfterEndOfDxe = TRUE;
//
// The image might be first time loaded after EndOfDxe,
// So ImageInfo can be NULL.
@@ -334,6 +383,7 @@ Defer3rdPartyImageLoadInitialize (
EFI_STATUS Status;
EFI_HANDLE Handle;
EFI_EVENT Event;
+ VOID *Registration;
Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
@@ -353,4 +403,12 @@ Defer3rdPartyImageLoadInitialize (
&Event
);
ASSERT_EFI_ERROR (Status);
+
+ EfiCreateProtocolNotifyEvent (
+ &gEfiDxeSmmReadyToLockProtocolGuid,
+ TPL_CALLBACK,
+ DxeSmmReadyToLock,
+ NULL,
+ &Registration
+ );
}
diff --git a/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.h b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.h
index 3fab258..75553ba 100644
--- a/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.h
+++ b/MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.h
@@ -15,16 +15,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#ifndef _DEFER_3RD_PARTY_IMAGE_LOAD_H_
#define _DEFER_3RD_PARTY_IMAGE_LOAD_H_
-#include <Uefi.h>
+#include <PiDxe.h>
#include <Guid/EventGroup.h>
#include <Protocol/DeferredImageLoad.h>
#include <Protocol/FirmwareVolume2.h>
+#include <Protocol/DxeSmmReadyToLock.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DevicePathLib.h>
#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/ReportStatusCodeLib.h>
/**
Returns information about a deferred image.
diff --git a/MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf b/MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
index be6ce6c..7f8f6cb 100644
--- a/MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
+++ b/MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
@@ -41,6 +41,8 @@ [LibraryClasses]
UefiBootServicesTableLib
DebugLib
SecurityManagementLib
+ ReportStatusCodeLib
+ UefiLib
[Guids]
gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event
@@ -49,6 +51,7 @@ [Protocols]
gEfiSecurityArchProtocolGuid ## PRODUCES
gEfiSecurity2ArchProtocolGuid ## PRODUCES
gEfiDeferredImageLoadProtocolGuid ## PRODUCES
+ gEfiDxeSmmReadyToLockProtocolGuid ## CONSUMES
[Depex]
TRUE
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v2 5/9] ArmVirPkg/PlatformBds: Dispatch deferred images after EndOfDxe
2016-11-08 12:29 [PATCH v2 0/9] Defer 3rd party images loading to after EndOfDxe Ruiyu Ni
` (3 preceding siblings ...)
2016-11-08 12:29 ` [PATCH v2 4/9] MdeModulePkg/SecurityStubDxe: Report failure if image is load earlier Ruiyu Ni
@ 2016-11-08 12:29 ` Ruiyu Ni
2016-11-08 12:57 ` Laszlo Ersek
2016-11-08 12:29 ` [PATCH v2 6/9] OvmfPkg/PlatformBds: " Ruiyu Ni
` (4 subsequent siblings)
9 siblings, 1 reply; 25+ messages in thread
From: Ruiyu Ni @ 2016-11-08 12:29 UTC (permalink / raw)
To: edk2-devel; +Cc: Laszlo Ersek, Ard Biesheuvel
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
index 56f4c92..94da51a 100644
--- a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
@@ -586,6 +586,11 @@ PlatformBootManagerBeforeConsole (
EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
//
+ // Dispatch deferred images after EndOfDxe event.
+ //
+ EfiBootManagerDispatchDeferredImages ();
+
+ //
// Locate the PCI root bridges and make the PCI bus driver connect each,
// non-recursively. This will produce a number of child handles with PciIo on
// them.
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v2 5/9] ArmVirPkg/PlatformBds: Dispatch deferred images after EndOfDxe
2016-11-08 12:29 ` [PATCH v2 5/9] ArmVirPkg/PlatformBds: Dispatch deferred images after EndOfDxe Ruiyu Ni
@ 2016-11-08 12:57 ` Laszlo Ersek
0 siblings, 0 replies; 25+ messages in thread
From: Laszlo Ersek @ 2016-11-08 12:57 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Ard Biesheuvel
On 11/08/16 13:29, Ruiyu Ni wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
> index 56f4c92..94da51a 100644
> --- a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
> +++ b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
> @@ -586,6 +586,11 @@ PlatformBootManagerBeforeConsole (
> EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
>
> //
> + // Dispatch deferred images after EndOfDxe event.
> + //
> + EfiBootManagerDispatchDeferredImages ();
> +
> + //
> // Locate the PCI root bridges and make the PCI bus driver connect each,
> // non-recursively. This will produce a number of child handles with PciIo on
> // them.
>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 6/9] OvmfPkg/PlatformBds: Dispatch deferred images after EndOfDxe
2016-11-08 12:29 [PATCH v2 0/9] Defer 3rd party images loading to after EndOfDxe Ruiyu Ni
` (4 preceding siblings ...)
2016-11-08 12:29 ` [PATCH v2 5/9] ArmVirPkg/PlatformBds: Dispatch deferred images after EndOfDxe Ruiyu Ni
@ 2016-11-08 12:29 ` Ruiyu Ni
2016-11-08 13:04 ` Laszlo Ersek
2016-11-08 12:29 ` [PATCH v2 7/9] CorebootPayload/PlatformBds: " Ruiyu Ni
` (3 subsequent siblings)
9 siblings, 1 reply; 25+ messages in thread
From: Ruiyu Ni @ 2016-11-08 12:29 UTC (permalink / raw)
To: edk2-devel; +Cc: Jordan Justen, Laszlo Ersek
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index 66ee590..cc35630 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -389,6 +389,11 @@ Returns:
NULL);
ASSERT_EFI_ERROR (Status);
+ //
+ // Dispatch deferred images after EndOfDxe event and ReadyToLock installation.
+ //
+ EfiBootManagerDispatchDeferredImages ();
+
PlatformInitializeConsole (gPlatformConsole);
PcdStatus = PcdSet16S (PcdPlatformBootTimeOut,
GetFrontPageTimeoutFromQemu ());
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v2 6/9] OvmfPkg/PlatformBds: Dispatch deferred images after EndOfDxe
2016-11-08 12:29 ` [PATCH v2 6/9] OvmfPkg/PlatformBds: " Ruiyu Ni
@ 2016-11-08 13:04 ` Laszlo Ersek
2016-11-11 11:16 ` Laszlo Ersek
0 siblings, 1 reply; 25+ messages in thread
From: Laszlo Ersek @ 2016-11-08 13:04 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Jordan Justen
On 11/08/16 13:29, Ruiyu Ni wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> ---
> OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> index 66ee590..cc35630 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> @@ -389,6 +389,11 @@ Returns:
> NULL);
> ASSERT_EFI_ERROR (Status);
>
> + //
> + // Dispatch deferred images after EndOfDxe event and ReadyToLock installation.
> + //
> + EfiBootManagerDispatchDeferredImages ();
> +
> PlatformInitializeConsole (gPlatformConsole);
> PcdStatus = PcdSet16S (PcdPlatformBootTimeOut,
> GetFrontPageTimeoutFromQemu ());
>
Can you please add a note to the commit message that, if the platform
installs EfiDxeSmmReadyToLockProtocol, then the deferred images must not
be dispatched prior to that either, not just prior to EndOfDxe?
Simultaneously, I propose the following subject (72 chars):
OvmfPkg/PlatformBds: Dispatch deferred images after EndOfDxe/ReadyToLock
No need to repost just because of this; the commit message can be
updated before you commit the series.
With the commit message update:
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Thank you!
Laszlo
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 6/9] OvmfPkg/PlatformBds: Dispatch deferred images after EndOfDxe
2016-11-08 13:04 ` Laszlo Ersek
@ 2016-11-11 11:16 ` Laszlo Ersek
2016-11-11 11:24 ` Ni, Ruiyu
0 siblings, 1 reply; 25+ messages in thread
From: Laszlo Ersek @ 2016-11-11 11:16 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Jordan Justen
Ray,
On 11/08/16 14:04, Laszlo Ersek wrote:
> On 11/08/16 13:29, Ruiyu Ni wrote:
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
>> Cc: Jordan Justen <jordan.l.justen@intel.com>
>> Cc: Laszlo Ersek <lersek@redhat.com>
>> ---
>> OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
>> index 66ee590..cc35630 100644
>> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
>> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
>> @@ -389,6 +389,11 @@ Returns:
>> NULL);
>> ASSERT_EFI_ERROR (Status);
>>
>> + //
>> + // Dispatch deferred images after EndOfDxe event and ReadyToLock installation.
>> + //
>> + EfiBootManagerDispatchDeferredImages ();
>> +
>> PlatformInitializeConsole (gPlatformConsole);
>> PcdStatus = PcdSet16S (PcdPlatformBootTimeOut,
>> GetFrontPageTimeoutFromQemu ());
>>
>
> Can you please add a note to the commit message that, if the platform
> installs EfiDxeSmmReadyToLockProtocol, then the deferred images must not
> be dispatched prior to that either, not just prior to EndOfDxe?
>
> Simultaneously, I propose the following subject (72 chars):
>
> OvmfPkg/PlatformBds: Dispatch deferred images after EndOfDxe/ReadyToLock
>
> No need to repost just because of this; the commit message can be
> updated before you commit the series.
>
> With the commit message update:
>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
I see that you added my R-b to the commit message.
9789894e3ba3dae87bfc384e97f946caeab389e0
But, you didn't update the patch like I requested. :(
Please pay more attention. Otherwise next time I'll have to ask for a
full repost, to make sure that my request is addressed.
Laszlo
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 6/9] OvmfPkg/PlatformBds: Dispatch deferred images after EndOfDxe
2016-11-11 11:16 ` Laszlo Ersek
@ 2016-11-11 11:24 ` Ni, Ruiyu
0 siblings, 0 replies; 25+ messages in thread
From: Ni, Ruiyu @ 2016-11-11 11:24 UTC (permalink / raw)
To: Laszlo Ersek; +Cc: edk2-devel@ml01.01.org, Justen, Jordan L
Sorry for that! :(
I really forgot it.
发自我的 iPhone
> 在 2016年11月11日,下午7:16,Laszlo Ersek <lersek@redhat.com> 写道:
>
> Ray,
>
>> On 11/08/16 14:04, Laszlo Ersek wrote:
>>> On 11/08/16 13:29, Ruiyu Ni wrote:
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
>>> Cc: Jordan Justen <jordan.l.justen@intel.com>
>>> Cc: Laszlo Ersek <lersek@redhat.com>
>>> ---
>>> OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 5 +++++
>>> 1 file changed, 5 insertions(+)
>>>
>>> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
>>> index 66ee590..cc35630 100644
>>> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
>>> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
>>> @@ -389,6 +389,11 @@ Returns:
>>> NULL);
>>> ASSERT_EFI_ERROR (Status);
>>>
>>> + //
>>> + // Dispatch deferred images after EndOfDxe event and ReadyToLock installation.
>>> + //
>>> + EfiBootManagerDispatchDeferredImages ();
>>> +
>>> PlatformInitializeConsole (gPlatformConsole);
>>> PcdStatus = PcdSet16S (PcdPlatformBootTimeOut,
>>> GetFrontPageTimeoutFromQemu ());
>>>
>>
>> Can you please add a note to the commit message that, if the platform
>> installs EfiDxeSmmReadyToLockProtocol, then the deferred images must not
>> be dispatched prior to that either, not just prior to EndOfDxe?
>>
>> Simultaneously, I propose the following subject (72 chars):
>>
>> OvmfPkg/PlatformBds: Dispatch deferred images after EndOfDxe/ReadyToLock
>>
>> No need to repost just because of this; the commit message can be
>> updated before you commit the series.
>>
>> With the commit message update:
>>
>> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
>
> I see that you added my R-b to the commit message.
>
> 9789894e3ba3dae87bfc384e97f946caeab389e0
>
> But, you didn't update the patch like I requested. :(
>
> Please pay more attention. Otherwise next time I'll have to ask for a
> full repost, to make sure that my request is addressed.
>
> Laszlo
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 7/9] CorebootPayload/PlatformBds: Dispatch deferred images after EndOfDxe
2016-11-08 12:29 [PATCH v2 0/9] Defer 3rd party images loading to after EndOfDxe Ruiyu Ni
` (5 preceding siblings ...)
2016-11-08 12:29 ` [PATCH v2 6/9] OvmfPkg/PlatformBds: " Ruiyu Ni
@ 2016-11-08 12:29 ` Ruiyu Ni
2016-11-09 0:13 ` Ma, Maurice
2016-11-08 12:29 ` [PATCH v2 8/9] QuarkPlatformPkg/PlatformBds: " Ruiyu Ni
` (2 subsequent siblings)
9 siblings, 1 reply; 25+ messages in thread
From: Ruiyu Ni @ 2016-11-08 12:29 UTC (permalink / raw)
To: edk2-devel; +Cc: Maurice Ma, Prince Agyeman
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Prince Agyeman <prince.agyeman@intel.com>
---
.../Library/PlatformBootManagerLib/PlatformBootManager.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index 5cb26e6..56be30f 100644
--- a/CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
@@ -214,6 +214,11 @@ PlatformBootManagerBeforeConsole (
// This needs to be done before option rom dispatched.
//
InstallReadyToLock ();
+
+ //
+ // Dispatch deferred images after EndOfDxe event and ReadyToLock installation.
+ //
+ EfiBootManagerDispatchDeferredImages ();
}
/**
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v2 7/9] CorebootPayload/PlatformBds: Dispatch deferred images after EndOfDxe
2016-11-08 12:29 ` [PATCH v2 7/9] CorebootPayload/PlatformBds: " Ruiyu Ni
@ 2016-11-09 0:13 ` Ma, Maurice
0 siblings, 0 replies; 25+ messages in thread
From: Ma, Maurice @ 2016-11-09 0:13 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Agyeman, Prince
Reviewed-by: Maurice Ma <maurice.ma@intel.com>
-----Original Message-----
From: Ni, Ruiyu
Sent: Tuesday, November 08, 2016 4:29 AM
To: edk2-devel@lists.01.org
Cc: Ma, Maurice <maurice.ma@intel.com>; Agyeman, Prince <prince.agyeman@intel.com>
Subject: [PATCH v2 7/9] CorebootPayload/PlatformBds: Dispatch deferred images after EndOfDxe
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Prince Agyeman <prince.agyeman@intel.com>
---
.../Library/PlatformBootManagerLib/PlatformBootManager.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index 5cb26e6..56be30f 100644
--- a/CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
@@ -214,6 +214,11 @@ PlatformBootManagerBeforeConsole (
// This needs to be done before option rom dispatched.
//
InstallReadyToLock ();
+
+ //
+ // Dispatch deferred images after EndOfDxe event and ReadyToLock installation.
+ //
+ EfiBootManagerDispatchDeferredImages ();
}
/**
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v2 8/9] QuarkPlatformPkg/PlatformBds: Dispatch deferred images after EndOfDxe
2016-11-08 12:29 [PATCH v2 0/9] Defer 3rd party images loading to after EndOfDxe Ruiyu Ni
` (6 preceding siblings ...)
2016-11-08 12:29 ` [PATCH v2 7/9] CorebootPayload/PlatformBds: " Ruiyu Ni
@ 2016-11-08 12:29 ` Ruiyu Ni
2016-11-08 15:39 ` Kinney, Michael D
2016-11-08 12:29 ` [PATCH v2 9/9] Nt32Pkg/PlatformBds: " Ruiyu Ni
2016-11-10 5:56 ` [PATCH v2 0/9] Defer 3rd party images loading to " Wang, Sunny (HPS SW)
9 siblings, 1 reply; 25+ messages in thread
From: Ruiyu Ni @ 2016-11-08 12:29 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael D Kinney, Kelly Steele
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Kelly Steele <kelly.steele@intel.com>
---
.../Library/PlatformBootManagerLib/PlatformBootManager.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/QuarkPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/QuarkPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index 19ff3d0..eb54ce5 100644
--- a/QuarkPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/QuarkPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
@@ -2,7 +2,7 @@
This file include all platform action which can be customized
by IBV/OEM.
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -285,6 +285,11 @@ PlatformBootManagerBeforeConsole (
NULL
);
ASSERT_EFI_ERROR (Status);
+
+ //
+ // Dispatch deferred images after EndOfDxe event and ReadyToLock installation.
+ //
+ EfiBootManagerDispatchDeferredImages ();
}
/**
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v2 8/9] QuarkPlatformPkg/PlatformBds: Dispatch deferred images after EndOfDxe
2016-11-08 12:29 ` [PATCH v2 8/9] QuarkPlatformPkg/PlatformBds: " Ruiyu Ni
@ 2016-11-08 15:39 ` Kinney, Michael D
0 siblings, 0 replies; 25+ messages in thread
From: Kinney, Michael D @ 2016-11-08 15:39 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org, Kinney, Michael D
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Tuesday, November 8, 2016 4:29 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Steele, Kelly
> <kelly.steele@intel.com>
> Subject: [PATCH v2 8/9] QuarkPlatformPkg/PlatformBds: Dispatch deferred images after
> EndOfDxe
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Kelly Steele <kelly.steele@intel.com>
> ---
> .../Library/PlatformBootManagerLib/PlatformBootManager.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/QuarkPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> b/QuarkPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> index 19ff3d0..eb54ce5 100644
> --- a/QuarkPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> +++ b/QuarkPlatformPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> @@ -2,7 +2,7 @@
> This file include all platform action which can be customized
> by IBV/OEM.
>
> -Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD License
> which accompanies this distribution. The full text of the license may be found at
> @@ -285,6 +285,11 @@ PlatformBootManagerBeforeConsole (
> NULL
> );
> ASSERT_EFI_ERROR (Status);
> +
> + //
> + // Dispatch deferred images after EndOfDxe event and ReadyToLock installation.
> + //
> + EfiBootManagerDispatchDeferredImages ();
> }
>
> /**
> --
> 2.9.0.windows.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 9/9] Nt32Pkg/PlatformBds: Dispatch deferred images after EndOfDxe
2016-11-08 12:29 [PATCH v2 0/9] Defer 3rd party images loading to after EndOfDxe Ruiyu Ni
` (7 preceding siblings ...)
2016-11-08 12:29 ` [PATCH v2 8/9] QuarkPlatformPkg/PlatformBds: " Ruiyu Ni
@ 2016-11-08 12:29 ` Ruiyu Ni
2016-11-09 6:55 ` Dong, Eric
2016-11-10 5:56 ` [PATCH v2 0/9] Defer 3rd party images loading to " Wang, Sunny (HPS SW)
9 siblings, 1 reply; 25+ messages in thread
From: Ruiyu Ni @ 2016-11-08 12:29 UTC (permalink / raw)
To: edk2-devel; +Cc: Eric Dong
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
---
Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index 7a840d0..99f30f9 100644
--- a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
@@ -124,6 +124,11 @@ PlatformBootManagerBeforeConsole (
// the platform should signal the event EFI_END_OF_DXE_EVENT_GUID
//
EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
+
+ //
+ // Dispatch deferred images after EndOfDxe event.
+ //
+ EfiBootManagerDispatchDeferredImages ();
}
/**
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v2 9/9] Nt32Pkg/PlatformBds: Dispatch deferred images after EndOfDxe
2016-11-08 12:29 ` [PATCH v2 9/9] Nt32Pkg/PlatformBds: " Ruiyu Ni
@ 2016-11-09 6:55 ` Dong, Eric
0 siblings, 0 replies; 25+ messages in thread
From: Dong, Eric @ 2016-11-09 6:55 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org
Reviewed-by: Eric Dong <eric.dong@intel.com>
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Tuesday, November 08, 2016 8:29 PM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric
> Subject: [PATCH v2 9/9] Nt32Pkg/PlatformBds: Dispatch deferred images after EndOfDxe
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> ---
> Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> index 7a840d0..99f30f9 100644
> --- a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> +++ b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> @@ -124,6 +124,11 @@ PlatformBootManagerBeforeConsole (
> // the platform should signal the event EFI_END_OF_DXE_EVENT_GUID
> //
> EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
> +
> + //
> + // Dispatch deferred images after EndOfDxe event.
> + //
> + EfiBootManagerDispatchDeferredImages ();
> }
>
> /**
> --
> 2.9.0.windows.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 0/9] Defer 3rd party images loading to after EndOfDxe
2016-11-08 12:29 [PATCH v2 0/9] Defer 3rd party images loading to after EndOfDxe Ruiyu Ni
` (8 preceding siblings ...)
2016-11-08 12:29 ` [PATCH v2 9/9] Nt32Pkg/PlatformBds: " Ruiyu Ni
@ 2016-11-10 5:56 ` Wang, Sunny (HPS SW)
9 siblings, 0 replies; 25+ messages in thread
From: Wang, Sunny (HPS SW) @ 2016-11-10 5:56 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel@lists.01.org; +Cc: Wang, Sunny (HPS SW), Haskell, Darrell
Reviewed all BDS related patches including PlatformBds libraries. All look good to me.
Thanks for offline addressing my PlatformBds related questions.
Reviewed-by: Sunny Wang <sunnywang@hpe.com>
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Tuesday, November 08, 2016 8:29 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH v2 0/9] Defer 3rd party images loading to after EndOfDxe
The patches change the default image loading policy by deferring 3rd party images loading to after EndOfDxe and add a new BDS API to dispatch the deferred images.
Platform needs to call the new BDS API
EfiBootManagerDispatchDeferredImages after EndOfDxe to ensure that any deferred images are loaded.
v2 puts the deferred images checking in DEBUG_CODE macro, corrects a typo of function name, and puts CpuDeadLoop() after ASSERT(FALSE).
v2 includes all the platform changes.
Ruiyu Ni (9):
MdeModulePkg/SecurityStubDxe: Defer 3rd party image before EndOfDxe
MdeModulePkg/UefiBootManager: Add EfiBootManagerDispatchDeferredImages
MdeModulePkg/BdsDxe: Check deferred images before booting to OS
MdeModulePkg/SecurityStubDxe: Report failure if image is load earlier
ArmVirPkg/PlatformBds: Dispatch deferred images after EndOfDxe
OvmfPkg/PlatformBds: Dispatch deferred images after EndOfDxe
CorebootPayload/PlatformBds: Dispatch deferred images after EndOfDxe
QuarkPlatformPkg/PlatformBds: Dispatch deferred images after EndOfDxe
Nt32Pkg/PlatformBds: Dispatch deferred images after EndOfDxe
.../Library/PlatformBootManagerLib/PlatformBm.c | 5 +
.../PlatformBootManagerLib/PlatformBootManager.c | 5 +
MdeModulePkg/Include/Library/UefiBootManagerLib.h | 13 +
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 113 ++++++
.../Library/UefiBootManagerLib/InternalBm.h | 1 +
.../UefiBootManagerLib/UefiBootManagerLib.inf | 1 +
MdeModulePkg/Universal/BdsDxe/Bds.h | 4 +-
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 2 +
MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 90 +++++
.../SecurityStubDxe/Defer3rdPartyImageLoad.c | 414 +++++++++++++++++++++
.../SecurityStubDxe/Defer3rdPartyImageLoad.h | 95 +++++
.../Universal/SecurityStubDxe/SecurityStub.c | 14 +-
.../Universal/SecurityStubDxe/SecurityStubDxe.inf | 11 +-
.../PlatformBootManagerLib/PlatformBootManager.c | 5 +
.../Library/PlatformBootManagerLib/BdsPlatform.c | 5 +
.../PlatformBootManagerLib/PlatformBootManager.c | 7 +-
16 files changed, 781 insertions(+), 4 deletions(-) create mode 100644 MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.c
create mode 100644 MdeModulePkg/Universal/SecurityStubDxe/Defer3rdPartyImageLoad.h
--
2.9.0.windows.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 25+ messages in thread