Move {acpi_}device_init() and device_get_class() to common code
v3 cover Move {acpi_}device_init() and device_get_class() to common code
The {acpi_}device_init() and device_get_class() functions are identical across Arm and RISC-V, and they are likely to remain the same for other architectures like PPC.
Since there is no architecture-specific logic within these functions, they are good candidates to be moved to the common codebase.
This patch series refactors the code by moving these functions to the common directory, reducing code duplication and simplifying future maintenance.
---
Changes in V3:
- drop _SECTIONS from the name of the macros ADEV_INFO and DT_DEV_INFO
- update the definion of macros ADEV_INFO and DT_DEV_INFO
- drop DEVICE_INIT config.
---
Changes in v2:
- Introduce macros for definition of ACPI and Device Tree sections.
- Introduce CONFIG_DEVICE_INIT to make common/device.o compilable only for Arm, PPC and RISC-V.
---
Oleksii Kurochko (5):
xen: define ACPI and DT device info sections macros xen/arm: use {DT,ACPI}_DEV_INFO for device info sections xen/ppc: add section for device information in linker script xen/riscv: add section for device information in linker script xen/common: move device initialization code to common code
xen/arch/arm/device.c | 71 +-------------------------------- xen/arch/arm/xen.lds.S | 10 +---- xen/arch/ppc/xen.lds.S | 5 +++ xen/arch/riscv/xen.lds.S | 5 +++ xen/common/Makefile | 2 + xen/common/device.c | 82 +++++++++++++++++++++++++++++++++++++++ xen/include/xen/xen.lds.h | 10 +++++ 7 files changed, 108 insertions(+), 77 deletions(-) create mode 100644 xen/common/device.c
Signature · 1 line
2.46.1
PATCH v3 1/5 xen: define ACPI and DT device info sections macros
Introduce macros to define device information sections based on the configuration of ACPI or device tree support. These sections are required for common code of device initialization and getting an information about a device.
These macros are expected to be used across different architectures (Arm, PPC, RISC-V), so they are moved to the common xen/xen.lds.h, based on their original definition in Arm.
---
Changes in V2:
- drop SEC* at the end of ACPI AND DT device info section mancros.
- refactor ADEV_INFO and DT_DEV_INFO macros.
--- xen/include/xen/xen.lds.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
xen/include/xen/xen.lds.h +10 -0
@@ -114,6 +114,11 @@/* List of constructs other than *_SECTIONS in alphabetical order. */ +#define ADEV_INFO \ + _asdevice = .; \ + *(.adev.info) \ + _aedevice = .; +#define BUGFRAMES \ __start_bug_frames_0 = .; \ *(.bug_frames.0) \
@@ -131,6 +136,11 @@ *(.bug_frames.3) \ __stop_bug_frames_3 = .; +#define DT_DEV_INFO \ + _sdevice = .; \ + *(.dev.info) \ + _edevice = .; +#ifdef CONFIG_HYPFS #define HYPFS_PARAM \ . = ALIGN(POINTER_ALIGN); \
Signature · 1 line
2.46.1
PATCH v3 2/5 xen/arm: use {DT,ACPI}_DEV_INFO for device info sections
In reply to Oleksii KurochkoRefactor arm/xen.lds.S by replacing the inline definitions for device info sections with the newly introduced {DT,ACPI}_DEV_INFO macros from xen/xen.lds.h.
---
Changes in V2:
- use refactored ADEV_INFO and DT_DEV_INFO macros.
---
xen/arch/arm/xen.lds.S | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
xen/arch/arm/xen.lds.S +2 -8
@@ -126,19 +126,13 @@ SECTIONS . = ALIGN(8); .dev.info : { - _sdevice = .; - *(.dev.info) - _edevice = .; + DT_DEV_INFO } :text -#ifdef CONFIG_ACPI . = ALIGN(8); .adev.info : { - _asdevice = .; - *(.adev.info) - _aedevice = .; + ADEV_INFO } :text -#endif . = ALIGN(8); .teemediator.info : {
Signature · 1 line
2.46.1
PATCH v3 4/5 xen/riscv: add section for device information in linker script
In reply to Oleksii KurochkoIntroduce a new .dev.info section in the RISC-V linker script to handle device-specific information. This section is required by common code (common/device.c: device_init(), device_get_class() ). This section is aligned to POINTER_ALIGN, with _sdevice and _edevice marking the start and end of the section, respectively.
---
Changes in V2:
- use refactored DT_DEV_INFO macros.
--- xen/arch/riscv/xen.lds.S | 5 +++++ 1 file changed, 5 insertions(+)
xen/arch/riscv/xen.lds.S +5 -0
@@ -91,6 +91,11 @@ SECTIONS CONSTRUCTORS } :text + . = ALIGN(POINTER_ALIGN); /* Devicetree based device info */ + .dev.info : { + DT_DEV_INFO + } :text + . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; .init.text : {
Signature · 1 line
2.46.1
PATCH v3 3/5 xen/ppc: add section for device information in linker script
In reply to Oleksii KurochkoIntroduce a new .dev.info section in the PPC linker script to handle device-specific information. This section is required by common code (common/device.c: device_init(), device_get_class() ). This section is aligned to POINTER_ALIGN, with _sdevice and _edevice marking the start and end of the section, respectively.
---
Changes in V2:
- use refactored DT_DEV_INFO macros.
- Add Acked-by: Shawn Anastasio <[email protected]>
--- xen/arch/ppc/xen.lds.S | 5 +++++ 1 file changed, 5 insertions(+)
xen/arch/ppc/xen.lds.S +5 -0
@@ -94,6 +94,11 @@ SECTIONS CONSTRUCTORS } :text + . = ALIGN(POINTER_ALIGN); /* Devicetree based device info */ + DECL_SECTION(.dev.info) { + DT_DEV_INFO + } :text + . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; DECL_SECTION(.init.text) {
Signature · 1 line
2.46.1
PATCH v3 5/5 xen/common: move device initialization code to common code
In reply to Oleksii KurochkoRemove the device initialization code from xen/arch/arm/device.c and move it to the common code to avoid duplication and make it accessible for both ARM and other architectures.device_get_class(), device_init(), _sdevice[] and _edevice[] are wrapped by "#ifdef CONFIG_HAS_DEVICE_TREE" for the case if an arch doesn't support device tree.
Remove unnecessary inclusions of <asm/device.h> and <xen/init.h> from xen/arch/arm/device.c as no code in the file relies on these headers. Fix the inclusion order by moving <asm/setup.h> after <xen/*> headers to resolve a compilation error:
./include/public/xen.h:968:35: error: unknown type name 'uint64_t'
968 | __DEFINE_XEN_GUEST_HANDLE(uint64, uint64_t);
| ^~~~~~~~ ./include/public/arch-arm.h:191:21: note: in definition of macro '___DEFINE_XEN_GUEST_HANDLE'
191 | typedef union { type *p; uint64_aligned_t q; } \
| ^~~~
./include/public/xen.h:968:1: note: in expansion of macro '__DEFINE_XEN_GUEST_HANDLE' 968 | __DEFINE_XEN_GUEST_HANDLE(uint64, uint64_t);
because <asm/setup.h> includes <public/version.h>, which in turn includes "xen.h", which requires <xen/types.h> to be processed correctly.
Additionally, add <xen/device_tree.h> to device.c as functions from this header are used within the file.
---
Changes in V2:
- drop DEVICE_INIT config.
- update the commit message.
--- xen/arch/arm/device.c | 71 ++----------------------------------- xen/common/Makefile | 2 ++ xen/common/device.c | 82 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 69 deletions(-) create mode 100644 xen/common/device.c
xen/arch/arm/device.c +2 -69
@@ -8,79 +8,12 @@* Copyright (C) 2013 Linaro Limited. */ -#include <asm/device.h> -#include <asm/setup.h> +#include <xen/device_tree.h> #include <xen/errno.h> -#include <xen/init.h> #include <xen/iocap.h> #include <xen/lib.h> -extern const struct device_desc _sdevice[], _edevice[]; - -#ifdef CONFIG_ACPI -extern const struct acpi_device_desc _asdevice[], _aedevice[]; -#endif - -int __init device_init (struct dt_device_node *dev,enum device_class class, -const void *data) -{ -const struct device_desc *desc; - -ASSERT (dev !=NULL ); - -if ( !dt_device_is_available (dev) ||dt_device_for_passthrough (dev) ) -return -ENODEV ; - -for ( desc = _sdevice; desc != _edevice; desc++ ) - { -if ( desc->class != class ) -continue ; - -if (dt_match_node (desc->dt_match, dev) ) - { -ASSERT (desc->init !=NULL ); - -return desc->init (dev, data); - } - - } - -return -EBADF ; -} - -#ifdef CONFIG_ACPI -int __init acpi_device_init (enum device_class class,const void *data,int class_type) -{ -const struct acpi_device_desc *desc; - -for ( desc = _asdevice; desc != _aedevice; desc++ ) - { -if ( ( desc->class != class ) || ( desc->class_type != class_type ) ) -continue ; - -ASSERT (desc->init !=NULL ); - -return desc->init (data); - } - -return -EBADF ; -} -#endif - -enum device_class device_get_class (const struct dt_device_node *dev) -{ -const struct device_desc *desc; - -ASSERT (dev !=NULL ); - -for ( desc = _sdevice; desc != _edevice; desc++ ) - { -if (dt_match_node (desc->dt_match, dev) ) -return desc->class; - } - -return DEVICE_UNKNOWN ; -} +#include <asm/setup.h> int map_irq_to_domain (struct domain *d,unsigned int irq,bool need_mapping,const char *devname)
xen/common/Makefile +2 -0
@@ -6,6 +6,8 @@ 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.o +obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) += device.o obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree/ obj-$(CONFIG_IOREQ_SERVER) += dm.o obj-y += domain.o
xen/common/device.c new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
2.46.1
Re: [PATCH v3 1/5] xen: define ACPI and DT device info sections macros
In reply to Oleksii KurochkoQuoted 15 lines · Oleksii Kurochko
xen/include/xen/xen.lds.h +5
-0@@ -114,6 +114,11 @@/* List of constructs other than *_SECTIONS in alphabetical order. */ +#define ADEV_INFO \ + _asdevice = .; \ + *(.adev.info) \ + _aedevice = .; +#define BUGFRAMES \ __start_bug_frames_0 = .; \ *(.bug_frames.0) \
xen/include/xen/xen.lds.h line 142
Quoted 7 lines
xen/include/xen/xen.lds.h +4
-0@@ -131,6 +136,11 @@ *(.bug_frames.3) \ __stop_bug_frames_3 = .; +#define DT_DEV_INFO \ + _sdevice = .; \ + *(.dev.info) \ + _edevice = .;
I have a question more to the Arm maintainers than to you, Oleksii: Section names as well as the names of the symbols bounding the sections are overly unspecific. There's nothing indicating DT at all, and it's solely 'a' to indicate ACPI. I consider this a possible problem going forward, when this is now being generalized.
In turn I wonder about ADEV_INFO when comparing with DT_DEV_INFO. The latter makes clear it's DT. The former doesn't make clear it's ACPI; 'A' could stand for about anything, including "a device" (of any kind).
Finally, Oleksii, looking at Arm's present uses - why is the abstraction limited to the inner part of the section statements in the linker script? IOW why isn't it all (or at least quite a bit more) of
. = ALIGN(8);
.dev.info : {
_sdevice = .;
*(.dev.info)
_edevice = .;
} :textthat moves into DT_DEV_INFO? I can see that the :text may want leaving to the architectures (yet then perhaps as a macro argument). I could also see a remote need for the ALIGN()'s value to be arch-controlled. (Why is it uniformly 8 anyway on Arm?)
PPC's desire to use DECL_SECTION() can certainly be covered by providing a (trivial) DECL_SECTION() also for Arm and RISC-V. Seeing that even x86 overrides the default to the trivial form for building xen.efi, I'm inclined to suggest we should actually have a way for an arch to indicate to xen.lds.h that it wants just the trivial form (avoiding a later #undef).
When to be generalized I further wonder whether the ALIGN()s are actually well placed. I'd have expected
.dev.info ALIGN(POINTER_ALIGN) : {
_sdevice = .;
*(.dev.info)
_edevice = .;
} :textJan
Re: [PATCH v3 2/5] xen/arm: use {DT,ACPI}_DEV_INFO for device info sections
In reply to Oleksii KurochkoQuoted 11 lines · Oleksii Kurochko
xen/arch/arm/xen.lds.S +1
-3@@ -126,19 +126,13 @@ SECTIONS . = ALIGN(8); .dev.info : { - _sdevice = .; - *(.dev.info) - _edevice = .; + DT_DEV_INFO } :text
xen/arch/arm/xen.lds.S SECTIONS · line 141
Quoted 10 lines
xen/arch/arm/xen.lds.S +1
-5-#ifdef CONFIG_ACPI . = ALIGN(8); .adev.info : { - _asdevice = .; - *(.adev.info) - _aedevice = .; + ADEV_INFO } :text -#endif
Why's the #ifdef going away here?
Jan
Re: [PATCH v3 5/5] xen/common: move device initialization code to common code
In reply to Oleksii KurochkoQuoted 19 lines · Oleksii Kurochko
Remove the device initialization code from
xen/arch/arm/device.cand move it to the common code to avoid duplication and make it accessible for both ARM and other architectures.device_get_class(),device_init(), _sdevice[] and _edevice[] are wrapped by "#ifdefCONFIG_HAS_DEVICE_TREE" for the case if an arch doesn't support device tree.Remove unnecessary inclusions of <
asm/device.h> and <xen/init.h> fromxen/arch/arm/device.cas no code in the file relies on these headers. Fix the inclusion order by moving <asm/setup.h> after <xen/*> headers to resolve a compilation error:./include/public/xen.h:968:35: error: unknown type name 'uint64_t' 968 | __DEFINE_XEN_GUEST_HANDLE(uint64, uint64_t); | ^~~~~~~~ ./include/public/arch-arm.h:191:21: note: in definition of macro '___DEFINE_XEN_GUEST_HANDLE' 191 | typedef union { type *p; uint64_aligned_t q; } \ | ^~~~ ./include/public/xen.h:968:1: note: in expansion of macro '__DEFINE_XEN_GUEST_HANDLE' 968 | __DEFINE_XEN_GUEST_HANDLE(uint64, uint64_t);
Quoted 6 lines
because <
asm/setup.h> includes <public/version.h>, which in turn includes "xen.h", which requires <xen/types.h> to be processed correctly. Additionally, add <xen/device_tree.h> todevice.cas functions from this header are used within the file.Signed-off-by Oleksii Kurochko <[email protected]>
Re: [PATCH v3 1/5] xen: define ACPI and DT device info sections macros
In reply to Jan BeulichQuoted 40 lines · Jan Beulich
Quoted 18 lines · Oleksii Kurochko
xen/include/xen/xen.lds.h +0
-0@@ -114,6 +114,11 @@
/* List of constructs other than*_SECTIONSin alphabetical order. */xen/include/xen/xen.lds.h +5
-0+#define ADEV_INFO \ + _asdevice = .; \ + *(.adev.info) \ + _aedevice = .; +#define BUGFRAMES \
__start_bug_frames_0= .; \
*(.bug_frames.0) \xen/include/xen/xen.lds.h +0
-0@@ -131,6 +136,11 @@ *(.bug_frames.3) \ __stop_bug_frames_3 = .;Quoted 5 lines
+#defineDT_DEV_INFO\
+_sdevice= .; \
+ *(.dev.info) \
+_edevice= .;I have a question more to the Arm maintainers than to you, Oleksii:
Section
names as well as the names of the symbols bounding the sections are overly
unspecific. There's nothing indicating DT at all, and it's solely 'a' to
indicate ACPI. I consider this a possible problem going forward, when this
is now being generalized.In turn I wonder about
ADEV_INFOwhen comparing withDT_DEV_INFO. The latter makes clear it's DT. The former doesn't make clear it's ACPI; 'A'
could stand for about anything, including "a device" (of any kind).
Quoted 4 lines
Finally, Oleksii, looking at Arm's present uses - why is the abstraction
limited to the inner part of the section statements in the linker script?
I tried to abstract not only inner part of the section statements but based on the comments to previous patch series, at least, I made an abstraction not in the best way but I considered the comments as it would be better to limit everything to the inner part.
Quoted 9 lines
IOW why isn't it all (or at least quite a bit more) of
. = ALIGN(8);
.dev.info : {
_sdevice= .;
*(.dev.info)
_edevice= .;
} :text
Quoted 3 lines
that moves into
DT_DEV_INFO? I can see that the :text may want leaving
to the architectures (yet then perhaps as a macro argument).
I prefer using a macro argument, but in this case (or a similar section for ACPI), I think we could place the :text into common macros. If someone needs to update the :text part in the future, it would be better to introduce a macro argument when it becomes necessary as every architecture uses :text for these sections.
Quoted 3 lines
I could
also see a remote need for the ALIGN()'s value to be arch-controlled. (Why is it uniformly 8 anyway on Arm?)
I think it was done just to cover Arm32 and Arm64 alignment requirements. Probably, POINTER_ALIGN hadn't been introduced before this section was declared.
But it could align value could be make as macro argument.
Quoted 10 lines
PPC's desire to use
DECL_SECTION()can certainly be covered by providing
a (trivial)DECL_SECTION()also for Arm and RISC-V. Seeing that even x86
overrides the default to the trivial form for building xen.efi, I'm inclined to suggest we should actually have a way for an arch to indicate
toxen.lds.hthat it wants just the trivial form (avoiding a later #undef).
In the first version I wanted to introduce the following:
#ifndef USE_TRIVIAL_DECL_SECTION
#ifdef CONFIG_LD_IS_GNU # define DECL_SECTION(x) x : AT(ADDR(#x) - __XEN_VIRT_START) #else # define DECL_SECTION(x) x : AT(ADDR(x) - __XEN_VIRT_START) #endif
#else /* USE_TRIVIAL_DECL_SECTION
# define DECL_SECTION(x) x :
#endif
But I decided that it would be too much just to make ACPI_DEV_INFO and
DT_DEV_INFO more abstract and that was the reason why I had another
macro argument for DT_DEV_INFO() to abstract the usage of DECL_SECTION:
+#define USE_DECL_SECTION(x) DECL_SECTION(x)
+
+#define NOUSE_DECL_SECTION(x) x :
+
+#define ACPI_DEV_INFO_SEC(secname, DECL_SECTION_MACROS_NAME)\
+ DECL_SECTION_MACROS_NAME(secname) { \
+ _asdevice = .; \
+ *(secname) \
+ _aedevice = .; \
+ } :textQuoted 10 lines
When to be generalized I further wonder whether the ALIGN()s are actually
well placed. I'd have expected.dev.info
ALIGN(POINTER_ALIGN): {
_sdevice= .;
*(.dev.info)
_edevice= .;
} :text
But in case of PPC which is using DECL_SECTION then shouldn't DECL_SECTION macros have an align value as a macro argument?
Considering everything what was said above could we consider the updated version of the initial abstraction for DT_DEV_INFO section ( and the similar for ACPI dev info )?
+#define DT_DEV_INFO_SEC(secname) \
+ DECL_SECTION(secname) { \
+ _sdevice = .; \
+ *(secname) \
+ _edevice = .; \+ } :text
Or alignment could be also inside the macros:
(if Arm is okay with using POINTER_ALIGN instead of 8 ):
+#define DT_DEV_INFO_SEC(secname) \
+ . = ALIGN(POINTER_ALIGN) \
+ DECL_SECTION(secname) { \
+ _sdevice = .; \
+ *(secname) \
+ _edevice = .; \
+ } :text
( or if Arm isn't okay ):
+#define DT_DEV_INFO_SEC(secname, align) \
+ . = ALIGN(align) \
+ DECL_SECTION(secname) { \
+ _sdevice = .; \
+ *(secname) \
+ _edevice = .; \+ } :text
~ Oleksii
Re: [PATCH v3 1/5] xen: define ACPI and DT device info sections macros
Quoted 9 lines · On 25.09.2024 13:02, [email protected] wrote:
Or alignment could be also inside the macros:
(if Arm is okay with usingPOINTER_ALIGNinstead of 8 ):+#define DT_DEV_INFO_SEC(secname) \ + . = ALIGN(POINTER_ALIGN) \ + DECL_SECTION(secname) { \ + _sdevice = .; \ + *(secname) \ + _edevice = .; \+ } :text
#define DT_DEV_INFO_SEC(secname) \
DECL_SECTION(secname) { \
. = ALIGN(POINTER_ALIGN); \
_sdevice = .; \
*(secname) \
_edevice = .; \
} :textwould be my preferred form then.
Jan
Quoted 11 lines
( or if Arm isn't okay ):
+#defineDT_DEV_INFO_SEC(secname, align)\+ . = ALIGN(align) \ + DECL_SECTION(secname) { \ + _sdevice = .; \ + *(secname) \ + _edevice = .; \+ } :text
~ Oleksii
Re: [PATCH v3 2/5] xen/arm: use {DT,ACPI}_DEV_INFO for device info sections
In reply to Jan BeulichQuoted 16 lines · Jan Beulich
Quoted 15 lines · Oleksii Kurochko
xen/arch/arm/xen.lds.S +0
-0@@ -126,19 +126,13 @@ SECTIONS
. = ALIGN(8);
.dev.info : {
-_sdevice= .;
- *(.dev.info)
-_edevice= .;
+DT_DEV_INFO
} :text
-#ifdefCONFIG_ACPI
. = ALIGN(8);
.adev.info : {
Quoted 8 lines
Quoted 6 lines
-
_asdevice= .;
- *(.adev.info)
-_aedevice= .;
+ADEV_INFO
} :text
-#endifWhy's the #ifdef going away here?
It is incorrect as ADEV_INFO isn't covered by #ifdef anymore. Some rebasing issue happens... I will fix that in the next patch version. Thanks.
~ Oleksii
Re: [PATCH v3 1/5] xen: define ACPI and DT device info sections macros
In reply to Jan BeulichQuoted 9 lines · Jan Beulich
PPC's desire to use
DECL_SECTION()can certainly be covered by providing
a (trivial)DECL_SECTION()also for Arm and RISC-V. Seeing that even x86
overrides the default to the trivial form for building xen.efi, I'm inclined to suggest we should actually have a way for an arch to indicate
toxen.lds.hthat it wants just the trivial form (avoiding a later #undef).
If to go with what I suggested before then x86 will look like:
xen/arch/x86/xen.lds.S +4 -2
@@ -3,6 +3,10 @@ #include <xen/cache.h> #include <xen/lib.h> + +#ifdef EFI +#define SIMPLE_DECL_SECTION +#endif #include <xen/xen.lds.h> #include <asm/page.h> #undef ENTRY
@@ -12,9 +16,7 @@ #define FORMAT "pei-x86-64" #undef __XEN_VIRT_START -#undef DECL_SECTION #define __XEN_VIRT_START __image_base__ -#define DECL_SECTION(x) x : ENTRY(efi_start)
xen/include/xen/xen.lds.h +6 -0
@@ -5,6 +5,8 @@* Common macros to be used in architecture specific linker scripts. */ +#ifdef SIMPLE_DECL_SECTION +/* * Declare a section whose load address is based at PA 0 rather than * Xen's virtual base address.
@@ -15,6 +17,10 @@# define DECL_SECTION (x) x : AT(ADDR(x) - __XEN_VIRT_START)#endif +#else /* SIMPLE_DECL_SECION */ +# define DECL_SECTION (x) x : +#endif +/* * To avoid any confusion, please note that the EFI macro does not
correspond
* to EFI support and is used when linking a native EFI (i.e. PE/COFF)
binary,
Does it make sense? Or it would be better to follow way for each architecture:
#undef DECL_SECTION
#define DECL_SECTION(x) x :
~ Oleksii
Re: [PATCH v3 1/5] xen: define ACPI and DT device info sections macros
Quoted 42 lines · On 25.09.2024 18:08, [email protected] wrote:
Quoted 9 lines · Jan Beulich
PPC's desire to use
DECL_SECTION()can certainly be covered by providing
a (trivial)DECL_SECTION()also for Arm and RISC-V. Seeing that even x86
overrides the default to the trivial form for building xen.efi, I'm inclined to suggest we should actually have a way for an arch to indicate
toxen.lds.hthat it wants just the trivial form (avoiding a later #undef).If to go with what I suggested before then x86 will look like:
xen/arch/x86/xen.lds.S +4
-2@@ -3,6 +3,10 @@ #include <xen/cache.h> #include <xen/lib.h> + +#ifdef EFI +#define SIMPLE_DECL_SECTION +#endif #include <xen/xen.lds.h> #include <asm/page.h> #undef ENTRY@@ -12,9 +16,7 @@ #define FORMAT "pei-x86-64" #undef __XEN_VIRT_START -#undef DECL_SECTION #define __XEN_VIRT_START __image_base__ -#define DECL_SECTION(x) x : ENTRY(efi_start)xen/include/xen/xen.lds.h +0
-0
xen/include/xen/xen.lds.h line 8
Quoted 4 lines
xen/include/xen/xen.lds.h +1
-0@@ -5,6 +5,8 @@* Common macros to be used in architecture specific linker scripts. */ +#ifdef SIMPLE_DECL_SECTION
#ifndef I guess?
Quoted 14 lines
xen/include/xen/xen.lds.h +4
-0@@ -15,6 +17,10 @@# define DECL_SECTION (x) x : AT(ADDR(x) - __XEN_VIRT_START)#endif +#else /* SIMPLE_DECL_SECION */ +# define DECL_SECTION (x) x : +#endif +/* * To avoid any confusion, please note that the EFI macro does not correspond
* to EFI support and is used when linking a native EFI (i.e. PE/COFF)
binary,
Quoted 4 lines
Does it make sense? Or it would be better to follow way for each architecture:
#undef DECL_SECTION #define DECL_SECTION(x) x :
Hard to tell which one's better; I was asking myself that same question when writing an earlier reply. I'm slightly in favor of the form you have now.
Jan
Re: [PATCH v3 1/5] xen: define ACPI and DT device info sections macros
Quoted 69 lines · Jan Beulich
Quoted 46 lines · On 25.09.2024 18:08, [email protected] wrote:
Quoted 4 lines · Jan Beulich
PPC's desire to use
DECL_SECTION()can certainly be covered by providing
a (trivial)DECL_SECTION()also for Arm and RISC-V. Seeing that evenQuoted 8 lines
x86
overrides the default to the trivial form for building xen.efi, I'm
inclined to suggest we should actually have a way for an arch to indicate
toxen.lds.hthat it wants just the trivial form (avoiding a later
#undef).If to go with what I suggested before then x86 will look like:
xen/arch/x86/xen.lds.S +0
-0@@ -3,6 +3,10 @@
#include <xen/cache.h>
#include <xen/lib.h>xen/arch/x86/xen.lds.S +4
-0+ +#ifdef EFI +#define SIMPLE_DECL_SECTION +#endif#include <
xen/xen.lds.h>
#include <asm/page.h>
#undef ENTRYxen/arch/x86/xen.lds.S +0
-0@@ -12,9 +16,7 @@
#define FORMAT "pei-x86-64"
#undef__XEN_VIRT_START
-#undefDECL_SECTION
#define__XEN_VIRT_START__image_base__
-#defineDECL_SECTION(x)x :
ENTRY(efi_start)xen/include/xen/xen.lds.h +0
-0@@ -5,6 +5,8 @@ * Common macros to be used in architecture specific linkerQuoted 4 lines
scripts.
*/
+#ifdefSIMPLE_DECL_SECTION#ifndef I guess?
Quoted 15 lines
xen/include/xen/xen.lds.h +0
-0@@ -15,6 +17,10 @@ # define DECL_SECTION(x) x : AT(ADDR(x) - __XEN_VIRT_START) #endifxen/include/xen/xen.lds.h +4
-0+#else /* SIMPLE_DECL_SECION */ +# define DECL_SECTION (x) x : +#endif +/*
* To avoid any confusion, please note that the EFI macro does not correspond
* to EFI support and is used when linking a native EFI (i.e. PE/COFF)
binary,
Quoted 10 lines
Quoted 4 lines
Does it make sense? Or it would be better to follow way for each architecture:
#undefDECL_SECTION
#defineDECL_SECTION(x)x :Hard to tell which one's better; I was asking myself that same question
when writing an earlier reply. I'm slightly in favor of the form you have
now.
Do you mean moving only a content of section without secname and laddr ( in case of x86 and PPC ), and alignment to xen.lds.h ?
~ Oleksii
Re: [PATCH v3 1/5] xen: define ACPI and DT device info sections macros
Quoted 80 lines · On 26.09.2024 11:15, [email protected] wrote:
Quoted 69 lines · Jan Beulich
Quoted 46 lines · On 25.09.2024 18:08, [email protected] wrote:
Quoted 4 lines · Jan Beulich
PPC's desire to use
DECL_SECTION()can certainly be covered by providing
a (trivial)DECL_SECTION()also for Arm and RISC-V. Seeing that evenQuoted 8 lines
x86
overrides the default to the trivial form for building xen.efi, I'm
inclined to suggest we should actually have a way for an arch to indicate
toxen.lds.hthat it wants just the trivial form (avoiding a later
#undef).If to go with what I suggested before then x86 will look like:
xen/arch/x86/xen.lds.S +0
-0@@ -3,6 +3,10 @@
#include <xen/cache.h>
#include <xen/lib.h>xen/arch/x86/xen.lds.S +4
-0+ +#ifdef EFI +#define SIMPLE_DECL_SECTION +#endif#include <
xen/xen.lds.h>
#include <asm/page.h>
#undef ENTRYxen/arch/x86/xen.lds.S +0
-0@@ -12,9 +16,7 @@
#define FORMAT "pei-x86-64"
#undef__XEN_VIRT_START
-#undefDECL_SECTION
#define__XEN_VIRT_START__image_base__
-#defineDECL_SECTION(x)x :
ENTRY(efi_start)xen/include/xen/xen.lds.h +0
-0@@ -5,6 +5,8 @@ * Common macros to be used in architecture specific linkerQuoted 4 lines
scripts.
*/
+#ifdefSIMPLE_DECL_SECTION#ifndef I guess?
Quoted 15 lines
xen/include/xen/xen.lds.h +0
-0@@ -15,6 +17,10 @@ # define DECL_SECTION(x) x : AT(ADDR(x) - __XEN_VIRT_START) #endifxen/include/xen/xen.lds.h +4
-0+#else /* SIMPLE_DECL_SECION */ +# define DECL_SECTION (x) x : +#endif +/*
* To avoid any confusion, please note that the EFI macro does not correspond
* to EFI support and is used when linking a native EFI (i.e. PE/COFF)
binary,Quoted 10 lines
Quoted 4 lines
Does it make sense? Or it would be better to follow way for each architecture:
#undefDECL_SECTION
#defineDECL_SECTION(x)x :Hard to tell which one's better; I was asking myself that same question
when writing an earlier reply. I'm slightly in favor of the form you have
now.
Quoted 2 lines
Do you mean moving only a content of section without secname and laddr ( in case of x86 and PPC ), and alignment to
xen.lds.h?
No. I was solely referring to the DECL_SECTION() aspect.
Jan