All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-arch@vger.kernel.org,
	Parisc List <linux-parisc@vger.kernel.org>,
	linux-ia64@vger.kernel.org, linuxppc-dev@ozlabs.org
Subject: [PATCH] Correct printk %pF to work on all architectures
Date: Wed, 03 Sep 2008 15:18:57 -0500	[thread overview]
Message-ID: <1220473137.3254.29.camel@localhost.localdomain> (raw)

It was introduced by 

commit 0fe1ef24f7bd0020f29ffe287dfdb9ead33ca0b2
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Jul 6 16:43:12 2008 -0700

    vsprintf: add support for '%pS' and '%pF' pointer formats


However, the current way its coded doesn't work on parisc64.  For two
reasons:  1) parisc isn't in the #ifdef and 2) parisc has a different
format for function descriptors

Make dereference_function_descriptor() more accommodating by allowing
architecture overrides.  I put the three overrides (for parisc64, ppc64
and ia64) in arch/kernel/module.c because that's where the kernel
internal linker which knows how to deal with function descriptors sits.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
---
 arch/ia64/kernel/module.c       |    9 +++++++++
 arch/parisc/kernel/module.c     |   13 +++++++++++++
 arch/powerpc/kernel/module_64.c |    9 +++++++++
 include/linux/kernel.h          |    3 +++
 lib/vsprintf.c                  |   12 ++++++------
 5 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
index 29aad34..596a862 100644
--- a/arch/ia64/kernel/module.c
+++ b/arch/ia64/kernel/module.c
@@ -31,6 +31,7 @@
 #include <linux/elf.h>
 #include <linux/moduleloader.h>
 #include <linux/string.h>
+#include <linux/uaccess.h>
 #include <linux/vmalloc.h>
 
 #include <asm/patch.h>
@@ -941,3 +942,11 @@ module_arch_cleanup (struct module *mod)
 	if (mod->arch.core_unw_table)
 		unw_remove_unwind_table(mod->arch.core_unw_table);
 }
+
+void *dereference_function_descriptor(void *ptr)
+{
+	void *p = NULL;
+	if (!probe_kernel_address(ptr, p))
+		ptr = p;
+	return p;
+}
diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
index fdacdd4..4ad80a5 100644
--- a/arch/parisc/kernel/module.c
+++ b/arch/parisc/kernel/module.c
@@ -47,6 +47,7 @@
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/bug.h>
+#include <linux/uaccess.h>
 
 #include <asm/unwind.h>
 
@@ -860,3 +861,15 @@ void module_arch_cleanup(struct module *mod)
 	deregister_unwind_table(mod);
 	module_bug_cleanup(mod);
 }
+
+#ifdef CONFIG_64BIT
+void *dereference_function_descriptor(void *ptr)
+{
+	Elf64_Fdesc *desc = ptr;
+	void *p = NULL;
+
+	if (!probe_kernel_address(&desc->addr, p))
+		ptr = p;
+	return p;
+}
+#endif
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index ee6a298..60e9749 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -21,6 +21,7 @@
 #include <linux/err.h>
 #include <linux/vmalloc.h>
 #include <linux/bug.h>
+#include <linux/uaccess.h>
 #include <asm/module.h>
 #include <asm/uaccess.h>
 #include <asm/firmware.h>
@@ -451,3 +452,11 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
 
 	return 0;
 }
+
+void *dereference_function_descriptor(void *ptr)
+{
+	void *p = NULL;
+	if (!probe_kernel_address(ptr, p))
+		ptr = p;
+	return p;
+}
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2651f80..8ff19b3 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -189,6 +189,9 @@ extern int __kernel_text_address(unsigned long addr);
 extern int kernel_text_address(unsigned long addr);
 struct pid;
 extern struct pid *session_of_pgrp(struct pid *pgrp);
+/* function descriptor handling (if any) */
+extern void *dereference_function_descriptor(void *ptr);
+
 
 #ifdef CONFIG_PRINTK
 asmlinkage int vprintk(const char *fmt, va_list args)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index d8d1d11..cffcd95 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -513,13 +513,13 @@ static char *string(char *buf, char *end, char *s, int field_width, int precisio
 	return buf;
 }
 
