Skip to content

Commit

Permalink
extable, core_kernel_data(): Make sure all archs define _sdata
Browse files Browse the repository at this point in the history
A new utility function (core_kernel_data()) is used to determine if a
passed in address is part of core kernel data or not. It may or may not
return true for RO data, but this utility must work for RW data.

Thus both _sdata and _edata must be defined and continuous,
without .init sections that may later be freed and replaced by
volatile memory (memory that can be freed).

This utility function is used to determine if data is safe from
ever being freed. Thus it should return true for all RW global
data that is not in a module or has been allocated, or false
otherwise.

Also change core_kernel_data() back to the more precise _sdata condition
and document the function.

Signed-off-by: Steven Rostedt <[email protected]>
Acked-by: Ralf Baechle <[email protected]>
Acked-by: Hirokazu Takata <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: Matt Turner <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Roman Zippel <[email protected]>
Cc: [email protected]
Cc: Kyle McMartin <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: JamesE.J.Bottomley <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
----
 arch/alpha/kernel/vmlinux.lds.S   |    1 +
 arch/m32r/kernel/vmlinux.lds.S    |    1 +
 arch/m68k/kernel/vmlinux-std.lds  |    2 ++
 arch/m68k/kernel/vmlinux-sun3.lds |    1 +
 arch/mips/kernel/vmlinux.lds.S    |    1 +
 arch/parisc/kernel/vmlinux.lds.S  |    3 +++
 kernel/extable.c                  |   12 +++++++++++-
 7 files changed, 20 insertions(+), 1 deletion(-)
  • Loading branch information
rostedt authored and Ingo Molnar committed May 20, 2011
1 parent c16dbd5 commit a2d063a
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions arch/alpha/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ SECTIONS
__init_end = .;
/* Freed after init ends here */

_sdata = .; /* Start of rw data section */
_data = .;
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)

Expand Down
1 change: 1 addition & 0 deletions arch/m32r/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ SECTIONS
EXCEPTION_TABLE(16)
NOTES

_sdata = .; /* Start of data section */
RODATA
RW_DATA_SECTION(32, PAGE_SIZE, THREAD_SIZE)
_edata = .; /* End of data section */
Expand Down
2 changes: 2 additions & 0 deletions arch/m68k/kernel/vmlinux-std.lds
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ SECTIONS

EXCEPTION_TABLE(16)

_sdata = .; /* Start of data section */

RODATA

RW_DATA_SECTION(16, PAGE_SIZE, THREAD_SIZE)
Expand Down
1 change: 1 addition & 0 deletions arch/m68k/kernel/vmlinux-sun3.lds
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ SECTIONS
_etext = .; /* End of text section */

EXCEPTION_TABLE(16) :data
_sdata = .; /* Start of rw data section */
RW_DATA_SECTION(16, PAGE_SIZE, THREAD_SIZE) :data
/* End of data goes *here* so that freeing init code works properly. */
_edata = .;
Expand Down
1 change: 1 addition & 0 deletions arch/mips/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ SECTIONS
NOTES :text :note
.dummy : { *(.dummy) } :text

_sdata = .; /* Start of data section */
RODATA

/* writeable */
Expand Down
3 changes: 3 additions & 0 deletions arch/parisc/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ SECTIONS
/* End of text section */
_etext = .;

/* Start of data section */
_sdata = .;

RODATA

/* writeable */
Expand Down
12 changes: 11 additions & 1 deletion kernel/extable.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,19 @@ int core_kernel_text(unsigned long addr)
return 0;
}

/**
* core_kernel_data - tell if addr points to kernel data
* @addr: address to test
*
* Returns true if @addr passed in is from the core kernel data
* section.
*
* Note: On some archs it may return true for core RODATA, and false
* for others. But will always be true for core RW data.
*/
int core_kernel_data(unsigned long addr)
{
if (addr >= (unsigned long)_stext &&
if (addr >= (unsigned long)_sdata &&
addr < (unsigned long)_edata)
return 1;
return 0;
Expand Down

0 comments on commit a2d063a

Please sign in to comment.