Gentoo Archives: gentoo-commits

From: "Robin H. Johnson (robbat2)" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo commit in src/patchsets/grub/0.97: 300_all_grub-0.97-pie-safety.patch
Date: Fri, 26 Jun 2009 23:38:34
Message-Id: E1MKL05-0005Jn-1Z@stork.gentoo.org
1 robbat2 09/06/26 23:38:33
2
3 Added: 300_all_grub-0.97-pie-safety.patch
4 Log:
5 Prototype patch to fix bug #139277 - hardened GCC register compile issues.
6
7 Revision Changes Path
8 1.1 src/patchsets/grub/0.97/300_all_grub-0.97-pie-safety.patch
9
10 file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/grub/0.97/300_all_grub-0.97-pie-safety.patch?rev=1.1&view=markup
11 plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/grub/0.97/300_all_grub-0.97-pie-safety.patch?rev=1.1&content-type=text/plain
12
13 Index: 300_all_grub-0.97-pie-safety.patch
14 ===================================================================
15 Make GRUB PIE-safe.
16
17 X-WARNING: untested, waiting for feedback on bug #139277.
18 Signed-off-by: Robin H. Johnson <robbat2@g.o>
19
20 diff -Nuar -Nuar --exclude '*o' --exclude config.log --exclude '*.exec' --exclude '*[0-9]' --exclude '*.a' --exclude mbchk --exclude Makefile --exclude config.status -wBb grub-0.97.orig/netboot/pci.c grub-0.97/netboot/pci.c
21 --- grub-0.97.orig/netboot/pci.c 2003-07-09 11:45:38.000000000 +0000
22 +++ grub-0.97/netboot/pci.c 2009-06-26 22:02:15.000000000 +0000
23 @@ -105,13 +105,16 @@
24
25 save_flags(flags);
26 __asm__(
27 + "pushl %%ebx\n\t" /* save %ebx */
28 #ifdef ABSOLUTE_WITHOUT_ASTERISK
29 - "lcall (%%edi)"
30 + "lcall (%%edi)\n\t"
31 #else
32 - "lcall *(%%edi)"
33 + "lcall *(%%edi)\n\t"
34 #endif
35 + "movl %%ebx, %1\n\t" /* capture what was in %ebx */
36 + "popl %%ebx\n\t" /* restore %ebx */
37 : "=a" (return_code),
38 - "=b" (address),
39 + "=r" (address),
40 "=c" (length),
41 "=d" (entry)
42 : "0" (service),
43 @@ -141,18 +144,21 @@
44
45 save_flags(flags);
46 __asm__(
47 + "pushl %%ebx\n\t" /* save %ebx */
48 + "movl %3, %%ebx\n\t" /* put the value into ebx */
49 #ifdef ABSOLUTE_WITHOUT_ASTERISK
50 "lcall (%%esi)\n\t"
51 #else
52 "lcall *(%%esi)\n\t"
53 #endif
54 "jc 1f\n\t"
55 - "xor %%ah, %%ah\n"
56 + "popl %%ebx\n\t" /* restore %ebx */
57 + "xor %%ah, %%ah\n\t"
58 "1:"
59 : "=c" (*value),
60 "=a" (ret)
61 : "1" (PCIBIOS_READ_CONFIG_BYTE),
62 - "b" (bx),
63 + "r" (bx),
64 "D" ((long) where),
65 "S" (&pci_indirect));
66 restore_flags(flags);
67 @@ -168,18 +174,21 @@
68
69 save_flags(flags);
70 __asm__(
71 + "pushl %%ebx\n\t" /* save %ebx */
72 + "movl %3, %%ebx\n\t" /* put the value into ebx */
73 #ifdef ABSOLUTE_WITHOUT_ASTERISK
74 "lcall (%%esi)\n\t"
75 #else
76 "lcall *(%%esi)\n\t"
77 #endif
78 "jc 1f\n\t"
79 - "xor %%ah, %%ah\n"
80 + "popl %%ebx\n\t" /* restore %ebx */
81 + "xor %%ah, %%ah\n\t"
82 "1:"
83 : "=c" (*value),
84 "=a" (ret)
85 : "1" (PCIBIOS_READ_CONFIG_WORD),
86 - "b" (bx),
87 + "r" (bx),
88 "D" ((long) where),
89 "S" (&pci_indirect));
90 restore_flags(flags);
91 @@ -195,18 +204,21 @@
92
93 save_flags(flags);
94 __asm__(
95 + "pushl %%ebx\n\t" /* save %ebx */
96 + "movl %3, %%ebx\n\t" /* put the value into ebx */
97 #ifdef ABSOLUTE_WITHOUT_ASTERISK
98 "lcall (%%esi)\n\t"
99 #else
100 "lcall *(%%esi)\n\t"
101 #endif
102 "jc 1f\n\t"
103 - "xor %%ah, %%ah\n"
104 + "popl %%ebx\n\t" /* restore %ebx */
105 + "xor %%ah, %%ah\n\t"
106 "1:"
107 : "=c" (*value),
108 "=a" (ret)
109 : "1" (PCIBIOS_READ_CONFIG_DWORD),
110 - "b" (bx),
111 + "r" (bx),
112 "D" ((long) where),
113 "S" (&pci_indirect));
114 restore_flags(flags);
115 @@ -222,18 +234,21 @@
116
117 save_flags(flags); cli();
118 __asm__(
119 + "pushl %%ebx\n\t" /* save %ebx */
120 + "movl %3, %%ebx\n\t" /* put the value into ebx */
121 #ifdef ABSOLUTE_WITHOUT_ASTERISK
122 "lcall (%%esi)\n\t"
123 #else
124 "lcall *(%%esi)\n\t"
125 #endif
126 "jc 1f\n\t"
127 - "xor %%ah, %%ah\n"
128 + "popl %%ebx\n\t" /* restore %ebx */
129 + "xor %%ah, %%ah\n\t"
130 "1:"
131 : "=a" (ret)
132 : "0" (PCIBIOS_WRITE_CONFIG_BYTE),
133 "c" (value),
134 - "b" (bx),
135 + "r" (bx),
136 "D" ((long) where),
137 "S" (&pci_indirect));
138 restore_flags(flags);
139 @@ -249,18 +264,21 @@
140
141 save_flags(flags); cli();
142 __asm__(
143 + "pushl %%ebx\n\t" /* save %ebx */
144 + "movl %3, %%ebx\n\t" /* put the value into ebx */
145 #ifdef ABSOLUTE_WITHOUT_ASTERISK
146 "lcall (%%esi)\n\t"
147 #else
148 "lcall *(%%esi)\n\t"
149 #endif
150 "jc 1f\n\t"
151 - "xor %%ah, %%ah\n"
152 + "popl %%ebx\n\t" /* restore %ebx */
153 + "xor %%ah, %%ah\n\t"
154 "1:"
155 : "=a" (ret)
156 : "0" (PCIBIOS_WRITE_CONFIG_WORD),
157 "c" (value),
158 - "b" (bx),
159 + "r" (bx),
160 "D" ((long) where),
161 "S" (&pci_indirect));
162 restore_flags(flags);
163 @@ -276,18 +294,21 @@
164
165 save_flags(flags); cli();
166 __asm__(
167 + "pushl %%ebx\n\t" /* save %ebx */
168 + "movl %3, %%ebx\n\t" /* put the value into ebx */
169 #ifdef ABSOLUTE_WITHOUT_ASTERISK
170 "lcall (%%esi)\n\t"
171 #else
172 "lcall *(%%esi)\n\t"
173 #endif
174 "jc 1f\n\t"
175 - "xor %%ah, %%ah\n"
176 + "popl %%ebx\n\t" /* restore %ebx */
177 + "xor %%ah, %%ah\n\t"
178 "1:"
179 : "=a" (ret)
180 : "0" (PCIBIOS_WRITE_CONFIG_DWORD),
181 "c" (value),
182 - "b" (bx),
183 + "r" (bx),
184 "D" ((long) where),
185 "S" (&pci_indirect));
186 restore_flags(flags);
187 @@ -308,20 +329,22 @@
188
189 save_flags(flags);
190 __asm__(
191 + "pushl %%ebx\n\t" /* save %ebx */
192 #ifdef ABSOLUTE_WITHOUT_ASTERISK
193 "lcall (%%edi)\n\t"
194 #else
195 "lcall *(%%edi)\n\t"
196 #endif
197 "jc 1f\n\t"
198 - "xor %%ah, %%ah\n"
199 + "xor %%ah, %%ah\n\t"
200 "1:\tshl $8, %%eax\n\t"
201 - "movw %%bx, %%ax"
202 + "movw %%bx, %%ax\n\t"
203 + "popl %%ebx\n\t" /* restore %ebx */
204 : "=d" (signature),
205 "=a" (pack)
206 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
207 "D" (&pci_indirect)
208 - : "bx", "cx");
209 + : "cx");
210 restore_flags(flags);
211
212 present_status = (pack >> 16) & 0xff;