virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux
@ 2006-08-22 14:26 Ian Campbell
  2006-08-22 14:48 ` Andi Kleen
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ian Campbell @ 2006-08-22 14:26 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Andrew Morton, Xen-devel, Jeremy Fitzhardinge, Virtualization,
	Linux Kernel, Chris Wright, Ian Pratt, Eric W. Biederman,
	Christoph Lameter

This patch updates x86_64 linker script to pack any .note.* sections
into a PT_NOTE segment in the output file.

To do this, we tell ld that we need a PT_NOTE segment.  This requires
us to start explicitly mapping sections to segments, so we also need
to explicitly create PT_LOAD segments for text and data, and map the
sections to them appropriately.  Fortunately, each section will
default to its previous section's segment, so it doesn't take many
changes to vmlinux.lds.S.

The corresponding change is already made for i386 in -mm and I'd like
this patch to join it. The section to segment mappings do change as do
the segment flags so some time in -mm would be good for that reason as
well, just in case.

In particular .data and .bss move from the text segment to the data
segment and .data.cacheline_aligned .data.read_mostly are put in the
data segment instead of a separate one.

I think that it would be possible to exactly match the existing section
to segment mapping and flags but it would be a more intrusive change and
I'm not sure there is a reason for the existing layout other than it is
what you get by default if you don't explicitly specify something else.
If there is a reason for the existing layout then I will of course make
the more intrusive change. If there is no reason we could probably drop
the executable or writable flags from some segments but I don't know how
much attention is paid to them anyway so it might not be worth the
effort.

The vsyscall related sections need to go in a different segment to the
normal data segment and so I invented a "user" segment to contain them.
I believe this should appear to be another data segment as far as the
kernel is concerned so the flags are setup accordingly.

The notes will be used in the Xen paravirt_ops backend to provide
additional information to the domain builder. I am in the process of
converting the xen-unstable kernels and tools over to this scheme at the
moment to support this in the future.

It has been suggested to me that the notes segment should have flags 0
(i.e. not readable) since it is only used by the loader and is not used
at runtime. For now I went with a readable segment since that is what
the i386 patch uses.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>

diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
index 7c4de31..ef418b3 100644
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -13,6 +13,12 @@ OUTPUT_FORMAT("elf64-x86-64", "elf64-x86
 OUTPUT_ARCH(i386:x86-64)
 ENTRY(phys_startup_64)
 jiffies_64 = jiffies;
+PHDRS {
+	text PT_LOAD FLAGS(5);	/* R_E */
+	data PT_LOAD FLAGS(7);	/* RWE */
+	user PT_LOAD FLAGS(7);	/* RWE */
+	note PT_NOTE FLAGS(4);	/* R__ */
+}
 SECTIONS
 {
   . = __START_KERNEL;
@@ -31,7 +37,7 @@ SECTIONS
 	KPROBES_TEXT
 	*(.fixup)
 	*(.gnu.warning)
-	} = 0x9090
+	} :text = 0x9090
   				/* out-of-line lock text */
   .text.lock : AT(ADDR(.text.lock) - LOAD_OFFSET) { *(.text.lock) }
 
@@ -57,7 +63,7 @@ #endif
   .data : AT(ADDR(.data) - LOAD_OFFSET) {
 	*(.data)
 	CONSTRUCTORS
-	}
+	} :data
 
   _edata = .;			/* End of data section */
 
@@ -89,7 +95,7 @@ #define VVIRT_OFFSET (VSYSCALL_ADDR - VS
 #define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
 
   . = VSYSCALL_ADDR;
-  .vsyscall_0 :	 AT(VSYSCALL_PHYS_ADDR) { *(.vsyscall_0) }
+  .vsyscall_0 :	 AT(VSYSCALL_PHYS_ADDR) { *(.vsyscall_0) } :user
   __vsyscall_0 = VSYSCALL_VIRT_ADDR;
 
   . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
@@ -132,7 +138,7 @@ #undef VVIRT
   . = ALIGN(8192);		/* init_task */
   .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
 	*(.data.init_task)
-  }
+  } :data
 
   . = ALIGN(4096);
   .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
@@ -235,4 +241,6 @@ #endif
   STABS_DEBUG
 
   DWARF_DEBUG
+
+  NOTES
 }

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

* Re: [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux
  2006-08-22 14:26 [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux Ian Campbell
@ 2006-08-22 14:48 ` Andi Kleen
  2006-08-22 14:59 ` [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux II Andi Kleen
  2006-08-22 15:11 ` [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux Jeremy Fitzhardinge
  2 siblings, 0 replies; 6+ messages in thread
From: Andi Kleen @ 2006-08-22 14:48 UTC (permalink / raw)
  To: Ian Campbell
  Cc: Andrew Morton, Xen-devel, Jeremy Fitzhardinge, Virtualization,
	Linux Kernel, Chris Wright, Ian Pratt, Eric W. Biederman,
	Christoph Lameter

On Tuesday 22 August 2006 16:26, Ian Campbell wrote:
> This patch updates x86_64 linker script to pack any .note.* sections
> into a PT_NOTE segment in the output file.

Thanks added.

-Andi

P.S.: 2-3 paragraphs description would have been enough, but that is fine
too.

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

* Re: [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux II
  2006-08-22 14:26 [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux Ian Campbell
  2006-08-22 14:48 ` Andi Kleen
@ 2006-08-22 14:59 ` Andi Kleen
  2006-08-22 15:13   ` Jeremy Fitzhardinge
  2006-08-22 15:26   ` Ian Campbell
  2006-08-22 15:11 ` [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux Jeremy Fitzhardinge
  2 siblings, 2 replies; 6+ messages in thread
From: Andi Kleen @ 2006-08-22 14:59 UTC (permalink / raw)
  To: Ian Campbell
  Cc: Andrew Morton, Xen-devel, Jeremy Fitzhardinge, Virtualization,
	Linux Kernel, Chris Wright, Ian Pratt, Eric W. Biederman,
	Christoph Lameter

On Tuesday 22 August 2006 16:26, Ian Campbell wrote:
> This patch updates x86_64 linker script to pack any .note.* sections
> into a PT_NOTE segment in the output file.


Sorry I tried to apply it, but at least 2.6.18rc4 mainline (which my tree
is based on) doesn't have a NOTES macro so it doesn't link

I dropped the NOTES addition for now, presumably it will need to be readded
later.

-Andi

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

* Re: [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux
  2006-08-22 14:26 [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux Ian Campbell
  2006-08-22 14:48 ` Andi Kleen
  2006-08-22 14:59 ` [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux II Andi Kleen
@ 2006-08-22 15:11 ` Jeremy Fitzhardinge
  2 siblings, 0 replies; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2006-08-22 15:11 UTC (permalink / raw)
  To: Ian Campbell
  Cc: Andrew Morton, Ian Pratt, Xen-devel, Eric W. Biederman,
	Chris Wright, Virtualization, Linux Kernel, Christoph Lameter

Ian Campbell wrote:
> It has been suggested to me that the notes segment should have flags 0
> (i.e. not readable) since it is only used by the loader and is not used
> at runtime. For now I went with a readable segment since that is what
> the i386 patch uses.
>   

Note that the PT_NOTEs segment is aliased to a part of one of the 
PT_LOADs - ie, it points into the data segment.  So making it -rwx would 
either be ignored, or also require putting the bits into a new PT_LOAD 
segment with 0 permissions, which is pretty pointless.  I made it R_E 
just so there was no permissions conflict, though the _E part could 
probably go.

    J

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

* Re: [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux II
  2006-08-22 14:59 ` [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux II Andi Kleen
@ 2006-08-22 15:13   ` Jeremy Fitzhardinge
  2006-08-22 15:26   ` Ian Campbell
  1 sibling, 0 replies; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2006-08-22 15:13 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Ian Campbell, Andrew Morton, Ian Pratt, Xen-devel, Chris Wright,
	Virtualization, Christoph Lameter, Linux Kernel,
	Eric W. Biederman

Andi Kleen wrote:
> Sorry I tried to apply it, but at least 2.6.18rc4 mainline (which my tree
> is based on) doesn't have a NOTES macro so it doesn't link
>
> I dropped the NOTES addition for now, presumably it will need to be readded
> later.

Yes, Ian's patch is incremental on top of mine, which defines the NOTES 
macro in include/asm-generic/vmlinux.lds.h:

#define NOTES                                                           \
                .notes : { *(.note.*) } :note


    J

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

* Re: [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux II
  2006-08-22 14:59 ` [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux II Andi Kleen
  2006-08-22 15:13   ` Jeremy Fitzhardinge
@ 2006-08-22 15:26   ` Ian Campbell
  1 sibling, 0 replies; 6+ messages in thread
From: Ian Campbell @ 2006-08-22 15:26 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Andrew Morton, Xen-devel, Jeremy Fitzhardinge, Virtualization,
	Linux Kernel, Chris Wright, Ian Pratt, Eric W. Biederman,
	Christoph Lameter

On Tue, 2006-08-22 at 16:59 +0200, Andi Kleen wrote:
> On Tuesday 22 August 2006 16:26, Ian Campbell wrote:
> > This patch updates x86_64 linker script to pack any .note.* sections
> > into a PT_NOTE segment in the output file.

> Sorry I tried to apply it, but at least 2.6.18rc4 mainline (which my tree
> is based on) doesn't have a NOTES macro so it doesn't link
> 
> I dropped the NOTES addition for now, presumably it will need to be readded
> later.

Sorry, I should have been clearer about the dependency on the i386 patch
which is currently in -mm. 

Ian.

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

end of thread, other threads:[~2006-08-22 15:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-22 14:26 [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux Ian Campbell
2006-08-22 14:48 ` Andi Kleen
2006-08-22 14:59 ` [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux II Andi Kleen
2006-08-22 15:13   ` Jeremy Fitzhardinge
2006-08-22 15:26   ` Ian Campbell
2006-08-22 15:11 ` [PATCH 1 of 1] x86_64: Put .note.* sections into a PT_NOTE segment in vmlinux Jeremy Fitzhardinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).