Re: history of extratext sections?

Previous thread: 2.6.24-rc1 freezes on powerbook at first boot stage by Elimar Riesebieter on Wednesday, October 24, 2007 - 8:07 am. (6 messages)

Next thread: [PATCH] hash: Add explicit u32 and u64 versions of hash by Matthew Wilcox on Wednesday, October 24, 2007 - 8:46 am. (1 message)
To: <paulus@...>
Cc: <linux-kernel@...>, Andrew Morton <akpm@...>
Date: Wednesday, October 24, 2007 - 8:36 am

Paul:

I noticed that when passing a zero address to kallsyms_lookup(), the kernel
thought it was a valid kernel address, even if it was not for the specific
architecture I was running things on.

This was because is_kernel_extratext() was checking against labels that don't
exist on many archs. Since PPC is the only kernel which defines _extra_text,
(which doesn't seem to be used anymore?) there are three options:
- make the check dependant on PPC
- make the check dependant on extratext being populated
- remove _extra_text support from:
linux-2.6.x/arch/ppc/kernel/vmlinux.lds.S
linux-2.6.x/include/asm-generic/sections.h
linux-2.6.x/kernel/kallsyms.c
linux-2.6.x/scripts/kallsyms.c

Since I don't know the history on that label I thought I would ask (since you
seem to be the only arch using it) before I sent a patch.

-Robin

Because #1 & #2 are trivial, here is what I was thinking:

- make the check dependant on PPC
===================================================================
--- linux-2.6.x/kernel/kallsyms.c (revision 3760)
+++ linux-2.6.x/kernel/kallsyms.c (working copy)
@@ -51,7 +51,8 @@
static inline int is_kernel_extratext(unsigned long addr)
{
+ #ifdef CONFIG_PPC
if (addr >= (unsigned long)_sextratext
&& addr <= (unsigned long)_eextratext)
return 1;
+ #endif
return 0;
}

OR

- make the check dependant on extratext being populated
===================================================================
--- linux-2.6.x/kernel/kallsyms.c (revision 3760)
+++ linux-2.6.x/kernel/kallsyms.c (working copy)
@@ -51,7 +51,8 @@
static inline int is_kernel_extratext(unsigned long addr)
{
if (addr >= (unsigned long)_sextratext
- && addr <= (unsigned long)_eextratext)
+ && addr <= (unsigned long)_eextratext
+ && _sextratext && _eextratext)
return 1;
ret...

To: David Woodhouse <dwmw2@...>, Jon Loeliger <jdl@...>
Cc: <paulus@...>, <linux-kernel@...>
Date: Friday, October 26, 2007 - 5:57 am

OK, it looks like:

David Woodhouse added this functionality 5 May 2005:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commi...

and then Jon Loeliger removed everything in this section 17 Sep 2005
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commi...

David/Jon:

Is this section still used on PPC, or can the entire support for extratext be removed?

Thanks
-

To: Robin Getz <rgetz@...>
Cc: Jon Loeliger <jdl@...>, <paulus@...>, <linux-kernel@...>
Date: Friday, October 26, 2007 - 10:31 am

I think it can die.

--
dwmw2

-

To: David Woodhouse <dwmw2@...>
Cc: Robin Getz <rgetz@...>, <paulus@...>, <linux-kernel@...>
Date: Friday, October 26, 2007 - 10:40 am

To: Andrew Morton <akpm@...>
Cc: Jon Loeliger <jdl@...>, David Woodhouse <dwmw2@...>, <paulus@...>, <linux-kernel@...>
Date: Friday, October 26, 2007 - 3:43 pm

From: Robin Getz <rgetz@blackfin.uclinux.org>

when passing a zero address to kallsyms_lookup(), the kernel thought it was a
valid kernel address, even if it is not. This is because is_ksym_addr() called
is_kernel_extratext() and checked against labels that don't exist on many
archs (which default as zero). Since PPC was the only kernel which defines
_extra_text, (in 2005), and no longer needs it, this patch removes _extra_text
support.

arch/ppc/kernel/vmlinux.lds.S | 5 -----
include/asm-generic/sections.h | 2 --
kernel/kallsyms.c | 11 +----------
scripts/kallsyms.c | 12 +++---------
4 files changed, 4 insertions(+), 26 deletions(-)

Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
cc: David Woodhouse <dwmw2@infradead.org>
cc: Jon Loeliger <jdl@freescale.com>
cc: Paul Mackerras <paulus@samba.org>

