direct-io.hg

view patches/linux-2.6.16.13/x86-put-note-sections-into-a-pt_note-segment-in-vmlinux.patch @ 11522:1fae74cd3963

[POWERPC][XEN] Fix infinite loop caused by hdec storm

This was the cause of the periodic hang on secondary processors that has
been holding back the submission of the SMP patch.

Signed-off-by: Amos Waterland <apw@us.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Thu Sep 14 22:06:15 2006 -0400 (2006-09-14)
parents a4550b748840
children
line source
1 Taken from 2.6.18-rc4-mm1.
3 From: Jeremy Fitzhardinge <jeremy@xensource.com>
5 This patch will pack any .note.* section into a PT_NOTE segment in the output
6 file.
8 To do this, we tell ld that we need a PT_NOTE segment. This requires us to
9 start explicitly mapping sections to segments, so we also need to explicitly
10 create PT_LOAD segments for text and data, and map the sections to them
11 appropriately. Fortunately, each section will default to its previous
12 section's segment, so it doesn't take many changes to vmlinux.lds.S.
14 This only changes i386 for now, but I presume the corresponding changes for
15 other architectures will be as simple.
17 This change also adds <linux/elfnote.h>, which defines C and Assembler macros
18 for actually creating ELF notes.
20 Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
21 Cc: Eric W. Biederman <ebiederm@xmission.com>
22 Cc: Hollis Blanchard <hollisb@us.ibm.com>
23 Signed-off-by: Andrew Morton <akpm@osdl.org>
24 ---
26 arch/i386/kernel/vmlinux.lds.S | 12 +++
27 include/asm-generic/vmlinux.lds.h | 3
28 include/linux/elfnote.h | 88 ++++++++++++++++++++++++++++
29 3 files changed, 101 insertions(+), 2 deletions(-)
31 diff -puN arch/i386/kernel/vmlinux.lds.S~x86-put-note-sections-into-a-pt_note-segment-in-vmlinux arch/i386/kernel/vmlinux.lds.S
32 --- a/arch/i386/kernel/vmlinux.lds.S~x86-put-note-sections-into-a-pt_note-segment-in-vmlinux
33 +++ a/arch/i386/kernel/vmlinux.lds.S
34 @@ -13,6 +13,12 @@ OUTPUT_FORMAT("elf32-i386", "elf32-i386"
35 OUTPUT_ARCH(i386)
36 ENTRY(phys_startup_32)
37 jiffies = jiffies_64;
38 +
39 +PHDRS {
40 + text PT_LOAD FLAGS(5); /* R_E */
41 + data PT_LOAD FLAGS(7); /* RWE */
42 + note PT_NOTE FLAGS(4); /* R__ */
43 +}
44 SECTIONS
45 {
46 . = __KERNEL_START;
47 @@ -26,7 +32,7 @@ SECTIONS
48 KPROBES_TEXT
49 *(.fixup)
50 *(.gnu.warning)
51 - } = 0x9090
52 + } :text = 0x9090
54 _etext = .; /* End of text section */
56 @@ -50,7 +56,7 @@ SECTIONS
57 .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
58 *(.data)
59 CONSTRUCTORS
60 - }
61 + } :data
63 . = ALIGN(4096);
64 __nosave_begin = .;
65 @@ -186,4 +192,6 @@ SECTIONS
66 STABS_DEBUG
68 DWARF_DEBUG
69 +
70 + NOTES
71 }
72 diff -puN include/asm-generic/vmlinux.lds.h~x86-put-note-sections-into-a-pt_note-segment-in-vmlinux include/asm-generic/vmlinux.lds.h
73 --- a/include/asm-generic/vmlinux.lds.h~x86-put-note-sections-into-a-pt_note-segment-in-vmlinux
74 +++ a/include/asm-generic/vmlinux.lds.h
75 @@ -194,3 +194,6 @@
76 .stab.index 0 : { *(.stab.index) } \
77 .stab.indexstr 0 : { *(.stab.indexstr) } \
78 .comment 0 : { *(.comment) }
79 +
80 +#define NOTES \
81 + .notes : { *(.note.*) } :note
82 diff -puN /dev/null include/linux/elfnote.h
83 --- /dev/null
84 +++ a/include/linux/elfnote.h
85 @@ -0,0 +1,88 @@
86 +#ifndef _LINUX_ELFNOTE_H
87 +#define _LINUX_ELFNOTE_H
88 +/*
89 + * Helper macros to generate ELF Note structures, which are put into a
90 + * PT_NOTE segment of the final vmlinux image. These are useful for
91 + * including name-value pairs of metadata into the kernel binary (or
92 + * modules?) for use by external programs.
93 + *
94 + * Each note has three parts: a name, a type and a desc. The name is
95 + * intended to distinguish the note's originator, so it would be a
96 + * company, project, subsystem, etc; it must be in a suitable form for
97 + * use in a section name. The type is an integer which is used to tag
98 + * the data, and is considered to be within the "name" namespace (so
99 + * "FooCo"'s type 42 is distinct from "BarProj"'s type 42). The
100 + * "desc" field is the actual data. There are no constraints on the
101 + * desc field's contents, though typically they're fairly small.
102 + *
103 + * All notes from a given NAME are put into a section named
104 + * .note.NAME. When the kernel image is finally linked, all the notes
105 + * are packed into a single .notes section, which is mapped into the
106 + * PT_NOTE segment. Because notes for a given name are grouped into
107 + * the same section, they'll all be adjacent the output file.
108 + *
109 + * This file defines macros for both C and assembler use. Their
110 + * syntax is slightly different, but they're semantically similar.
111 + *
112 + * See the ELF specification for more detail about ELF notes.
113 + */
114 +
115 +#ifdef __ASSEMBLER__
116 +/*
117 + * Generate a structure with the same shape as Elf{32,64}_Nhdr (which
118 + * turn out to be the same size and shape), followed by the name and
119 + * desc data with appropriate padding. The 'desc' argument includes
120 + * the assembler pseudo op defining the type of the data: .asciz
121 + * "hello, world"
122 + */
123 +.macro ELFNOTE name type desc:vararg
124 +.pushsection ".note.\name"
125 + .align 4
126 + .long 2f - 1f /* namesz */
127 + .long 4f - 3f /* descsz */
128 + .long \type
129 +1:.asciz "\name"
130 +2:.align 4
131 +3:\desc
132 +4:.align 4
133 +.popsection
134 +.endm
135 +#else /* !__ASSEMBLER__ */
136 +#include <linux/elf.h>
137 +/*
138 + * Use an anonymous structure which matches the shape of
139 + * Elf{32,64}_Nhdr, but includes the name and desc data. The size and
140 + * type of name and desc depend on the macro arguments. "name" must
141 + * be a literal string, and "desc" must be passed by value. You may
142 + * only define one note per line, since __LINE__ is used to generate
143 + * unique symbols.
144 + */
145 +#define _ELFNOTE_PASTE(a,b) a##b
146 +#define _ELFNOTE(size, name, unique, type, desc) \
147 + static const struct { \
148 + struct elf##size##_note _nhdr; \
149 + unsigned char _name[sizeof(name)] \
150 + __attribute__((aligned(sizeof(Elf##size##_Word)))); \
151 + typeof(desc) _desc \
152 + __attribute__((aligned(sizeof(Elf##size##_Word)))); \
153 + } _ELFNOTE_PASTE(_note_, unique) \
154 + __attribute_used__ \
155 + __attribute__((section(".note." name), \
156 + aligned(sizeof(Elf##size##_Word)), \
157 + unused)) = { \
158 + { \
159 + sizeof(name), \
160 + sizeof(desc), \
161 + type, \
162 + }, \
163 + name, \
164 + desc \
165 + }
166 +#define ELFNOTE(size, name, type, desc) \
167 + _ELFNOTE(size, name, __LINE__, type, desc)
168 +
169 +#define ELFNOTE32(name, type, desc) ELFNOTE(32, name, type, desc)
170 +#define ELFNOTE64(name, type, desc) ELFNOTE(64, name, type, desc)
171 +#endif /* __ASSEMBLER__ */
172 +
173 +#endif /* _LINUX_ELFNOTE_H */
174 _