summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2016-11-29 09:28:24 +0000
committerStefan Hajnoczi <stefanha@redhat.com>2016-11-29 09:28:24 +0000
commit517dcb8785de4ce078810f75d9598474cd6fbca8 (patch)
tree466300ced83e404c6480d2c243aaaa331de89e51 /hw
parent406c97c41f643dc835f32a3bcb6c612b2320547e (diff)
parentb77257d7bae26a0fca6a90af88d54ee2c45f5b61 (diff)
downloadqemu-517dcb8785de4ce078810f75d9598474cd6fbca8.tar.gz
qemu-517dcb8785de4ce078810f75d9598474cd6fbca8.tar.bz2
qemu-517dcb8785de4ce078810f75d9598474cd6fbca8.zip
Merge remote-tracking branch 'pm215/tags/pull-target-arm-20161128' into staging
target-arm queue: * hw/arm/boot: fix crash handling device trees with no /chosen or /memory nodes * generic-loader: only set PC if a CPU is specified # gpg: Signature made Mon 28 Nov 2016 01:47:21 PM GMT # gpg: using RSA key 0x3C2525ED14360CDE # gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" # gpg: aka "Peter Maydell <pmaydell@gmail.com>" # gpg: aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" # Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83 15CF 3C25 25ED 1436 0CDE * pm215/tags/pull-target-arm-20161128: arm: Create /chosen and /memory devicetree nodes if necessary generic-loader: file: Only set a PC if a CPU is specified Message-id: 1480341071-5367-1-git-send-email-peter.maydell@linaro.org Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/arm/boot.c17
-rw-r--r--hw/core/generic-loader.c7
2 files changed, 23 insertions, 1 deletions
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 942416d95a..ff621e4b6a 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -9,6 +9,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
+#include <libfdt.h>
#include "hw/hw.h"
#include "hw/arm/arm.h"
#include "hw/arm/linux-boot-if.h"
@@ -486,6 +487,17 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
g_free(nodename);
}
} else {
+ Error *err = NULL;
+
+ rc = fdt_path_offset(fdt, "/memory");
+ if (rc < 0) {
+ qemu_fdt_add_subnode(fdt, "/memory");
+ }
+
+ if (!qemu_fdt_getprop(fdt, "/memory", "device_type", NULL, &err)) {
+ qemu_fdt_setprop_string(fdt, "/memory", "device_type", "memory");
+ }
+
rc = qemu_fdt_setprop_sized_cells(fdt, "/memory", "reg",
acells, binfo->loader_start,
scells, binfo->ram_size);
@@ -495,6 +507,11 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
}
}
+ rc = fdt_path_offset(fdt, "/chosen");
+ if (rc < 0) {
+ qemu_fdt_add_subnode(fdt, "/chosen");
+ }
+
if (binfo->kernel_cmdline && *binfo->kernel_cmdline) {
rc = qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
binfo->kernel_cmdline);
diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c
index 79ab6df357..208f549dff 100644
--- a/hw/core/generic-loader.c
+++ b/hw/core/generic-loader.c
@@ -93,7 +93,12 @@ static void generic_loader_realize(DeviceState *dev, Error **errp)
"image");
return;
}
- s->set_pc = true;
+ /* The user specified a file, only set the PC if they also specified
+ * a CPU to use.
+ */
+ if (s->cpu_num != CPU_NONE) {
+ s->set_pc = true;
+ }
} else if (s->addr) {
/* User is setting the PC */
if (s->data || s->data_len || s->data_be) {