[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XEN][PATCH] common/libfdt: optimize usage


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Fri, 14 Nov 2025 18:01:32 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XiNGl3ZXa6y3CFfQsH463W3pcuo8YvXy7QmlmKcHFuI=; b=Yof2g1kwB+thVdlZnXzCh9dc1vyTsNH1dyX1FjVCg7XFqqWYKDQS1uy301Yl9AJa3r2s8U+cY0xIms7XUAVZHci+qsIjBnlcFxVY9vQH/Z4dxxqvcf66a5+UjvBEGtCn52Gcw7511wggKTjOmumlFm2QGQx8p+m6Cibl+LTBFJHVP/0/zftXNJrmofra+ihm5X1azKAduUfROpxl7hzzMm/bnLYHzOI/rZJFdhinKwjGPwiU3ecHApJKw0YeXSz1+wwro2dVuuiNE1+h+aM3HFfj+1C0PfxtSjM7hmYc25x4oPiKN3mzwPn3IEMUt4yWEwiT4HFXS82jrUyGcZXhVg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZPxR75x713JzE5IC0YAi+azhGpF6bzT9Hq0DcYEg7pg/QJhP1P6UPzA6w83AKUVJuHihFzRsGoGG7Z/3o6zB+VbJLH/tXHyDVrLBa7V4/K52g63Mv9OMAbc0+daiADb4MUlnLd2WkZmB+9DEXoiGksZRGKxA6x45GwldAktVzqF9iu8uULmIwXXzHiJlCIqGhQgUjQAcA+wCqpTAuy4s2IhKYNvUs8ICQriSVkz94/NjxXa/AVGpGiyjZGoeQs8DhUlp/qqEJCGvahpdf7zwU6gTeViZzBtiG4SpcPm+pAc/hcrxNBH1CA+LVokw/wSqZ4DIjSp1c8St0zvDJRc+xw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Grygorii Strashko <grygorii_strashko@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>
  • Delivery-date: Fri, 14 Nov 2025 18:01:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcVZC1OaGU/KuFYUqRuKRHxQFN9g==
  • Thread-topic: [XEN][PATCH] common/libfdt: optimize usage

From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>

Now all libfdt features are built-it unconditionally, but...

X86: The libfdt is used on x86 only to parse Hyperlaunch/dom0less Xen
nodes, so full libfdt is not needed in this case and minimal, RO
configuration can be used.

ARM - situation is more complicated:
1) ARM reads Host DT (fdt.c RO)
2) ARM reads passthrough DT (RO)
3) ARM generates dom0/hwdom DT from Host DT (there is a mix of WIP and SW APIs)
4) ARM generates domU DT (there is a mix of WIP and SW APIs)
4) With EFI enabled - ARM needs RW API and fdt_empty_tree
5) With CONFIG_OVERLAY_DTB - ARM needs RW and fdt_overlay API

Hence, add possibility for optimizing libfdt usage by introducing separate
Kconfig options for each libfdt feature and select them where needed.

Following libfdt modules are not used after this change:
 Makefile.libfdt
 fdt_addresses.c
 fdt_strerror.c
 fdt_check.c

Signed-off-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
---
Not sure about using DOMAIN_BUILD_HELPERS for selecting 
LIBFDT features, as DOMAIN_BUILD_HELPERS doesn't exactly
says that domain's DT will be generated when selected.

 xen/arch/arm/Kconfig       |  4 ++++
 xen/common/Kconfig         |  4 ++++
 xen/common/libfdt/Kconfig  | 14 ++++++++++++++
 xen/common/libfdt/Makefile | 12 +++++++++---
 4 files changed, 31 insertions(+), 3 deletions(-)
 create mode 100644 xen/common/libfdt/Kconfig

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index cf6af68299f6..f10cd3d7effc 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -111,6 +111,8 @@ config ARM_EFI
        bool "UEFI boot service support"
        depends on ARM_64 && !MPU
        default y
+       select LIBFDT_RW
+       select LIBFDT_EMPTY_TREE
        help
          This option provides support for boot services through
          UEFI firmware. A UEFI stub is provided to allow Xen to
@@ -149,6 +151,8 @@ config HAS_ITS
 config OVERLAY_DTB
        bool "DTB overlay support (UNSUPPORTED)" if UNSUPPORTED
        depends on SYSCTL
+       select LIBFDT_RW
+       select LIBFDT_OVERLAY
        help
          Dynamic addition/removal of Xen device tree nodes using a dtbo.
 
diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index 401d5046f6f5..256aff269c3b 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -28,6 +28,8 @@ config DOM0LESS_BOOT
 
 config DOMAIN_BUILD_HELPERS
        bool
+       select LIBFDT_WIP
+       select LIBFDT_SW
 
 config GRANT_TABLE
        bool "Grant table support" if EXPERT
@@ -680,4 +682,6 @@ config PM_STATS
          Enable collection of performance management statistics to aid in
          analyzing and tuning power/performance characteristics of the system
 
+source "common/libfdt/Kconfig"
+
 endmenu
diff --git a/xen/common/libfdt/Kconfig b/xen/common/libfdt/Kconfig
new file mode 100644
index 000000000000..3abd904b2969
--- /dev/null
+++ b/xen/common/libfdt/Kconfig
@@ -0,0 +1,14 @@
+config LIBFDT_WIP
+       bool
+
+config LIBFDT_SW
+    bool
+
+config LIBFDT_RW
+    bool
+
+config LIBFDT_EMPTY_TREE
+    bool
+
+config LIBFDT_OVERLAY
+    bool
diff --git a/xen/common/libfdt/Makefile b/xen/common/libfdt/Makefile
index 6ce679f98f47..c832d1849a5c 100644
--- a/xen/common/libfdt/Makefile
+++ b/xen/common/libfdt/Makefile
@@ -1,7 +1,13 @@
-include $(src)/Makefile.libfdt
 
 SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
 
+obj-libfdt-y := fdt.o fdt_ro.o
+obj-libfdt-$(CONFIG_LIBFDT_WIP) += fdt_wip.o
+obj-libfdt-$(CONFIG_LIBFDT_SW) += fdt_sw.o
+obj-libfdt-$(CONFIG_LIBFDT_RW) += fdt_rw.o
+obj-libfdt-$(CONFIG_LIBFDT_EMPTY_TREE) += fdt_empty_tree.o
+obj-libfdt-$(CONFIG_LIBFDT_OVERLAY) += fdt_overlay.o
+
 # For CONFIG_OVERLAY_DTB, libfdt functionalities will be needed during runtime.
 ifneq ($(CONFIG_OVERLAY_DTB),y)
 OBJCOPYFLAGS := $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s))
@@ -15,7 +21,7 @@ CFLAGS-y += -I$(srctree)/include/xen/libfdt/
 $(obj)/libfdt.o: $(obj)/libfdt-temp.o FORCE
        $(call if_changed,objcopy)
 
-$(obj)/libfdt-temp.o: $(addprefix $(obj)/,$(LIBFDT_OBJS)) FORCE
+$(obj)/libfdt-temp.o: $(addprefix $(obj)/,$(obj-libfdt-y)) FORCE
        $(call if_changed,ld)
 
-targets += libfdt-temp.o $(LIBFDT_OBJS)
+targets += libfdt-temp.o $(obj-libfdt-y)
-- 
2.34.1



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.