[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 22/22] s390x/ipl: Fix crash of ELF images with arbitr
From: |
Christian Borntraeger |
Subject: |
[Qemu-devel] [PULL 22/22] s390x/ipl: Fix crash of ELF images with arbitrary entry points |
Date: |
Fri, 28 Feb 2014 10:31:06 +0100 |
From: Thomas Huth <address@hidden>
When loading S390 kernels, the current code expects an ELF file with the
start address 0x10000. Other ELF files cause a segmentation fault. To avoid
these crashes, we should get the start address from the ELF file instead
of always using a hard-coded address.
Signed-off-by: Thomas Huth <address@hidden>
Acked-by: Cornelia Huck <address@hidden>
Signed-off-by: Christian Borntraeger <address@hidden>
---
hw/s390x/ipl.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 1a6397b..04fb1a8 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -95,7 +95,8 @@ static int s390_ipl_init(SysBusDevice *dev)
}
return 0;
} else {
- kernel_size = load_elf(ipl->kernel, NULL, NULL, NULL, NULL,
+ uint64_t pentry = KERN_IMAGE_START;
+ kernel_size = load_elf(ipl->kernel, NULL, NULL, &pentry, NULL,
NULL, 1, ELF_MACHINE, 0);
if (kernel_size == -1) {
kernel_size = load_image_targphys(ipl->kernel, 0, ram_size);
@@ -104,15 +105,19 @@ static int s390_ipl_init(SysBusDevice *dev)
fprintf(stderr, "could not load kernel '%s'\n", ipl->kernel);
return -1;
}
- /* we have to overwrite values in the kernel image, which are "rom" */
- strcpy(rom_ptr(KERN_PARM_AREA), ipl->cmdline);
-
/*
- * we can not rely on the ELF entry point, since up to 3.2 this
- * value was 0x800 (the SALIPL loader) and it wont work. For
- * all (Linux) cases 0x10000 (KERN_IMAGE_START) should be fine.
+ * Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the
+ * kernel parameters here as well. Note: For old kernels (up to 3.2)
+ * we can not rely on the ELF entry point - it was 0x800 (the SALIPL
+ * loader) and it won't work. For this case we force it to 0x10000,
too.
*/
- ipl->start_addr = KERN_IMAGE_START;
+ if (pentry == KERN_IMAGE_START || pentry == 0x800) {
+ ipl->start_addr = KERN_IMAGE_START;
+ /* Overwrite parameters in the kernel image, which are "rom" */
+ strcpy(rom_ptr(KERN_PARM_AREA), ipl->cmdline);
+ } else {
+ ipl->start_addr = pentry;
+ }
}
if (ipl->initrd) {
ram_addr_t initrd_offset;
--
1.8.4.2
- [Qemu-devel] [PULL 16/22] s390-ccw.img: Fix sporadic errors with ccw boot image - initialize css, (continued)
- [Qemu-devel] [PULL 16/22] s390-ccw.img: Fix sporadic errors with ccw boot image - initialize css, Christian Borntraeger, 2014/02/28
- [Qemu-devel] [PULL 20/22] s390x/kvm: Add missing SIGP CPU RESET order, Christian Borntraeger, 2014/02/28
- [Qemu-devel] [PULL 02/22] s390x/kvm: implement floating-interrupt controller device, Christian Borntraeger, 2014/02/28
- [Qemu-devel] [PULL 07/22] s390x/eventfacility: mask out commands, Christian Borntraeger, 2014/02/28
- [Qemu-devel] [PULL 21/22] s390x/kvm: Rework priv instruction handlers, Christian Borntraeger, 2014/02/28
- [Qemu-devel] [PULL 14/22] s390x/event-facility: exploit realize/unrealize, Christian Borntraeger, 2014/02/28
- [Qemu-devel] [PULL 19/22] s390x/kvm: Rework SIGP INITIAL CPU RESET handler, Christian Borntraeger, 2014/02/28
- [Qemu-devel] [PULL 04/22] s390x/kvm: Fixed bad SIGP SET-ARCHITECTURE handler, Christian Borntraeger, 2014/02/28
- [Qemu-devel] [PULL 13/22] s390x/event-facility: add support for live migration, Christian Borntraeger, 2014/02/28
- [Qemu-devel] [PULL 18/22] s390x/cpu: Use ioctl to reset state in the kernel, Christian Borntraeger, 2014/02/28
- [Qemu-devel] [PULL 22/22] s390x/ipl: Fix crash of ELF images with arbitrary entry points,
Christian Borntraeger <=