----

For some history (provided by Jon):
http://ozlabs.org/pipermail/linuxppc-dev/2005-September/019734.html
http://ozlabs.org/pipermail/linuxppc-dev/2005-September/019736.html
http://ozlabs.org/pipermail/linuxppc-dev/2005-September/019751.html

Index: kernel/kallsyms.c
===================================================================
--- kernel/kallsyms.c (revision 3780)
+++ kernel/kallsyms.c (working copy)
@@ -48,14 +48,6 @@
return 0;
}

-static inline int is_kernel_extratext(unsigned long addr)
-{
- if (addr >= (unsigned long)_sextratext
- && addr <= (unsigned long)_eextratext)
- return 1;
- return 0;
-}
-
static inline int is_kernel_text(unsigned long addr)
{
if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext)
@@ -79,8 +71,7 @@
if (all_var)
return is_kernel(addr);

- return is_kernel_text(addr) || is_kernel_inittext(addr) ||
- is_kernel_extratext(addr);
+ return is_kernel_text(addr) || is_kernel_inittext(addr);
}

/* expand a compressed symbol data into the resulting uncompressed string,
Index: include/asm-ge...

To: Robin Getz <rgetz@...>
Cc: <jdl@...>, <dwmw2@...>, <paulus@...>, <linux-kernel@...>
Date: Monday, October 29, 2007 - 6:22 pm

On Fri, 26 Oct 2007 15:43:56 -0400

I hit numerous rejects here. I am not sure which kernel you patched but I

Please prepare patches in `patch -p1' form. This should have been

--- foo/kernel/kallsyms.c (revision 3780)

I don't understand why this hunk is changing _einittext handling, and I
suspect this was a mistake, so I left that bit out.

I ended up with this:

From: Robin Getz <rgetz@blackfin.uclinux.org>

When passing a zero address to kallsyms_lookup(), the kernel thought it was
a valid kernel address, even if it is not. This is because is_ksym_addr()
called is_kernel_extratext() and checked against labels that don't exist on
many archs (which default as zero). Since PPC was the only kernel which
defines _extra_text, (in 2005), and no longer needs it, this patch removes
_extra_text support.

For some history (provided by Jon):
http://ozlabs.org/pipermail/linuxppc-dev/2005-September/019734.html
http://ozlabs.org/pipermail/linuxppc-dev/2005-September/019736.html
http://ozlabs.org/pipermail/linuxppc-dev/2005-September/019751.html

Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Jon Loeliger <jdl@freescale.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

arch/ppc/kernel/vmlinux.lds.S | 5 -----
include/asm-generic/sections.h | 2 --
kernel/kallsyms.c | 11 +----------
scripts/kallsyms.c | 24 ++++++++++--------------
4 files changed, 11 insertions(+), 31 deletions(-)

diff -puN arch/ppc/kernel/vmlinux.lds.S~remove-support-for-un-needed-_extratext-section arch/ppc/kernel/vmlinux.lds.S
--- a/arch/ppc/kernel/vmlinux.lds.S~remove-support-for-un-needed-_extratext-section
+++ a/arch/ppc/kernel/vmlinux.lds.S
@@ -143,11 +143,6 @@ SECTIONS

. = ALIGN(4096);
__init_end = .;
...

To: Andrew Morton <akpm@...>
Cc: <jdl@...>, <dwmw2@...>, <paulus@...>, <linux-kernel@...>
Date: Monday, October 29, 2007 - 8:11 pm

I didn't think I did change the _einittext handling - just removed
_eextratext, and removed the trailing ||, and closed the parentheses for
the if statement.

- (s->addr == _einittext && strcmp((char*)s->sym + offset, "_einittext")) ||
+ (s->addr == _einittext && strcmp((char*)s->sym + offset, "_einittext")))

?
-

To: Robin Getz <rgetz@...>
Cc: <paulus@...>, <linux-kernel@...>, Andrew Morton <akpm@...>
Date: Wednesday, October 24, 2007 - 12:19 pm

i think you'd want:
if (_sextratext && _eextratext &&
... everything else ...
-mike
-

Previous thread: 2.6.24-rc1 freezes on powerbook at first boot stage by Elimar Riesebieter on Wednesday, October 24, 2007 - 8:07 am. (6 messages)

Next thread: [PATCH] hash: Add explicit u32 and u64 versions of hash by Matthew Wilcox on Wednesday, October 24, 2007 - 8:46 am. (1 message)