All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: add PAGE_ALIGNED_DATA to linker script
@ 2013-10-08 20:37 Mark Salter
  2013-10-09 10:14 ` Will Deacon
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Salter @ 2013-10-08 20:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Catalin Marinas, Will Deacon, Mark Salter

The arm64 linker script doesn't use the PAGE_ALIGNED_DATA macro which
leads to a ".data..page_aligned" section being placed between the end
of .data and start of .bss:

 % readelf -e vmlinux
   ...
 Section to Segment mapping:
  Segment Sections...
   00     .head.text .text .text.init .rodata __ksymtab __ksymtab_gpl \
          __ksymtab_strings __param __modver __ex_table .notes \
          .init.text .init.data .data..percpu .data .data..page_aligned .bss

This causes problems for the EFI stub which may have to relocate the
kernel image based on stext and _edata symbols.

This patch adds PAGE_ALIGNED_DATA() to the linker script inside the
the .data section.

Signed-off-by: Mark Salter <msalter@redhat.com>
---
 arch/arm64/kernel/vmlinux.lds.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index f8ab9d8..e441556 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -110,6 +110,7 @@ SECTIONS
 		 */
 		INIT_TASK_DATA(THREAD_SIZE)
 		NOSAVE_DATA
+		PAGE_ALIGNED_DATA(PAGE_SIZE)
 		CACHELINE_ALIGNED_DATA(64)
 		READ_MOSTLY_DATA(64)
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: add PAGE_ALIGNED_DATA to linker script
  2013-10-08 20:37 [PATCH] arm64: add PAGE_ALIGNED_DATA to linker script Mark Salter
@ 2013-10-09 10:14 ` Will Deacon
  2013-10-09 17:31   ` Mark Salter
  2013-10-11 12:18   ` Mark Salter
  0 siblings, 2 replies; 10+ messages in thread
From: Will Deacon @ 2013-10-09 10:14 UTC (permalink / raw)
  To: Mark Salter; +Cc: linux-kernel, Catalin Marinas

On Tue, Oct 08, 2013 at 09:37:39PM +0100, Mark Salter wrote:
> The arm64 linker script doesn't use the PAGE_ALIGNED_DATA macro which
> leads to a ".data..page_aligned" section being placed between the end
> of .data and start of .bss:
> 
>  % readelf -e vmlinux
>    ...
>  Section to Segment mapping:
>   Segment Sections...
>    00     .head.text .text .text.init .rodata __ksymtab __ksymtab_gpl \
>           __ksymtab_strings __param __modver __ex_table .notes \
>           .init.text .init.data .data..percpu .data .data..page_aligned .bss
> 
> This causes problems for the EFI stub which may have to relocate the
> kernel image based on stext and _edata symbols.
> 
> This patch adds PAGE_ALIGNED_DATA() to the linker script inside the
> the .data section.
> 
> Signed-off-by: Mark Salter <msalter@redhat.com>
> ---
>  arch/arm64/kernel/vmlinux.lds.S | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
> index f8ab9d8..e441556 100644
> --- a/arch/arm64/kernel/vmlinux.lds.S
> +++ b/arch/arm64/kernel/vmlinux.lds.S
> @@ -110,6 +110,7 @@ SECTIONS
>  		 */
>  		INIT_TASK_DATA(THREAD_SIZE)
>  		NOSAVE_DATA
> +		PAGE_ALIGNED_DATA(PAGE_SIZE)
>  		CACHELINE_ALIGNED_DATA(64)
>  		READ_MOSTLY_DATA(64)

Can we just replace this chunk with RW_DATA_SECTION(64, PAGE_SIZE,
THREAD_SIZE) instead?

