public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo commit in src/patchsets/grub/0.97: 300_all_grub-0.97-pie-safety.patch
@ 2009-06-26 23:38 Robin H. Johnson (robbat2)
  0 siblings, 0 replies; only message in thread
From: Robin H. Johnson (robbat2) @ 2009-06-26 23:38 UTC (permalink / raw
  To: gentoo-commits

robbat2     09/06/26 23:38:33

  Added:                300_all_grub-0.97-pie-safety.patch
  Log:
  Prototype patch to fix bug #139277 - hardened GCC register compile issues.

Revision  Changes    Path
1.1                  src/patchsets/grub/0.97/300_all_grub-0.97-pie-safety.patch

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
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

Index: 300_all_grub-0.97-pie-safety.patch
===================================================================
Make GRUB PIE-safe.

X-WARNING: untested, waiting for feedback on bug #139277.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>

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
--- grub-0.97.orig/netboot/pci.c	2003-07-09 11:45:38.000000000 +0000
+++ grub-0.97/netboot/pci.c	2009-06-26 22:02:15.000000000 +0000
@@ -105,13 +105,16 @@
 
 	save_flags(flags);
 	__asm__(
+		"pushl %%ebx\n\t" /* save %ebx */
 #ifdef ABSOLUTE_WITHOUT_ASTERISK
-		"lcall (%%edi)"
+		"lcall (%%edi)\n\t"
 #else
-		"lcall *(%%edi)"
+		"lcall *(%%edi)\n\t"
 #endif
+		"movl %%ebx, %1\n\t" /* capture what was in %ebx */
+		"popl %%ebx\n\t" /* restore %ebx */
 		: "=a" (return_code),
-		  "=b" (address),
+		  "=r" (address),
 		  "=c" (length),
 		  "=d" (entry)
 		: "0" (service),
@@ -141,18 +144,21 @@
 
         save_flags(flags);
         __asm__(
+		"pushl %%ebx\n\t" /* save %ebx */
+		"movl %3, %%ebx\n\t" /* put the value into ebx */
 #ifdef ABSOLUTE_WITHOUT_ASTERISK
 		"lcall (%%esi)\n\t"
 #else
 		"lcall *(%%esi)\n\t"
 #endif
                 "jc 1f\n\t"
-                "xor %%ah, %%ah\n"
+		"popl %%ebx\n\t" /* restore %ebx */
+		"xor %%ah, %%ah\n\t"
                 "1:"
                 : "=c" (*value),
                   "=a" (ret)
                 : "1" (PCIBIOS_READ_CONFIG_BYTE),
-                  "b" (bx),
+                  "r" (bx),
                   "D" ((long) where),
                   "S" (&pci_indirect));
         restore_flags(flags);
@@ -168,18 +174,21 @@
 
         save_flags(flags);
         __asm__(
+		"pushl %%ebx\n\t" /* save %ebx */
+		"movl %3, %%ebx\n\t" /* put the value into ebx */
 #ifdef ABSOLUTE_WITHOUT_ASTERISK
 		"lcall (%%esi)\n\t"
 #else
 		"lcall *(%%esi)\n\t"
 #endif
                 "jc 1f\n\t"
-                "xor %%ah, %%ah\n"
+		"popl %%ebx\n\t" /* restore %ebx */
+		"xor %%ah, %%ah\n\t"
                 "1:"
                 : "=c" (*value),
                   "=a" (ret)
                 : "1" (PCIBIOS_READ_CONFIG_WORD),
-                  "b" (bx),
+		"r" (bx),
                   "D" ((long) where),
                   "S" (&pci_indirect));
         restore_flags(flags);
@@ -195,18 +204,21 @@
 
         save_flags(flags);
         __asm__(
+	    "pushl %%ebx\n\t" /* save %ebx */
+	    "movl %3, %%ebx\n\t" /* put the value into ebx */
 #ifdef ABSOLUTE_WITHOUT_ASTERISK
 		"lcall (%%esi)\n\t"
 #else
 		"lcall *(%%esi)\n\t"
 #endif
                 "jc 1f\n\t"
-                "xor %%ah, %%ah\n"
+	    "popl %%ebx\n\t" /* restore %ebx */
+	    "xor %%ah, %%ah\n\t"
                 "1:"
                 : "=c" (*value),
                   "=a" (ret)
                 : "1" (PCIBIOS_READ_CONFIG_DWORD),
-                  "b" (bx),
+	    "r" (bx),
                   "D" ((long) where),
                   "S" (&pci_indirect));
         restore_flags(flags);
@@ -222,18 +234,21 @@
 
 	save_flags(flags); cli();
 	__asm__(
+	    "pushl %%ebx\n\t" /* save %ebx */
+	    "movl %3, %%ebx\n\t" /* put the value into ebx */
 #ifdef ABSOLUTE_WITHOUT_ASTERISK
 		"lcall (%%esi)\n\t"
 #else
 		"lcall *(%%esi)\n\t"
 #endif
 		"jc 1f\n\t"
-		"xor %%ah, %%ah\n"
+	    "popl %%ebx\n\t" /* restore %ebx */
+	    "xor %%ah, %%ah\n\t"
 		"1:"
 		: "=a" (ret)
 		: "0" (PCIBIOS_WRITE_CONFIG_BYTE),
 		  "c" (value),
-		  "b" (bx),
+	    "r" (bx),
 		  "D" ((long) where),
 		  "S" (&pci_indirect));
 	restore_flags(flags);
@@ -249,18 +264,21 @@
 
 	save_flags(flags); cli();
 	__asm__(
+	    "pushl %%ebx\n\t" /* save %ebx */
+	    "movl %3, %%ebx\n\t" /* put the value into ebx */
 #ifdef ABSOLUTE_WITHOUT_ASTERISK
 		"lcall (%%esi)\n\t"
 #else
 		"lcall *(%%esi)\n\t"
 #endif
 		"jc 1f\n\t"
-		"xor %%ah, %%ah\n"
+	    "popl %%ebx\n\t" /* restore %ebx */
+	    "xor %%ah, %%ah\n\t"
 		"1:"
 		: "=a" (ret)
 		: "0" (PCIBIOS_WRITE_CONFIG_WORD),
 		  "c" (value),
-		  "b" (bx),
+	    "r" (bx),
 		  "D" ((long) where),
 		  "S" (&pci_indirect));
 	restore_flags(flags);
@@ -276,18 +294,21 @@
 
 	save_flags(flags); cli();
 	__asm__(
+	    "pushl %%ebx\n\t" /* save %ebx */
+	    "movl %3, %%ebx\n\t" /* put the value into ebx */
 #ifdef ABSOLUTE_WITHOUT_ASTERISK
 		"lcall (%%esi)\n\t"
 #else
 		"lcall *(%%esi)\n\t"
 #endif
 		"jc 1f\n\t"
-		"xor %%ah, %%ah\n"
+	    "popl %%ebx\n\t" /* restore %ebx */
+	    "xor %%ah, %%ah\n\t"
 		"1:"
 		: "=a" (ret)
 		: "0" (PCIBIOS_WRITE_CONFIG_DWORD),
 		  "c" (value),
-		  "b" (bx),
+	    "r" (bx),
 		  "D" ((long) where),
 		  "S" (&pci_indirect));
 	restore_flags(flags);
@@ -308,20 +329,22 @@
 
 		save_flags(flags);
 		__asm__(
+		"pushl %%ebx\n\t" /* save %ebx */
 #ifdef ABSOLUTE_WITHOUT_ASTERISK
 			"lcall (%%edi)\n\t"
 #else
 			"lcall *(%%edi)\n\t"
 #endif
 			"jc 1f\n\t"
-			"xor %%ah, %%ah\n"
+		"xor %%ah, %%ah\n\t"
 			"1:\tshl $8, %%eax\n\t"
-			"movw %%bx, %%ax"
+		"movw %%bx, %%ax\n\t"
+		"popl %%ebx\n\t" /* restore %ebx */
 			: "=d" (signature),
 			  "=a" (pack)
 			: "1" (PCIBIOS_PCI_BIOS_PRESENT),
 			  "D" (&pci_indirect)
-			: "bx", "cx");
+		: "cx");
 		restore_flags(flags);
 
 		present_status = (pack >> 16) & 0xff;






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-06-26 23:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-26 23:38 [gentoo-commits] gentoo commit in src/patchsets/grub/0.97: 300_all_grub-0.97-pie-safety.patch Robin H. Johnson (robbat2)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox