diff mbox series

[RFC,04/10] device-tree: split agnostic device-tree from arm

Message ID 20211217233437.13791-5-dpsmith@apertussolutions.com (mailing list archive)
State New, archived
Headers show
Series Hyperlaunch x86 Dom0 launch | expand

Commit Message

Daniel P. Smith Dec. 17, 2021, 11:34 p.m. UTC
This commit is purely for RFC to highlight some concerns and changes necessary
in order for hyperlaunch to utilize device tree as the boot configuration
container.

Despite being in common, the core device tree support enabled through
CONFIG_HAS_DEVICE_TREE will not build for an x86 configuration. This is due to
the fact that despite `struct device` appearing to be intended as a common data
structure is in fact unique on x86 and Arm. There is code in
xen/common/device_tree.c and include/xen/iommu.h that uses struct members found
in Arm's `struct device` that are not present in x86's version. This obviously
ends in compilation errors when enabling CONFIG_HAS_DEVICE_TREE on x86.

As a result this commit seeks to separate between requiring the ability to
parse DTB files and obtaining hardware definition from those DTB files. The
Kconfig parameter CORE_DEVICE_TREE was introduced for when only the former is
necessary and not the latter. It specifically allows for the inclusion of the
device tree parsing code without enabling the areas that make use of Arm
specific `struct device`.

For the RFC when the Arm specific `struct device` is referenced within device
tree parsing code, check for Arm has been added as an interim solution until a
long term solution, that is beyond the scope of the hyperlaunch patch set, can
be proposed and implemented.

Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
Reviewed-by: Christopher Clark <christopher.clark@starlab.io>
---
 xen/common/Kconfig            | 5 +++++
 xen/common/Makefile           | 4 ++--
 xen/common/device_tree.c      | 2 ++
 xen/include/xen/device_tree.h | 4 ++++
 4 files changed, 13 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index 5e6aad644e..aece21c9e5 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -31,8 +31,12 @@  config HAS_ALTERNATIVE
 config HAS_COMPAT
 	bool
 
+config CORE_DEVICE_TREE
+	bool
+
 config HAS_DEVICE_TREE
 	bool
+	select CORE_DEVICE_TREE
 
 config HAS_EX_TABLE
 	bool
@@ -333,6 +337,7 @@  config ARGO
 
 config HYPERLAUNCH
 	bool "Hyperlaunch support (UNSUPPORTED)" if UNSUPPORTED
+	select CORE_DEVICE_TREE
 	---help---
 	  Enables launch of multiple VMs at host boot as an alternative
 	  method of starting a Xen system.
diff --git a/xen/common/Makefile b/xen/common/Makefile
index a6337e065a..f22aec72a0 100644
--- a/xen/common/Makefile
+++ b/xen/common/Makefile
@@ -4,7 +4,7 @@  obj-$(CONFIG_HYPFS_CONFIG) += config_data.o
 obj-$(CONFIG_CORE_PARKING) += core_parking.o
 obj-y += cpu.o
 obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o
-obj-$(CONFIG_HAS_DEVICE_TREE) += device_tree.o
+obj-$(CONFIG_CORE_DEVICE_TREE) += device_tree.o
 obj-$(CONFIG_IOREQ_SERVER) += dm.o
 obj-y += domain.o
 obj-y += event_2l.o
@@ -73,7 +73,7 @@  obj-y += sched/
 obj-$(CONFIG_UBSAN) += ubsan/
 
 obj-$(CONFIG_NEEDS_LIBELF) += libelf/
-obj-$(CONFIG_HAS_DEVICE_TREE) += libfdt/
+obj-$(CONFIG_CORE_DEVICE_TREE) += libfdt/
 
 CONF_FILE := $(if $(patsubst /%,,$(KCONFIG_CONFIG)),$(BASEDIR)/)$(KCONFIG_CONFIG)
 config.gz: $(CONF_FILE)
diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 4aae281e89..d92fad2998 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -2012,9 +2012,11 @@  static unsigned long __init unflatten_dt_node(const void *fdt,
             ((char *)pp->value)[sz - 1] = 0;
             dt_dprintk("fixed up name for %s -> %s\n", pathp,
                        (char *)pp->value);
+#ifdef CONFIG_ARM
             /* Generic device initialization */
             np->dev.type = DEV_DT;
             np->dev.of_node = np;
+#endif
         }
     }
     if ( allnextpp )
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index fd6cd00b43..ca9f7672e9 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -101,9 +101,12 @@  struct dt_device_node {
      */
     struct list_head domain_list;
 
+#ifdef CONFIG_ARM
     struct device dev;
+#endif
 };
 
+#ifdef CONFIG_ARM
 #define dt_to_dev(dt_node)  (&(dt_node)->dev)
 
 static inline struct dt_device_node *dev_to_dt(struct device *dev)
@@ -112,6 +115,7 @@  static inline struct dt_device_node *dev_to_dt(struct device *dev)
 
     return container_of(dev, struct dt_device_node, dev);
 }
+#endif
 
 #define MAX_PHANDLE_ARGS 16
 struct dt_phandle_args {