On 23.01.2014, at 01:23, Scott Wood <scottw...@freescale.com> wrote:
> On Mon, 2014-01-20 at 00:44 +0100, Alexander Graf wrote: >> Almost all platforms QEMU emulates have some sort of firmware they can load >> to expose a guest environment that closely resembles the way it would look >> like on real hardware. >> >> This patch introduces such a firmware on our e500 platforms. U-boot is the >> default firmware for most of these systems and as such our preferred choice. >> >> For now, it is able to expose the same functionality to the user as the >> direct >> -kernel option was, just that it prints some nice messages beforehand. >> >> However, if you abort the boot (press any key) or boot without -kernel you >> are actually able to modify the boot environment, execute a networked boot >> through the e1000 emulation and execute u-boot payloads. > > Have you removed support for loading the kernel directly? I thought you > said you were only going to load U-Boot in the absence of -kernel. > Given the absence of runtime services, and the presence of a > standardized OS entry mechanism (ePAPR), inserting firmware into the > process seems like a niche use case rather than something that should be > the default, much less mandatory. It's definitely not mandatory, but it makes things consistent. I'm not sure it's the better approach, but I figured we should definitely be able to go through the full u-boot cycle before we enter the guest kernel. > >> + /* Load u-boot (ELF) */ >> + if (bios_name == NULL) { >> + bios_name = "u-boot.e500"; >> + } >> + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); >> + >> + bios_size = load_elf(filename, NULL, NULL, &bios_entry, &loadaddr, NULL, >> + 1, ELF_MACHINE, 0); >> + if (bios_size < 0) { >> + /* >> + * Hrm. No ELF image? Try a uImage, maybe someone is giving us an >> + * ePAPR compliant kernel >> + */ > > ePAPR specifies ELF, not uImage (though QEMU does currently support > ePAPR-ish loading of uImages, as U-Boot does) -- and you still seem to > be trying to load firmware here, not a kernel. Hrm. How do we load an ELF image when we have non-0 mapped memory? In fact, I'm wondering the same on uImages now that I think of it :). So what this code does is it treats the "-bios" parameter the same as we used to treat -kernel, just in reverse probe order. So we check if -bios is an ELF image, if so, load it. If not, we load it as uImage and run it. That means if you do -bios uImage you get a direct kernel boot, the same way we used to with -kernel before this patch set. If we really want to make firmware only pop up when no -kernel is given (again, I'm not decided on that one yet), all we need to do is add this piece of code before the bios loader: if (args->kernel_filename) { /* Treat a -kernel passed kernel as firmware. This is possible because we don't have runtime services. */ bios_name = args->kernel_filename; } Then if we ever want to support both, all we need to do is replace the above piece of code with something that checks for a machine option on whether we want to skip firmware or not. Alex