-static inline void *dereference_function_descriptor(void *ptr)
+/*
+ * Some architectures need special handling for pointers
+ * to functions, which are done via function descriptors
+ * Do a non weak override of this function for them
+ */
+void __weak *dereference_function_descriptor(void *ptr)
 {
-#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
-	void *p;
-	if (!probe_kernel_address(ptr, p))
-		ptr = p;
-#endif
 	return ptr;
 }
 
-- 
1.5.6.5




WARNING: multiple messages have this Message-ID (diff)
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-arch@vger.kernel.org,
	Parisc List <linux-parisc@vger.kernel.org>,
	linux-ia64@vger.kernel.org, linuxppc-dev@ozlabs.org
Subject: [PATCH] Correct printk %pF to work on all architectures
Date: Wed, 03 Sep 2008 20:18:57 +0000	[thread overview]
Message-ID: <1220473137.3254.29.camel@localhost.localdomain> (raw)

It was introduced by 

commit 0fe1ef24f7bd0020f29ffe287dfdb9ead33ca0b2
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Jul 6 16:43:12 2008 -0700

    vsprintf: add support for '%pS' and '%pF' pointer formats


However, the current way its coded doesn't work on parisc64.  For two
reasons:  1) parisc isn't in the #ifdef and 2) parisc has a different
format for function descriptors

Make dereference_function_descriptor() more accommodating by allowing
architecture overrides.  I put the three overrides (for parisc64, ppc64
and ia64) in arch/kernel/module.c because that's where the kernel
internal linker which knows how to deal with function descriptors sits.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
---
 arch/ia64/kernel/module.c       |    9 +++++++++
 arch/parisc/kernel/module.c     |   13 +++++++++++++
 arch/powerpc/kernel/module_64.c |    9 +++++++++
 include/linux/kernel.h          |    3 +++
 lib/vsprintf.c                  |   12 ++++++------
 5 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
index 29aad34..596a862 100644
--- a/arch/ia64/kernel/module.c
+++ b/arch/ia64/kernel/module.c
@@ -31,6 +31,7 @@
 #include <linux/elf.h>
 #include <linux/moduleloader.h>
 #include <linux/string.h>
+#include <linux/uaccess.h>
 #include <linux/vmalloc.h>
 
 #include <asm/patch.h>
@@ -941,3 +942,11 @@ module_arch_cleanup (struct module *mod)
 	if (mod->arch.core_unw_table)
 		unw_remove_unwind_table(mod->arch.core_unw_table);
 }
+
+void *dereference_function_descriptor(void *ptr)
+{
+	void *p = NULL;
+	if (!probe_kernel_address(ptr, p))
+		ptr = p;
+	return p;
+}
diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
index fdacdd4..4ad80a5 100644
--- a/arch/parisc/kernel/module.c
+++ b/arch/parisc/kernel/module.c
@@ -47,6 +47,7 @@
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/bug.h>
+#include <linux/uaccess.h>
 
 #include <asm/unwind.h>
 
@@ -860,3 +861,15 @@ void module_arch_cleanup(struct module *mod)
 	deregister_unwind_table(mod);
 	module_bug_cleanup(mod);
 }
+
+#ifdef CONFIG_64BIT
+void *dereference_function_descriptor(void *ptr)
+{
+	Elf64_Fdesc *desc = ptr;
+	void *p = NULL;
+
+	if (!probe_kernel_address(&desc->addr, p))
+		ptr = p;
+	return p;
+}
+#endif
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index ee6a298..60e9749 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -21,6 +21,7 @@
 #include <linux/err.h>
 #include <linux/vmalloc.h>
 #include <linux/bug.h>
+#include <linux/uaccess.h>
 #include <asm/module.h>
 #include <asm/uaccess.h>
 #include <asm/firmware.h>
@@ -451,3 +452,11 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
 
 	return 0;
 }
+
+void *dereference_function_descriptor(void *ptr)
+{
+	void *p = NULL;
+	if (!probe_kernel_address(ptr, p))
+		ptr = p;
+	return p;
+}
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2651f80..8ff19b3 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -189,6 +189,9 @@ extern int __kernel_text_address(unsigned long addr);
 extern int kernel_text_address(unsigned long addr);
 struct pid;
 extern struct pid *session_of_pgrp(struct pid *pgrp);
