Thanks Ersek, 

I did change my code to match what you have here as far as the allocation. I 
did some more debugging and registered up a callback in exit boot services, and 
did an integrity check of the memory I previously allocated and put the ramdisk 
in. I checked the memory right before I call loadimage (to launch the kernel), 
and then again I check in the callback during exit boot services. So some point 
between the memory actually does get changed. So it might be something 
happening during exit boot services. 

Just a question, after allocating that memory as you mentioned below, other 
code should not be able to allocate and use that same address range right? Even 
during exit boot services?



-----Original Message-----
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Tuesday, May 17, 2016 11:41 AM
To: Foster, Matthew I <matthew.i.fos...@intel.com>
Cc: edk2-devel@lists.01.org <edk2-de...@ml01.01.org>
Subject: Re: [edk2] Using the Shell to launch a kernel using a RAMDISK

On 05/17/16 19:13, Foster, Matthew I wrote:
> I am trying to boot a linux kernel from within the shell that is using 
> a ramdisk filesystem. I allocate memory in the shell for a ramdisk. I 
> read the filesystem out of flash memory after allocating memory in the 
> shell:
> 
> KernelRootFS = AllocatePages(((KernelFSSize/FOUR_KB_ALIGNED) +1));
> 
> I then use that address (KernelRootFS) to pass it to the kernel 
> command line to tell there kernel where the filesystem is in memory.
> When it goes to use the ramdisk at some in the kernel boot, the 
> ramdisk appears to be corrupted and I get SQUASHFS errors.
> 
> If I do that exact procedure in BdsBoot, I do not see the corruption.
> Which leads me to believe the shell might be somehow trampling over 
> the memory. Does anyone have any ideas on what I might do, or what 
> could be going on here?

Please see the following messages in the list archive:

http://thread.gmane.org/gmane.comp.bios.edk2.devel/10766
http://thread.gmane.org/gmane.comp.bios.edk2.devel/9885/focus=9923

In a nutshell (basically just summarizing what others have described):
- Reserved memory is needed only if you want to boot off of a RAM disk
  (as opposed to just playing with the filesystem on it while in the
  UEFI shell or similar).
- If you want to boot off of a RAM disk, then reserved memory *is*
  necessary.
- The RAM disks created with the firmware setup forms (HII) are not
  meant for booting off of.

So, you should do something like this:

  EFI_STATUS           Status;
  EFI_PHYSICAL_ADDRESS KernelRootFsAddress;

  Status = gBS->AllocatePages (
                  AllocateAnyPages,
                  EfiReservedMemoryType,
                  EFI_SIZE_TO_PAGES ((UINTN)KernelFsSize),
                  &KernelRootFsAddress
                  );
  if (!EFI_ERROR (Status)) {
    VOID *KernelRootFs;

    KernelRootFs = (VOID *)(UINTN)KernelRootFsAddress;
    /* ... */
  }

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

Reply via email to