summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2012-03-05 18:55:11 +0000
committerBlue Swirl <blauwirbel@gmail.com>2012-03-05 18:55:11 +0000
commit27a9476cf75c4e147cb7d8c10c415928b3791b91 (patch)
treec203e4dd1676f6f9329e4f0f3a5a0bcfcc3e73a5
parenta2d335214a53b0cc6f7a4a2009d842bea1958085 (diff)
parent3208afbe04ad976e038fdb55d11f9f90629a5217 (diff)
downloadfocaccia-qemu-27a9476cf75c4e147cb7d8c10c415928b3791b91.tar.gz
focaccia-qemu-27a9476cf75c4e147cb7d8c10c415928b3791b91.zip
Merge branch 's390-for-upstream' of git://repo.or.cz/qemu/agraf
* 's390-for-upstream' of git://repo.or.cz/qemu/agraf:
  Move helpers.h to helper.h
  s390: Rework kernel loading: supports elf and newer kernels
-rw-r--r--hw/s390-virtio.c30
-rw-r--r--target-s390x/helper.h (renamed from target-s390x/helpers.h)0
-rw-r--r--target-s390x/op_helper.c2
-rw-r--r--target-s390x/translate.c4
4 files changed, 21 insertions, 15 deletions
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index 51123a7535..15e3ef389a 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -224,13 +224,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 {
@@ -243,7 +247,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) {
@@ -263,15 +267,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 */
diff --git a/target-s390x/helpers.h b/target-s390x/helper.h
index 01c8d0ea84..01c8d0ea84 100644
--- a/target-s390x/helpers.h
+++ b/target-s390x/helper.h
diff --git a/target-s390x/op_helper.c b/target-s390x/op_helper.c
index cf26b29ee9..70d98a80df 100644
--- a/target-s390x/op_helper.c
+++ b/target-s390x/op_helper.c
@@ -21,7 +21,7 @@
 #include "cpu.h"
 #include "dyngen-exec.h"
 #include "host-utils.h"
-#include "helpers.h"
+#include "helper.h"
 #include <string.h>
 #include "kvm.h"
 #include "qemu-timer.h"
diff --git a/target-s390x/translate.c b/target-s390x/translate.c
index 71f9dcdff5..8fab38cb1d 100644
--- a/target-s390x/translate.c
+++ b/target-s390x/translate.c
@@ -38,9 +38,9 @@
 static TCGv_ptr cpu_env;
 
 #include "gen-icount.h"
-#include "helpers.h"
+#include "helper.h"
 #define GEN_HELPER 1
-#include "helpers.h"
+#include "helper.h"
 
 typedef struct DisasContext DisasContext;
 struct DisasContext {