[PATCH] xen/link: Don't separate .data.read_mostly from .data

Andrew Cooper posted 1 patch 1 week, 4 days ago
xen/arch/arm/xen.lds.S   | 8 +++-----
xen/arch/ppc/xen.lds.S   | 8 +++-----
xen/arch/riscv/xen.lds.S | 7 ++-----
xen/arch/x86/xen.lds.S   | 4 +---
4 files changed, 9 insertions(+), 18 deletions(-)
[PATCH] xen/link: Don't separate .data.read_mostly from .data
Posted by Andrew Cooper 1 week, 4 days ago
This appears to be an error in x86 which got copied into all other
architectures.  .data.read_mostly is an internal detail, and none of the
similar sections get exposed externally.

Simply place .data.read_mostly in .data.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <jbeulich@suse.com>
CC: Roger Pau Monné <roger@xenproject.org>
CC: Teddy Astie <teddy.astie@vates.tech>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien@xen.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Baptiste Le Duc <baptiste.le-duc@vates.tech>
CC: Timothy Pearson <tpearson@raptorengineering.com>
CC: Ross Lagerwall <ross.lagerwall@citrix.com>

This is to simplfy the script checking that xen.efi's section
attributes/alignments are correct for UEFI SecureBoot.
---
 xen/arch/arm/xen.lds.S   | 8 +++-----
 xen/arch/ppc/xen.lds.S   | 8 +++-----
 xen/arch/riscv/xen.lds.S | 7 ++-----
 xen/arch/x86/xen.lds.S   | 4 +---
 4 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index d1bb6c62d208..8d0954c90afd 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -86,16 +86,14 @@ SECTIONS
       __ro_after_init_end = .;
   } : text
 
-  .data.read_mostly : {
-       *(.data.read_mostly)
-  } :text
-
   . = ALIGN(SMP_CACHE_BYTES);
   .data : {                    /* Data */
-       *(.data.page_aligned)
+       *(.data.read_mostly)
 
        HYPFS_PARAM
 
+       *(.data.page_aligned)
+
        *(.data .data.*)
        CONSTRUCTORS
   } :text
diff --git a/xen/arch/ppc/xen.lds.S b/xen/arch/ppc/xen.lds.S
index cddb70855307..b2159279169c 100644
--- a/xen/arch/ppc/xen.lds.S
+++ b/xen/arch/ppc/xen.lds.S
@@ -77,16 +77,14 @@ SECTIONS
         __ro_after_init_end = .;
     } :text
 
-    DECL_SECTION(.data.read_mostly) {
-        *(.data.read_mostly)
-    } :text
-
     . = ALIGN(PAGE_SIZE);
     DECL_SECTION(.data) {                    /* Data */
-        *(.data.page_aligned)
+        *(.data.read_mostly)
 
         HYPFS_PARAM
 
+        *(.data.page_aligned)
+
         *(.data .data.*)
         CONSTRUCTORS
     } :text
diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S
index 250ee3f36f4f..d1c5ce59c90d 100644
--- a/xen/arch/riscv/xen.lds.S
+++ b/xen/arch/riscv/xen.lds.S
@@ -84,16 +84,13 @@ SECTIONS
         __ro_after_init_end = .;
     } : text
 