Will

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: add PAGE_ALIGNED_DATA to linker script
  2013-10-09 10:14 ` Will Deacon
@ 2013-10-09 17:31   ` Mark Salter
  2013-10-11 12:18   ` Mark Salter
  1 sibling, 0 replies; 10+ messages in thread
From: Mark Salter @ 2013-10-09 17:31 UTC (permalink / raw)
  To: Will Deacon; +Cc: linux-kernel, Catalin Marinas

On Wed, 2013-10-09 at 11:14 +0100, Will Deacon wrote:
> On Tue, Oct 08, 2013 at 09:37:39PM +0100, Mark Salter wrote:
> > The arm64 linker script doesn't use the PAGE_ALIGNED_DATA macro which
> > leads to a ".data..page_aligned" section being placed between the end
> > of .data and start of .bss:
> > 
> >  % readelf -e vmlinux
> >    ...
> >  Section to Segment mapping:
> >   Segment Sections...
> >    00     .head.text .text .text.init .rodata __ksymtab __ksymtab_gpl \
> >           __ksymtab_strings __param __modver __ex_table .notes \
> >           .init.text .init.data .data..percpu .data .data..page_aligned .bss
> > 
> > This causes problems for the EFI stub which may have to relocate the
> > kernel image based on stext and _edata symbols.
> > 
> > This patch adds PAGE_ALIGNED_DATA() to the linker script inside the
> > the .data section.
> > 
> > Signed-off-by: Mark Salter <msalter@redhat.com>
> > ---
> >  arch/arm64/kernel/vmlinux.lds.S | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
> > index f8ab9d8..e441556 100644
> > --- a/arch/arm64/kernel/vmlinux.lds.S
> > +++ b/arch/arm64/kernel/vmlinux.lds.S
> > @@ -110,6 +110,7 @@ SECTIONS
> >  		 */
> >  		INIT_TASK_DATA(THREAD_SIZE)
> >  		NOSAVE_DATA
> > +		PAGE_ALIGNED_DATA(PAGE_SIZE)
> >  		CACHELINE_ALIGNED_DATA(64)
> >  		READ_MOSTLY_DATA(64)
> 
> Can we just replace this chunk with RW_DATA_SECTION(64, PAGE_SIZE,
> THREAD_SIZE) instead?

Possibly. The layout of the included macros is the same. The only
difference being the placement of _data, _sdata, and _edata inside
.data and the use of __data_loc.

--Mark



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: add PAGE_ALIGNED_DATA to linker script
  2013-10-09 10:14 ` Will Deacon
  2013-10-09 17:31   ` Mark Salter
@ 2013-10-11 12:18   ` Mark Salter
  2013-11-01 15:01     ` Mark Salter
  2013-11-04 11:28     ` Catalin Marinas
  1 sibling, 2 replies; 10+ messages in thread
From: Mark Salter @ 2013-10-11 12:18 UTC (permalink / raw)
  To: Will Deacon; +Cc: linux-kernel, Catalin Marinas

On Wed, 2013-10-09 at 11:14 +0100, Will Deacon wrote:
> > @@ -110,6 +110,7 @@ SECTIONS
> >                */
> >               INIT_TASK_DATA(THREAD_SIZE)
> >               NOSAVE_DATA
> > +             PAGE_ALIGNED_DATA(PAGE_SIZE)
> >               CACHELINE_ALIGNED_DATA(64)
> >               READ_MOSTLY_DATA(64)
> 
> Can we just replace this chunk with RW_DATA_SECTION(64, PAGE_SIZE,
> THREAD_SIZE) instead?
> 

I took a look at this. It can be done, but the RW_DATA_SECTION aligns
data to PAGE_SIZE where the existing alignment is THREAD_SIZE. So using
RW_DATA_SECTION would waste some space if using 64K pagesize.

--Mark



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: add PAGE_ALIGNED_DATA to linker script
  2013-10-11 12:18   ` Mark Salter
@ 2013-11-01 15:01     ` Mark Salter
  2013-11-01 16:17       ` Will Deacon
  2013-11-04 11:28     ` Catalin Marinas
  1 sibling, 1 reply; 10+ messages in thread
From: Mark Salter @ 2013-11-01 15:01 UTC (permalink / raw)
  To: Will Deacon; +Cc: linux-kernel, Catalin Marinas

On Fri, 2013-10-11 at 08:18 -0400, Mark Salter wrote:
> On Wed, 2013-10-09 at 11:14 +0100, Will Deacon wrote:
> > > @@ -110,6 +110,7 @@ SECTIONS
> > >                */
> > >               INIT_TASK_DATA(THREAD_SIZE)
> > >               NOSAVE_DATA
> > > +             PAGE_ALIGNED_DATA(PAGE_SIZE)
> > >               CACHELINE_ALIGNED_DATA(64)
> > >               READ_MOSTLY_DATA(64)
> > 
> > Can we just replace this chunk with RW_DATA_SECTION(64, PAGE_SIZE,
> > THREAD_SIZE) instead?
> > 
> 
> I took a look at this. It can be done, but the RW_DATA_SECTION aligns
> data to PAGE_SIZE where the existing alignment is THREAD_SIZE. So using
> RW_DATA_SECTION would waste some space if using 64K pagesize.
> 
> --Mark

