@@ -125,6 +125,22 @@ config DOM0LESS_BOOT
Xen boot without the need of a control domain (Dom0), which could be
present anyway.
+config HOST_DTB_EXPORT
+ bool "Export host device tree to hypfs if enabled"
+ depends on ARM && HYPFS && !ACPI
+ help
+
+ Export host device-tree to hypfs so toolstack can have an access for the
+ host device tree from Dom0. If you unsure say N.
+
+config HOST_DTB_MAX_SIZE
+ int "Max host dtb export size"
+ depends on HOST_DTB_EXPORT
+ default 8192
+ help
+
+ Maximum size of the host device-tree exported to hypfs.
+
config GICV3
bool "GICv3 driver"
depends on !NEW_VGIC
@@ -20,6 +20,7 @@ obj-$(CONFIG_DOM0LESS_BOOT) += dom0less-build.init.o
obj-y += domain.o
obj-y += domain_build.init.o
obj-y += domctl.o
+obj-$(CONFIG_HOST_DTB_EXPORT) += host_dtb_export.o
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
obj-y += efi/
obj-y += gic.o
new file mode 100644
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Export host FDT to the hypfs
+ *
+ * Copyright (C) 2024 EPAM Systems
+ */
+
+#include <xen/device_tree.h>
+#include <xen/hypfs.h>
+#include <xen/init.h>
+#include <xen/libfdt/libfdt.h>
+
+static HYPFS_VARSIZE_INIT(dt_prop, XEN_HYPFS_TYPE_BLOB,
+ "devicetree", CONFIG_HOST_DTB_MAX_SIZE,
+ &hypfs_leaf_ro_funcs);
+
+static int __init host_dtb_export_init(void)
+{
+ ASSERT(dt_host && (dt_host->sibling == NULL));
+
+ dt_prop.u.content = device_tree_flattened;
+ dt_prop.e.size = fdt_totalsize(device_tree_flattened);
+ hypfs_add_leaf(&hypfs_root, &dt_prop, true);
+
+ return 0;
+}
+
+__initcall(host_dtb_export_init);