public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: huge gcc 4.1.{0,1} __weak problem
@ 2008-05-01 23:55 Chris Knadle
  2008-05-02  9:19 ` Miquel van Smoorenburg
  2008-05-02  9:55 ` Alistair John Strachan
  0 siblings, 2 replies; 34+ messages in thread
From: Chris Knadle @ 2008-05-01 23:55 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Adrian Bunk, venkatesh.pallipadi, davem, trini, mingo, tglx, hpa,
	linux-kernel, suresh.b.siddha

On Thu, 1 May 2008, Linus Torvalds wrote:
> On Thu, 1 May 2008, Andrew Morton wrote:
> > > 
> > > I see only the following choices:
> > > - remove __weak and replace all current usages
> > > - move all __weak functions into own files, and ensure that also happens
> > >   for future usages
> > > - #error for gcc 4.1.{0,1}
> > 
> > Can we detect the {0,1}?  __GNUC_EVEN_MORE_MINOR__?
>
> It's __GNUC_PATCHLEVEL__, I believe.
>
> So yes, we can distinguish 4.1.2 (good, and very common) from 4.1.{0,1} 
> (bad, and rather uncommon).
> And yes, considering that 4.1.1 (and even more so 4.1.0) should be rare to 
> begin with, I think it's better to just not support it.
>
>			Linus

   Unfortunately Debian Stable (i.e. Etch), which is relatively popular for server 