So where do we stand with this one?



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: add PAGE_ALIGNED_DATA to linker script
  2013-11-01 15:01     ` Mark Salter
@ 2013-11-01 16:17       ` Will Deacon
  0 siblings, 0 replies; 10+ messages in thread
From: Will Deacon @ 2013-11-01 16:17 UTC (permalink / raw)
  To: Mark Salter; +Cc: linux-kernel, Catalin Marinas

On Fri, Nov 01, 2013 at 03:01:30PM +0000, Mark Salter wrote:
> On Fri, 2013-10-11 at 08:18 -0400, Mark Salter wrote:
> > On Wed, 2013-10-09 at 11:14 +0100, Will Deacon wrote:
> > > > @@ -110,6 +110,7 @@ SECTIONS
> > > >                */
> > > >               INIT_TASK_DATA(THREAD_SIZE)
> > > >               NOSAVE_DATA
> > > > +             PAGE_ALIGNED_DATA(PAGE_SIZE)
> > > >               CACHELINE_ALIGNED_DATA(64)
> > > >               READ_MOSTLY_DATA(64)
> > > 
> > > Can we just replace this chunk with RW_DATA_SECTION(64, PAGE_SIZE,
> > > THREAD_SIZE) instead?
> > > 
> > 
> > I took a look at this. It can be done, but the RW_DATA_SECTION aligns
> > data to PAGE_SIZE where the existing alignment is THREAD_SIZE. So using
> > RW_DATA_SECTION would waste some space if using 64K pagesize.
> > 
> > --Mark
> 
> So where do we stand with this one?

I'd probably go for using the generic macro, but I don't have strong
preferences either way.

Will

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: add PAGE_ALIGNED_DATA to linker script
  2013-10-11 12:18   ` Mark Salter
  2013-11-01 15:01     ` Mark Salter
@ 2013-11-04 11:28     ` Catalin Marinas
  2013-11-04 16:38       ` [PATCH] arm64: use generic RW_DATA_SECTION macro in " Mark Salter
  1 sibling, 1 reply; 10+ messages in thread
From: Catalin Marinas @ 2013-11-04 11:28 UTC (permalink / raw)
  To: Mark Salter; +Cc: Will Deacon, linux-kernel

On Fri, Oct 11, 2013 at 01:18:41PM +0100, Mark Salter wrote:
> On Wed, 2013-10-09 at 11:14 +0100, Will Deacon wrote:
> > > @@ -110,6 +110,7 @@ SECTIONS
> > >                */
> > >               INIT_TASK_DATA(THREAD_SIZE)
> > >               NOSAVE_DATA
> > > +             PAGE_ALIGNED_DATA(PAGE_SIZE)
> > >               CACHELINE_ALIGNED_DATA(64)
> > >               READ_MOSTLY_DATA(64)
> > 
> > Can we just replace this chunk with RW_DATA_SECTION(64, PAGE_SIZE,
> > THREAD_SIZE) instead?
> > 
> 
> I took a look at this. It can be done, but the RW_DATA_SECTION aligns
> data to PAGE_SIZE where the existing alignment is THREAD_SIZE. So using
> RW_DATA_SECTION would waste some space if using 64K pagesize.

I think that's ok, especially since we may get security patches in the
future to create more restrictive page table attributes (well, with the
drawback of more TLB pressure). So I'm for more cleanup in the vmlinux
file by using the generic defines.

-- 
Catalin

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] arm64: use generic RW_DATA_SECTION macro in linker script
  2013-11-04 11:28     ` Catalin Marinas
@ 2013-11-04 16:38       ` Mark Salter
  2013-11-04 17:20         ` Will Deacon
  2013-11-04 18:19         ` Catalin Marinas
  0 siblings, 2 replies; 10+ messages in thread
From: Mark Salter @ 2013-11-04 16:38 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: Will Deacon, linux-kernel

