From patchwork Fri Dec 30 09:10:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Borntraeger X-Patchwork-Id: 133622 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4965EB6FC4 for ; Fri, 30 Dec 2011 20:11:22 +1100 (EST) Received: from localhost ([::1]:36820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgYUe-00046R-0Z for incoming@patchwork.ozlabs.org; Fri, 30 Dec 2011 04:11:16 -0500 Received: from eggs.gnu.org ([140.186.70.92]:47950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgYUX-00044g-TL for qemu-devel@nongnu.org; Fri, 30 Dec 2011 04:11:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RgYUW-0003E7-Ip for qemu-devel@nongnu.org; Fri, 30 Dec 2011 04:11:09 -0500 Received: from e06smtp18.uk.ibm.com ([195.75.94.114]:52653) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgYUW-0003Dz-8r for qemu-devel@nongnu.org; Fri, 30 Dec 2011 04:11:08 -0500 Received: from /spool/local by e06smtp18.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 30 Dec 2011 09:11:06 -0000 Received: from d06nrmr1307.portsmouth.uk.ibm.com ([9.149.38.129]) by e06smtp18.uk.ibm.com ([192.168.101.148]) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 30 Dec 2011 09:10:44 -0000 Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBU9Ahfc2617532 for ; Fri, 30 Dec 2011 09:10:43 GMT Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pBU9AhGh015937 for ; Fri, 30 Dec 2011 02:10:43 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pBU9Ah2e015932; Fri, 30 Dec 2011 02:10:43 -0700 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id ED93A12243A7; Fri, 30 Dec 2011 10:10:42 +0100 (CET) From: Christian Borntraeger To: Alexander Graf Date: Fri, 30 Dec 2011 10:10:26 +0100 Message-Id: <1325236226-2949-1-git-send-email-borntraeger@de.ibm.com> X-Mailer: git-send-email 1.7.8.2 x-cbid: 11123009-6892-0000-0000-00000095B81E X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.114 Cc: Cornelia Huck , Christian Borntraeger , Jens Freimann , qemu-devel Subject: [Qemu-devel] [PATCH] s390: Rework kernel loading: supports elf and newer kernels X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This reworks the image loading on s390. Newer kernels will not always have a 0dd0 (basr 13,0) at address 0x10000. We must not rely on specific code at certain addresses. This check was introduced to warn users that tried to load vmlinux, since ELF loading was not supported. Lets wire that up. If elf loading fails, we assume that this is a standard kernel image and load that via load_image_targphys. This patch also changes all other users of load_image to load_image_targphys to be consistent. (the elf loader registers the kernel as rom). Signed-off-by: Christian Borntraeger --- hw/s390-virtio.c | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-) diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c index 61b67e8..c17e7f8 100644 --- a/hw/s390-virtio.c +++ b/hw/s390-virtio.c @@ -223,13 +223,17 @@ static void s390_init(ram_addr_t my_ram_size, s390_add_running_cpu(env); if (kernel_filename) { - kernel_size = load_image(kernel_filename, qemu_get_ram_ptr(0)); - if (lduw_be_phys(KERN_IMAGE_START) != 0x0dd0) { - fprintf(stderr, "Specified image is not an s390 boot image\n"); - exit(1); + kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, NULL, + NULL, 1, ELF_MACHINE, 0); + if (kernel_size == -1UL) { + kernel_size = load_image_targphys(kernel_filename, 0, ram_size); } - + /* + * 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. + */ env->psw.addr = KERN_IMAGE_START; env->psw.mask = 0x0000000180000000ULL; } else { @@ -242,7 +246,7 @@ static void s390_init(ram_addr_t my_ram_size, } bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); - bios_size = load_image(bios_filename, qemu_get_ram_ptr(ZIPL_LOAD_ADDR)); + bios_size = load_image_targphys(bios_filename, ZIPL_LOAD_ADDR, 4096); g_free(bios_filename); if ((long)bios_size < 0) { @@ -262,15 +266,17 @@ static void s390_init(ram_addr_t my_ram_size, while (kernel_size + 0x100000 > initrd_offset) { initrd_offset += 0x100000; } - initrd_size = load_image(initrd_filename, qemu_get_ram_ptr(initrd_offset)); - - stq_be_phys(INITRD_PARM_START, initrd_offset); - stq_be_phys(INITRD_PARM_SIZE, initrd_size); + initrd_size = load_image_targphys(initrd_filename, initrd_offset, + ram_size - initrd_offset); + /* we have to overwrite values in the kernel image, which are "rom" */ + memcpy(rom_ptr(INITRD_PARM_START), &initrd_offset, 8); + memcpy(rom_ptr(INITRD_PARM_SIZE), &initrd_size, 8); } if (kernel_cmdline) { - cpu_physical_memory_write(KERN_PARM_AREA, kernel_cmdline, - strlen(kernel_cmdline) + 1); + /* we have to overwrite values in the kernel image, which are "rom" */ + memcpy(rom_ptr(KERN_PARM_AREA), kernel_cmdline, + strlen(kernel_cmdline) + 1); } /* Create VirtIO network adapters */