Re: [PATCH 4/4] ppc4xx: load Bamboo kernel, initrd, and fdt at fixed addresses
On Thu, Aug 5, 2010 at 7:39 PM, Liu Yu-B13201 b13...@freescale.com wrote: -Original Message- From: kvm-ppc-ow...@vger.kernel.org [mailto:kvm-ppc-ow...@vger.kernel.org] On Behalf Of Hollis Blanchard Sent: Thursday, August 05, 2010 8:22 AM To: qemu-de...@nongnu.org Cc: kvm-ppc@vger.kernel.org Subject: [PATCH 4/4] ppc4xx: load Bamboo kernel, initrd, and fdt at fixed addresses We can't use the return value of load_uimage() for the kernel because it can't account for BSS size, and the PowerPC kernel does not relocate blobs before zeroing BSS. Instead, we now load at the fixed addresses chosen by u-boot (the normal firmware for the board). What will us do if the uImage become bigger and fixed size is not enough? That was my question to Edgar, which was not answered. In u-boot, one would change some environment variables. With this code in qemu, the only recourse would be to edit ppc440_bamboo.c and rebuild. Perhaps in the future we can do something more sophisticated by specifying load addresses in a qemu device tree, but I don't understand that stuff enough to know if that is an intended use. -Hollis -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/4] ppc4xx: load Bamboo kernel, initrd, and fdt at fixed addresses
We can't use the return value of load_uimage() for the kernel because it can't account for BSS size, and the PowerPC kernel does not relocate blobs before zeroing BSS. Instead, we now load at the fixed addresses chosen by u-boot (the normal firmware for the board). Signed-off-by: Hollis Blanchard hol...@penguinppc.org --- hw/ppc440_bamboo.c | 39 ++- 1 files changed, 18 insertions(+), 21 deletions(-) This fixes a critical bug in PowerPC 440 Bamboo board emulation. diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index d471d5d..34ddf45 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -27,6 +27,11 @@ #define BINARY_DEVICE_TREE_FILE bamboo.dtb +/* from u-boot */ +#define KERNEL_ADDR 0x100 +#define FDT_ADDR 0x180 +#define RAMDISK_ADDR 0x190 + static int bamboo_load_device_tree(target_phys_addr_t addr, uint32_t ramsize, target_phys_addr_t initrd_base, @@ -98,10 +103,8 @@ static void bamboo_init(ram_addr_t ram_size, uint64_t elf_lowaddr; target_phys_addr_t entry = 0; target_phys_addr_t loadaddr = 0; -target_long kernel_size = 0; -target_ulong initrd_base = 0; target_long initrd_size = 0; -target_ulong dt_base = 0; +int success; int i; /* Setup CPU. */ @@ -118,15 +121,15 @@ static void bamboo_init(ram_addr_t ram_size, /* Load kernel. */ if (kernel_filename) { -kernel_size = load_uimage(kernel_filename, entry, loadaddr, NULL); -if (kernel_size 0) { -kernel_size = load_elf(kernel_filename, NULL, NULL, elf_entry, - elf_lowaddr, NULL, 1, ELF_MACHINE, 0); +success = load_uimage(kernel_filename, entry, loadaddr, NULL); +if (success 0) { +success = load_elf(kernel_filename, NULL, NULL, elf_entry, + elf_lowaddr, NULL, 1, ELF_MACHINE, 0); entry = elf_entry; loadaddr = elf_lowaddr; } /* XXX try again as binary */ -if (kernel_size 0) { +if (success 0) { fprintf(stderr, qemu: could not load kernel '%s'\n, kernel_filename); exit(1); @@ -135,26 +138,20 @@ static void bamboo_init(ram_addr_t ram_size, /* Load initrd. */ if (initrd_filename) { -initrd_base = kernel_size + loadaddr; -initrd_size = load_image_targphys(initrd_filename, initrd_base, - ram_size - initrd_base); +initrd_size = load_image_targphys(initrd_filename, RAMDISK_ADDR, + ram_size - RAMDISK_ADDR); if (initrd_size 0) { -fprintf(stderr, qemu: could not load initial ram disk '%s'\n, -initrd_filename); +fprintf(stderr, qemu: could not load ram disk '%s' at %x\n, +initrd_filename, RAMDISK_ADDR); exit(1); } } /* If we're loading a kernel directly, we must load the device tree too. */ if (kernel_filename) { -if (initrd_base) -dt_base = initrd_base + initrd_size; -else -dt_base = kernel_size + loadaddr; - -if (bamboo_load_device_tree(dt_base, ram_size, -initrd_base, initrd_size, kernel_cmdline) 0) { +if (bamboo_load_device_tree(FDT_ADDR, ram_size, RAMDISK_ADDR, +initrd_size, kernel_cmdline) 0) { fprintf(stderr, couldn't load device tree\n); exit(1); } @@ -163,7 +160,7 @@ static void bamboo_init(ram_addr_t ram_size, /* Set initial guest state. */ env-gpr[1] = (1620) - 8; -env-gpr[3] = dt_base; +env-gpr[3] = FDT_ADDR; env-nip = entry; /* XXX we currently depend on KVM to create some initial TLB entries. */ } -- 1.7.2 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Qemu-devel] [PATCH 4/4] ppc4xx: load Bamboo kernel, initrd, and fdt at fixed addresses
On Wed, Aug 04, 2010 at 05:21:37PM -0700, Hollis Blanchard wrote: We can't use the return value of load_uimage() for the kernel because it can't account for BSS size, and the PowerPC kernel does not relocate blobs before zeroing BSS. Instead, we now load at the fixed addresses chosen by u-boot (the normal firmware for the board). Signed-off-by: Hollis Blanchard hol...@penguinppc.org This looks good to me, thanks Hollis. Acked-by: Edgar E. Iglesias edgar.igles...@gmail.com --- hw/ppc440_bamboo.c | 39 ++- 1 files changed, 18 insertions(+), 21 deletions(-) This fixes a critical bug in PowerPC 440 Bamboo board emulation. diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index d471d5d..34ddf45 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -27,6 +27,11 @@ #define BINARY_DEVICE_TREE_FILE bamboo.dtb +/* from u-boot */ +#define KERNEL_ADDR 0x100 +#define FDT_ADDR 0x180 +#define RAMDISK_ADDR 0x190 + static int bamboo_load_device_tree(target_phys_addr_t addr, uint32_t ramsize, target_phys_addr_t initrd_base, @@ -98,10 +103,8 @@ static void bamboo_init(ram_addr_t ram_size, uint64_t elf_lowaddr; target_phys_addr_t entry = 0; target_phys_addr_t loadaddr = 0; -target_long kernel_size = 0; -target_ulong initrd_base = 0; target_long initrd_size = 0; -target_ulong dt_base = 0; +int success; int i; /* Setup CPU. */ @@ -118,15 +121,15 @@ static void bamboo_init(ram_addr_t ram_size, /* Load kernel. */ if (kernel_filename) { -kernel_size = load_uimage(kernel_filename, entry, loadaddr, NULL); -if (kernel_size 0) { -kernel_size = load_elf(kernel_filename, NULL, NULL, elf_entry, - elf_lowaddr, NULL, 1, ELF_MACHINE, 0); +success = load_uimage(kernel_filename, entry, loadaddr, NULL); +if (success 0) { +success = load_elf(kernel_filename, NULL, NULL, elf_entry, + elf_lowaddr, NULL, 1, ELF_MACHINE, 0); entry = elf_entry; loadaddr = elf_lowaddr; } /* XXX try again as binary */ -if (kernel_size 0) { +if (success 0) { fprintf(stderr, qemu: could not load kernel '%s'\n, kernel_filename); exit(1); @@ -135,26 +138,20 @@ static void bamboo_init(ram_addr_t ram_size, /* Load initrd. */ if (initrd_filename) { -initrd_base = kernel_size + loadaddr; -initrd_size = load_image_targphys(initrd_filename, initrd_base, - ram_size - initrd_base); +initrd_size = load_image_targphys(initrd_filename, RAMDISK_ADDR, + ram_size - RAMDISK_ADDR); if (initrd_size 0) { -fprintf(stderr, qemu: could not load initial ram disk '%s'\n, -initrd_filename); +fprintf(stderr, qemu: could not load ram disk '%s' at %x\n, +initrd_filename, RAMDISK_ADDR); exit(1); } } /* If we're loading a kernel directly, we must load the device tree too. */ if (kernel_filename) { -if (initrd_base) -dt_base = initrd_base + initrd_size; -else -dt_base = kernel_size + loadaddr; - -if (bamboo_load_device_tree(dt_base, ram_size, -initrd_base, initrd_size, kernel_cmdline) 0) { +if (bamboo_load_device_tree(FDT_ADDR, ram_size, RAMDISK_ADDR, +initrd_size, kernel_cmdline) 0) { fprintf(stderr, couldn't load device tree\n); exit(1); } @@ -163,7 +160,7 @@ static void bamboo_init(ram_addr_t ram_size, /* Set initial guest state. */ env-gpr[1] = (1620) - 8; -env-gpr[3] = dt_base; +env-gpr[3] = FDT_ADDR; env-nip = entry; /* XXX we currently depend on KVM to create some initial TLB entries. */ } -- 1.7.2 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html