use, is still using 4.1.1  :-(  (The current gcc package is gcc-4.1.1-21)

   I have not looked to see if Debian Stable's gcc-4.1.1-21 has been patched for 
the currently discussed __weak bug.

   -- Chris

Chris Knadle
Chris.Knadle@coredump.us

^ permalink raw reply	[flat|nested] 34+ messages in thread
* [PATCH] /dev/mem gcc weak function workaround
@ 2008-04-30  1:31 Venki Pallipadi
  2008-04-30  4:28 ` David Miller
  0 siblings, 1 reply; 34+ messages in thread
From: Venki Pallipadi @ 2008-04-30  1:31 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton; +Cc: linux-kernel


Some flavors of gcc 4.1.0 and 4.1.1 seems to have trouble understanding
weak function definitions. Calls to function from the same file where it is
defined as weak _may_ get inlined, even when there is a non-weak definition of
the function elsewhere. I tried using attribute 'noinline' which does not
seem to help either.

One workaround for this is to have weak functions defined in different
file as below. Other possible way is to not use weak functions and go back
to ifdef logic.

There are few other usages in kernel that seem to depend on weak (and noinline)
working correctly, which can also potentially break and needs such workarounds.
Example -
mach_reboot_fixups() in arch/x86/kernel/reboot.c is one such call which
is getting inlined with a flavor of gcc 4.1.1.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>

---
 drivers/char/Makefile     |    2 +-
 drivers/char/mem.c        |   23 +----------------------
 drivers/char/mem_weak.c   |   25 +++++++++++++++++++++++++
 include/asm-x86/io.h      |    1 -
 include/asm-x86/pgtable.h |    2 --
 include/linux/mmap.h      |   15 +++++++++++++++
 6 files changed, 42 insertions(+), 26 deletions(-)

Index: linux-2.6/drivers/char/mem_weak.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6/drivers/char/mem_weak.c	2008-04-29 18:14:10.000000000 -0700
@@ -0,0 +1,25 @@
+
+#include <linux/mmap.h>
+
+void __attribute__((weak)) unxlate_dev_mem_ptr(unsigned long phys, void *addr)
+{
+}
+
+int __attribute__((weak)) phys_mem_access_prot_allowed(struct file *file,
+	unsigned long pfn, unsigned long size, pgprot_t *vma_prot)
+{
+	return 1;
+}
+
+void __attribute__((weak))
+map_devmem(unsigned long pfn, unsigned long len, pgprot_t prot)
+{
+	/* nothing. architectures can override. */
+}
+
+void __attribute__((weak))
+unmap_devmem(unsigned long pfn, unsigned long len, pgprot_t prot)
+{
+	/* nothing. architectures can override. */
+}
+
Index: linux-2.6/drivers/char/mem.c
===================================================================
--- linux-2.6.orig/drivers/char/mem.c	2008-04-29 18:12:14.000000000 -0700
+++ linux-2.6/drivers/char/mem.c	2008-04-29 18:14:43.000000000 -0700
@@ -26,6 +26,7 @@
 #include <linux/bootmem.h>
 #include <linux/splice.h>
 #include <linux/pfn.h>
+#include <linux/mmap.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -105,10 +106,6 @@ static inline int range_is_allowed(unsig
 }
 #endif
 
-void __attribute__((weak)) unxlate_dev_mem_ptr(unsigned long phys, void *addr)
-{
-}
-
 /*
  * This funcion reads the *physical* memory. The f_pos points directly to the 
  * memory location. 
@@ -254,12 +251,6 @@ static ssize_t write_mem(struct file * f
 	return written;
 }
 
-int __attribute__((weak)) phys_mem_access_prot_allowed(struct file *file,
-	unsigned long pfn, unsigned long size, pgprot_t *vma_prot)
-{
-	return 1;
-}
-
 #ifndef __HAVE_PHYS_MEM_ACCESS_PROT
 static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
 				     unsigned long size, pgprot_t vma_prot)
@@ -300,18 +291,6 @@ static inline int private_mapping_ok(str
 }
 #endif
 
-void __attribute__((weak))
-map_devmem(unsigned long pfn, unsigned long len, pgprot_t prot)
-{
-	/* nothing. architectures can override. */
-}
-
-void __attribute__((weak))
-unmap_devmem(unsigned long pfn, unsigned long len, pgprot_t prot)
-{
-	/* nothing. architectures can override. */
-}
-
 static void mmap_mem_open(struct vm_area_struct *vma)
 {
 	map_devmem(vma->vm_pgoff,  vma->vm_end - vma->vm_start,
Index: linux-2.6/include/linux/mmap.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6/include/linux/mmap.h	2008-04-29 18:14:10.000000000 -0700
@@ -0,0 +1,15 @@
+#ifndef _LINUX_MMAP_H
+#define _LINUX_MMAP_H
+
+#include <linux/fs.h>
+#include <asm/page.h>
+
+extern void unxlate_dev_mem_ptr(unsigned long phys, void *addr);
+
+extern int phys_mem_access_prot_allowed(struct file *file,
+	unsigned long pfn, unsigned long size, pgprot_t *vma_prot);
+
+extern void map_devmem(unsigned long pfn, unsigned long len, pgprot_t prot);
+extern void unmap_devmem(unsigned long pfn, unsigned long len, pgprot_t prot);
+
+#endif /* _LINUX_MMAP_H */
Index: linux-2.6/include/asm-x86/io.h
===================================================================
--- linux-2.6.orig/include/asm-x86/io.h	2008-04-29 17:27:43.000000000 -0700
+++ linux-2.6/include/asm-x86/io.h	2008-04-29 18:14:10.000000000 -0700
@@ -10,7 +10,6 @@
 #endif
 
 extern void *xlate_dev_mem_ptr(unsigned long phys);
-extern void unxlate_dev_mem_ptr(unsigned long phys, void *addr);
 
 extern int ioremap_change_attr(unsigned long vaddr, unsigned long size,
 				unsigned long prot_val);
Index: linux-2.6/include/asm-x86/pgtable.h
===================================================================
--- linux-2.6.orig/include/asm-x86/pgtable.h	2008-04-29 17:27:43.000000000 -0700
+++ linux-2.6/include/asm-x86/pgtable.h	2008-04-29 18:14:10.000000000 -0700
@@ -303,8 +303,6 @@ static inline pte_t pte_modify(pte_t pte
 struct file;
 pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
                               unsigned long size, pgprot_t vma_prot);
-int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
-                              unsigned long size, pgprot_t *vma_prot);
 #endif
 
 #ifdef CONFIG_PARAVIRT
Index: linux-2.6/drivers/char/Makefile
===================================================================
--- linux-2.6.orig/drivers/char/Makefile	2008-04-29 18:12:14.000000000 -0700
+++ linux-2.6/drivers/char/Makefile	2008-04-29 18:14:43.000000000 -0700
@@ -7,7 +7,7 @@
 #
 FONTMAPFILE = cp437.uni
 
-obj-y	 += mem.o random.o tty_io.o n_tty.o tty_ioctl.o
+obj-y	 += mem.o mem_weak.o random.o tty_io.o n_tty.o tty_ioctl.o
 
 obj-$(CONFIG_LEGACY_PTYS)	+= pty.o
 obj-$(CONFIG_UNIX98_PTYS)	+= pty.o

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

end of thread, other threads:[~2008-05-02 22:02 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-01 23:55 huge gcc 4.1.{0,1} __weak problem Chris Knadle
2008-05-02  9:19 ` Miquel van Smoorenburg
2008-05-02  9:55 ` Alistair John Strachan
2008-05-02 10:43   ` Sam Ravnborg
2008-05-02 11:48     ` Alistair John Strachan
2008-05-02 13:57       ` Sam Ravnborg
2008-05-02 14:11         ` Jakub Jelinek
2008-05-02 15:26           ` Alistair John Strachan
2008-05-02 14:57         ` Jeremy Fitzhardinge
2008-05-02 12:40   ` Sven-Haegar Koch
  -- strict thread matches above, loose matches on Subject: below --
2008-04-30  1:31 [PATCH] /dev/mem gcc weak function workaround Venki Pallipadi
2008-04-30  4:28 ` David Miller
2008-04-30 12:49   ` Pallipadi, Venkatesh
2008-05-01 21:56     ` huge gcc 4.1.{0,1} __weak problem Adrian Bunk
2008-05-01 22:20       ` Andrew Morton
2008-05-01 22:27         ` Linus Torvalds
2008-05-01 22:33           ` Andrew Morton
2008-05-01 23:24             ` Tom Rini
2008-05-01 23:59               ` Andrew Morton
2008-05-02  0:21                 ` Justin Mattock
2008-05-02  7:18                 ` Vegard Nossum
2008-05-02 13:43                   ` Theodore Tso
2008-05-02  8:10                 ` Adrian Bunk
2008-05-02  9:09                 ` Andi Kleen
2008-05-01 22:35           ` Venki Pallipadi
2008-05-01 22:42             ` Andrew Morton
2008-05-01 22:49               ` Jakub Jelinek
2008-05-01 23:21               ` Tom Rini
2008-05-01 23:30                 ` Venki Pallipadi
2008-05-02  0:34                   ` Linus Torvalds
2008-05-02  0:39                     ` Suresh Siddha
2008-05-02 21:11                       ` Jeremy Fitzhardinge
2008-05-02 22:02                         ` David Miller
2008-05-01 23:23             ` Tom Rini
2008-05-01 22:51           ` David Miller
2008-05-02 21:09       ` Jeremy Fitzhardinge
2008-05-02 21:19         ` Adrian Bunk

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