+/* function descriptor handling (if any) */
+extern void *dereference_function_descriptor(void *ptr);
+
 
 #ifdef CONFIG_PRINTK
 asmlinkage int vprintk(const char *fmt, va_list args)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index d8d1d11..cffcd95 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -513,13 +513,13 @@ static char *string(char *buf, char *end, char *s, int field_width, int precisio
 	return buf;
 }
 
-static inline void *dereference_function_descriptor(void *ptr)
+/*
+ * Some architectures need special handling for pointers
+ * to functions, which are done via function descriptors
+ * Do a non weak override of this function for them
+ */
+void __weak *dereference_function_descriptor(void *ptr)
 {
-#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
-	void *p;
-	if (!probe_kernel_address(ptr, p))
-		ptr = p;
-#endif
 	return ptr;
 }
 
-- 
1.5.6.5




WARNING: multiple messages have this Message-ID (diff)
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-arch@vger.kernel.org, linuxppc-dev@ozlabs.org,
	linux-ia64@vger.kernel.org,
	Parisc List <linux-parisc@vger.kernel.org>
Subject: [PATCH] Correct printk %pF to work on all architectures
Date: Wed, 03 Sep 2008 15:18:57 -0500	[thread overview]
Message-ID: <1220473137.3254.29.camel@localhost.localdomain> (raw)

It was introduced by 

commit 0fe1ef24f7bd0020f29ffe287dfdb9ead33ca0b2
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Jul 6 16:43:12 2008 -0700

    vsprintf: add support for '%pS' and '%pF' pointer formats


However, the current way its coded doesn't work on parisc64.  For two
reasons:  1) parisc isn't in the #ifdef and 2) parisc has a different
format for function descriptors

Make dereference_function_descriptor() more accommodating by allowing
architecture overrides.  I put the three overrides (for parisc64, ppc64
and ia64) in arch/kernel/module.c because that's where the kernel
internal linker which knows how to deal with function descriptors sits.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
---
 arch/ia64/kernel/module.c       |    9 +++++++++
 arch/parisc/kernel/module.c     |   13 +++++++++++++
 arch/powerpc/kernel/module_64.c |    9 +++++++++
 include/linux/kernel.h          |    3 +++
 lib/vsprintf.c                  |   12 ++++++------
 5 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
index 29aad34..596a862 100644
--- a/arch/ia64/kernel/module.c
+++ b/arch/ia64/kernel/module.c
@@ -31,6 +31,7 @@
 #include <linux/elf.h>
 #include <linux/moduleloader.h>
 #include <linux/string.h>
+#include <linux/uaccess.h>
 #include <linux/vmalloc.h>
 
 #include <asm/patch.h>
@@ -941,3 +942,11 @@ module_arch_cleanup (struct module *mod)
 	if (mod->arch.core_unw_table)
 		unw_remove_unwind_table(mod->arch.core_unw_table);
 }
+
+void *dereference_function_descriptor(void *ptr)
+{
+	void *p = NULL;
+	if (!probe_kernel_address(ptr, p))
+		ptr = p;
+	return p;
+}
diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
index fdacdd4..4ad80a5 100644
--- a/arch/parisc/kernel/module.c
+++ b/arch/parisc/kernel/module.c
@@ -47,6 +47,7 @@
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/bug.h>
+#include <linux/uaccess.h>
 
 #include <asm/unwind.h>
 
@@ -860,3 +861,15 @@ void module_arch_cleanup(struct module *mod)
 	deregister_unwind_table(mod);
 	module_bug_cleanup(mod);
 }
+
+#ifdef CONFIG_64BIT
+void *dereference_function_descriptor(void *ptr)
+{
+	Elf64_Fdesc *desc = ptr;
+	void *p = NULL;
+
+	if (!probe_kernel_address(&desc->addr, p))
+		ptr = p;
+	return p;
+}
+#endif
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index ee6a298..60e9749 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -21,6 +21,7 @@
 #include <linux/err.h>
 #include <linux/vmalloc.h>
 #include <linux/bug.h>
