[PATCH 1/2] xen: Centralize scheduler linker definition

Jason Andryuk posted 2 patches 2 days, 21 hours ago
[PATCH 1/2] xen: Centralize scheduler linker definition
Posted by Jason Andryuk 2 days, 21 hours ago
Use a define to centralize the common scheduler data in the per-arch
linker scripts.  This is in preparation for marking it KEEP().

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
---
 xen/arch/arm/xen.lds.S    | 5 +----
 xen/arch/ppc/xen.lds.S    | 5 +----
 xen/arch/riscv/xen.lds.S  | 5 +----
 xen/arch/x86/xen.lds.S    | 5 +----
 xen/include/xen/xen.lds.h | 6 ++++++
 5 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index db17ff1efa..2d5f1c516d 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -92,11 +92,8 @@ SECTIONS
   . = ALIGN(SMP_CACHE_BYTES);
   .data : {                    /* Data */
        *(.data.page_aligned)
-       . = ALIGN(8);
-       __start_schedulers_array = .;
-       *(.data.schedulers)
-       __end_schedulers_array = .;
 
+       SCHEDULER_ARRAY
        HYPFS_PARAM
 
        *(.data .data.*)
diff --git a/xen/arch/ppc/xen.lds.S b/xen/arch/ppc/xen.lds.S
index 1de0b77fc6..d0f2ed43f1 100644
--- a/xen/arch/ppc/xen.lds.S
+++ b/xen/arch/ppc/xen.lds.S
@@ -83,11 +83,8 @@ SECTIONS
     . = ALIGN(PAGE_SIZE);
     DECL_SECTION(.data) {                    /* Data */
         *(.data.page_aligned)
-        . = ALIGN(8);
-        __start_schedulers_array = .;
-        *(.data.schedulers)
-        __end_schedulers_array = .;
 
+        SCHEDULER_ARRAY
         HYPFS_PARAM
 
         *(.data .data.*)
diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S
index edcadff90b..45d2e053d0 100644
--- a/xen/arch/riscv/xen.lds.S
+++ b/xen/arch/riscv/xen.lds.S
@@ -78,11 +78,8 @@ SECTIONS
     . = ALIGN(PAGE_SIZE);
     .data : {                    /* Data */
         *(.data.page_aligned)
-        . = ALIGN(8);
-        __start_schedulers_array = .;
-        *(.data.schedulers)
-        __end_schedulers_array = .;
 
+        SCHEDULER_ARRAY
         HYPFS_PARAM
 
         *(.data .data.*)
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 1ee08a3ea3..2aa41306ca 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -309,11 +309,8 @@ SECTIONS
   . = ALIGN(SMP_CACHE_BYTES);
   DECL_SECTION(.data.read_mostly) {
        *(.data.read_mostly)
-       . = ALIGN(8);
-       __start_schedulers_array = .;
-       *(.data.schedulers)
-       __end_schedulers_array = .;
 
+       SCHEDULER_ARRAY
        HYPFS_PARAM
   } PHDR(text)
 
diff --git a/xen/include/xen/xen.lds.h b/xen/include/xen/xen.lds.h
index f54fb2d152..2d66d618b3 100644
--- a/xen/include/xen/xen.lds.h
+++ b/xen/include/xen/xen.lds.h
@@ -173,6 +173,12 @@
        _edevice = .;        \
   } :text
 
+#define SCHEDULER_ARRAY              \
+       . = ALIGN(8);                 \
+       __start_schedulers_array = .; \
+       *(.data.schedulers)           \
+       __end_schedulers_array = .;
+
 #ifdef CONFIG_HYPFS
 #define HYPFS_PARAM              \
        . = ALIGN(POINTER_ALIGN); \
-- 
2.52.0
Re: [PATCH 1/2] xen: Centralize scheduler linker definition
Posted by Jan Beulich 2 days, 11 hours ago
On 09.12.2025 22:47, Jason Andryuk wrote:
> --- a/xen/include/xen/xen.lds.h
> +++ b/xen/include/xen/xen.lds.h
> @@ -173,6 +173,12 @@
>         _edevice = .;        \
>    } :text
>  
> +#define SCHEDULER_ARRAY              \
> +       . = ALIGN(8);                 \

While indeed it was 8 in all original locations, I question that for Arm32
(and a possible future RV32, for example); imo it wants to be ...

> +       __start_schedulers_array = .; \
> +       *(.data.schedulers)           \
> +       __end_schedulers_array = .;
> +
>  #ifdef CONFIG_HYPFS
>  #define HYPFS_PARAM              \
>         . = ALIGN(POINTER_ALIGN); \

... exactly like this. Preferably with that change (happy to carry out while
committing, alongside a respective addition to the description, so long as
there's agreement):
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan
Re: [PATCH 1/2] xen: Centralize scheduler linker definition
Posted by Andrew Cooper 2 days, 3 hours ago
On 10/12/2025 8:08 am, Jan Beulich wrote:
> On 09.12.2025 22:47, Jason Andryuk wrote:
>> --- a/xen/include/xen/xen.lds.h
>> +++ b/xen/include/xen/xen.lds.h
>> @@ -173,6 +173,12 @@
>>         _edevice = .;        \
>>    } :text
>>  
>> +#define SCHEDULER_ARRAY              \
>> +       . = ALIGN(8);                 \
> While indeed it was 8 in all original locations, I question that for Arm32
> (and a possible future RV32, for example); imo it wants to be ...
>
>> +       __start_schedulers_array = .; \
>> +       *(.data.schedulers)           \
>> +       __end_schedulers_array = .;
>> +
>>  #ifdef CONFIG_HYPFS
>>  #define HYPFS_PARAM              \
>>         . = ALIGN(POINTER_ALIGN); \
> ... exactly like this. Preferably with that change (happy to carry out while
> committing, alongside a respective addition to the description, so long as
> there's agreement):
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

I thought the same.  struct scheduler is entirely pointers, and one
unsigned int.

I'm pretty sure that this "array" predates the introduction of
POINTER_ALIGN.

So yes, with it converted to POINTER_ALIGN, Reviewed-by: Andrew Cooper
<andrew.cooper3@citrix.com>

Re: [PATCH 1/2] xen: Centralize scheduler linker definition
Posted by Jason Andryuk 2 days, 2 hours ago
On 2025-12-10 11:32, Andrew Cooper wrote:
> On 10/12/2025 8:08 am, Jan Beulich wrote:
>> On 09.12.2025 22:47, Jason Andryuk wrote:
>>> --- a/xen/include/xen/xen.lds.h
>>> +++ b/xen/include/xen/xen.lds.h
>>> @@ -173,6 +173,12 @@
>>>          _edevice = .;        \
>>>     } :text
>>>   
>>> +#define SCHEDULER_ARRAY              \
>>> +       . = ALIGN(8);                 \
>> While indeed it was 8 in all original locations, I question that for Arm32
>> (and a possible future RV32, for example); imo it wants to be ...
>>
>>> +       __start_schedulers_array = .; \
>>> +       *(.data.schedulers)           \
>>> +       __end_schedulers_array = .;
>>> +
>>>   #ifdef CONFIG_HYPFS
>>>   #define HYPFS_PARAM              \
>>>          . = ALIGN(POINTER_ALIGN); \
>> ... exactly like this. Preferably with that change (happy to carry out while
>> committing, alongside a respective addition to the description, so long as
>> there's agreement):
>> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> 
> I thought the same.  struct scheduler is entirely pointers, and one
> unsigned int.
> 
> I'm pretty sure that this "array" predates the introduction of
> POINTER_ALIGN.
> 
> So yes, with it converted to POINTER_ALIGN, Reviewed-by: Andrew Cooper
> <andrew.cooper3@citrix.com>

Converting to POINTER_ALIGN works for me.

Thanks,
Jason