This issue can be reproduced by the following steps:
1. Boot to HTTP boot option and the boot file is a ISO file like Ubuntu PE 
image.
2. Exit from boot option (GRUB) and then back to boot manager menu.
3. Boot to the same HTTP boot option again or a HTTP boot option pointing to 
the same HTTP ISO file. It will fail to boot.
Root cause:
When booting a HTTP boot option, the HTTP boot driver will save the Boot File's 
information in its private data as cache data for skipping the Boot file 
discovery from next time boot. However, the cache data doesn't include 
ImageType data, which would cause HTTP boot driver using the invalid ImageType 
(ImageTypeMax) and then fail to boot the cached boot file. In other words, for 
the second time boot, the HttpBootLoadFile() doesn't update ImageType (it 
returns a valid ImageType), which causes that the HttpBootDxeLoadFile() skips 
to Register a RAM Disk for downloaded HTTP ISO file and then BDS code can't 
find the RAM disk to boot.
Solution:
Save ImageType to private data for next time HTTP boot.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Sunny Wang <sunnyw...@hpe.com>
---
 NetworkPkg/HttpBootDxe/HttpBootDxe.h  | 1 +
 NetworkPkg/HttpBootDxe/HttpBootImpl.c | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.h 
b/NetworkPkg/HttpBootDxe/HttpBootDxe.h
index 76b7943..806429c 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDxe.h
+++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.h
@@ -189,6 +189,7 @@ struct _HTTP_BOOT_PRIVATE_DATA {
   VOID                                      *BootFileUriParser;
   UINTN                                     BootFileSize;
   BOOLEAN                                   NoGateway;
+  HTTP_BOOT_IMAGE_TYPE                      ImageType;
 
   //
   // URI string extracted from the input FilePath parameter.
diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c 
b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
index cf643d8..4b850b6 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
@@ -2,6 +2,7 @@
   The implementation of EFI_LOAD_FILE_PROTOCOL for UEFI HTTP boot.
 
 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
 This program and the accompanying materials are licensed and made available 
under 
 the terms and conditions of the BSD License that accompanies this 
distribution.  
 The full text of the license may be found at
@@ -271,7 +272,7 @@ HttpBootLoadFile (
                TRUE,
                &Private->BootFileSize,
                NULL,
-               ImageType
+               &Private->ImageType
                );
     if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
       //
@@ -283,7 +284,7 @@ HttpBootLoadFile (
                  FALSE,
                  &Private->BootFileSize,
                  NULL,
-                 ImageType
+                 &Private->ImageType
                  );
       if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
         return Status;
@@ -293,6 +294,7 @@ HttpBootLoadFile (
 
   if (*BufferSize < Private->BootFileSize) {
     *BufferSize = Private->BootFileSize;
+    *ImageType = Private->ImageType;
     return EFI_BUFFER_TOO_SMALL;
   }
 
-- 
2.5.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to