+#include <linux/uaccess.h>
 #include <asm/module.h>
 #include <asm/uaccess.h>
 #include <asm/firmware.h>
@@ -451,3 +452,11 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
 
 	return 0;
 }
+
+void *dereference_function_descriptor(void *ptr)
+{
+	void *p = NULL;
+	if (!probe_kernel_address(ptr, p))
+		ptr = p;
+	return p;
+}
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2651f80..8ff19b3 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -189,6 +189,9 @@ extern int __kernel_text_address(unsigned long addr);
 extern int kernel_text_address(unsigned long addr);
 struct pid;
 extern struct pid *session_of_pgrp(struct pid *pgrp);
+/* function descriptor handling (if any) */
+extern void *dereference_function_descriptor(void *ptr);
+
 
 #ifdef CONFIG_PRINTK
 asmlinkage int vprintk(const char *fmt, va_list args)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index d8d1d11..cffcd95 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -513,13 +513,13 @@ static char *string(char *buf, char *end, char *s, int field_width, int precisio
 	return buf;
 }
 
-static inline void *dereference_function_descriptor(void *ptr)
+/*
+ * Some architectures need special handling for pointers
+ * to functions, which are done via function descriptors
+ * Do a non weak override of this function for them
+ */
+void __weak *dereference_function_descriptor(void *ptr)
 {
-#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
-	void *p;
-	if (!probe_kernel_address(ptr, p))
-		ptr = p;
-#endif
 	return ptr;
 }
 
-- 
1.5.6.5

             reply	other threads:[~2008-09-03 20:18 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-03 20:18 James Bottomley [this message]
2008-09-03 20:18 ` [PATCH] Correct printk %pF to work on all architectures James Bottomley
2008-09-03 20:18 ` James Bottomley
2008-09-03 21:22 ` Linus Torvalds
2008-09-03 21:22   ` Linus Torvalds
2008-09-03 21:22   ` Linus Torvalds
2008-09-03 22:42   ` James Bottomley
2008-09-03 22:42     ` James Bottomley
2008-09-03 22:42     ` James Bottomley
2008-09-03 22:42     ` James Bottomley
2008-09-03 22:54     ` Linus Torvalds
2008-09-03 22:54       ` Linus Torvalds
2008-09-03 22:54       ` Linus Torvalds
2008-09-03 23:00       ` James Bottomley
2008-09-03 23:00         ` James Bottomley
2008-09-03 23:00         ` James Bottomley
2008-09-03 23:15         ` Linus Torvalds
2008-09-03 23:15           ` Linus Torvalds
2008-09-03 23:15           ` Linus Torvalds
2008-09-03 23:33           ` James Bottomley
2008-09-03 23:33             ` James Bottomley
2008-09-03 23:33             ` James Bottomley
2008-09-04  0:01             ` Linus Torvalds
2008-09-04  0:01               ` Linus Torvalds
2008-09-04  0:01               ` Linus Torvalds
2008-09-04  1:43               ` James Bottomley
2008-09-04  1:43                 ` James Bottomley
2008-09-04  1:43                 ` James Bottomley
2008-09-04 22:36                 ` Benjamin Herrenschmidt
2008-09-04 22:36                   ` Benjamin Herrenschmidt
2008-09-04 22:36                   ` Benjamin Herrenschmidt
2008-09-04 23:07                   ` Luck, Tony
2008-09-04 23:07                     ` Luck, Tony
2008-09-04 23:07                     ` Luck, Tony
2008-09-09 14:12                     ` James Bottomley
2008-09-09 14:12                       ` James Bottomley
2008-09-09 14:12                       ` James Bottomley
2008-09-09 18:08                       ` Kyle McMartin
2008-09-09 18:08                         ` Kyle McMartin
2008-09-09 18:08                         ` Kyle McMartin
2008-09-09 22:05                         ` Benjamin Herrenschmidt
2008-09-09 22:05                           ` Benjamin Herrenschmidt
2008-09-09 22:05                           ` Benjamin Herrenschmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1220473137.3254.29.camel@localhost.localdomain \
    --to=james.bottomley@hansenpartnership.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.