diff mbox series

[1/2] powerpc/vmlinux.lds: Ensure STRICT_ALIGN_SIZE is at least page aligned

Message ID 20220916131422.318752-1-mpe@ellerman.id.au (mailing list archive)
State Accepted
Headers show
Series [1/2] powerpc/vmlinux.lds: Ensure STRICT_ALIGN_SIZE is at least page aligned | expand

Commit Message

Michael Ellerman Sept. 16, 2022, 1:14 p.m. UTC
Add a check that STRICT_ALIGN_SIZE is aligned to at least PAGE_SIZE.

That then makes the alignment to PAGE_SIZE immediately after the
alignment to STRICT_ALIGN_SIZE redundant, so remove it.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/vmlinux.lds.S | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Christophe Leroy Sept. 16, 2022, 1:32 p.m. UTC | #1
Le 16/09/2022 à 15:14, Michael Ellerman a écrit :
> Add a check that STRICT_ALIGN_SIZE is aligned to at least PAGE_SIZE.

This cannot happen, the definitions in arch/powerpc/Kconfig don't allow 
that.

> 
> That then makes the alignment to PAGE_SIZE immediately after the
> alignment to STRICT_ALIGN_SIZE redundant, so remove it.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>   arch/powerpc/kernel/vmlinux.lds.S | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> index fe22d940412f..4e56fc0ee42a 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -32,6 +32,10 @@
>   
>   #define STRICT_ALIGN_SIZE	(1 << CONFIG_DATA_SHIFT)
>   
> +#if STRICT_ALIGN_SIZE < PAGE_SIZE
> +#error "CONFIG_DATA_SHIFT must be >= PAGE_SIZE"

s/PAGE_SIZE/PAGE_SHIFT

> +#endif
> +
>   ENTRY(_stext)
>   
>   PHDRS {
> @@ -215,7 +219,6 @@ SECTIONS
>    */
>   	. = ALIGN(STRICT_ALIGN_SIZE);
>   	__init_begin = .;
> -	. = ALIGN(PAGE_SIZE);
>   	.init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
>   		_sinittext = .;
>   		INIT_TEXT
Michael Ellerman Sept. 17, 2022, 6:40 a.m. UTC | #2
Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Le 16/09/2022 à 15:14, Michael Ellerman a écrit :
>> Add a check that STRICT_ALIGN_SIZE is aligned to at least PAGE_SIZE.
>
> This cannot happen, the definitions in arch/powerpc/Kconfig don't allow 
> that.

It can't happen yet :)

There's enough combinations of DATA_SHIFT and PAGE_SIZE that it would be
easy to add a new value for either and miss the implications. So I'd
rather have a check.

>> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
>> index fe22d940412f..4e56fc0ee42a 100644
>> --- a/arch/powerpc/kernel/vmlinux.lds.S
>> +++ b/arch/powerpc/kernel/vmlinux.lds.S
>> @@ -32,6 +32,10 @@
>>   
>>   #define STRICT_ALIGN_SIZE	(1 << CONFIG_DATA_SHIFT)
>>   
>> +#if STRICT_ALIGN_SIZE < PAGE_SIZE
>> +#error "CONFIG_DATA_SHIFT must be >= PAGE_SIZE"
>
> s/PAGE_SIZE/PAGE_SHIFT

Thanks.

cheers
Michael Ellerman Oct. 4, 2022, 1:24 p.m. UTC | #3
On Fri, 16 Sep 2022 23:14:21 +1000, Michael Ellerman wrote:
> Add a check that STRICT_ALIGN_SIZE is aligned to at least PAGE_SIZE.
> 
> That then makes the alignment to PAGE_SIZE immediately after the
> alignment to STRICT_ALIGN_SIZE redundant, so remove it.
> 
> 

Applied to powerpc/next.

[1/2] powerpc/vmlinux.lds: Ensure STRICT_ALIGN_SIZE is at least page aligned
      https://git.kernel.org/powerpc/c/331771e836e6a32c8632d8cf5e2cdd94471258ad
[2/2] powerpc/vmlinux.lds: Add an explicit symbol for the SRWX boundary
      https://git.kernel.org/powerpc/c/b150a4d12b919baf956b807aa305cf78df03d0fe

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index fe22d940412f..4e56fc0ee42a 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -32,6 +32,10 @@ 
 
 #define STRICT_ALIGN_SIZE	(1 << CONFIG_DATA_SHIFT)
 
+#if STRICT_ALIGN_SIZE < PAGE_SIZE
+#error "CONFIG_DATA_SHIFT must be >= PAGE_SIZE"
+#endif
+
 ENTRY(_stext)
 
 PHDRS {
@@ -215,7 +219,6 @@  SECTIONS
  */
 	. = ALIGN(STRICT_ALIGN_SIZE);
 	__init_begin = .;
-	. = ALIGN(PAGE_SIZE);
 	.init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
 		_sinittext = .;
 		INIT_TEXT