common/libfdt: optimize usage
PATCH 1/1 common/libfdt: optimize usage
From: Grygorii Strashko <[email protected]>
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
---
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
xen/arch/arm/Kconfig +4 -0
@@ -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.
xen/common/Kconfig +4 -0
@@ -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
xen/common/libfdt/Kconfig new file +14 -0
@@ -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
xen/common/libfdt/Makefile +9 -3
@@ -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)
Signature · 1 line
2.34.1
Quoted 8 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
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.
Quoted 7 lines
ARM - situation is more complicated:
1) ARM reads Host DT (fdt.cRO)
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 andfdt_empty_tree
5) WithCONFIG_OVERLAY_DTB- ARM needs RW andfdt_overlayAPI
This goes too far, imo.
Quoted 7 lines
xen/common/libfdt/Kconfig new file +4
-0@@ -0,0 +1,14 @@ +config LIBFDT_WIP + bool + +config LIBFDT_SW
xen/common/libfdt/Kconfig line 14
Quoted 10 lines
xen/common/libfdt/Kconfig new file +10
-0+ bool + +config LIBFDT_RW + bool + +config LIBFDT_EMPTY_TREE + bool + +config LIBFDT_OVERLAY + bool
Nit: Inconsistent indentation.
Also, how would one be to guess which of these may need selecting? What do "WIP", "SW", and "RW" stand for? What exactly would "empty tree" mean? Yes, you follow what the files are named under libfdt/, but that naming is overly cryptic, too. The comments at the top of these files also don't say anything helpful.
Jan
Quoted 17 lines · Jan Beulich
Quoted 8 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
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.
Quoted 7 lines
ARM - situation is more complicated:
1) ARM reads Host DT (fdt.cRO)
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 andfdt_empty_tree
5) WithCONFIG_OVERLAY_DTB- ARM needs RW andfdt_overlayAPI
Quoted 1 line
This goes too far, imo.
The more that, unless OVERLAY_DTB=y, all code and data moves to .init.*. Is coverage in in .init.* really of as much concern as runtime code/data?
Jan
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Jan Beulich
Quoted 15 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
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.cRO)
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 andfdt_empty_tree
5) WithCONFIG_OVERLAY_DTB- ARM needs RW andfdt_overlayAPI
Quoted 4 lines
Quoted 1 line
This goes too far, imo.
The more that, unless OVERLAY_DTB=y, all code and data moves to .init.*. Is coverage in in .init.* really of as much concern as runtime code/data?
It is less priority, but still is. Any way it is unnecessary build units (build time) and increased binary size.
Actually, I see interesting behavior - when build with CONFIG_CC_SPLIT_SECTIONS=y (CONFIG_LIVEPATCH=y) the libfdt code is not moved in ".init"
0xa000027aa10 T fdt_ro_probe_
0xa00002c0000 T __init_begin
Signature · 2 lines
Best regards, -grygorii
Quoted 30 lines · Grygorii Strashko
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Jan Beulich
Quoted 15 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
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.cRO)
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 andfdt_empty_tree
5) WithCONFIG_OVERLAY_DTB- ARM needs RW andfdt_overlayAPIQuoted 4 lines
Quoted 1 line
This goes too far, imo.
The more that, unless OVERLAY_DTB=y, all code and data moves to .init.*. Is coverage in in .init.* really of as much concern as runtime code/data?
It is less priority, but still is. Any way it is unnecessary build units (build time) and increased binary size.
Quoted 6 lines
Actually, I see interesting behavior - when build with
CONFIG_CC_SPLIT_SECTIONS=y(CONFIG_LIVEPATCH=y) the libfdt code is not moved in ".init"
0xa000027aa10Tfdt_ro_probe_
0xa00002c0000T__init_begin
Hmm, that's a bug, resulting from libfdt/ not using the usual machinery to do the conversion.
Jan
Quoted 17 lines · Jan Beulich
Quoted 8 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
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.
Quoted 7 lines
ARM - situation is more complicated:
1) ARM reads Host DT (fdt.cRO)
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 andfdt_empty_tree
5) WithCONFIG_OVERLAY_DTB- ARM needs RW andfdt_overlayAPI
Quoted 6 lines
This goes too far, imo.
xen/common/libfdt/Kconfig line 1
Quoted 4 lines
xen/common/libfdt/Kconfig new file +1
-0@@ -0,0 +1,14 @@ +config LIBFDT_WIP
"Write-in-place"
- update property in place
- NOP the property or node
(no resize)
Quoted 3 lines
xen/common/libfdt/Kconfig line 4
Quoted 3 lines
xen/common/libfdt/Kconfig new file +3
-0+ bool + +config LIBFDT_SW
"Sequential-write"
Used to create DT in a buffer sequentially in one pass fdt_create
fdt_begin_node
fdt_property
...
fdt_end_node
...fdt_finish
Quoted 3 lines
xen/common/libfdt/Kconfig line 7
Quoted 3 lines
xen/common/libfdt/Kconfig new file +3
-0+ bool + +config LIBFDT_RW
"Full read-write"
- add/del/change nodes or properties in fdt blob
- no automatic resize
Quoted 3 lines
xen/common/libfdt/Kconfig line 10
Quoted 3 lines
xen/common/libfdt/Kconfig new file +3
-0+ bool + +config LIBFDT_EMPTY_TREE
Enables fdt_create_empty_tree() helper
Quoted 3 lines
xen/common/libfdt/Kconfig line 13
Quoted 3 lines
xen/common/libfdt/Kconfig new file +3
-0+ bool + +config LIBFDT_OVERLAY
Enables DT overlay helpers (deps: RW, WIP)
Quoted 9 lines
xen/common/libfdt/Kconfig line 14
Quoted 1 line
xen/common/libfdt/Kconfig new file +1
-0+ boolNit: Inconsistent indentation.
Also, how would one be to guess which of these may need selecting? What do "WIP", "SW", and "RW" stand for? What exactly would "empty tree" mean? Yes, you follow what the files are named under libfdt/, but that naming is overly cryptic, too. The comments at the top of these files also don't say anything helpful.
Indeed.
Signature · 2 lines
Best regards, -grygorii
Quoted 16 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
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.cRO)
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 andfdt_empty_tree
5) WithCONFIG_OVERLAY_DTB- ARM needs RW andfdt_overlayAPI
Quoted 8 lines
Hence, add possibility for optimizing libfdt usage by introducing separate
Kconfigoptions 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
This is a nice idea, and the less we compile of this nonsense library the better.
Quoted 6 lines
Signed-off-by Grygorii Strashko <[email protected]>---
Not sure about usingDOMAIN_BUILD_HELPERSfor selecting LIBFDT features, asDOMAIN_BUILD_HELPERSdoesn't exactly says that domain's DT will be generated when selected.
We likely want a DEVICE_TREE_WRITER Kconfig, or some such. That would compile in all code that performs DTB writes and gate the DTB overlay. Not having it restricts libfdt to fdt.c and fdt_ro.c, and having it adds fdt_rw, and allows the others depending on EFI and/or overlay settings.
But the helpers themselves are not terribly well organized, so I'd say it's not strictly required for now.
Quoted 13 lines
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/Kconfigxen/arch/arm/Kconfig +0
-0
xen/arch/arm/Kconfig config ARM_EFI · line 115
Quoted 5 lines
xen/arch/arm/Kconfig +2
-0@@ -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
Only on UEFI? That's surprising. Why does this entry point need more than creating a DTB for a domU in dom0less?
Quoted 17 lines
xen/arch/arm/Kconfig +2
-0help 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.xen/common/Kconfig +0
-0
xen/common/Kconfig config DOM0LESS_BOOT · line 32
Quoted 5 lines
xen/common/Kconfig +2
-0@@ -28,6 +28,8 @@ config DOM0LESS_BOOT config DOMAIN_BUILD_HELPERS bool + select LIBFDT_WIP + select LIBFDT_SW
Out of curiosity, what's the relationship between those libfdt files and the helpers? What do they use them for?
It's not like LIBFDT_WIP or LIBFDT_SW have very insighful names (through no fault of your own. The original file organization is dubious at best), so why not just compile those files conditionally on DOMAIN_BUILD_HELPERS instead?
Something like...
Quoted 35 lines
xen/common/Kconfig +2
-0config 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" + endmenuxen/common/libfdt/Kconfig new file +14
-0@@ -0,0 +1,14 @@ +config LIBFDT_WIP + bool + +config LIBFDT_SW + bool + +config LIBFDT_RW + bool + +config LIBFDT_EMPTY_TREE + bool + +config LIBFDT_OVERLAY + boolxen/common/libfdt/Makefile +0
-0
xen/common/libfdt/Makefile line 7
Quoted 8 lines
xen/common/libfdt/Makefile +3
-1@@ -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
... turning these two into:
obj-libfdt-$(CONFIG_DOMAIN_BUILD_HELPERS) += fdt_sw.o fdt_wip.o
Likewise for fdt_empty_tree.o and fdt_overlay.o for ARM_EFI and OVERLAY_DTB respectively.
Quoted 8 lines
xen/common/libfdt/Makefile +4
-0+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))
xen/common/libfdt/Makefile CFLAGS-y += -I$(srctree)/include/xen/libfdt/ · line 27
Quoted 9 lines
xen/common/libfdt/Makefile +2
-2@@ -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)
Cheers,
Alejandro
Hi
Quoted 31 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
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.cRO)
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 andfdt_empty_tree
5) WithCONFIG_OVERLAY_DTB- ARM needs RW andfdt_overlayAPIHence, add possibility for optimizing libfdt usage by introducing separate
Kconfigoptions 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.cSigned-off-by Grygorii Strashko <[email protected]>---
Not sure about usingDOMAIN_BUILD_HELPERSfor selecting LIBFDT features, asDOMAIN_BUILD_HELPERSdoesn't exactly says that domain's DT will be generated when selected.
Quoted 7 lines
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
Before continue Kconfig related discussion...
I've been thinking what if we use libfdt as a library (.a)? We'd get the same result as linker can do optimization basing on obj granularity while linking with library (.a).
OK. I've started experimenting - obvious choice is to use "lib-y" and build system will do the rest. But in this case we'll lose ".init" and libfdt will be built-in.
I've tried to preserve exiting behavior when libfdt is moved in ".init", but, honestly got lost a bit in Xen build system.
Below diff is what I've came up with - probably no exactly right.
Does it make sense?
xen/Makefile +1 -0
@@ -464,6 +464,7 @@ ALL_OBJS-y += arch/$(SRCARCH)/built_in.o ALL_OBJS-$(CONFIG_CRYPTO) += crypto/built_in.o ALL_LIBS-y := lib/lib.a +ALL_LIBS-$(CONFIG_LIBFDT) += common/libfdt/libfdt.a include $(srctree)/arch/$(SRCARCH)/arch.mk
$(obj-y) $(obj-bin-y) $(extra-y) $(lib-y): _c_flags += $(cov-cflags-y)
xen/common/libfdt/Makefile +16 -9
@@ -1,21 +1,28 @@ -include $(src)/Makefile.libfdt SECTIONS := text data $(SPECIAL_DATA_SECTIONS) +obj-libfdt-y := fdt.o fdt_ro.o +obj-libfdt-y += fdt_wip.o +obj-libfdt-y += fdt_sw.o +obj-libfdt-y += fdt_rw.o +obj-libfdt-y += fdt_empty_tree.o +obj-libfdt-y += 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)) -nocov-y += libfdt.o +nocov-y += $(obj-libfdt-y) endif -obj-y += libfdt.o - CFLAGS-y += -I$(srctree)/include/xen/libfdt/ -$(obj)/libfdt.o: $(obj)/libfdt-temp.o FORCE - $(call if_changed,objcopy) +#lib-y += $(obj-libfdt-y) -$(obj)/libfdt-temp.o: $(addprefix $(obj)/,$(LIBFDT_OBJS)) FORCE - $(call if_changed,ld) +$(obj)/libfdt-temp.a: $(addprefix $(obj)/,$(obj-libfdt-y)) FORCE + $(call if_changed,ar) + +$(obj)/libfdt.a: $(obj)/libfdt-temp.a FORCE + $(call if_changed,objcopy) -targets += libfdt-temp.o $(LIBFDT_OBJS) +extra-y += libfdt.a $(obj-libfdt-y) +targets += libfdt-temp.a $(obj-libfdt-y)
Signature · 2 lines
Best regards, -grygorii
Quoted 120 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
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.cRO)
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 andfdt_empty_tree
5) WithCONFIG_OVERLAY_DTB- ARM needs RW andfdt_overlayAPIHence, add possibility for optimizing libfdt usage by introducing separate
Kconfigoptions 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.cSigned-off-by Grygorii Strashko <[email protected]>---
Not sure about usingDOMAIN_BUILD_HELPERSfor selecting LIBFDT features, asDOMAIN_BUILD_HELPERSdoesn'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/Kconfigxen/arch/arm/Kconfig +4
-0@@ -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.xen/common/Kconfig +4
-0@@ -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" + endmenuxen/common/libfdt/Kconfig new file +14
-0@@ -0,0 +1,14 @@ +config LIBFDT_WIP + bool + +config LIBFDT_SW + bool + +config LIBFDT_RW + bool + +config LIBFDT_EMPTY_TREE + bool + +config LIBFDT_OVERLAY + boolxen/common/libfdt/Makefile +7
-1@@ -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))
xen/common/libfdt/Makefile CFLAGS-y += -I$(srctree)/include/xen/libfdt/ · line 27
Quoted 9 lines
xen/common/libfdt/Makefile +2
-2@@ -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)
Pulling together several aspects.
Now that we have xen/lib, library stuff should be in it, including this libfdt. I suggest moving it to xen/lib/fdt.
The build system problems are created by using non-standard rules to bodge the init-ness. For livepatches, we have init_or_livepatch as friends to do conditional init-ness. I'd suggest a similar approach here.
You might want a prompt-less CONFIG_LIBFDT_NONINIT which can be selected by CONFIG_DTB_OVERLAY, because that's going to be better than trying to make an implication directly about DTB_OVERLAY.
As to other issues hinted at:
* Init coverage. The only reason we don't have init coverage is because of the overly-restrictive SPECIAL_DATA_SECTIONS check, and while it serves a purpose, it does a lot of harm too. It should be disabled by things like CONFIG_COVERAGE so that we can retrieve coverage of boot time paths, and because data placement is not interesting for these types of builds.
* -f{function,data}-sections and --gc-sections. This gets dead code/data elimination with better granularity than the translation unit, and removes the need for interior ifdefary to achieve the same savings. We already have -f*-sections for livepatching, so this is really just using --gc-sections and will probably net a good win in one fell swoop.
~Andrew
Quoted 157 lines · Andrew Cooper
Quoted 123 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
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.cRO)
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 andfdt_empty_tree
5) WithCONFIG_OVERLAY_DTB- ARM needs RW andfdt_overlayAPIHence, add possibility for optimizing libfdt usage by introducing separate
Kconfigoptions 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.cSigned-off-by Grygorii Strashko <[email protected]>---
Not sure about usingDOMAIN_BUILD_HELPERSfor selecting LIBFDT features, asDOMAIN_BUILD_HELPERSdoesn'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/Kconfigxen/arch/arm/Kconfig +4
-0@@ -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.xen/common/Kconfig +2
-0@@ -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 thesystem
xen/common/Kconfig +2
-0+source "common/libfdt/Kconfig" + endmenuxen/common/libfdt/Kconfig new file +14
-0@@ -0,0 +1,14 @@ +config LIBFDT_WIP + bool + +config LIBFDT_SW + bool + +config LIBFDT_RW + bool + +config LIBFDT_EMPTY_TREE + bool + +config LIBFDT_OVERLAY + boolxen/common/libfdt/Makefile +7
-1@@ -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 neededduring runtime.
ifneq ($(CONFIG_OVERLAY_DTB),y)
OBJCOPYFLAGS := $(foreach s,$(SECTIONS),--rename-section
.$(s)=.init.$(s))xen/common/libfdt/Makefile CFLAGS-y += -I$(srctree)/include/xen/libfdt/ · line 27
Quoted 9 lines
xen/common/libfdt/Makefile +2
-2@@ -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)Pulling together several aspects.
Now that we have xen/lib, library stuff should be in it, including this libfdt. I suggest moving it to xen/lib/fdt.
The build system problems are created by using non-standard rules to bodge the init-ness. For livepatches, we have
init_or_livepatchas friends to do conditional init-ness. I'd suggest a similar approach here.You might want a prompt-less
CONFIG_LIBFDT_NONINITwhich can be selected byCONFIG_DTB_OVERLAY, because that's going to be better than trying to make an implication directly aboutDTB_OVERLAY.As to other issues hinted at:
* Init coverage. The only reason we don't have init coverage is because of the overly-restrictive
SPECIAL_DATA_SECTIONScheck, and while it serves a purpose, it does a lot of harm too. It should be disabled by things likeCONFIG_COVERAGEso that we can retrieve coverage of boot time paths, and because data placement is not interesting for these types of builds.
Quoted 7 lines
* -f{function,data}-sections and --gc-sections. This gets dead code/data elimination with better granularity than the translation unit, and removes the need for interior ifdefary to achieve the same savings. We already have -f*-sections for livepatching, so this is really just using --gc-sections and will probably net a good win in one fell swoop.
~Andrew
I didn't check, but moving libfdt code might entail doing some replacements in ECLAIR deviations to keep guidelines clean, since there are a few assumptions about paths there and in "docs/misra/exclude-list.json", which is used also by ECLAIR.
Signature · 4 lines
Nicola Vetrini, B.Sc. Software Engineer BUGSENG (https://bugseng.com) LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253