aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdgar E. Iglesias <edgar.iglesias@xilinx.com>2020-04-23 14:11:14 +0200
committerPeter Maydell <peter.maydell@linaro.org>2020-04-30 15:35:41 +0100
commit6f7b6947a6639fff15c6a0956adf0f5ec004b789 (patch)
treed8c690e2d4e2744cb61091cda295a9819183fb69
parent4d1ac883a7635c4bd58991bc158eff0c81cb230c (diff)
hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodespull-target-arm-20200430-1
Disable unsupported FDT firmware nodes if a user passes us a DTB with nodes enabled that the machine cannot support due to lack of EL3 or EL2 support. Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Message-id: 20200423121114.4274-5-edgar.iglesias@gmail.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--hw/arm/xlnx-zcu102.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c
index 4eb117c755..a798e228b7 100644
--- a/hw/arm/xlnx-zcu102.c
+++ b/hw/arm/xlnx-zcu102.c
@@ -23,6 +23,7 @@
#include "qemu/error-report.h"
#include "qemu/log.h"
#include "sysemu/qtest.h"
+#include "sysemu/device_tree.h"
typedef struct XlnxZCU102 {
MachineState parent_obj;
@@ -68,6 +69,34 @@ static void zcu102_set_virt(Object *obj, bool value, Error **errp)
s->virt = value;
}
+static void zcu102_modify_dtb(const struct arm_boot_info *binfo, void *fdt)
+{
+ XlnxZCU102 *s = container_of(binfo, XlnxZCU102, binfo);
+ bool method_is_hvc;
+ char **node_path;
+ const char *r;
+ int prop_len;
+ int i;
+
+ /* If EL3 is enabled, we keep all firmware nodes active. */
+ if (!s->secure) {
+ node_path = qemu_fdt_node_path(fdt, NULL, "xlnx,zynqmp-firmware",
+ &error_fatal);
+
+ for (i = 0; node_path && node_path[i]; i++) {
+ r = qemu_fdt_getprop(fdt, node_path[i], "method", &prop_len, NULL);
+ method_is_hvc = r && !strcmp("hvc", r);
+
+ /* Allow HVC based firmware if EL2 is enabled. */
+ if (method_is_hvc && s->virt) {
+ continue;
+ }
+ qemu_fdt_setprop_string(fdt, node_path[i], "status", "disabled");
+ }
+ g_strfreev(node_path);
+ }
+}
+
static void xlnx_zcu102_init(MachineState *machine)
{
XlnxZCU102 *s = ZCU102_MACHINE(machine);
@@ -169,6 +198,7 @@ static void xlnx_zcu102_init(MachineState *machine)
s->binfo.ram_size = ram_size;
s->binfo.loader_start = 0;
+ s->binfo.modify_dtb = zcu102_modify_dtb;
arm_load_kernel(s->soc.boot_cpu_ptr, machine, &s->binfo);
}