[Qemu-devel] Re: [PATCH 27/27] Add SLOF-based partition firmware for pSeries machine, allowing more boot options
On 28.03.2011, at 12:51, Paolo Bonzini wrote: > On 03/28/2011 12:30 PM, Alexander Graf wrote: >>> diff --git a/pc-bios/README b/pc-bios/README >>> index 3fc0944..646a31a 100644 >>> --- a/pc-bios/README >>> +++ b/pc-bios/README >>> @@ -13,6 +13,11 @@ >>> The included image for PowerPC (for 32 and 64 bit PPC CPUs), Sparc32 >>> and Sparc64 are built from OpenBIOS SVN revision 1018. >>> >>> +- SLOF (Slimline Open Firmware) is a free IEEE 1275 Open Firmware >>> + implementation for certain IBM POWER hardware. The sources are at >>> + https://github.com/dgibson/SLOF, and the image currently in qemu is >>> + built from git tag qemu-slof-20110323. >>> + >>> - The PXE roms come from Rom-o-Matic gPXE 0.9.9 with BANNER_TIMEOUT=0 >> >> Is this a line removal? > > No, it's a bug in your mailer. :) > > Glad to see Thunderbird isn't the only one that butcher replies to patches > (in addition to patches of course). Glad to head that it's a bug O_o. Phew :) Alex
[Qemu-devel] Re: [PATCH 27/27] Add SLOF-based partition firmware for pSeries machine, allowing more boot options
On 03/28/2011 12:30 PM, Alexander Graf wrote: On 25.03.2011, at 04:21, David Gibson wrote: Currently, the emulated pSeries machine requires the use of the -kernel parameter in order to explicitly load a guest kernel. This means booting from the virtual disk, cdrom or network is not possible. This patch addresses this limitation by inserting a within-partition firmware image (derived from the "SLOF" free Open Firmware project). If -kernel is not specified, qemu will now load the SLOF image, which has access to the qemu boot device list through the device tree, and can boot from any of the usual virtual devices. In order to support the new firmware, an extension to the emulated machine/hypervisor is necessary. Unlike Linux, which expects multi-CPU entry to be handled kexec() style, the SLOF firmware expects only one CPU to be active at entry, and to use a hypervisor RTAS method to enable the other CPUs one by one. This patch also implements this 'start-cpu' method, so that SLOF can start the secondary CPUs and marshal them into the kexec() holding pattern ready for entry into the guest OS. Linux should, and in the future might directly use the start-cpu method to enable initially disabled CPUs, but for now it does require kexec() entry. Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Paul Mackerras Signed-off-by: David Gibson --- Makefile |2 +- hw/spapr.c | 35 +--- hw/spapr_rtas.c | 78 ++ pc-bios/README |5 +++ pc-bios/slof.bin | Bin 0 -> 579072 bytes 5 files changed, 115 insertions(+), 5 deletions(-) create mode 100644 pc-bios/slof.bin diff --git a/Makefile b/Makefile index e0b3fea..989622b 100644 --- a/Makefile +++ b/Makefile @@ -214,7 +214,7 @@ pxe-rtl8139.bin pxe-virtio.bin \ bamboo.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \ multiboot.bin linuxboot.bin \ s390-zipl.rom \ -spapr-rtas.bin +spapr-rtas.bin slof.bin else BLOBS= endif diff --git a/hw/spapr.c b/hw/spapr.c index 9d611a7..c6454e6 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -44,6 +44,10 @@ #define INITRD_LOAD_ADDR0x0280 #define FDT_MAX_SIZE0x1 #define RTAS_MAX_SIZE 0x1 +#define FW_MAX_SIZE 0x40 +#define FW_FILE_NAME"slof.bin" + +#define MIN_RAM_SLOF 512UL #define TIMEBASE_FREQ 51200ULL @@ -56,6 +60,7 @@ static void *spapr_create_fdt(int *fdt_size, ram_addr_t ramsize, sPAPREnvironment *spapr, target_phys_addr_t initrd_base, target_phys_addr_t initrd_size, + const char *boot_device, const char *kernel_cmdline, target_phys_addr_t rtas_addr, target_phys_addr_t rtas_size, @@ -104,6 +109,7 @@ static void *spapr_create_fdt(int *fdt_size, ram_addr_t ramsize, &start_prop, sizeof(start_prop; _FDT((fdt_property(fdt, "linux,initrd-end", &end_prop, sizeof(end_prop; +_FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device))); _FDT((fdt_end_node(fdt))); @@ -260,7 +266,7 @@ static void ppc_spapr_init(ram_addr_t ram_size, ram_addr_t ram_offset; target_phys_addr_t fdt_addr, rtas_addr; uint32_t kernel_base, initrd_base; -long kernel_size, initrd_size, htab_size, rtas_size; +long kernel_size, initrd_size, htab_size, rtas_size, fw_size; long pteg_shift = 17; int fdt_size; char *filename; @@ -392,13 +398,33 @@ static void ppc_spapr_init(ram_addr_t ram_size, initrd_size = 0; } } else { -fprintf(stderr, "pSeries machine needs -kernel for now"); -exit(1); +if (ram_size< (MIN_RAM_SLOF<< 20)) { +fprintf(stderr, "qemu: pSeries SLOF firmware requires>= " +"%ldM guest RAM\n", MIN_RAM_SLOF); +exit(1); +} +filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "slof.bin"); +fw_size = load_image_targphys(filename, 0, FW_MAX_SIZE); +if (fw_size< 0) { +hw_error("qemu: could not load LPAR rtas '%s'\n", filename); +exit(1); +} +qemu_free(filename); +kernel_base = 0x100; +initrd_base = 0; +initrd_size = 0; + +/* SLOF will startup the secondary CPUs using RTAS, + rather than expecting a kexec() style entry */ +for (i = 0; i< smp_cpus; i++) { +envs[i]->halted = 1; +} } /* Prepare the device tree */ fdt = spapr_create_fdt(&fdt_size, ram_size, cpu_model, envs, spapr, - initrd_base, initrd_size, kernel_cmdline, + initrd_base, initrd_size, + boot_device, kernel_cmdline, rtas_addr, rtas_size, pteg
[Qemu-devel] Re: [PATCH 27/27] Add SLOF-based partition firmware for pSeries machine, allowing more boot options
On 03/28/2011 12:30 PM, Alexander Graf wrote: diff --git a/pc-bios/README b/pc-bios/README index 3fc0944..646a31a 100644 --- a/pc-bios/README +++ b/pc-bios/README @@ -13,6 +13,11 @@ The included image for PowerPC (for 32 and 64 bit PPC CPUs), Sparc32 and Sparc64 are built from OpenBIOS SVN revision 1018. +- SLOF (Slimline Open Firmware) is a free IEEE 1275 Open Firmware + implementation for certain IBM POWER hardware. The sources are at + https://github.com/dgibson/SLOF, and the image currently in qemu is + built from git tag qemu-slof-20110323. + - The PXE roms come from Rom-o-Matic gPXE 0.9.9 with BANNER_TIMEOUT=0 Is this a line removal? No, it's a bug in your mailer. :) Glad to see Thunderbird isn't the only one that butcher replies to patches (in addition to patches of course). Paolo
[Qemu-devel] Re: [PATCH 27/27] Add SLOF-based partition firmware for pSeries machine, allowing more boot options
On 25.03.2011, at 04:21, David Gibson wrote: > Currently, the emulated pSeries machine requires the use of the > -kernel parameter in order to explicitly load a guest kernel. This > means booting from the virtual disk, cdrom or network is not possible. > > This patch addresses this limitation by inserting a within-partition > firmware image (derived from the "SLOF" free Open Firmware project). > If -kernel is not specified, qemu will now load the SLOF image, which > has access to the qemu boot device list through the device tree, and > can boot from any of the usual virtual devices. > > In order to support the new firmware, an extension to the emulated > machine/hypervisor is necessary. Unlike Linux, which expects > multi-CPU entry to be handled kexec() style, the SLOF firmware expects > only one CPU to be active at entry, and to use a hypervisor RTAS > method to enable the other CPUs one by one. > > This patch also implements this 'start-cpu' method, so that SLOF can > start the secondary CPUs and marshal them into the kexec() holding > pattern ready for entry into the guest OS. Linux should, and in the > future might directly use the start-cpu method to enable initially > disabled CPUs, but for now it does require kexec() entry. > > Signed-off-by: Benjamin Herrenschmidt > Signed-off-by: Paul Mackerras > Signed-off-by: David Gibson > --- > Makefile |2 +- > hw/spapr.c | 35 +--- > hw/spapr_rtas.c | 78 ++ > pc-bios/README |5 +++ > pc-bios/slof.bin | Bin 0 -> 579072 bytes > 5 files changed, 115 insertions(+), 5 deletions(-) > create mode 100644 pc-bios/slof.bin > > diff --git a/Makefile b/Makefile > index e0b3fea..989622b 100644 > --- a/Makefile > +++ b/Makefile > @@ -214,7 +214,7 @@ pxe-rtl8139.bin pxe-virtio.bin \ > bamboo.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \ > multiboot.bin linuxboot.bin \ > s390-zipl.rom \ > -spapr-rtas.bin > +spapr-rtas.bin slof.bin > else > BLOBS= > endif > diff --git a/hw/spapr.c b/hw/spapr.c > index 9d611a7..c6454e6 100644 > --- a/hw/spapr.c > +++ b/hw/spapr.c > @@ -44,6 +44,10 @@ > #define INITRD_LOAD_ADDR0x0280 > #define FDT_MAX_SIZE0x1 > #define RTAS_MAX_SIZE 0x1 > +#define FW_MAX_SIZE 0x40 > +#define FW_FILE_NAME"slof.bin" > + > +#define MIN_RAM_SLOF 512UL > > #define TIMEBASE_FREQ 51200ULL > > @@ -56,6 +60,7 @@ static void *spapr_create_fdt(int *fdt_size, ram_addr_t > ramsize, > sPAPREnvironment *spapr, > target_phys_addr_t initrd_base, > target_phys_addr_t initrd_size, > + const char *boot_device, > const char *kernel_cmdline, > target_phys_addr_t rtas_addr, > target_phys_addr_t rtas_size, > @@ -104,6 +109,7 @@ static void *spapr_create_fdt(int *fdt_size, ram_addr_t > ramsize, >&start_prop, sizeof(start_prop; > _FDT((fdt_property(fdt, "linux,initrd-end", >&end_prop, sizeof(end_prop; > +_FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device))); > > _FDT((fdt_end_node(fdt))); > > @@ -260,7 +266,7 @@ static void ppc_spapr_init(ram_addr_t ram_size, > ram_addr_t ram_offset; > target_phys_addr_t fdt_addr, rtas_addr; > uint32_t kernel_base, initrd_base; > -long kernel_size, initrd_size, htab_size, rtas_size; > +long kernel_size, initrd_size, htab_size, rtas_size, fw_size; > long pteg_shift = 17; > int fdt_size; > char *filename; > @@ -392,13 +398,33 @@ static void ppc_spapr_init(ram_addr_t ram_size, > initrd_size = 0; > } > } else { > -fprintf(stderr, "pSeries machine needs -kernel for now"); > -exit(1); > +if (ram_size < (MIN_RAM_SLOF << 20)) { > +fprintf(stderr, "qemu: pSeries SLOF firmware requires >= " > +"%ldM guest RAM\n", MIN_RAM_SLOF); > +exit(1); > +} > +filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "slof.bin"); > +fw_size = load_image_targphys(filename, 0, FW_MAX_SIZE); > +if (fw_size < 0) { > +hw_error("qemu: could not load LPAR rtas '%s'\n", filename); > +exit(1); > +} > +qemu_free(filename); > +kernel_base = 0x100; > +initrd_base = 0; > +initrd_size = 0; > + > +/* SLOF will startup the secondary CPUs using RTAS, > + rather than expecting a kexec() style entry */ > +for (i = 0; i < smp_cpus; i++) { > +envs[i]->halted = 1; > +} > } > > /* Prepare the device tree */ > fdt = spapr_create_fdt(&fdt_size, ram_size, cpu_model, envs, spapr, > - initrd_base, initrd_size, kernel_cm
[Qemu-devel] Re: [PATCH 27/27] Add SLOF-based partition firmware for pSeries machine, allowing more boot options
On Wed, Mar 23, 2011 at 08:55:53PM +1100, Benjamin Herrenschmidt wrote: > On Wed, 2011-03-23 at 19:51 +1100, Benjamin Herrenschmidt wrote: > > On Wed, 2011-03-23 at 16:30 +1100, David Gibson wrote: > > > +- SLOF (Slimline Open Firmware) is a free IEEE 1275 Open Firmware > > > + implementation for certain IBM POWER hardware. The image currently > > > + in qemu is built from git tag qemu-slof-20110323. > > > + > > > > For those who can't wait to check it out ... > > > > David forgot to mention the actual git URL ;-) > > > > It's on github (https://github.com/dgibson/SLOF) > > And I just realized it wasn't actually pushed out either :-) I've just > fixed that. *facepalm* Sorry. -- David Gibson| I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
[Qemu-devel] Re: [PATCH 27/27] Add SLOF-based partition firmware for pSeries machine, allowing more boot options
On Wed, 2011-03-23 at 19:51 +1100, Benjamin Herrenschmidt wrote: > On Wed, 2011-03-23 at 16:30 +1100, David Gibson wrote: > > +- SLOF (Slimline Open Firmware) is a free IEEE 1275 Open Firmware > > + implementation for certain IBM POWER hardware. The image currently > > + in qemu is built from git tag qemu-slof-20110323. > > + > > For those who can't wait to check it out ... > > David forgot to mention the actual git URL ;-) > > It's on github (https://github.com/dgibson/SLOF) And I just realized it wasn't actually pushed out either :-) I've just fixed that. Cheers, Ben.
[Qemu-devel] Re: [PATCH 27/27] Add SLOF-based partition firmware for pSeries machine, allowing more boot options
On Wed, 2011-03-23 at 16:30 +1100, David Gibson wrote: > +- SLOF (Slimline Open Firmware) is a free IEEE 1275 Open Firmware > + implementation for certain IBM POWER hardware. The image currently > + in qemu is built from git tag qemu-slof-20110323. > + For those who can't wait to check it out ... David forgot to mention the actual git URL ;-) It's on github (https://github.com/dgibson/SLOF) Cheers, Ben.