The .data section in the arm64 linker script currently lacks a
definition for page-aligned data. This leads to a .page_aligned
section being placed between the end of data and start of bss.
This patch corrects that by using the generic RW_DATA_SECTION
macro which includes support for page-aligned data.

Signed-off-by: Mark Salter <msalter@redhat.com>
---
 arch/arm64/kernel/vmlinux.lds.S | 31 +++++++------------------------
 1 file changed, 7 insertions(+), 24 deletions(-)

diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index f8ab9d8..4ff9dcf 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -97,30 +97,13 @@ SECTIONS
 	PERCPU_SECTION(64)
 
 	__init_end = .;
-	. = ALIGN(THREAD_SIZE);
-	__data_loc = .;
-
-	.data : AT(__data_loc) {
-		_data = .;		/* address in memory */
-		_sdata = .;
-
-		/*
-		 * first, the init task union, aligned
-		 * to an 8192 byte boundary.
-		 */
-		INIT_TASK_DATA(THREAD_SIZE)
-		NOSAVE_DATA
-		CACHELINE_ALIGNED_DATA(64)
-		READ_MOSTLY_DATA(64)
-
-		/*
-		 * and the usual data section
-		 */
-		DATA_DATA
-		CONSTRUCTORS
-
-		_edata = .;
-	}
+
+	. = ALIGN(PAGE_SIZE);
+	_data = .;
+	__data_loc = _data - LOAD_OFFSET;
+	_sdata = .;
+	RW_DATA_SECTION(64, PAGE_SIZE, THREAD_SIZE)
+	_edata = .;
 	_edata_loc = __data_loc + SIZEOF(.data);
 
 	BSS_SECTION(0, 0, 0)
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: use generic RW_DATA_SECTION macro in linker script
  2013-11-04 16:38       ` [PATCH] arm64: use generic RW_DATA_SECTION macro in " Mark Salter
@ 2013-11-04 17:20         ` Will Deacon
  2013-11-04 18:19         ` Catalin Marinas
  1 sibling, 0 replies; 10+ messages in thread
From: Will Deacon @ 2013-11-04 17:20 UTC (permalink / raw)
  To: Mark Salter; +Cc: Catalin Marinas, linux-kernel

On Mon, Nov 04, 2013 at 04:38:47PM +0000, Mark Salter wrote:
> The .data section in the arm64 linker script currently lacks a
> definition for page-aligned data. This leads to a .page_aligned
> section being placed between the end of data and start of bss.
> This patch corrects that by using the generic RW_DATA_SECTION
> macro which includes support for page-aligned data.
> 
> Signed-off-by: Mark Salter <msalter@redhat.com>

  Acked-by: Will Deacon <will.deacon@arm.com>

Cheers Mark!

Will

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: use generic RW_DATA_SECTION macro in linker script
  2013-11-04 16:38       ` [PATCH] arm64: use generic RW_DATA_SECTION macro in " Mark Salter
  2013-11-04 17:20         ` Will Deacon
@ 2013-11-04 18:19         ` Catalin Marinas
  1 sibling, 0 replies; 10+ messages in thread
From: Catalin Marinas @ 2013-11-04 18:19 UTC (permalink / raw)
  To: Mark Salter; +Cc: Will Deacon, linux-kernel

On Mon, Nov 04, 2013 at 04:38:47PM +0000, Mark Salter wrote:
> The .data section in the arm64 linker script currently lacks a
> definition for page-aligned data. This leads to a .page_aligned
> section being placed between the end of data and start of bss.
> This patch corrects that by using the generic RW_DATA_SECTION
> macro which includes support for page-aligned data.
> 
> Signed-off-by: Mark Salter <msalter@redhat.com>

Thanks. Applied.

-- 
Catalin

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-11-04 18:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-08 20:37 [PATCH] arm64: add PAGE_ALIGNED_DATA to linker script Mark Salter
2013-10-09 10:14 ` Will Deacon
2013-10-09 17:31   ` Mark Salter
2013-10-11 12:18   ` Mark Salter
2013-11-01 15:01     ` Mark Salter
2013-11-01 16:17       ` Will Deacon
2013-11-04 11:28     ` Catalin Marinas
2013-11-04 16:38       ` [PATCH] arm64: use generic RW_DATA_SECTION macro in " Mark Salter
2013-11-04 17:20         ` Will Deacon
2013-11-04 18:19         ` Catalin Marinas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.