-    .data.read_mostly : {
-        *(.data.read_mostly)
-    } :text
-
     . = ALIGN(PAGE_SIZE);
     .data : {                    /* Data */
-        *(.data.page_aligned)
+        *(.data.read_mostly)
 
         HYPFS_PARAM
 
+        *(.data.page_aligned)
         *(.sdata .sdata.*)
         *(.data .data.*)
         CONSTRUCTORS
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 925848980219..99802aed4e13 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -295,13 +295,11 @@ SECTIONS
 
   __2M_rwdata_start = .;       /* Start of 2M superpages, mapped RW. */
   . = ALIGN(SMP_CACHE_BYTES);
-  DECL_SECTION(.data.read_mostly) {
+  DECL_SECTION(.data) {
        *(.data.read_mostly)
 
        HYPFS_PARAM
-  } PHDR(text)
 
-  DECL_SECTION(.data) {
        *(.data.page_aligned)
        *(.data .data.*)
   } PHDR(text)

base-commit: 4263fe42b736596cfa5bfec661f2f55f02759aa7
prerequisite-patch-id: 680071148129321ffaf7bd7435d031904014f556
-- 
2.39.5


Re: [PATCH] xen/link: Don't separate .data.read_mostly from .data
Posted by Jason Andryuk 1 week, 3 days ago
On 2026-11-12 13:58, Andrew Cooper wrote:
> This appears to be an error in x86 which got copied into all other
> architectures.  .data.read_mostly is an internal detail, and none of the
> similar sections get exposed externally.
> 
> Simply place .data.read_mostly in .data.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---

> 
> This is to simplfy the script checking that xen.efi's section
> attributes/alignments are correct for UEFI SecureBoot.

This is worth moving to the commit message to explain why the change is 
made.  Also "simplify".  Also, also stating the rearrangement of 
.data.page_aligned and HYPFS_PARAM is worth adding.

With that:
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>

Thanks,
Jason
Re: [PATCH] xen/link: Don't separate .data.read_mostly from .data
Posted by Oleksii Kurochko 1 week, 3 days ago

On 11/12/26 7:58 PM, Andrew Cooper wrote:
> This appears to be an error in x86 which got copied into all other
> architectures.  .data.read_mostly is an internal detail, and none of the
> similar sections get exposed externally.
> 
> Simply place .data.read_mostly in .data.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <jbeulich@suse.com>
> CC: Roger Pau Monné <roger@xenproject.org>
> CC: Teddy Astie <teddy.astie@vates.tech>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien@xen.org>
> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
> CC: Bertrand Marquis <bertrand.marquis@arm.com>
> CC: Michal Orzel <michal.orzel@amd.com>
> CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> CC: Baptiste Le Duc <baptiste.le-duc@vates.tech>
> CC: Timothy Pearson <tpearson@raptorengineering.com>
> CC: Ross Lagerwall <ross.lagerwall@citrix.com>
> 
> This is to simplfy the script checking that xen.efi's section
> attributes/alignments are correct for UEFI SecureBoot.
> ---
>   xen/arch/arm/xen.lds.S   | 8 +++-----
>   xen/arch/ppc/xen.lds.S   | 8 +++-----
>   xen/arch/riscv/xen.lds.S | 7 ++-----
>   xen/arch/x86/xen.lds.S   | 4 +---
>   4 files changed, 9 insertions(+), 18 deletions(-)
> 
> diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
> index d1bb6c62d208..8d0954c90afd 100644
> --- a/xen/arch/arm/xen.lds.S
> +++ b/xen/arch/arm/xen.lds.S
> @@ -86,16 +86,14 @@ SECTIONS
>         __ro_after_init_end = .;
>     } : text
>   
> -  .data.read_mostly : {
> -       *(.data.read_mostly)
> -  } :text
> -
>     . = ALIGN(SMP_CACHE_BYTES);
>     .data : {                    /* Data */
> -       *(.data.page_aligned)
> +       *(.data.read_mostly)
>   
>          HYPFS_PARAM
>   
> +       *(.data.page_aligned)
> +
>          *(.data .data.*)
>          CONSTRUCTORS
>     } :text
> diff --git a/xen/arch/ppc/xen.lds.S b/xen/arch/ppc/xen.lds.S
> index cddb70855307..b2159279169c 100644
> --- a/xen/arch/ppc/xen.lds.S
> +++ b/xen/arch/ppc/xen.lds.S
> @@ -77,16 +77,14 @@ SECTIONS
>           __ro_after_init_end = .;
>       } :text
>   
> -    DECL_SECTION(.data.read_mostly) {
> -        *(.data.read_mostly)
> -    } :text
> -
>       . = ALIGN(PAGE_SIZE);
>       DECL_SECTION(.data) {                    /* Data */
> -        *(.data.page_aligned)
> +        *(.data.read_mostly)
>   
>           HYPFS_PARAM
>   
> +        *(.data.page_aligned)
> +
>           *(.data .data.*)
>           CONSTRUCTORS
>       } :text
> diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S
> index 250ee3f36f4f..d1c5ce59c90d 100644
> --- a/xen/arch/riscv/xen.lds.S
> +++ b/xen/arch/riscv/xen.lds.S
> @@ -84,16 +84,13 @@ SECTIONS
>           __ro_after_init_end = .;
>       } : text
>   
> -    .data.read_mostly : {
> -        *(.data.read_mostly)
> -    } :text
> -
>       . = ALIGN(PAGE_SIZE);
>       .data : {                    /* Data */
> -        *(.data.page_aligned)
> +        *(.data.read_mostly)
>   
>           HYPFS_PARAM
>   
> +        *(.data.page_aligned)
>           *(.sdata .sdata.*)
>           *(.data .data.*)
>           CONSTRUCTORS
> diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
> index 925848980219..99802aed4e13 100644
> --- a/xen/arch/x86/xen.lds.S
> +++ b/xen/arch/x86/xen.lds.S
> @@ -295,13 +295,11 @@ SECTIONS
>   
>     __2M_rwdata_start = .;       /* Start of 2M superpages, mapped RW. */
>     . = ALIGN(SMP_CACHE_BYTES);
> -  DECL_SECTION(.data.read_mostly) {
> +  DECL_SECTION(.data) {
>          *(.data.read_mostly)
>   
>          HYPFS_PARAM
> -  } PHDR(text)
>   
> -  DECL_SECTION(.data) {
>          *(.data.page_aligned)
>          *(.data .data.*)
>     } PHDR(text)

The ordering is preserved, but the alignment between the two isn't.
Today the ALIGN() before .data sits between .data.read_mostly and
regular .data.  After this patch it sits before .data.read_mostly, and
the only thing separating it from *(.sdata/.data) is
*(.data.page_aligned), which has no inputs on RISC-V, PPC or Arm with
CONFIG_MPU. So the tail of .data.read_mostly will share a cache line
with ordinary .data, which is the false sharing __read_mostly is meant
to avoid (IIUC).

Could you add ". = ALIGN(SMP_CACHE_BYTES);" after HYPFS_PARAM, so the
separation doesn't depend on whether an arch has any
.data.page_aligned?

~ Oleksii



Re: [PATCH] xen/link: Don't separate .data.read_mostly from .data
Posted by Andrew Cooper 1 week, 3 days ago
On 13/11/2026 8:51 am, Oleksii Kurochko wrote:
>
>
> On 11/12/26 7:58 PM, Andrew Cooper wrote:
>> This appears to be an error in x86 which got copied into all other
>> architectures.  .data.read_mostly is an internal detail, and none of the
>> similar sections get exposed externally.
>>
>> Simply place .data.read_mostly in .data.
>>
>> No functional change.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>> ---
>> CC: Jan Beulich <jbeulich@suse.com>
>> CC: Roger Pau Monné <roger@xenproject.org>
>> CC: Teddy Astie <teddy.astie@vates.tech>
>> CC: Stefano Stabellini <sstabellini@kernel.org>
>> CC: Julien Grall <julien@xen.org>
>> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
>> CC: Bertrand Marquis <bertrand.marquis@arm.com>
>> CC: Michal Orzel <michal.orzel@amd.com>
>> CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
>> CC: Baptiste Le Duc <baptiste.le-duc@vates.tech>
>> CC: Timothy Pearson <tpearson@raptorengineering.com>
>> CC: Ross Lagerwall <ross.lagerwall@citrix.com>
>>
>> This is to simplfy the script checking that xen.efi's section
>> attributes/alignments are correct for UEFI SecureBoot.
>> ---
>>   xen/arch/arm/xen.lds.S   | 8 +++-----
>>   xen/arch/ppc/xen.lds.S   | 8 +++-----
>>   xen/arch/riscv/xen.lds.S | 7 ++-----
>>   xen/arch/x86/xen.lds.S   | 4 +---
>>   4 files changed, 9 insertions(+), 18 deletions(-)
>>
>> diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
>> index d1bb6c62d208..8d0954c90afd 100644
>> --- a/xen/arch/arm/xen.lds.S
>> +++ b/xen/arch/arm/xen.lds.S
>> @@ -86,16 +86,14 @@ SECTIONS
>>         __ro_after_init_end = .;
>>     } : text
>>   -  .data.read_mostly : {
>> -       *(.data.read_mostly)
>> -  } :text
>> -
>>     . = ALIGN(SMP_CACHE_BYTES);
>>     .data : {                    /* Data */
>> -       *(.data.page_aligned)
>> +       *(.data.read_mostly)
>>            HYPFS_PARAM
>>   +       *(.data.page_aligned)
>> +
>>          *(.data .data.*)
>>          CONSTRUCTORS
>>     } :text
>> diff --git a/xen/arch/ppc/xen.lds.S b/xen/arch/ppc/xen.lds.S
>> index cddb70855307..b2159279169c 100644
>> --- a/xen/arch/ppc/xen.lds.S
>> +++ b/xen/arch/ppc/xen.lds.S
>> @@ -77,16 +77,14 @@ SECTIONS
>>           __ro_after_init_end = .;
>>       } :text
>>   -    DECL_SECTION(.data.read_mostly) {
>> -        *(.data.read_mostly)
>> -    } :text
>> -
>>       . = ALIGN(PAGE_SIZE);
>>       DECL_SECTION(.data) {                    /* Data */
>> -        *(.data.page_aligned)
>> +        *(.data.read_mostly)
>>             HYPFS_PARAM
>>   +        *(.data.page_aligned)
>> +
>>           *(.data .data.*)
>>           CONSTRUCTORS
>>       } :text
>> diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S
>> index 250ee3f36f4f..d1c5ce59c90d 100644
>> --- a/xen/arch/riscv/xen.lds.S
>> +++ b/xen/arch/riscv/xen.lds.S
>> @@ -84,16 +84,13 @@ SECTIONS
>>           __ro_after_init_end = .;
>>       } : text
>>   -    .data.read_mostly : {
>> -        *(.data.read_mostly)
>> -    } :text
>> -
>>       . = ALIGN(PAGE_SIZE);
>>       .data : {                    /* Data */
>> -        *(.data.page_aligned)
>> +        *(.data.read_mostly)
>>             HYPFS_PARAM
>>   +        *(.data.page_aligned)
>>           *(.sdata .sdata.*)
>>           *(.data .data.*)
>>           CONSTRUCTORS
>> diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
>> index 925848980219..99802aed4e13 100644
>> --- a/xen/arch/x86/xen.lds.S
>> +++ b/xen/arch/x86/xen.lds.S
>> @@ -295,13 +295,11 @@ SECTIONS
>>       __2M_rwdata_start = .;       /* Start of 2M superpages, mapped
>> RW. */
>>     . = ALIGN(SMP_CACHE_BYTES);
>> -  DECL_SECTION(.data.read_mostly) {
>> +  DECL_SECTION(.data) {
>>          *(.data.read_mostly)
>>            HYPFS_PARAM
>> -  } PHDR(text)
>>   -  DECL_SECTION(.data) {
>>          *(.data.page_aligned)
>>          *(.data .data.*)
>>     } PHDR(text)
>
> The ordering is preserved, but the alignment between the two isn't.
> Today the ALIGN() before .data sits between .data.read_mostly and
> regular .data.  After this patch it sits before .data.read_mostly, and
> the only thing separating it from *(.sdata/.data) is
> *(.data.page_aligned), which has no inputs on RISC-V, PPC or Arm with
> CONFIG_MPU. So the tail of .data.read_mostly will share a cache line
> with ordinary .data, which is the false sharing __read_mostly is meant
> to avoid (IIUC).

__read_mostly is indeed meant to reduce false sharing, but this patch
does not introduce any.

HYPFS_PARAM should have been read_mostly to begin with, and page
alignment is greater th cache alignment so there's no sharing there either.

~Andrew

Re: [PATCH] xen/link: Don't separate .data.read_mostly from .data
Posted by Oleksii Kurochko 1 week, 3 days ago

On 11/13/26 11:55 AM, Andrew Cooper wrote:
> On 13/11/2026 8:51 am, Oleksii Kurochko wrote:
>>
>>
>> On 11/12/26 7:58 PM, Andrew Cooper wrote:
>>> This appears to be an error in x86 which got copied into all other
>>> architectures.  .data.read_mostly is an internal detail, and none of the
>>> similar sections get exposed externally.
>>>
>>> Simply place .data.read_mostly in .data.
>>>
>>> No functional change.
>>>
>>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>>> ---
>>> CC: Jan Beulich <jbeulich@suse.com>
>>> CC: Roger Pau Monné <roger@xenproject.org>
>>> CC: Teddy Astie <teddy.astie@vates.tech>
>>> CC: Stefano Stabellini <sstabellini@kernel.org>
>>> CC: Julien Grall <julien@xen.org>
>>> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
>>> CC: Bertrand Marquis <bertrand.marquis@arm.com>
>>> CC: Michal Orzel <michal.orzel@amd.com>
>>> CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
>>> CC: Baptiste Le Duc <baptiste.le-duc@vates.tech>
>>> CC: Timothy Pearson <tpearson@raptorengineering.com>
>>> CC: Ross Lagerwall <ross.lagerwall@citrix.com>
>>>
>>> This is to simplfy the script checking that xen.efi's section
>>> attributes/alignments are correct for UEFI SecureBoot.
>>> ---
>>>    xen/arch/arm/xen.lds.S   | 8 +++-----
>>>    xen/arch/ppc/xen.lds.S   | 8 +++-----
>>>    xen/arch/riscv/xen.lds.S | 7 ++-----
>>>    xen/arch/x86/xen.lds.S   | 4 +---
>>>    4 files changed, 9 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
>>> index d1bb6c62d208..8d0954c90afd 100644
>>> --- a/xen/arch/arm/xen.lds.S
>>> +++ b/xen/arch/arm/xen.lds.S
>>> @@ -86,16 +86,14 @@ SECTIONS
>>>          __ro_after_init_end = .;
>>>      } : text
>>>    -  .data.read_mostly : {
>>> -       *(.data.read_mostly)
>>> -  } :text
>>> -
>>>      . = ALIGN(SMP_CACHE_BYTES);
>>>      .data : {                    /* Data */
>>> -       *(.data.page_aligned)
>>> +       *(.data.read_mostly)
>>>             HYPFS_PARAM
>>>    +       *(.data.page_aligned)
>>> +
>>>           *(.data .data.*)
>>>           CONSTRUCTORS
>>>      } :text
>>> diff --git a/xen/arch/ppc/xen.lds.S b/xen/arch/ppc/xen.lds.S
>>> index cddb70855307..b2159279169c 100644
>>> --- a/xen/arch/ppc/xen.lds.S
>>> +++ b/xen/arch/ppc/xen.lds.S
>>> @@ -77,16 +77,14 @@ SECTIONS
>>>            __ro_after_init_end = .;
>>>        } :text
>>>    -    DECL_SECTION(.data.read_mostly) {
>>> -        *(.data.read_mostly)
>>> -    } :text
>>> -
>>>        . = ALIGN(PAGE_SIZE);
>>>        DECL_SECTION(.data) {                    /* Data */
>>> -        *(.data.page_aligned)
>>> +        *(.data.read_mostly)
>>>              HYPFS_PARAM
>>>    +        *(.data.page_aligned)
>>> +
>>>            *(.data .data.*)
>>>            CONSTRUCTORS
>>>        } :text
>>> diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S
>>> index 250ee3f36f4f..d1c5ce59c90d 100644
>>> --- a/xen/arch/riscv/xen.lds.S
>>> +++ b/xen/arch/riscv/xen.lds.S
>>> @@ -84,16 +84,13 @@ SECTIONS
>>>            __ro_after_init_end = .;
>>>        } : text
>>>    -    .data.read_mostly : {
>>> -        *(.data.read_mostly)
>>> -    } :text
>>> -
>>>        . = ALIGN(PAGE_SIZE);
>>>        .data : {                    /* Data */
>>> -        *(.data.page_aligned)
>>> +        *(.data.read_mostly)
>>>              HYPFS_PARAM
>>>    +        *(.data.page_aligned)
>>>            *(.sdata .sdata.*)
>>>            *(.data .data.*)
>>>            CONSTRUCTORS
>>> diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
>>> index 925848980219..99802aed4e13 100644
>>> --- a/xen/arch/x86/xen.lds.S
>>> +++ b/xen/arch/x86/xen.lds.S
>>> @@ -295,13 +295,11 @@ SECTIONS
>>>        __2M_rwdata_start = .;       /* Start of 2M superpages, mapped
>>> RW. */
>>>      . = ALIGN(SMP_CACHE_BYTES);
>>> -  DECL_SECTION(.data.read_mostly) {
>>> +  DECL_SECTION(.data) {
>>>           *(.data.read_mostly)
>>>             HYPFS_PARAM
>>> -  } PHDR(text)
>>>    -  DECL_SECTION(.data) {
>>>           *(.data.page_aligned)
>>>           *(.data .data.*)
>>>      } PHDR(text)
>>
>> The ordering is preserved, but the alignment between the two isn't.
>> Today the ALIGN() before .data sits between .data.read_mostly and
>> regular .data.  After this patch it sits before .data.read_mostly, and
>> the only thing separating it from *(.sdata/.data) is
>> *(.data.page_aligned), which has no inputs on RISC-V, PPC or Arm with
>> CONFIG_MPU. So the tail of .data.read_mostly will share a cache line
>> with ordinary .data, which is the false sharing __read_mostly is meant
>> to avoid (IIUC).
> 
> __read_mostly is indeed meant to reduce false sharing, but this patch
> does not introduce any.
> 
> HYPFS_PARAM should have been read_mostly to begin with, and page
> alignment is greater th cache alignment so there's no sharing there either.
Thanks for clarifying. Then:

Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>

~ Oleksii

Re: [PATCH] xen/link: Don't separate .data.read_mostly from .data
Posted by Jan Beulich 1 week, 3 days ago
On 12.11.2026 19:58, Andrew Cooper wrote:
> This appears to be an error in x86 which got copied into all other
> architectures.  .data.read_mostly is an internal detail, and none of the
> similar sections get exposed externally.

Why "error" though? Our linking scripts were, aiui, originally derived from
Linux'es, where the section (and many others) was also separate back at the
time. It just so happened that folding of various output sections never has
gone as far as also dealing with this one.

> Simply place .data.read_mostly in .data.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Preferably with the description adjusted a little:
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan
Re: [PATCH] xen/link: Don't separate .data.read_mostly from .data
Posted by Volodymyr Babchuk 1 week, 3 days ago
Hi Andrew,

Andrew Cooper <andrew.cooper3@citrix.com> writes:

> This appears to be an error in x86 which got copied into all other
> architectures.  .data.read_mostly is an internal detail, and none of the
> similar sections get exposed externally.
>
> Simply place .data.read_mostly in .data.
>
> No functional change.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <jbeulich@suse.com>
> CC: Roger Pau Monné <roger@xenproject.org>
> CC: Teddy Astie <teddy.astie@vates.tech>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien@xen.org>
> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
> CC: Bertrand Marquis <bertrand.marquis@arm.com>
> CC: Michal Orzel <michal.orzel@amd.com>
> CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> CC: Baptiste Le Duc <baptiste.le-duc@vates.tech>
> CC: Timothy Pearson <tpearson@raptorengineering.com>
> CC: Ross Lagerwall <ross.lagerwall@citrix.com>
>
> This is to simplfy the script checking that xen.efi's section
> attributes/alignments are correct for UEFI SecureBoot.
> ---
>  xen/arch/arm/xen.lds.S   | 8 +++-----
>  xen/arch/ppc/xen.lds.S   | 8 +++-----
>  xen/arch/riscv/xen.lds.S | 7 ++-----
>  xen/arch/x86/xen.lds.S   | 4 +---
>  4 files changed, 9 insertions(+), 18 deletions(-)
>
> diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
> index d1bb6c62d208..8d0954c90afd 100644
> --- a/xen/arch/arm/xen.lds.S
> +++ b/xen/arch/arm/xen.lds.S
> @@ -86,16 +86,14 @@ SECTIONS
>        __ro_after_init_end = .;
>    } : text
>  
> -  .data.read_mostly : {
> -       *(.data.read_mostly)
> -  } :text
> -
>    . = ALIGN(SMP_CACHE_BYTES);
>    .data : {                    /* Data */
> -       *(.data.page_aligned)
> +       *(.data.read_mostly)
>  
>         HYPFS_PARAM
>  
> +       *(.data.page_aligned)

A small question: why are you moving data.page_aligned? I don't think
that this can cause issues, but I want to understand the reason.

> +
>         *(.data .data.*)
>         CONSTRUCTORS
>    } :text
> diff --git a/xen/arch/ppc/xen.lds.S b/xen/arch/ppc/xen.lds.S
> index cddb70855307..b2159279169c 100644
> --- a/xen/arch/ppc/xen.lds.S
> +++ b/xen/arch/ppc/xen.lds.S
> @@ -77,16 +77,14 @@ SECTIONS
>          __ro_after_init_end = .;
>      } :text
>  
> -    DECL_SECTION(.data.read_mostly) {
> -        *(.data.read_mostly)
> -    } :text
> -
>      . = ALIGN(PAGE_SIZE);
>      DECL_SECTION(.data) {                    /* Data */
> -        *(.data.page_aligned)
> +        *(.data.read_mostly)
>  
>          HYPFS_PARAM
>  
> +        *(.data.page_aligned)
> +
>          *(.data .data.*)
>          CONSTRUCTORS
>      } :text
> diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S
> index 250ee3f36f4f..d1c5ce59c90d 100644
> --- a/xen/arch/riscv/xen.lds.S
> +++ b/xen/arch/riscv/xen.lds.S
> @@ -84,16 +84,13 @@ SECTIONS
>          __ro_after_init_end = .;
>      } : text
>  
> -    .data.read_mostly : {
> -        *(.data.read_mostly)
> -    } :text
> -
>      . = ALIGN(PAGE_SIZE);
>      .data : {                    /* Data */
> -        *(.data.page_aligned)
> +        *(.data.read_mostly)
>  
>          HYPFS_PARAM
>  
> +        *(.data.page_aligned)
>          *(.sdata .sdata.*)
>          *(.data .data.*)
>          CONSTRUCTORS
> diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
> index 925848980219..99802aed4e13 100644
> --- a/xen/arch/x86/xen.lds.S
> +++ b/xen/arch/x86/xen.lds.S
> @@ -295,13 +295,11 @@ SECTIONS
>  
>    __2M_rwdata_start = .;       /* Start of 2M superpages, mapped RW. */
>    . = ALIGN(SMP_CACHE_BYTES);
> -  DECL_SECTION(.data.read_mostly) {
> +  DECL_SECTION(.data) {
>         *(.data.read_mostly)
>  
>         HYPFS_PARAM
> -  } PHDR(text)
>  
> -  DECL_SECTION(.data) {
>         *(.data.page_aligned)
>         *(.data .data.*)
>    } PHDR(text)
>
> base-commit: 4263fe42b736596cfa5bfec661f2f55f02759aa7
> prerequisite-patch-id: 680071148129321ffaf7bd7435d031904014f556

-- 
WBR, Volodymyr
Re: [PATCH] xen/link: Don't separate .data.read_mostly from .data
Posted by Andrew Cooper 1 week, 3 days ago
On 13/11/2026 1:38 am, Volodymyr Babchuk wrote:
> Hi Andrew,
>
> Andrew Cooper <andrew.cooper3@citrix.com> writes:
>
>> diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
>> index d1bb6c62d208..8d0954c90afd 100644
>> --- a/xen/arch/arm/xen.lds.S
>> +++ b/xen/arch/arm/xen.lds.S
>> @@ -86,16 +86,14 @@ SECTIONS
>>        __ro_after_init_end = .;
>>    } : text
>>  
>> -  .data.read_mostly : {
>> -       *(.data.read_mostly)
>> -  } :text
>> -
>>    . = ALIGN(SMP_CACHE_BYTES);
>>    .data : {                    /* Data */
>> -       *(.data.page_aligned)
>> +       *(.data.read_mostly)
>>  
>>         HYPFS_PARAM
>>  
>> +       *(.data.page_aligned)
> A small question: why are you moving data.page_aligned? I don't think
> that this can cause issues, but I want to understand the reason.

Because HYPFS_DATA is read_mostly too.

~Andrew