* [PATCH v2 1/4] device_tree: Allow name wildcards in qemu_fdt_node_path()
2020-04-23 12:11 [PATCH v2 0/4] hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes Edgar E. Iglesias
@ 2020-04-23 12:11 ` Edgar E. Iglesias
2020-04-23 12:11 ` [PATCH v2 2/4] device_tree: Constify compat " Edgar E. Iglesias
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Edgar E. Iglesias @ 2020-04-23 12:11 UTC (permalink / raw)
To: qemu-devel
Cc: figlesia, peter.maydell, sstabellini, edgar.iglesias,
sai.pavan.boddu, frasse.iglesias, alistair, richard.henderson,
frederic.konrad, qemu-arm, philmd, luc.michel, david
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
Allow name wildcards in qemu_fdt_node_path(). This is useful
to find all nodes with a given compatibility string.
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
device_tree.c | 2 +-
include/sysemu/device_tree.h | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/device_tree.c b/device_tree.c
index bba6cc2164..f5b4699aed 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -308,7 +308,7 @@ char **qemu_fdt_node_path(void *fdt, const char *name, char *compat,
offset = len;
break;
}
- if (!strcmp(iter_name, name)) {
+ if (!name || !strcmp(iter_name, name)) {
char *path;
path = g_malloc(path_len);
diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h
index c16fd69bc0..7c53ef7634 100644
--- a/include/sysemu/device_tree.h
+++ b/include/sysemu/device_tree.h
@@ -39,6 +39,9 @@ void *load_device_tree_from_sysfs(void);
* NULL. If there is no error but no matching node was found, the
* returned array contains a single element equal to NULL. If an error
* was encountered when parsing the blob, the function returns NULL
+ *
+ * @name may be NULL to wildcard names and only match compatibility
+ * strings.
*/
char **qemu_fdt_node_path(void *fdt, const char *name, char *compat,
Error **errp);
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/4] device_tree: Constify compat in qemu_fdt_node_path()
2020-04-23 12:11 [PATCH v2 0/4] hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes Edgar E. Iglesias
2020-04-23 12:11 ` [PATCH v2 1/4] device_tree: Allow name wildcards in qemu_fdt_node_path() Edgar E. Iglesias
@ 2020-04-23 12:11 ` Edgar E. Iglesias
2020-04-23 12:11 ` [PATCH v2 3/4] hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102 Edgar E. Iglesias
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Edgar E. Iglesias @ 2020-04-23 12:11 UTC (permalink / raw)
To: qemu-devel
Cc: figlesia, peter.maydell, sstabellini, edgar.iglesias,
sai.pavan.boddu, frasse.iglesias, alistair, richard.henderson,
frederic.konrad, qemu-arm, philmd, luc.michel, david
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
Make compat in qemu_fdt_node_path() const char *.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
device_tree.c | 2 +-
include/sysemu/device_tree.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/device_tree.c b/device_tree.c
index f5b4699aed..b335dae707 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -291,7 +291,7 @@ char **qemu_fdt_node_unit_path(void *fdt, const char *name, Error **errp)
return path_array;
}
-char **qemu_fdt_node_path(void *fdt, const char *name, char *compat,
+char **qemu_fdt_node_path(void *fdt, const char *name, const char *compat,
Error **errp)
{
int offset, len, ret;
diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h
index 7c53ef7634..982c89345f 100644
--- a/include/sysemu/device_tree.h
+++ b/include/sysemu/device_tree.h
@@ -43,7 +43,7 @@ void *load_device_tree_from_sysfs(void);
* @name may be NULL to wildcard names and only match compatibility
* strings.
*/
-char **qemu_fdt_node_path(void *fdt, const char *name, char *compat,
+char **qemu_fdt_node_path(void *fdt, const char *name, const char *compat,
Error **errp);
/**
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 3/4] hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102
2020-04-23 12:11 [PATCH v2 0/4] hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes Edgar E. Iglesias
2020-04-23 12:11 ` [PATCH v2 1/4] device_tree: Allow name wildcards in qemu_fdt_node_path() Edgar E. Iglesias
2020-04-23 12:11 ` [PATCH v2 2/4] device_tree: Constify compat " Edgar E. Iglesias
@ 2020-04-23 12:11 ` Edgar E. Iglesias
2020-04-23 12:11 ` [PATCH v2 4/4] hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes Edgar E. Iglesias
2020-04-27 13:12 ` [PATCH v2 0/4] " Peter Maydell
4 siblings, 0 replies; 6+ messages in thread
From: Edgar E. Iglesias @ 2020-04-23 12:11 UTC (permalink / raw)
To: qemu-devel
Cc: figlesia, peter.maydell, sstabellini, edgar.iglesias,
sai.pavan.boddu, frasse.iglesias, alistair, richard.henderson,
frederic.konrad, qemu-arm, philmd, luc.michel, david
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
Move arm_boot_info into XlnxZCU102.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
hw/arm/xlnx-zcu102.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c
index bd645ad818..4eb117c755 100644
--- a/hw/arm/xlnx-zcu102.c
+++ b/hw/arm/xlnx-zcu102.c
@@ -31,13 +31,14 @@ typedef struct XlnxZCU102 {
bool secure;
bool virt;
+
+ struct arm_boot_info binfo;
} XlnxZCU102;
#define TYPE_ZCU102_MACHINE MACHINE_TYPE_NAME("xlnx-zcu102")
#define ZCU102_MACHINE(obj) \
OBJECT_CHECK(XlnxZCU102, (obj), TYPE_ZCU102_MACHINE)
-static struct arm_boot_info xlnx_zcu102_binfo;
static bool zcu102_get_secure(Object *obj, Error **errp)
{
@@ -166,9 +167,9 @@ static void xlnx_zcu102_init(MachineState *machine)
/* TODO create and connect IDE devices for ide_drive_get() */
- xlnx_zcu102_binfo.ram_size = ram_size;
- xlnx_zcu102_binfo.loader_start = 0;
- arm_load_kernel(s->soc.boot_cpu_ptr, machine, &xlnx_zcu102_binfo);
+ s->binfo.ram_size = ram_size;
+ s->binfo.loader_start = 0;
+ arm_load_kernel(s->soc.boot_cpu_ptr, machine, &s->binfo);
}
static void xlnx_zcu102_machine_instance_init(Object *obj)
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 4/4] hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes
2020-04-23 12:11 [PATCH v2 0/4] hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes Edgar E. Iglesias
` (2 preceding siblings ...)
2020-04-23 12:11 ` [PATCH v2 3/4] hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102 Edgar E. Iglesias
@ 2020-04-23 12:11 ` Edgar E. Iglesias
2020-04-27 13:12 ` [PATCH v2 0/4] " Peter Maydell
4 siblings, 0 replies; 6+ messages in thread
From: Edgar E. Iglesias @ 2020-04-23 12:11 UTC (permalink / raw)
To: qemu-devel
Cc: figlesia, peter.maydell, sstabellini, edgar.iglesias,
sai.pavan.boddu, frasse.iglesias, alistair, richard.henderson,
frederic.konrad, qemu-arm, philmd, luc.michel, david
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
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>
---
hw/arm/xlnx-zcu102.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
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);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/4] hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes
2020-04-23 12:11 [PATCH v2 0/4] hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes Edgar E. Iglesias
` (3 preceding siblings ...)
2020-04-23 12:11 ` [PATCH v2 4/4] hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes Edgar E. Iglesias
@ 2020-04-27 13:12 ` Peter Maydell
4 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2020-04-27 13:12 UTC (permalink / raw)
To: Edgar E. Iglesias
Cc: figlesia, Edgar Iglesias, Stefano Stabellini, Sai Pavan Boddu,
Francisco Iglesias, Alistair Francis, Richard Henderson,
QEMU Developers, KONRAD Frederic, qemu-arm,
Philippe Mathieu-Daudé, Luc Michel, David Gibson
On Thu, 23 Apr 2020 at 13:11, Edgar E. Iglesias
<edgar.iglesias@gmail.com> wrote:
>
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>
> When users try direct Linux runs on the ZynqMP models without enabling
> EL3 (and using appropriate FW) they run into trouble because the
> upstream kernel device-tree has EL3 based firmware nodes by default.
> PSCI firmware nodes work because we emulate the firmware in QEMU.
>
> This series avoids that problem by disabling firmware nodes that the
> machine cannot support due to lack of EL3 or EL2 support.
>
> This means we can now (without manually editing DTBs) run the following
> in a current Linux tree:
>
> qemu-system-aarch64 -M xlnx-zcu102 -m 2G -dtb arch/arm64/boot/dts/xilinx/zynqmp-zcu102-rev1.0.dtb -serial mon:stdio -kernel arch/arm64/boot/Image -initrd zu-rootfs.cpio.gz -append rdinit=/bin/sh
>
> Cheers,
> Edgar
Applied to target-arm.next, thanks.
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread