Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1338193 > unrolled thread
| Started by | "Luis R. Rodriguez" <mcgrof@kernel.org> |
|---|---|
| First post | 2016-02-19 14:50 +0100 |
| Last post | 2016-02-19 22:20 +0100 |
| Articles | 20 on this page of 23 — 6 participants |
Back to article view | Back to linux.kernel
[RFC v2 0/7] linux: add linker tables "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-02-19 14:50 +0100
[RFC v2 3/7] firmware: port built-in section to linker table "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-02-19 14:50 +0100
[RFC v2 6/7] dynamic_debug: port to use linker tables "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-02-19 14:50 +0100
[RFC v2 5/7] jump_label: port __jump_table to linker tables "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-02-19 14:50 +0100
[RFC v2 1/7] sections.h: add sections header to collect all section info "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-02-19 14:50 +0100
Re: [RFC v2 1/7] sections.h: add sections header to collect all section info Greg KH <gregkh@linuxfoundation.org> - 2016-02-19 17:30 +0100
Re: [RFC v2 1/7] sections.h: add sections header to collect all section info "Luis R. Rodriguez" <mcgrof@suse.com> - 2016-02-19 21:10 +0100
Re: [RFC v2 1/7] sections.h: add sections header to collect all section info Greg KH <gregkh@linuxfoundation.org> - 2016-02-19 22:30 +0100
Re: [RFC v2 1/7] sections.h: add sections header to collect all section info "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-02-19 23:10 +0100
[RFC v2 4/7] asm/sections: add a generic push_section_tbl() "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-02-19 14:50 +0100
Re: [RFC v2 4/7] asm/sections: add a generic push_section_tbl() "H. Peter Anvin" <hpa@zytor.com> - 2016-02-19 21:40 +0100
Re: [RFC v2 4/7] asm/sections: add a generic push_section_tbl() "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-02-19 22:10 +0100
Re: [RFC v2 4/7] asm/sections: add a generic push_section_tbl() "H. Peter Anvin" <hpa@zytor.com> - 2016-02-22 04:00 +0100
[RFC v2 7/7] kprobes: port to linker table "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-02-19 14:50 +0100
Re: [RFC v2 7/7] kprobes: port to linker table Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-02-19 15:20 +0100
Re: [RFC v2 7/7] kprobes: port to linker table "Luis R. Rodriguez" <mcgrof@suse.com> - 2016-02-19 16:00 +0100
RE: [RFC v2 7/7] kprobes: port to linker table 平松雅巳 / HIRAMATU,MASAMI <masami.hiramatsu.pt@hitachi.com> - 2016-02-22 02:40 +0100
Re: [RFC v2 0/7] linux: add linker tables "H. Peter Anvin" <hpa@zytor.com> - 2016-02-19 21:30 +0100
Re: [RFC v2 0/7] linux: add linker tables "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-02-19 22:30 +0100
Re: [RFC v2 2/7] tables.h: add linker table support "H. Peter Anvin" <hpa@zytor.com> - 2016-02-19 21:40 +0100
Re: [RFC v2 2/7] tables.h: add linker table support "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-02-19 22:50 +0100
Re: [RFC v2 2/7] tables.h: add linker table support "H. Peter Anvin" <hpa@zytor.com> - 2016-02-19 21:40 +0100
Re: [RFC v2 2/7] tables.h: add linker table support "Luis R. Rodriguez" <mcgrof@suse.com> - 2016-02-19 22:20 +0100
Page 1 of 2 [1] 2 Next page →
| From | "Luis R. Rodriguez" <mcgrof@kernel.org> |
|---|---|
| Date | 2016-02-19 14:50 +0100 |
| Subject | [RFC v2 0/7] linux: add linker tables |
| Message-ID | <r3TBv-5OY-1@gated-at.bofh.it> |
This is my v2 of the original linker table work [0], now with six proof of concepts ports of existing code using custom section with custom linker script modifications: * DEFINE_LINKTABLE_TEXT(char, kprobes); * DEFINE_LINKTABLE_DATA(struct jump_entry, __jump_table); * DEFINE_LINKTABLE_DATA(struct _ddebug, __verbose); * DEFINE_LINKTABLE_RO(struct builtin_fw, builtin_fw); * DEFINE_LINKTABLE_INIT(struct x86_init_fn, x86_init_fns); * DEFINE_LINKTABLE_INIT_DATA(unsigned long, _kprobe_blacklist); I've tested all except jump tables, I'd appreaciate some help with that. As requested by hpa I've used standard sections and by doing so it gives us the ability to simply categorize any custom table by actual section used. To help avoid further unnecessary linker script modifications, and to help bring some clarify to how all these works I went to some lengths to give documentating standard kernel sections a shot. The implementation deviates now from iPXE's linker table solution more in favor for what we're used to and expect on Linux. This series leaves out the paravirt_enabled() changes, and the x86 use of linker tables. The paravirt_enabled() stuff is now being dealt with separately [1] [2], and the x86 use case for this will be sent as a separate series for review. Although the diffstat is large, that's mostly documentation and the new code. If you skip that you get: 54 files changed, 104 insertions(+), 136 deletions(-) Most of the savings come from the ability to skip custom linker table entries. The users space solutoin has a new home [3]. [0] http://1450217797-19295-1-git-send-email-mcgrof@do-not-panic.com [1] http://kernelnewbies.org/KernelProjects/remove-paravirt-enabled [2] http://lkml.kernel.org/r/1455887316-9223-1-git-send-email-mcgrof@kernel.org [3] https://git.kernel.org/cgit/linux/kernel/git/mcgrof/linker-tables.git/ Luis R. Rodriguez (7): sections.h: add sections header to collect all section info tables.h: add linker table support firmware: port built-in section to linker table asm/sections: add a generic push_section_tbl() jump_label: port __jump_table to linker tables dynamic_debug: port to use linker tables kprobes: port to linker table Documentation/DocBook/Makefile | 3 +- Documentation/DocBook/linker-tables.tmpl | 169 ++++++++ Documentation/DocBook/sections.tmpl | 99 +++++ Documentation/kbuild/makefiles.txt | 19 + arch/arc/kernel/vmlinux.lds.S | 1 - arch/arm/include/asm/jump_label.h | 4 +- arch/arm/kernel/entry-armv.S | 2 +- arch/arm/kernel/vmlinux.lds.S | 1 - arch/arm64/include/asm/jump_label.h | 4 +- arch/avr32/kernel/entry-avr32b.S | 4 +- arch/avr32/kernel/vmlinux.lds.S | 1 - arch/blackfin/kernel/vmlinux.lds.S | 1 - arch/c6x/kernel/vmlinux.lds.S | 1 - arch/hexagon/kernel/vmlinux.lds.S | 1 - arch/ia64/kernel/jprobes.S | 2 +- arch/ia64/kernel/vmlinux.lds.S | 1 - arch/ia64/lib/flush.S | 4 +- arch/metag/kernel/vmlinux.lds.S | 1 - arch/microblaze/kernel/vmlinux.lds.S | 1 - arch/mips/include/asm/jump_label.h | 4 +- arch/mips/kernel/vmlinux.lds.S | 1 - arch/mn10300/kernel/vmlinux.lds.S | 1 - arch/nios2/kernel/vmlinux.lds.S | 1 - arch/openrisc/kernel/vmlinux.lds.S | 1 - arch/parisc/kernel/vmlinux.lds.S | 1 - arch/powerpc/include/asm/jump_label.h | 6 +- arch/powerpc/include/asm/ppc_asm.h | 6 +- arch/powerpc/kernel/vmlinux.lds.S | 1 - arch/s390/include/asm/jump_label.h | 4 +- arch/s390/kernel/entry.S | 4 +- arch/s390/kernel/kprobes.c | 2 +- arch/s390/kernel/mcount.S | 2 +- arch/s390/kernel/vmlinux.lds.S | 1 - arch/score/kernel/vmlinux.lds.S | 1 - arch/sh/kernel/vmlinux.lds.S | 1 - arch/sparc/include/asm/jump_label.h | 4 +- arch/sparc/kernel/vmlinux.lds.S | 1 - arch/sparc/mm/ultra.S | 2 +- arch/tile/kernel/vmlinux.lds.S | 1 - arch/x86/include/asm/jump_label.h | 9 +- arch/x86/kernel/cpu/microcode/core.c | 7 +- arch/x86/kernel/kprobes/core.c | 10 +- arch/x86/kernel/vmlinux.lds.S | 1 - arch/x86/tools/relocs.c | 3 + drivers/base/firmware_class.c | 11 +- firmware/Makefile | 2 +- include/asm-generic/sections.h | 14 +- include/asm-generic/vmlinux.lds.h | 47 +-- include/linux/compiler.h | 3 +- include/linux/dynamic_debug.h | 6 +- include/linux/jump_label.h | 5 +- include/linux/kprobes.h | 7 +- include/linux/sections.h | 224 ++++++++++ include/linux/tables.h | 696 +++++++++++++++++++++++++++++++ kernel/jump_label.c | 16 +- kernel/kprobes.c | 16 +- kernel/module.c | 6 +- lib/dynamic_debug.c | 13 +- scripts/Makefile.build | 4 +- scripts/Makefile.clean | 1 + scripts/Makefile.lib | 12 + scripts/mod/modpost.c | 3 +- scripts/recordmcount.c | 3 +- scripts/recordmcount.pl | 2 +- tools/include/linux/sections.h | 13 + 65 files changed, 1355 insertions(+), 143 deletions(-) create mode 100644 Documentation/DocBook/linker-tables.tmpl create mode 100644 Documentation/DocBook/sections.tmpl create mode 100644 include/linux/sections.h create mode 100644 include/linux/tables.h create mode 100644 tools/include/linux/sections.h -- 2.7.0
[toc] | [next] | [standalone]
| From | "Luis R. Rodriguez" <mcgrof@kernel.org> |
|---|---|
| Date | 2016-02-19 14:50 +0100 |
| Subject | [RFC v2 3/7] firmware: port built-in section to linker table |
| Message-ID | <r3TBv-5OY-3@gated-at.bofh.it> |
| In reply to | #1338193 |
This ports built-in firmware to use linker tables,
this replaces the custom section solution with a
generic solution.
This also demos the use of the .rodata (SECTION_RO)
linker tables.
Tested with 0 built-in firmware, 1 and 2 built-in
firmwares successfully.
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
arch/x86/kernel/cpu/microcode/core.c | 7 +++----
drivers/base/firmware_class.c | 11 +++++------
firmware/Makefile | 2 +-
include/asm-generic/vmlinux.lds.h | 7 -------
4 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index faec7120c508..7ee73cd64c95 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -99,15 +99,14 @@ static bool __init check_loader_disabled_bsp(void)
return *res;
}
-extern struct builtin_fw __start_builtin_fw[];
-extern struct builtin_fw __end_builtin_fw[];
+DECLARE_LINKTABLE_RO(struct builtin_fw, builtin_fw);
bool get_builtin_firmware(struct cpio_data *cd, const char *name)
{
#ifdef CONFIG_FW_LOADER
- struct builtin_fw *b_fw;
+ const struct builtin_fw *b_fw;
- for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) {
+ LINKTABLE_FOR_EACH(b_fw, builtin_fw) {
if (!strcmp(name, b_fw->name)) {
cd->size = b_fw->size;
cd->data = b_fw->data;
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index b9250e564ebf..50b9cf3d0294 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -42,14 +42,13 @@ MODULE_LICENSE("GPL");
#ifdef CONFIG_FW_LOADER
-extern struct builtin_fw __start_builtin_fw[];
-extern struct builtin_fw __end_builtin_fw[];
+DEFINE_LINKTABLE_RO(struct builtin_fw, builtin_fw);
static bool fw_get_builtin_firmware(struct firmware *fw, const char *name)
{
- struct builtin_fw *b_fw;
+ const struct builtin_fw *b_fw;
- for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) {
+ LINKTABLE_FOR_EACH(b_fw, builtin_fw) {
if (strcmp(name, b_fw->name) == 0) {
fw->size = b_fw->size;
fw->data = b_fw->data;
@@ -62,9 +61,9 @@ static bool fw_get_builtin_firmware(struct firmware *fw, const char *name)
static bool fw_is_builtin_firmware(const struct firmware *fw)
{
- struct builtin_fw *b_fw;
+ const struct builtin_fw *b_fw;
- for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++)
+ LINKTABLE_FOR_EACH(b_fw, builtin_fw)
if (fw->data == b_fw->data)
return true;
diff --git a/firmware/Makefile b/firmware/Makefile
index e297e1b52636..e13549362577 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -164,7 +164,7 @@ quiet_cmd_fwbin = MK_FW $@
echo " .p2align $${ASM_ALIGN}" >>$@;\
echo "_fw_$${FWSTR}_name:" >>$@;\
echo " .string \"$$FWNAME\"" >>$@;\
- echo " .section .builtin_fw,\"a\",$${PROGBITS}" >>$@;\
+ echo " .section .rodata.tbl.builtin_fw.all,\"a\",$${PROGBITS}" >>$@;\
echo " .p2align $${ASM_ALIGN}" >>$@;\
echo " $${ASM_WORD} _fw_$${FWSTR}_name" >>$@;\
echo " $${ASM_WORD} _fw_$${FWSTR}_bin" >>$@;\
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index eb23738ef4bd..91815fb1f2fa 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -302,13 +302,6 @@
VMLINUX_SYMBOL(__end_pci_fixups_suspend_late) = .; \
} \
\
- /* Built-in firmware blobs */ \
- .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) { \
- VMLINUX_SYMBOL(__start_builtin_fw) = .; \
- *(.builtin_fw) \
- VMLINUX_SYMBOL(__end_builtin_fw) = .; \
- } \
- \
TRACEDATA \
\
/* Kernel symbol table: Normal symbols */ \
--
2.7.0
[toc] | [prev] | [next] | [standalone]
| From | "Luis R. Rodriguez" <mcgrof@kernel.org> |
|---|---|
| Date | 2016-02-19 14:50 +0100 |
| Subject | [RFC v2 6/7] dynamic_debug: port to use linker tables |
| Message-ID | <r3TBv-5OY-9@gated-at.bofh.it> |
| In reply to | #1338193 |
This removes the custom vmlinux.lds.h hacks and uses
the generalized solution for .data (SECTION_DATA)
entries.
This is much more potential for further fine tuning here
though in the future. For instance, linker tables enable
an extra postfix for order level annotations, this could
easily be used as the KBUILD_MODNAME and with a bit of
linker table changes we may be able to get a direct O(1)
count of the entries for that KBUILD_MODNAME: it would
just be a count on the number of entries for the given
order level. This should help make dynamic_debug_init()
cleaner and also reduce the amount of time it takes at
boot time. Instead of iterating over each print until we
have all for a KBUILD_MODNAME, we'd instead directly
operate on each KBUILD_MODNAME directly.
Tested dynamic debug with dyndbg query ana debugfs control
and it works as expected.
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
include/asm-generic/vmlinux.lds.h | 5 -----
include/linux/dynamic_debug.h | 6 ++++--
kernel/module.c | 2 +-
lib/dynamic_debug.c | 13 ++++++-------
4 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 11e1adcbcb24..c5fcac902cbe 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -209,11 +209,6 @@
*(.data.unlikely) \
STRUCT_ALIGN(); \
*(__tracepoints) \
- /* implement dynamic printk debug */ \
- . = ALIGN(8); \
- VMLINUX_SYMBOL(__start___verbose) = .; \
- *(__verbose) \
- VMLINUX_SYMBOL(__stop___verbose) = .; \
LIKELY_PROFILE() \
BRANCH_PROFILE() \
TRACE_PRINTKS() \
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 4f1bbc68cd1b..6cd14a22b795 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -1,6 +1,8 @@
#ifndef _DYNAMIC_DEBUG_H
#define _DYNAMIC_DEBUG_H
+#include <linux/tables.h>
+
/*
* An instance of this structure is created in a special
* ELF section at every dynamic debug callsite. At runtime,
@@ -40,6 +42,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
const char *modname);
#if defined(CONFIG_DYNAMIC_DEBUG)
+DECLARE_LINKTABLE_DATA(struct _ddebug, __verbose);
extern int ddebug_remove_module(const char *mod_name);
extern __printf(2, 3)
void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...);
@@ -61,8 +64,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor,
const char *fmt, ...);
#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \
- static struct _ddebug __aligned(8) \
- __attribute__((section("__verbose"))) name = { \
+ static LINKTABLE_DATA(__verbose, all) name = { \
.modname = KBUILD_MODNAME, \
.function = __func__, \
.filename = __FILE__, \
diff --git a/kernel/module.c b/kernel/module.c
index 42249ee8e462..22d768abb1ec 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2962,7 +2962,7 @@ static int find_module_sections(struct module *mod, struct load_info *info)
if (section_addr(info, "__obsparm"))
pr_warn("%s: Ignoring obsolete parameters\n", mod->name);
- info->debug = section_objs(info, "__verbose",
+ info->debug = section_objs(info, SECTION_TBL(SECTION_DATA, __verbose,),
sizeof(*info->debug), &info->num_debug);
return 0;
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index fe42b6ec3f0c..ae7b9b4ac022 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -37,8 +37,7 @@
#include <linux/device.h>
#include <linux/netdevice.h>
-extern struct _ddebug __start___verbose[];
-extern struct _ddebug __stop___verbose[];
+DEFINE_LINKTABLE_DATA(struct _ddebug, __verbose);
struct ddebug_table {
struct list_head link;
@@ -971,14 +970,14 @@ static int __init dynamic_debug_init(void)
int n = 0, entries = 0, modct = 0;
int verbose_bytes = 0;
- if (__start___verbose == __stop___verbose) {
- pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n");
+ if (LINKTABLE_EMPTY(__verbose)) {
+ pr_warn("dynamic debug linker table empty on CONFIG_DYNAMIC_DEBUG build\n");
return 1;
}
- iter = __start___verbose;
+ iter = LINKTABLE_START(__verbose);
modname = iter->modname;
iter_start = iter;
- for (; iter < __stop___verbose; iter++) {
+ LINKTABLE_FOR_EACH(iter, __verbose) {
entries++;
verbose_bytes += strlen(iter->modname) + strlen(iter->function)
+ strlen(iter->filename) + strlen(iter->format);
@@ -1001,7 +1000,7 @@ static int __init dynamic_debug_init(void)
ddebug_init_success = 1;
vpr_info("%d modules, %d entries and %d bytes in ddebug tables, %d bytes in (readonly) verbose section\n",
modct, entries, (int)(modct * sizeof(struct ddebug_table)),
- verbose_bytes + (int)(__stop___verbose - __start___verbose));
+ verbose_bytes + (int)(LINKTABLE_SIZE(__verbose)));
/* apply ddebug_query boot param, dont unload tables on err */
if (ddebug_setup_string[0] != '\0') {
--
2.7.0
[toc] | [prev] | [next] | [standalone]
| From | "Luis R. Rodriguez" <mcgrof@kernel.org> |
|---|---|
| Date | 2016-02-19 14:50 +0100 |
| Subject | [RFC v2 5/7] jump_label: port __jump_table to linker tables |
| Message-ID | <r3TBw-5OY-15@gated-at.bofh.it> |
| In reply to | #1338193 |
Move the __jump_table from the a custom section solution
to a generic solution, this avoiding extra vmlinux.lds.h
customizations.
This also demos the use of the .data (SECTION_DATA)
linker tables and of push_section_tbl().
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
arch/arm/include/asm/jump_label.h | 4 ++--
arch/arm64/include/asm/jump_label.h | 4 ++--
arch/mips/include/asm/jump_label.h | 4 ++--
arch/powerpc/include/asm/jump_label.h | 6 +++---
arch/s390/include/asm/jump_label.h | 4 ++--
arch/sparc/include/asm/jump_label.h | 4 ++--
arch/x86/include/asm/jump_label.h | 9 +++++----
include/asm-generic/vmlinux.lds.h | 4 ----
include/linux/jump_label.h | 5 +++--
kernel/jump_label.c | 16 +++++++++-------
kernel/module.c | 4 +++-
11 files changed, 33 insertions(+), 31 deletions(-)
diff --git a/arch/arm/include/asm/jump_label.h b/arch/arm/include/asm/jump_label.h
index 34f7b6980d21..c1df4f105df3 100644
--- a/arch/arm/include/asm/jump_label.h
+++ b/arch/arm/include/asm/jump_label.h
@@ -12,7 +12,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran
{
asm_volatile_goto("1:\n\t"
WASM(nop) "\n\t"
- ".pushsection __jump_table, \"aw\"\n\t"
+ push_section_tbl(SECTION_DATA, __jump_table, all, aw)
".word 1b, %l[l_yes], %c0\n\t"
".popsection\n\t"
: : "i" (&((char *)key)[branch]) : : l_yes);
@@ -26,7 +26,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
{
asm_volatile_goto("1:\n\t"
WASM(b) " %l[l_yes]\n\t"
- ".pushsection __jump_table, \"aw\"\n\t"
+ push_section_tbl(SECTION_DATA, __jump_table, all, aw)
".word 1b, %l[l_yes], %c0\n\t"
".popsection\n\t"
: : "i" (&((char *)key)[branch]) : : l_yes);
diff --git a/arch/arm64/include/asm/jump_label.h b/arch/arm64/include/asm/jump_label.h
index 1b5e0e843c3a..18f5ca294eaa 100644
--- a/arch/arm64/include/asm/jump_label.h
+++ b/arch/arm64/include/asm/jump_label.h
@@ -29,7 +29,7 @@
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
{
asm goto("1: nop\n\t"
- ".pushsection __jump_table, \"aw\"\n\t"
+ push_section_tbl(SECTION_DATA, __jump_table, all, aw)
".align 3\n\t"
".quad 1b, %l[l_yes], %c0\n\t"
".popsection\n\t"
@@ -43,7 +43,7 @@ l_yes:
static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
{
asm goto("1: b %l[l_yes]\n\t"
- ".pushsection __jump_table, \"aw\"\n\t"
+ push_section_tbl(SECTION_DATA, __jump_table, all, aw)
".align 3\n\t"
".quad 1b, %l[l_yes], %c0\n\t"
".popsection\n\t"
diff --git a/arch/mips/include/asm/jump_label.h b/arch/mips/include/asm/jump_label.h
index e77672539e8e..13e70e290830 100644
--- a/arch/mips/include/asm/jump_label.h
+++ b/arch/mips/include/asm/jump_label.h
@@ -30,7 +30,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran
{
asm_volatile_goto("1:\t" NOP_INSN "\n\t"
"nop\n\t"
- ".pushsection __jump_table, \"aw\"\n\t"
+ push_section_tbl(SECTION_DATA, __jump_table, all, aw)
WORD_INSN " 1b, %l[l_yes], %0\n\t"
".popsection\n\t"
: : "i" (&((char *)key)[branch]) : : l_yes);
@@ -44,7 +44,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
{
asm_volatile_goto("1:\tj %l[l_yes]\n\t"
"nop\n\t"
- ".pushsection __jump_table, \"aw\"\n\t"
+ push_section_tbl(SECTION_DATA, __jump_table, all, aw)
WORD_INSN " 1b, %l[l_yes], %0\n\t"
".popsection\n\t"
: : "i" (&((char *)key)[branch]) : : l_yes);
diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h
index 47e155f15433..5fffc7b12361 100644
--- a/arch/powerpc/include/asm/jump_label.h
+++ b/arch/powerpc/include/asm/jump_label.h
@@ -22,7 +22,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran
{
asm_volatile_goto("1:\n\t"
"nop\n\t"
- ".pushsection __jump_table, \"aw\"\n\t"
+ push_section_tbl(SECTION_DATA, __jump_table, all, aw)
JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t"
".popsection \n\t"
: : "i" (&((char *)key)[branch]) : : l_yes);
@@ -36,7 +36,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
{
asm_volatile_goto("1:\n\t"
"b %l[l_yes]\n\t"
- ".pushsection __jump_table, \"aw\"\n\t"
+ push_section_tbl(SECTION_DATA, __jump_table, all, aw)
JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t"
".popsection \n\t"
: : "i" (&((char *)key)[branch]) : : l_yes);
@@ -61,7 +61,7 @@ struct jump_entry {
#else
#define ARCH_STATIC_BRANCH(LABEL, KEY) \
1098: nop; \
- .pushsection __jump_table, "aw"; \
+ .pushsection .data.tbl.__jump_table.all, "aw"; \
FTR_ENTRY_LONG 1098b, LABEL, KEY; \
.popsection
#endif
diff --git a/arch/s390/include/asm/jump_label.h b/arch/s390/include/asm/jump_label.h
index 7f9fd5e3f1bf..1ebfb7ddcb11 100644
--- a/arch/s390/include/asm/jump_label.h
+++ b/arch/s390/include/asm/jump_label.h
@@ -15,7 +15,7 @@
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
{
asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n"
- ".pushsection __jump_table, \"aw\"\n"
+ ".pushsection .data.tbl.__jump_table.all, \"aw\"\n"
".balign 8\n"
".quad 0b, %l[label], %0\n"
".popsection\n"
@@ -29,7 +29,7 @@ label:
static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
{
asm_volatile_goto("0: brcl 15, %l[label]\n"
- ".pushsection __jump_table, \"aw\"\n"
+ ".pushsection .data.tbl.__jump_table.all, \"aw\"\n"
".balign 8\n"
".quad 0b, %l[label], %0\n"
".popsection\n"
diff --git a/arch/sparc/include/asm/jump_label.h b/arch/sparc/include/asm/jump_label.h
index 62d0354d1727..848bece455bb 100644
--- a/arch/sparc/include/asm/jump_label.h
+++ b/arch/sparc/include/asm/jump_label.h
@@ -12,7 +12,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran
asm_volatile_goto("1:\n\t"
"nop\n\t"
"nop\n\t"
- ".pushsection __jump_table, \"aw\"\n\t"
+ push_section_tbl(SECTION_DATA, __jump_table, all, aw)
".align 4\n\t"
".word 1b, %l[l_yes], %c0\n\t"
".popsection \n\t"
@@ -28,7 +28,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
asm_volatile_goto("1:\n\t"
"b %l[l_yes]\n\t"
"nop\n\t"
- ".pushsection __jump_table, \"aw\"\n\t"
+ push_section_tbl(SECTION_DATA, __jump_table, all, aw)
".align 4\n\t"
".word 1b, %l[l_yes], %c0\n\t"
".popsection \n\t"
diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h
index adc54c12cbd1..5b80a0e755df 100644
--- a/arch/x86/include/asm/jump_label.h
+++ b/arch/x86/include/asm/jump_label.h
@@ -29,12 +29,13 @@
#include <linux/stringify.h>
#include <linux/types.h>
+#include <asm-generic/sections.h>
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
{
asm_volatile_goto("1:"
".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t"
- ".pushsection __jump_table, \"aw\" \n\t"
+ push_section_tbl(SECTION_DATA, __jump_table, all, aw)
_ASM_ALIGN "\n\t"
_ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t"
".popsection \n\t"
@@ -50,7 +51,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
asm_volatile_goto("1:"
".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"
"2:\n\t"
- ".pushsection __jump_table, \"aw\" \n\t"
+ push_section_tbl(SECTION_DATA, __jump_table, all, aw)
_ASM_ALIGN "\n\t"
_ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t"
".popsection \n\t"
@@ -85,7 +86,7 @@ struct jump_entry {
.else
.byte STATIC_KEY_INIT_NOP
.endif
- .pushsection __jump_table, "aw"
+ .pushsection .data.tbl.__jump_table.all, "aw"
_ASM_ALIGN
_ASM_PTR .Lstatic_jump_\@, \target, \key
.popsection
@@ -101,7 +102,7 @@ struct jump_entry {
.long \target - .Lstatic_jump_after_\@
.Lstatic_jump_after_\@:
.endif
- .pushsection __jump_table, "aw"
+ .pushsection .data.tbl.__jump_table.all, "aw"
_ASM_ALIGN
_ASM_PTR .Lstatic_jump_\@, \target, \key + 1
.popsection
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 91815fb1f2fa..11e1adcbcb24 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -210,10 +210,6 @@
STRUCT_ALIGN(); \
*(__tracepoints) \
/* implement dynamic printk debug */ \
- . = ALIGN(8); \
- VMLINUX_SYMBOL(__start___jump_table) = .; \
- *(__jump_table) \
- VMLINUX_SYMBOL(__stop___jump_table) = .; \
. = ALIGN(8); \
VMLINUX_SYMBOL(__start___verbose) = .; \
*(__verbose) \
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 0536524bb9eb..42b68b1e4a39 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -1,6 +1,8 @@
#ifndef _LINUX_JUMP_LABEL_H
#define _LINUX_JUMP_LABEL_H
+#include <linux/tables.h>
+
/*
* Jump label support
*
@@ -138,8 +140,7 @@ static __always_inline bool static_key_true(struct static_key *key)
return !arch_static_branch(key, true);
}
-extern struct jump_entry __start___jump_table[];
-extern struct jump_entry __stop___jump_table[];
+DECLARE_LINKTABLE_DATA(struct jump_entry, __jump_table);
extern void jump_label_init(void);
extern void jump_label_lock(void);
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 05254eeb4b4e..66d6e24148be 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -17,6 +17,8 @@
#ifdef HAVE_JUMP_LABEL
+DEFINE_LINKTABLE_DATA(struct jump_entry, __jump_table);
+
/* mutex to protect coming/going of the the jump_label table */
static DEFINE_MUTEX(jump_label_mutex);
@@ -200,15 +202,14 @@ static void __jump_label_update(struct static_key *key,
void __init jump_label_init(void)
{
- struct jump_entry *iter_start = __start___jump_table;
- struct jump_entry *iter_stop = __stop___jump_table;
struct static_key *key = NULL;
struct jump_entry *iter;
jump_label_lock();
- jump_label_sort_entries(iter_start, iter_stop);
+ jump_label_sort_entries(LINKTABLE_START(__jump_table),
+ LINKTABLE_END(__jump_table));
- for (iter = iter_start; iter < iter_stop; iter++) {
+ LINKTABLE_FOR_EACH(iter, __jump_table) {
struct static_key *iterk;
/* rewrite NOPs */
@@ -450,8 +451,9 @@ early_initcall(jump_label_init_module);
*/
int jump_label_text_reserved(void *start, void *end)
{
- int ret = __jump_label_text_reserved(__start___jump_table,
- __stop___jump_table, start, end);
+ int ret = __jump_label_text_reserved(LINKTABLE_START(__jump_table),
+ LINKTABLE_END(__jump_table),
+ start, end);
if (ret)
return ret;
@@ -464,7 +466,7 @@ int jump_label_text_reserved(void *start, void *end)
static void jump_label_update(struct static_key *key)
{
- struct jump_entry *stop = __stop___jump_table;
+ struct jump_entry *stop = LINKTABLE_END(__jump_table);
struct jump_entry *entry = static_key_entries(key);
#ifdef CONFIG_MODULES
struct module *mod;
diff --git a/kernel/module.c b/kernel/module.c
index 9537da37ce87..42249ee8e462 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2930,7 +2930,9 @@ static int find_module_sections(struct module *mod, struct load_info *info)
&mod->num_tracepoints);
#endif
#ifdef HAVE_JUMP_LABEL
- mod->jump_entries = section_objs(info, "__jump_table",
+ mod->jump_entries = section_objs(info,
+ SECTION_TBL(SECTION_DATA,
+ __jump_table,),
sizeof(*mod->jump_entries),
&mod->num_jump_entries);
#endif
--
2.7.0
[toc] | [prev] | [next] | [standalone]
| From | "Luis R. Rodriguez" <mcgrof@kernel.org> |
|---|---|
| Date | 2016-02-19 14:50 +0100 |
| Subject | [RFC v2 1/7] sections.h: add sections header to collect all section info |
| Message-ID | <r3TBw-5OY-17@gated-at.bofh.it> |
| In reply to | #1338193 |
Linux makes extensive use of custom ELF header sections, documentation for these are well scatterred. Unify this documentation in a central place. Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> --- Documentation/DocBook/Makefile | 3 +- Documentation/DocBook/sections.tmpl | 99 ++++++++++++++++ include/linux/sections.h | 224 ++++++++++++++++++++++++++++++++++++ 3 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 Documentation/DocBook/sections.tmpl create mode 100644 include/linux/sections.h diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile index d70f9b68174e..f2dfd46bf30a 100644 --- a/Documentation/DocBook/Makefile +++ b/Documentation/DocBook/Makefile @@ -15,7 +15,8 @@ DOCBOOKS := z8530book.xml device-drivers.xml \ 80211.xml debugobjects.xml sh.xml regulator.xml \ alsa-driver-api.xml writing-an-alsa-driver.xml \ tracepoint.xml gpu.xml media_api.xml w1.xml \ - writing_musb_glue_layer.xml crypto-API.xml iio.xml + writing_musb_glue_layer.xml crypto-API.xml iio.xml \ + sections.xml include Documentation/DocBook/media/Makefile diff --git a/Documentation/DocBook/sections.tmpl b/Documentation/DocBook/sections.tmpl new file mode 100644 index 000000000000..96d8d88c1b93 --- /dev/null +++ b/Documentation/DocBook/sections.tmpl @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE set PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" + "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []> +<set> + <setinfo> + <title>Linux ELF sections</title> + <subtitle> + Explains Linux ELF sections + </subtitle> + + <copyright> + <year>2016</year> + <holder>Luis R. Rodriguez</holder> + </copyright> + + <authorgroup> + <author> + <firstname>Luis</firstname> + <surname>Rodriguez</surname> + <affiliation> + <address><email>mcgrof@kernel.org</email></address> + </affiliation> + </author> + </authorgroup> + + <legalnotice> + <para> + This documentation is free software; you can redistribute + it and/or modify it under the terms of the GNU General Public + License version 2 as published by the Free Software Foundation. + </para> + <para> + This documentation is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + </para> + <para> + You should have received a copy of the GNU General Public + License along with this documentation; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307 USA + </para> + <para> + For more details see the file COPYING in the source + distribution of Linux. + </para> + </legalnotice> + + <abstract> + <para> + This book documents the different custom ELF sections used on the Linux + kernel and defined on Linux's custom linker script. + </para> + </abstract> + </setinfo> + <book id="linux-elf-sections"> + <bookinfo> + <title>Linux kernel ELF sections</title> + + <abstract> +!Pinclude/linux/sections.h Introduction + </abstract> + </bookinfo> + + <chapter> + <title>Core Linux kernel sections</title> +!Pinclude/linux/sections.h Core Linux kernel sections +!Finclude/linux/sections.h SECTION_RODATA +!Pinclude/linux/sections.h SECTION_TEXT +!Pinclude/linux/sections.h SECTION_DATA + </chapter> + + <chapter> + <title>Linux .init* sections</title> +!Pinclude/linux/sections.h Linux init sections +!Finclude/linux/sections.h SECTION_INIT_DATA +!Finclude/linux/sections.h SECTION_INIT_RODATA +!Finclude/linux/sections.h SECTION_INIT_CALL + </chapter> + + <chapter> + <title>Linux .exit* sections</title> +!Pinclude/linux/sections.h Linux exit sections +!Finclude/linux/sections.h SECTION_EXIT +!Finclude/linux/sections.h SECTION_EXIT_DATA +!Finclude/linux/sections.h SECTION_EXIT_CALL + </chapter> + + <chapter> + <title>Linux .ref* sections</title> +!Pinclude/linux/sections.h Linux references to init sections +!Finclude/linux/sections.h SECTION_REF +!Finclude/linux/sections.h SECTION_REF_DATA +!Finclude/linux/sections.h SECTION_REF_RODATA + </chapter> + + </book> +</set> diff --git a/include/linux/sections.h b/include/linux/sections.h new file mode 100644 index 000000000000..7b47bea4956a --- /dev/null +++ b/include/linux/sections.h @@ -0,0 +1,224 @@ +#ifndef _LINUX_SECTIONS_H +#define _LINUX_SECTIONS_H +/* + * Linux ELF sections + * + * Copyright (C) 2016 Luis R. Rodriguez <mcgrof@kernel.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Due to this file being licensed under the GPL there is controversy over + * whether this permits you to write a module that #includes this file + * without placing your module under the GPL. Please consult a lawyer for + * advice before doing this. + */ + +/** + * DOC: Introduction + * + * The Linux vmlinux binary uses a custom linker script which adds + * some custom specialized ELF sections. This aims to document those + * sections. Each section must document the goal of the section, and + * address concurrency considerations when applicable. + */ + +/** + * DOC: Core Linux kernel sections + * + * These are the core Linux kernel sections. + */ + +/** + * SECTION_RODATA - read only data + * + * Macro name for code which must be protected from write access. + */ +#define SECTION_RODATA .rodata + +/** + * SECTION_TEXT - kernel code execution section, read-only + * + * Macro name used to annotate code (functions) used during regular + * kernel run time. This is combined with SECTION_RODATA, only this + * section also gets execution allowed. + * + */ +#define SECTION_TEXT .text + +/** + * SECTION_DATA - for read-write data + * + * Macro name for read-write data. + */ +#define SECTION_DATA .data + +/** + * DOC: Linux init sections + * + * These sections are used for code and data structures used during boot or + * module initialization. On architectures that support it (x86, x86_64), all + * this code is freed up by the kernel right before the fist userspace init + * process is called when built-in to the kernel, and if modular it is freed + * after module initialization. Since the code is freed so early, in theory + * there should be no races against freeing this code with other CPUs. Init + * section code and data structures should never be exported with + * EXPORT_SYMBOL*() as the code will quickly become unavailable to the kernel + * after bootup. + */ + +/** + * SECTION_INIT - boot initialization code + * + * Macro name used to annotate code (functions) used only during boot or driver + * initialization. + * + */ +#define SECTION_INIT .init.text + +/** + * SECTION_INIT_DATA - boot initialization data + * + * Macro name used to annotate data structures used only during boot or driver + * initialization. + */ +#define SECTION_INIT_DATA .init.data + +/** + * SECTION_INIT_RODATA - boot read-only initialization data + * + * Macro name used to annotate read-only code (functions) used only during boot + * or driver initialization. + */ +#define SECTION_INIT_RODATA .init.rodata + +/** + * SECTION_INIT_CALL - special init call + * + * Special macro name used to annotate subsystem init call. These calls are + * are now grouped by functionality into separate subsections. Ordering inside + * the subsections is determined by link order. + */ +#define SECTION_INIT_CALL .initcall + +/** + * DOC: Linux exit sections + * + * These sections are used to declare a functions and data structures which + * are only required on exit, the function or data structure will be dropped + * if the code declaring this section is not compiled as a module on + * architectures that support this (x86, x86_64). There is no special case + * handling for this code when built-in to the kernel. + */ + +/** + * SECTION_EXIT - module exit code + * + * Macro name used to annotate code (functions) used only during module + * unload. + */ +#define SECTION_EXIT .exit.text + +/** + * SECTION_EXIT_DATA - module exit data structures + * + * Macro name used to annotate data structures used only during module + * unload. + */ +#define SECTION_EXIT_DATA .exit.data + +/** + * SECTION_EXIT_CALL - special exit call + * + * Special macro name used to annotate an exit exit routine, order + * is important and maintained by link order. + */ +#define SECTION_EXIT_CALL .exitcall.exit + +/** + * DOC: Linux references to init sections + * + * These sections are used to teach modpost to not warn about possible + * misuses of init section code from other sections. If you use this + * your use case should document why you are certain such use of init + * sectioned code is valid. For more details refer to include/linux/init.h + * __ref, __refdata, and __refconst documentation. + */ + +/** + * SECTION_REF - code referencing init is valid + * + * Macro name used to annotate that code (functions) declared with this section + * has been vetteed as valid for its reference or use of other code (functions) + * or data structures which are part of the init sections. + */ +#define SECTION_REF .ref.text + +/** + * SECTION_REF_DATA - reference data structure are valid + * + * Macro name used to annotate data structures declared with this section have + * been vetteed for its reference or use of other code (functions) or data + * structures part of the init sections. + */ +#define SECTION_REF_DATA .ref.data + +/** + * SECTION_REF_RODATA - const code or data structure referencing init is valid + * + * Macro name used to annotate const code (functions) const data structures which + * has been vetteed for its reference or use of other code (functions) or data + * structures part of the init sections. + */ +#define SECTION_REF_RODATA .ref.rodata + +/** + * DOC: Custom Linux sections + * + * These are very custom Linux sections. + */ + +#ifndef __ASSEMBLY__ + +/* + * Without this you end up with the section macro + * as part of the name + */ +#define __SECTION_TBL(section, name, level) \ + #section ".tbl." #name "." #level + +/** + * SECTION_TBL - Linux linker table section + * + * @section: respective section + * @name: used to describe the use case + * @level: the order-level for the linker table + * + * Macro name used to annotate a linker table. For more details refer to + * include/linux/tables.h. Linker tables use standard Linux sections defined + * in this file. + */ +#define SECTION_TBL(section, name, level) \ + __SECTION_TBL(section, name, level) + +/* + * For use on linker scripts and helpers + */ +#define ___SECTION_TBL(section, name) \ + section##.tbl.##name +/** + * SECTION_TBL_ALL - glob to capture all linker table uses for this section + * + * @section: respective section + * + * Macro name used by linker script to capture all linker tables uses for + * the given section. This is used by include/asm-generic/vmlinux.lds.h + */ +#define SECTION_TBL_ALL(section) \ + ___SECTION_TBL(section,*) + +#endif /* __ASSEMBLY__ */ + +#endif /* _LINUX_SECTIONS_H */ -- 2.7.0
[toc] | [prev] | [next] | [standalone]
| From | Greg KH <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2016-02-19 17:30 +0100 |
| Subject | Re: [RFC v2 1/7] sections.h: add sections header to collect all section info |
| Message-ID | <r3W6n-7OW-43@gated-at.bofh.it> |
| In reply to | #1338198 |
On Fri, Feb 19, 2016 at 05:45:53AM -0800, Luis R. Rodriguez wrote: > Linux makes extensive use of custom ELF header sections, > documentation for these are well scatterred. Unify this > documentation in a central place. Minor questions: > + <para> > + You should have received a copy of the GNU General Public > + License along with this documentation; if not, write to the Free > + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, > + MA 02111-1307 USA > + </para> Unless you are willing to personally track the office moves of the FSF for the next 20+ years, just drop this paragraph please :) > +++ b/include/linux/sections.h > @@ -0,0 +1,224 @@ > +#ifndef _LINUX_SECTIONS_H > +#define _LINUX_SECTIONS_H > +/* > + * Linux ELF sections > + * > + * Copyright (C) 2016 Luis R. Rodriguez <mcgrof@kernel.org> > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. Do you really mean "any later version"? > + * Due to this file being licensed under the GPL there is controversy over > + * whether this permits you to write a module that #includes this file > + * without placing your module under the GPL. Please consult a lawyer for > + * advice before doing this. Interesting wording, I don't think there's any "controversy" here, so I'd drop that word if at all possible. thanks, greg k-h
[toc] | [prev] | [next] | [standalone]
| From | "Luis R. Rodriguez" <mcgrof@suse.com> |
|---|---|
| Date | 2016-02-19 21:10 +0100 |
| Subject | Re: [RFC v2 1/7] sections.h: add sections header to collect all section info |
| Message-ID | <r3Zxg-2dl-19@gated-at.bofh.it> |
| In reply to | #1338336 |
On Fri, Feb 19, 2016 at 08:23:29AM -0800, Greg KH wrote: > On Fri, Feb 19, 2016 at 05:45:53AM -0800, Luis R. Rodriguez wrote: > > Linux makes extensive use of custom ELF header sections, > > documentation for these are well scatterred. Unify this > > documentation in a central place. > > Minor questions: > > > + <para> > > + You should have received a copy of the GNU General Public > > + License along with this documentation; if not, write to the Free > > + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, > > + MA 02111-1307 USA > > + </para> > > Unless you are willing to personally track the office moves of the FSF > for the next 20+ years, just drop this paragraph please :) Sure. > > +++ b/include/linux/sections.h > > @@ -0,0 +1,224 @@ > > +#ifndef _LINUX_SECTIONS_H > > +#define _LINUX_SECTIONS_H > > +/* > > + * Linux ELF sections > > + * > > + * Copyright (C) 2016 Luis R. Rodriguez <mcgrof@kernel.org> > > + * > > + * This program is free software; you can redistribute it and/or modify > > + * it under the terms of the GNU General Public License as published by > > + * the Free Software Foundation; either version 2 of the License, or > > + * (at your option) any later version. > > Do you really mean "any later version"? Yes. > > + * Due to this file being licensed under the GPL there is controversy over > > + * whether this permits you to write a module that #includes this file > > + * without placing your module under the GPL. Please consult a lawyer for > > + * advice before doing this. > > Interesting wording, This was copied from security.h. > I don't think there's any "controversy" here, so I'd drop that word if at all > possible. Change it for something else? Any preference? Luis
[toc] | [prev] | [next] | [standalone]
| From | Greg KH <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2016-02-19 22:30 +0100 |
| Subject | Re: [RFC v2 1/7] sections.h: add sections header to collect all section info |
| Message-ID | <r40MF-332-7@gated-at.bofh.it> |
| In reply to | #1338433 |
On Fri, Feb 19, 2016 at 09:06:03PM +0100, Luis R. Rodriguez wrote: > On Fri, Feb 19, 2016 at 08:23:29AM -0800, Greg KH wrote: > > On Fri, Feb 19, 2016 at 05:45:53AM -0800, Luis R. Rodriguez wrote: > > > + * Due to this file being licensed under the GPL there is controversy over > > > + * whether this permits you to write a module that #includes this file > > > + * without placing your module under the GPL. Please consult a lawyer for > > > + * advice before doing this. > > > > Interesting wording, > > This was copied from security.h. Ah, and look, I wrote that, nevermind then :) sorry for the noise, greg k-h
[toc] | [prev] | [next] | [standalone]
| From | "Luis R. Rodriguez" <mcgrof@kernel.org> |
|---|---|
| Date | 2016-02-19 23:10 +0100 |
| Subject | Re: [RFC v2 1/7] sections.h: add sections header to collect all section info |
| Message-ID | <r41po-3DD-13@gated-at.bofh.it> |
| In reply to | #1338492 |
On Fri, Feb 19, 2016 at 01:25:22PM -0800, Greg KH wrote: > On Fri, Feb 19, 2016 at 09:06:03PM +0100, Luis R. Rodriguez wrote: > > On Fri, Feb 19, 2016 at 08:23:29AM -0800, Greg KH wrote: > > > On Fri, Feb 19, 2016 at 05:45:53AM -0800, Luis R. Rodriguez wrote: > > > > + * Due to this file being licensed under the GPL there is controversy over > > > > + * whether this permits you to write a module that #includes this file > > > > + * without placing your module under the GPL. Please consult a lawyer for > > > > + * advice before doing this. > > > > > > Interesting wording, > > > > This was copied from security.h. > > Ah, and look, I wrote that, nevermind then :) > > sorry for the noise, Heh, thanks I'll leave it as-is and modify that pesky address to a URL. Luis
[toc] | [prev] | [next] | [standalone]
| From | "Luis R. Rodriguez" <mcgrof@kernel.org> |
|---|---|
| Date | 2016-02-19 14:50 +0100 |
| Subject | [RFC v2 4/7] asm/sections: add a generic push_section_tbl() |
| Message-ID | <r3TBw-5OY-25@gated-at.bofh.it> |
| In reply to | #1338193 |
With a generic linker tables solution in place we need a general asm solution for declaring entries with asm. The first easy target is to cover the C asm declarations, guard the header file for now and define a first generic entry push_section_tbl() to be used later for custom linker table annotations. Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> --- include/asm-generic/sections.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index af0254c09424..f5ea98bd85d2 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -3,8 +3,10 @@ /* References to section boundaries */ +#ifndef __ASSEMBLY__ #include <linux/compiler.h> #include <linux/types.h> +#include <linux/sections.h> /* * Usage guidelines: @@ -128,4 +130,12 @@ static inline bool init_section_intersects(void *virt, size_t size) return memory_intersects(__init_begin, __init_end, virt, size); } +/* + * Some architectures do not like the "\t" at the end (s39), we should be + * able to generalize this further, but so far this covers most architectures. + */ +#define push_section_tbl(section, name, level, flags) \ + ".pushsection " SECTION_TBL(section,name,level) ", \"" #flags "\"\n\t" +#endif + #endif /* _ASM_GENERIC_SECTIONS_H_ */ -- 2.7.0
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-02-19 21:40 +0100 |
| Subject | Re: [RFC v2 4/7] asm/sections: add a generic push_section_tbl() |
| Message-ID | <r400i-2qQ-17@gated-at.bofh.it> |
| In reply to | #1338200 |
On 02/19/2016 05:45 AM, Luis R. Rodriguez wrote: > With a generic linker tables solution in place we > need a general asm solution for declaring entries > with asm. The first easy target is to cover the C > asm declarations, guard the header file for now > and define a first generic entry push_section_tbl() > to be used later for custom linker table annotations. > > Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> > --- > include/asm-generic/sections.h | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h > index af0254c09424..f5ea98bd85d2 100644 > --- a/include/asm-generic/sections.h > +++ b/include/asm-generic/sections.h > @@ -3,8 +3,10 @@ > > /* References to section boundaries */ > > +#ifndef __ASSEMBLY__ > #include <linux/compiler.h> > #include <linux/types.h> > +#include <linux/sections.h> > > /* > * Usage guidelines: > @@ -128,4 +130,12 @@ static inline bool init_section_intersects(void *virt, size_t size) > return memory_intersects(__init_begin, __init_end, virt, size); > } > > +/* > + * Some architectures do not like the "\t" at the end (s39), we should be > + * able to generalize this further, but so far this covers most architectures. > + */ > +#define push_section_tbl(section, name, level, flags) \ > + ".pushsection " SECTION_TBL(section,name,level) ", \"" #flags "\"\n\t" > +#endif > + I think the \n\t is unnecessary. -hpa
[toc] | [prev] | [next] | [standalone]
| From | "Luis R. Rodriguez" <mcgrof@kernel.org> |
|---|---|
| Date | 2016-02-19 22:10 +0100 |
| Subject | Re: [RFC v2 4/7] asm/sections: add a generic push_section_tbl() |
| Message-ID | <r40tj-2SE-5@gated-at.bofh.it> |
| In reply to | #1338448 |
On Fri, Feb 19, 2016 at 12:26:51PM -0800, H. Peter Anvin wrote: > On 02/19/2016 05:45 AM, Luis R. Rodriguez wrote: > > With a generic linker tables solution in place we > > need a general asm solution for declaring entries > > with asm. The first easy target is to cover the C > > asm declarations, guard the header file for now > > and define a first generic entry push_section_tbl() > > to be used later for custom linker table annotations. > > > > Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> > > --- > > include/asm-generic/sections.h | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h > > index af0254c09424..f5ea98bd85d2 100644 > > --- a/include/asm-generic/sections.h > > +++ b/include/asm-generic/sections.h > > @@ -3,8 +3,10 @@ > > > > /* References to section boundaries */ > > > > +#ifndef __ASSEMBLY__ > > #include <linux/compiler.h> > > #include <linux/types.h> > > +#include <linux/sections.h> > > > > /* > > * Usage guidelines: > > @@ -128,4 +130,12 @@ static inline bool init_section_intersects(void *virt, size_t size) > > return memory_intersects(__init_begin, __init_end, virt, size); > > } > > > > +/* > > + * Some architectures do not like the "\t" at the end (s39), we should be > > + * able to generalize this further, but so far this covers most architectures. > > + */ > > +#define push_section_tbl(section, name, level, flags) \ > > + ".pushsection " SECTION_TBL(section,name,level) ", \"" #flags "\"\n\t" > > +#endif > > + > > I think the \n\t is unnecessary. Super! I wonder if we we can just use this on s390 as well without it pooping? I ask as this would set a precedent. Luis
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-02-22 04:00 +0100 |
| Subject | Re: [RFC v2 4/7] asm/sections: add a generic push_section_tbl() |
| Message-ID | <r4OT7-7hh-13@gated-at.bofh.it> |
| In reply to | #1338465 |
On 02/19/16 13:06, Luis R. Rodriguez wrote: >> >> I think the \n\t is unnecessary. > > Super! I wonder if we we can just use this on s390 as well without it pooping? > I ask as this would set a precedent. > Ask Heike, but I think just ; or \n ought be be fine. I do not know of *any* case where \t at the end of a string would ever be necessary, and it would *always* be possible to replace it with a space in a pinch. -hpa
[toc] | [prev] | [next] | [standalone]
| From | "Luis R. Rodriguez" <mcgrof@kernel.org> |
|---|---|
| Date | 2016-02-19 14:50 +0100 |
| Subject | [RFC v2 7/7] kprobes: port to linker table |
| Message-ID | <r3TBw-5OY-27@gated-at.bofh.it> |
| In reply to | #1338193 |
kprobe makes use of two custom sections:
type name begin end
init.data _kprobe_blacklist __start_kprobe_blacklist __stop_kprobe_blacklist
text .kprobes.text __kprobes_text_start __kprobes_text_end
Port these to the linker table generic solution. This lets
us remove all the custom kprobe section declarations on the
linker script.
Tested with CONFIG_KPROBES_SANITY_TEST, it passes with:
Kprobe smoke test: started
Kprobe smoke test: passed successfully
Then tested CONFIG_SAMPLE_KPROBES on do_fork, and the
kprobe bites and kicks as expected. Lastly tried registering
a kprobe on a kprobe blacklisted symbol (NOKPROBE_SYMBOL()),
and confirms that fails to work.
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
arch/arc/kernel/vmlinux.lds.S | 1 -
arch/arm/kernel/entry-armv.S | 2 +-
arch/arm/kernel/vmlinux.lds.S | 1 -
arch/avr32/kernel/entry-avr32b.S | 4 ++--
arch/avr32/kernel/vmlinux.lds.S | 1 -
arch/blackfin/kernel/vmlinux.lds.S | 1 -
arch/c6x/kernel/vmlinux.lds.S | 1 -
arch/hexagon/kernel/vmlinux.lds.S | 1 -
arch/ia64/kernel/jprobes.S | 2 +-
arch/ia64/kernel/vmlinux.lds.S | 1 -
arch/ia64/lib/flush.S | 4 ++--
arch/metag/kernel/vmlinux.lds.S | 1 -
arch/microblaze/kernel/vmlinux.lds.S | 1 -
arch/mips/kernel/vmlinux.lds.S | 1 -
arch/mn10300/kernel/vmlinux.lds.S | 1 -
arch/nios2/kernel/vmlinux.lds.S | 1 -
arch/openrisc/kernel/vmlinux.lds.S | 1 -
arch/parisc/kernel/vmlinux.lds.S | 1 -
arch/powerpc/include/asm/ppc_asm.h | 6 +++---
arch/powerpc/kernel/vmlinux.lds.S | 1 -
arch/s390/kernel/entry.S | 4 ++--
arch/s390/kernel/kprobes.c | 2 +-
arch/s390/kernel/mcount.S | 2 +-
arch/s390/kernel/vmlinux.lds.S | 1 -
arch/score/kernel/vmlinux.lds.S | 1 -
arch/sh/kernel/vmlinux.lds.S | 1 -
arch/sparc/kernel/vmlinux.lds.S | 1 -
arch/sparc/mm/ultra.S | 2 +-
arch/tile/kernel/vmlinux.lds.S | 1 -
arch/x86/kernel/kprobes/core.c | 10 ++++++----
arch/x86/kernel/vmlinux.lds.S | 1 -
include/asm-generic/sections.h | 4 ++--
include/asm-generic/vmlinux.lds.h | 16 ----------------
include/linux/compiler.h | 3 ++-
include/linux/kprobes.h | 7 +++++--
kernel/kprobes.c | 16 +++++++---------
scripts/mod/modpost.c | 3 ++-
scripts/recordmcount.c | 3 ++-
scripts/recordmcount.pl | 2 +-
39 files changed, 41 insertions(+), 72 deletions(-)
diff --git a/arch/arc/kernel/vmlinux.lds.S b/arch/arc/kernel/vmlinux.lds.S
index 894e696bddaa..52f23df2b9b6 100644
--- a/arch/arc/kernel/vmlinux.lds.S
+++ b/arch/arc/kernel/vmlinux.lds.S
@@ -98,7 +98,6 @@ SECTIONS
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
*(.fixup)
*(.gnu.warning)
}
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 3ce377f7251f..4959a83833fd 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -83,7 +83,7 @@
.endm
#ifdef CONFIG_KPROBES
- .section .kprobes.text,"ax",%progbits
+ .section .text.tbl.kprobes.all,"ax",%progbits
#else
.text
#endif
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index 8b60fde5ce48..8de7921ac331 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -108,7 +108,6 @@ SECTIONS
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
*(.gnu.warning)
*(.glue_7)
*(.glue_7t)
diff --git a/arch/avr32/kernel/entry-avr32b.S b/arch/avr32/kernel/entry-avr32b.S
index 7301f4806bbe..c0fe699d0a21 100644
--- a/arch/avr32/kernel/entry-avr32b.S
+++ b/arch/avr32/kernel/entry-avr32b.S
@@ -605,7 +605,7 @@ fault_exit_work:
brcc fault_resume_user
rjmp enter_monitor_mode
- .section .kprobes.text, "ax", @progbits
+ .section .text.tbl.kprobes.all, "ax", @progbits
.type handle_debug, @function
handle_debug:
sub sp, 4 /* r12_orig */
@@ -826,7 +826,7 @@ irq_level\level:
IRQ_LEVEL 2
IRQ_LEVEL 3
- .section .kprobes.text, "ax", @progbits
+ .section .text.tbl.kprobes.all, "ax", @progbits
.type enter_monitor_mode, @function
enter_monitor_mode:
/*
diff --git a/arch/avr32/kernel/vmlinux.lds.S b/arch/avr32/kernel/vmlinux.lds.S
index a4589176bed5..bf4f3f1f9dbb 100644
--- a/arch/avr32/kernel/vmlinux.lds.S
+++ b/arch/avr32/kernel/vmlinux.lds.S
@@ -49,7 +49,6 @@ SECTIONS
_stext = .;
*(.ex.text)
*(.irq.text)
- KPROBES_TEXT
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
diff --git a/arch/blackfin/kernel/vmlinux.lds.S b/arch/blackfin/kernel/vmlinux.lds.S
index c9eec84aa258..8a193fad4c5d 100644
--- a/arch/blackfin/kernel/vmlinux.lds.S
+++ b/arch/blackfin/kernel/vmlinux.lds.S
@@ -35,7 +35,6 @@ SECTIONS
#endif
LOCK_TEXT
IRQENTRY_TEXT
- KPROBES_TEXT
#ifdef CONFIG_ROMKERNEL
__sinittext = .;
INIT_TEXT
diff --git a/arch/c6x/kernel/vmlinux.lds.S b/arch/c6x/kernel/vmlinux.lds.S
index 5a6e141d1641..a23bed62cec3 100644
--- a/arch/c6x/kernel/vmlinux.lds.S
+++ b/arch/c6x/kernel/vmlinux.lds.S
@@ -72,7 +72,6 @@ SECTIONS
SCHED_TEXT
LOCK_TEXT
IRQENTRY_TEXT
- KPROBES_TEXT
*(.fixup)
*(.gnu.warning)
}
diff --git a/arch/hexagon/kernel/vmlinux.lds.S b/arch/hexagon/kernel/vmlinux.lds.S
index 5f268c1071b3..a358b699ec64 100644
--- a/arch/hexagon/kernel/vmlinux.lds.S
+++ b/arch/hexagon/kernel/vmlinux.lds.S
@@ -51,7 +51,6 @@ SECTIONS
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
*(.fixup)
}
_etext = .;
diff --git a/arch/ia64/kernel/jprobes.S b/arch/ia64/kernel/jprobes.S
index f69389c7be1d..c6c23a3e92fb 100644
--- a/arch/ia64/kernel/jprobes.S
+++ b/arch/ia64/kernel/jprobes.S
@@ -50,7 +50,7 @@
/*
* void jprobe_break(void)
*/
- .section .kprobes.text, "ax"
+ .section .text.tbl.kprobes.all, "ax"
ENTRY(jprobe_break)
break.m __IA64_BREAK_JPROBE
END(jprobe_break)
diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
index dc506b05ffbd..884f36d38989 100644
--- a/arch/ia64/kernel/vmlinux.lds.S
+++ b/arch/ia64/kernel/vmlinux.lds.S
@@ -47,7 +47,6 @@ SECTIONS {
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
*(.gnu.linkonce.t*)
}
diff --git a/arch/ia64/lib/flush.S b/arch/ia64/lib/flush.S
index 1d8c88860063..7f257810e858 100644
--- a/arch/ia64/lib/flush.S
+++ b/arch/ia64/lib/flush.S
@@ -20,7 +20,7 @@
*
* Note: "in0" and "in1" are preserved for debugging purposes.
*/
- .section .kprobes.text,"ax"
+ .section .text.tbl.kprobes.all,"ax"
GLOBAL_ENTRY(flush_icache_range)
.prologue
@@ -72,7 +72,7 @@ END(flush_icache_range)
*
* Note: "in0" and "in1" are preserved for debugging purposes.
*/
- .section .kprobes.text,"ax"
+ .section .text.tbl.kprobes.all,"ax"
GLOBAL_ENTRY(clflush_cache_range)
.prologue
diff --git a/arch/metag/kernel/vmlinux.lds.S b/arch/metag/kernel/vmlinux.lds.S
index e12055e88bfe..da1689c85bc8 100644
--- a/arch/metag/kernel/vmlinux.lds.S
+++ b/arch/metag/kernel/vmlinux.lds.S
@@ -22,7 +22,6 @@ SECTIONS
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
IRQENTRY_TEXT
*(.text.*)
*(.gnu.warning)
diff --git a/arch/microblaze/kernel/vmlinux.lds.S b/arch/microblaze/kernel/vmlinux.lds.S
index be9488d69734..94c1c5574a77 100644
--- a/arch/microblaze/kernel/vmlinux.lds.S
+++ b/arch/microblaze/kernel/vmlinux.lds.S
@@ -34,7 +34,6 @@ SECTIONS {
EXIT_CALL
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
IRQENTRY_TEXT
. = ALIGN (4) ;
_etext = . ;
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 0a93e83cd014..9183e9235651 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -56,7 +56,6 @@ SECTIONS
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
IRQENTRY_TEXT
*(.text.*)
*(.fixup)
diff --git a/arch/mn10300/kernel/vmlinux.lds.S b/arch/mn10300/kernel/vmlinux.lds.S
index 13c4814c29f8..ead5efc01802 100644
--- a/arch/mn10300/kernel/vmlinux.lds.S
+++ b/arch/mn10300/kernel/vmlinux.lds.S
@@ -31,7 +31,6 @@ SECTIONS
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
*(.fixup)
*(.gnu.warning)
} = 0xcb
diff --git a/arch/nios2/kernel/vmlinux.lds.S b/arch/nios2/kernel/vmlinux.lds.S
index 326fab40a9de..dc8a84183700 100644
--- a/arch/nios2/kernel/vmlinux.lds.S
+++ b/arch/nios2/kernel/vmlinux.lds.S
@@ -39,7 +39,6 @@ SECTIONS
SCHED_TEXT
LOCK_TEXT
IRQENTRY_TEXT
- KPROBES_TEXT
} =0
_etext = .;
diff --git a/arch/openrisc/kernel/vmlinux.lds.S b/arch/openrisc/kernel/vmlinux.lds.S
index 2d69a853b742..b010cb75edc4 100644
--- a/arch/openrisc/kernel/vmlinux.lds.S
+++ b/arch/openrisc/kernel/vmlinux.lds.S
@@ -48,7 +48,6 @@ SECTIONS
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
IRQENTRY_TEXT
*(.fixup)
*(.text.__*)
diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index 308f29081d46..9d9dc4984465 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -70,7 +70,6 @@ SECTIONS
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
IRQENTRY_TEXT
*(.text.do_softirq)
*(.text.sys_exit)
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 499d9f89435a..4e36e86338f3 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -218,7 +218,7 @@ name: \
.localentry name,.-name
#define _KPROBE(name) \
- .section ".kprobes.text","a"; \
+ .section ".text.tbl.kprobes.all","a"; \
.align 2 ; \
.type name,@function; \
.globl name; \
@@ -248,7 +248,7 @@ GLUE(.,name):
#define _GLOBAL_TOC(name) _GLOBAL(name)
#define _KPROBE(name) \
- .section ".kprobes.text","a"; \
+ .section ".text.tbl.kprobes.all","a"; \
.align 2 ; \
.globl name; \
.globl GLUE(.,name); \
@@ -280,7 +280,7 @@ n:
#define _GLOBAL_TOC(name) _GLOBAL(name)
#define _KPROBE(n) \
- .section ".kprobes.text","a"; \
+ .section ".text.tbl.kprobes.all","a"; \
.globl n; \
n:
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index d41fd0af8980..8779ae180783 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -53,7 +53,6 @@ SECTIONS
*(.text .fixup __ftr_alt_* .ref.text)
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
IRQENTRY_TEXT
#ifdef CONFIG_PPC32
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index cd5a191381b9..b09aa9ab5a1f 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -162,7 +162,7 @@ _PIF_WORK = (_PIF_PER_TRAP)
tm off+\addr, \mask
.endm
- .section .kprobes.text, "ax"
+ .section .text.tbl.kprobes.all, "ax"
/*
* Scheduler resume function, called by switch_to
@@ -965,7 +965,7 @@ ENTRY(restart_int_handler)
brc 2,2b
3: j 3b
- .section .kprobes.text, "ax"
+ .section .text.tbl.kprobes.all, "ax"
#ifdef CONFIG_CHECK_STACK
/*
diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
index 250f5972536a..376d4bd487c5 100644
--- a/arch/s390/kernel/kprobes.c
+++ b/arch/s390/kernel/kprobes.c
@@ -288,7 +288,7 @@ static void kprobe_reenter_check(struct kprobe_ctlblk *kcb, struct kprobe *p)
default:
/*
* A kprobe on the code path to single step an instruction
- * is a BUG. The code path resides in the .kprobes.text
+ * is a BUG. The code path resides in the .text.tbl.kprobes.all
* section and is executed with interrupts disabled.
*/
printk(KERN_EMERG "Invalid kprobe detected at %p.\n", p->addr);
diff --git a/arch/s390/kernel/mcount.S b/arch/s390/kernel/mcount.S
index e499370fbccb..4572045b968e 100644
--- a/arch/s390/kernel/mcount.S
+++ b/arch/s390/kernel/mcount.S
@@ -10,7 +10,7 @@
#include <asm/ftrace.h>
#include <asm/ptrace.h>
- .section .kprobes.text, "ax"
+ .section .text.tbl.kprobes.all, "ax"
ENTRY(ftrace_stub)
br %r14
diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S
index 445657fe658c..4614b5bcab5e 100644
--- a/arch/s390/kernel/vmlinux.lds.S
+++ b/arch/s390/kernel/vmlinux.lds.S
@@ -26,7 +26,6 @@ SECTIONS
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
IRQENTRY_TEXT
*(.fixup)
*(.gnu.warning)
diff --git a/arch/score/kernel/vmlinux.lds.S b/arch/score/kernel/vmlinux.lds.S
index 7274b5c4287e..36ebcb3b1215 100644
--- a/arch/score/kernel/vmlinux.lds.S
+++ b/arch/score/kernel/vmlinux.lds.S
@@ -41,7 +41,6 @@ SECTIONS
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
*(.text.*)
*(.fixup)
. = ALIGN (4) ;
diff --git a/arch/sh/kernel/vmlinux.lds.S b/arch/sh/kernel/vmlinux.lds.S
index db88cbf9eafd..af4f37375345 100644
--- a/arch/sh/kernel/vmlinux.lds.S
+++ b/arch/sh/kernel/vmlinux.lds.S
@@ -37,7 +37,6 @@ SECTIONS
EXTRA_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
IRQENTRY_TEXT
*(.fixup)
*(.gnu.warning)
diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S
index f1a2f688b28a..a1c8e3a3ebb6 100644
--- a/arch/sparc/kernel/vmlinux.lds.S
+++ b/arch/sparc/kernel/vmlinux.lds.S
@@ -46,7 +46,6 @@ SECTIONS
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
IRQENTRY_TEXT
*(.gnu.warning)
} = 0
diff --git a/arch/sparc/mm/ultra.S b/arch/sparc/mm/ultra.S
index b4f4733abc6e..a08fb40656ac 100644
--- a/arch/sparc/mm/ultra.S
+++ b/arch/sparc/mm/ultra.S
@@ -148,7 +148,7 @@ __spitfire_flush_tlb_mm_slow:
/*
* The following code flushes one page_size worth.
*/
- .section .kprobes.text, "ax"
+ .section .text.tbl.kprobes.all, "ax"
.align 32
.globl __flush_icache_page
__flush_icache_page: /* %o0 = phys_page */
diff --git a/arch/tile/kernel/vmlinux.lds.S b/arch/tile/kernel/vmlinux.lds.S
index 0e059a0101ea..0f04268fc394 100644
--- a/arch/tile/kernel/vmlinux.lds.S
+++ b/arch/tile/kernel/vmlinux.lds.S
@@ -43,7 +43,6 @@ SECTIONS
HEAD_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
IRQENTRY_TEXT
__fix_text_end = .; /* tile-cpack won't rearrange before this */
ALIGN_FUNCTION();
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 1deffe6cc873..dde4ec0e0185 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -577,7 +577,10 @@ static int reenter_kprobe(struct kprobe *p, struct pt_regs *regs,
case KPROBE_REENTER:
/* A probe has been hit in the codepath leading up to, or just
* after, single-stepping of a probed instruction. This entire
- * codepath should strictly reside in .kprobes.text section.
+ * codepath should strictly reside in the kprobes section:
+ *
+ * SECTION_TBL(SECTION_TEXT, kprobes, all)
+ *
* Raise a BUG or we'll continue in an endless reentering loop
* and eventually a stack overflow.
*/
@@ -1114,10 +1117,9 @@ NOKPROBE_SYMBOL(longjmp_break_handler);
bool arch_within_kprobe_blacklist(unsigned long addr)
{
- return (addr >= (unsigned long)__kprobes_text_start &&
- addr < (unsigned long)__kprobes_text_end) ||
+ return (LINKTABLE_ADDR_WITHIN(kprobes, addr) ||
(addr >= (unsigned long)__entry_text_start &&
- addr < (unsigned long)__entry_text_end);
+ addr < (unsigned long)__entry_text_end));
}
int __init arch_init_kprobes(void)
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 74e4bf11f562..80a9f9106d2a 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -99,7 +99,6 @@ SECTIONS
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
- KPROBES_TEXT
ENTRY_TEXT
IRQENTRY_TEXT
*(.fixup)
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index f5ea98bd85d2..0438aab5cb58 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -24,7 +24,7 @@
* Following global variables are optional and may be unavailable on some
* architectures and/or kernel configurations.
* _text, _data
- * __kprobes_text_start, __kprobes_text_end
+ * LINKTABLE_START(kprobes), LINKTABLE_END(kprobes)
* __entry_text_start, __entry_text_end
* __ctors_start, __ctors_end
*/
@@ -35,7 +35,7 @@ extern char __init_begin[], __init_end[];
extern char _sinittext[], _einittext[];
extern char _end[];
extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[];
-extern char __kprobes_text_start[], __kprobes_text_end[];
+DECLARE_LINKTABLE_TEXT(char, kprobes);
extern char __entry_text_start[], __entry_text_end[];
extern char __start_rodata[], __end_rodata[];
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index c5fcac902cbe..f1420714a549 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -112,15 +112,6 @@
#define BRANCH_PROFILE()
#endif
-#ifdef CONFIG_KPROBES
-#define KPROBE_BLACKLIST() . = ALIGN(8); \
- VMLINUX_SYMBOL(__start_kprobe_blacklist) = .; \
- *(_kprobe_blacklist) \
- VMLINUX_SYMBOL(__stop_kprobe_blacklist) = .;
-#else
-#define KPROBE_BLACKLIST()
-#endif
-
#ifdef CONFIG_EVENT_TRACING
#define FTRACE_EVENTS() . = ALIGN(8); \
VMLINUX_SYMBOL(__start_ftrace_events) = .; \
@@ -433,12 +424,6 @@
*(.spinlock.text) \
VMLINUX_SYMBOL(__lock_text_end) = .;
-#define KPROBES_TEXT \
- ALIGN_FUNCTION(); \
- VMLINUX_SYMBOL(__kprobes_text_start) = .; \
- *(.kprobes.text) \
- VMLINUX_SYMBOL(__kprobes_text_end) = .;
-
#define ENTRY_TEXT \
ALIGN_FUNCTION(); \
VMLINUX_SYMBOL(__entry_text_start) = .; \
@@ -504,7 +489,6 @@
*(.init.rodata) \
FTRACE_EVENTS() \
TRACE_SYSCALLS() \
- KPROBE_BLACKLIST() \
MEM_DISCARD(init.rodata) \
CLK_OF_TABLES() \
RESERVEDMEM_OF_TABLES() \
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 00b042c49ccd..8e33fc1ffd3c 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -546,7 +546,8 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
/* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
#ifdef CONFIG_KPROBES
-# define __kprobes __attribute__((__section__(".kprobes.text")))
+#include <linux/sections.h>
+# define __kprobes __attribute__((__section__(SECTION_TBL(SECTION_TEXT, kprobes, all))))
# define nokprobe_inline __always_inline
#else
# define __kprobes
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 8f6849084248..544eb59cdbb9 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -42,8 +42,12 @@
#include <linux/ftrace.h>
#ifdef CONFIG_KPROBES
+#include <linux/tables.h>
#include <asm/kprobes.h>
+DECLARE_LINKTABLE_TEXT(char, kprobes);
+DECLARE_LINKTABLE_INIT_DATA(unsigned long, _kprobe_blacklist);
+
/* kprobe_status settings */
#define KPROBE_HIT_ACTIVE 0x00000001
#define KPROBE_HIT_SS 0x00000002
@@ -487,8 +491,7 @@ static inline int enable_jprobe(struct jprobe *jp)
* by using this macro.
*/
#define __NOKPROBE_SYMBOL(fname) \
-static unsigned long __used \
- __attribute__((section("_kprobe_blacklist"))) \
+static LINKTABLE_INIT_DATA(_kprobe_blacklist, all) \
_kbl_addr_##fname = (unsigned long)fname;
#define NOKPROBE_SYMBOL(fname) __NOKPROBE_SYMBOL(fname)
#else
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index d10ab6b9b5e0..d816c659f358 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1328,8 +1328,7 @@ out:
bool __weak arch_within_kprobe_blacklist(unsigned long addr)
{
/* The __kprobes marked functions and entry code must not be probed */
- return addr >= (unsigned long)__kprobes_text_start &&
- addr < (unsigned long)__kprobes_text_end;
+ return LINKTABLE_ADDR_WITHIN(kprobes, addr);
}
bool within_kprobe_blacklist(unsigned long addr)
@@ -2054,14 +2053,13 @@ NOKPROBE_SYMBOL(dump_kprobe);
* since a kprobe need not necessarily be at the beginning
* of a function.
*/
-static int __init populate_kprobe_blacklist(unsigned long *start,
- unsigned long *end)
+static int __init populate_kprobe_blacklist(void)
{
unsigned long *iter;
struct kprobe_blacklist_entry *ent;
unsigned long entry, offset = 0, size = 0;
- for (iter = start; iter < end; iter++) {
+ LINKTABLE_FOR_EACH(iter, _kprobe_blacklist) {
entry = arch_deref_entry_point((void *)*iter);
if (!kernel_text_address(entry) ||
@@ -2126,8 +2124,9 @@ static struct notifier_block kprobe_module_nb = {
};
/* Markers of _kprobe_blacklist section */
-extern unsigned long __start_kprobe_blacklist[];
-extern unsigned long __stop_kprobe_blacklist[];
+DEFINE_LINKTABLE_INIT_DATA(unsigned long, _kprobe_blacklist);
+/* Actual kprobes linker table */
+DEFINE_LINKTABLE_TEXT(char, kprobes);
static int __init init_kprobes(void)
{
@@ -2141,8 +2140,7 @@ static int __init init_kprobes(void)
raw_spin_lock_init(&(kretprobe_table_locks[i].lock));
}
- err = populate_kprobe_blacklist(__start_kprobe_blacklist,
- __stop_kprobe_blacklist);
+ err = populate_kprobe_blacklist();
if (err) {
pr_err("kprobes: failed to populate blacklist: %d\n", err);
pr_err("Please take care of using kprobes.\n");
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 48958d3cec9e..b0a8f519efb8 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -22,6 +22,7 @@
#include "../../include/generated/autoconf.h"
#include "../../include/linux/license.h"
#include "../../include/linux/export.h"
+#include "../../include/linux/sections.h"
/* Are we using CONFIG_MODVERSIONS? */
static int modversions = 0;
@@ -888,7 +889,7 @@ static void check_section(const char *modname, struct elf_info *elf,
#define DATA_SECTIONS ".data", ".data.rel"
#define TEXT_SECTIONS ".text", ".text.unlikely", ".sched.text", \
- ".kprobes.text"
+ SECTION_TBL(SECTION_TEXT, kprobes, all)
#define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \
".fixup", ".entry.text", ".exception.text", ".text.*", \
".coldtext"
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index e167592793a7..f37dac17f033 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -32,6 +32,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "../../include/linux/sections.h"
#ifndef EM_METAG
/* Remove this when these make it to the standard system elf.h. */
@@ -356,7 +357,7 @@ is_mcounted_section_name(char const *const txtname)
strcmp(".sched.text", txtname) == 0 ||
strcmp(".spinlock.text", txtname) == 0 ||
strcmp(".irqentry.text", txtname) == 0 ||
- strcmp(".kprobes.text", txtname) == 0 ||
+ strcmp(SECTION_TBL(SECTION_TEXT, kprobe, all), txtname) == 0 ||
strcmp(".text.unlikely", txtname) == 0;
}
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 96e2486a6fc4..63e13009dda9 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -134,7 +134,7 @@ my %text_sections = (
".sched.text" => 1,
".spinlock.text" => 1,
".irqentry.text" => 1,
- ".kprobes.text" => 1,
+ ".text.tbl.kprobes.all" => 1,
".text.unlikely" => 1,
);
--
2.7.0
[toc] | [prev] | [next] | [standalone]
| From | Russell King - ARM Linux <linux@arm.linux.org.uk> |
|---|---|
| Date | 2016-02-19 15:20 +0100 |
| Subject | Re: [RFC v2 7/7] kprobes: port to linker table |
| Message-ID | <r3U4y-6g5-25@gated-at.bofh.it> |
| In reply to | #1338203 |
On Fri, Feb 19, 2016 at 05:45:59AM -0800, Luis R. Rodriguez wrote: > kprobe makes use of two custom sections: > > type name begin end > init.data _kprobe_blacklist __start_kprobe_blacklist __stop_kprobe_blacklist > text .kprobes.text __kprobes_text_start __kprobes_text_end > > Port these to the linker table generic solution. This lets > us remove all the custom kprobe section declarations on the > linker script. I don't like this. You create this "table" thing, which you use for tables, and then you go and use it for something else - for kprobes text which is not a table. The kprobes text section is a section for text which is not kprobe-able. So, it seems to be a complete mis-nomer to me. Maybe you can explain the rationale here? -- RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
[toc] | [prev] | [next] | [standalone]
| From | "Luis R. Rodriguez" <mcgrof@suse.com> |
|---|---|
| Date | 2016-02-19 16:00 +0100 |
| Subject | Re: [RFC v2 7/7] kprobes: port to linker table |
| Message-ID | <r3UHh-6xJ-27@gated-at.bofh.it> |
| In reply to | #1338220 |
On Fri, Feb 19, 2016 at 02:15:11PM +0000, Russell King - ARM Linux wrote: > On Fri, Feb 19, 2016 at 05:45:59AM -0800, Luis R. Rodriguez wrote: > > kprobe makes use of two custom sections: > > > > type name begin end > > init.data _kprobe_blacklist __start_kprobe_blacklist __stop_kprobe_blacklist > > text .kprobes.text __kprobes_text_start __kprobes_text_end > > > > Port these to the linker table generic solution. This lets > > us remove all the custom kprobe section declarations on the > > linker script. > > I don't like this. You create this "table" thing, which you use for > tables, and then you go and use it for something else - for kprobes > text which is not a table. The kprobes text section is a section for > text which is not kprobe-able. No the thing about linker tables is its generalizing custom section solutions we have scattered all over the place. > So, it seems to be a complete mis-nomer to me. Maybe you can explain > the rationale here? Sure, so each custom section solution requires modifying the linker script. With linker tables we end up only with a few basic types of tables, a read-only, text, data, init init_data, etc. A linker table belongs to one of these. The linker table provides a means by which to describe explicitly what type of section you are using for your solution but also allows us to enable such custom solutions without furthering the custom linker script. Luis
[toc] | [prev] | [next] | [standalone]
| From | 平松雅巳 / HIRAMATU,MASAMI <masami.hiramatsu.pt@hitachi.com> |
|---|---|
| Date | 2016-02-22 02:40 +0100 |
| Subject | RE: [RFC v2 7/7] kprobes: port to linker table |
| Message-ID | <r4NDH-6z9-1@gated-at.bofh.it> |
| In reply to | #1338203 |
>From: Luis R. Rodriguez [mailto:mcgrof@kernel.org]
>
>kprobe makes use of two custom sections:
>
>type name begin end
>init.data _kprobe_blacklist __start_kprobe_blacklist __stop_kprobe_blacklist
>text .kprobes.text __kprobes_text_start __kprobes_text_end
>
>Port these to the linker table generic solution. This lets
>us remove all the custom kprobe section declarations on the
>linker script.
>
>Tested with CONFIG_KPROBES_SANITY_TEST, it passes with:
>
>Kprobe smoke test: started
>Kprobe smoke test: passed successfully
>
>Then tested CONFIG_SAMPLE_KPROBES on do_fork, and the
>kprobe bites and kicks as expected. Lastly tried registering
>a kprobe on a kprobe blacklisted symbol (NOKPROBE_SYMBOL()),
>and confirms that fails to work.
Could you also check to run the testcases by using ftracetest as below?
$ cd tools/testing/selftests/ftrace/
$ sudo ./ftracetest
And I'm not sure about linker table. Is that possible to support
__kprobes prefix, which moves the functions into kprobes.text?
Actually, I'm on the way to replacing __kprobes to NOKPROBE_SYMBOL
macro, since NOKPROBE_SYMBOL() doesn't effect the kernel text itself.
On x86, it is already replaced (see commit 820aede0209a), and same
work should be done on other archs. So, could you hold this after
that? I think we should remove .kprobes.text first and move to
linker table.
Thank you,
>
>Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
>---
> arch/arc/kernel/vmlinux.lds.S | 1 -
> arch/arm/kernel/entry-armv.S | 2 +-
> arch/arm/kernel/vmlinux.lds.S | 1 -
> arch/avr32/kernel/entry-avr32b.S | 4 ++--
> arch/avr32/kernel/vmlinux.lds.S | 1 -
> arch/blackfin/kernel/vmlinux.lds.S | 1 -
> arch/c6x/kernel/vmlinux.lds.S | 1 -
> arch/hexagon/kernel/vmlinux.lds.S | 1 -
> arch/ia64/kernel/jprobes.S | 2 +-
> arch/ia64/kernel/vmlinux.lds.S | 1 -
> arch/ia64/lib/flush.S | 4 ++--
> arch/metag/kernel/vmlinux.lds.S | 1 -
> arch/microblaze/kernel/vmlinux.lds.S | 1 -
> arch/mips/kernel/vmlinux.lds.S | 1 -
> arch/mn10300/kernel/vmlinux.lds.S | 1 -
> arch/nios2/kernel/vmlinux.lds.S | 1 -
> arch/openrisc/kernel/vmlinux.lds.S | 1 -
> arch/parisc/kernel/vmlinux.lds.S | 1 -
> arch/powerpc/include/asm/ppc_asm.h | 6 +++---
> arch/powerpc/kernel/vmlinux.lds.S | 1 -
> arch/s390/kernel/entry.S | 4 ++--
> arch/s390/kernel/kprobes.c | 2 +-
> arch/s390/kernel/mcount.S | 2 +-
> arch/s390/kernel/vmlinux.lds.S | 1 -
> arch/score/kernel/vmlinux.lds.S | 1 -
> arch/sh/kernel/vmlinux.lds.S | 1 -
> arch/sparc/kernel/vmlinux.lds.S | 1 -
> arch/sparc/mm/ultra.S | 2 +-
> arch/tile/kernel/vmlinux.lds.S | 1 -
> arch/x86/kernel/kprobes/core.c | 10 ++++++----
> arch/x86/kernel/vmlinux.lds.S | 1 -
> include/asm-generic/sections.h | 4 ++--
> include/asm-generic/vmlinux.lds.h | 16 ----------------
> include/linux/compiler.h | 3 ++-
> include/linux/kprobes.h | 7 +++++--
> kernel/kprobes.c | 16 +++++++---------
> scripts/mod/modpost.c | 3 ++-
> scripts/recordmcount.c | 3 ++-
> scripts/recordmcount.pl | 2 +-
> 39 files changed, 41 insertions(+), 72 deletions(-)
>
>diff --git a/arch/arc/kernel/vmlinux.lds.S b/arch/arc/kernel/vmlinux.lds.S
>index 894e696bddaa..52f23df2b9b6 100644
>--- a/arch/arc/kernel/vmlinux.lds.S
>+++ b/arch/arc/kernel/vmlinux.lds.S
>@@ -98,7 +98,6 @@ SECTIONS
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> *(.fixup)
> *(.gnu.warning)
> }
>diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
>index 3ce377f7251f..4959a83833fd 100644
>--- a/arch/arm/kernel/entry-armv.S
>+++ b/arch/arm/kernel/entry-armv.S
>@@ -83,7 +83,7 @@
> .endm
>
> #ifdef CONFIG_KPROBES
>- .section .kprobes.text,"ax",%progbits
>+ .section .text.tbl.kprobes.all,"ax",%progbits
> #else
> .text
> #endif
>diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
>index 8b60fde5ce48..8de7921ac331 100644
>--- a/arch/arm/kernel/vmlinux.lds.S
>+++ b/arch/arm/kernel/vmlinux.lds.S
>@@ -108,7 +108,6 @@ SECTIONS
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> *(.gnu.warning)
> *(.glue_7)
> *(.glue_7t)
>diff --git a/arch/avr32/kernel/entry-avr32b.S b/arch/avr32/kernel/entry-avr32b.S
>index 7301f4806bbe..c0fe699d0a21 100644
>--- a/arch/avr32/kernel/entry-avr32b.S
>+++ b/arch/avr32/kernel/entry-avr32b.S
>@@ -605,7 +605,7 @@ fault_exit_work:
> brcc fault_resume_user
> rjmp enter_monitor_mode
>
>- .section .kprobes.text, "ax", @progbits
>+ .section .text.tbl.kprobes.all, "ax", @progbits
> .type handle_debug, @function
> handle_debug:
> sub sp, 4 /* r12_orig */
>@@ -826,7 +826,7 @@ irq_level\level:
> IRQ_LEVEL 2
> IRQ_LEVEL 3
>
>- .section .kprobes.text, "ax", @progbits
>+ .section .text.tbl.kprobes.all, "ax", @progbits
> .type enter_monitor_mode, @function
> enter_monitor_mode:
> /*
>diff --git a/arch/avr32/kernel/vmlinux.lds.S b/arch/avr32/kernel/vmlinux.lds.S
>index a4589176bed5..bf4f3f1f9dbb 100644
>--- a/arch/avr32/kernel/vmlinux.lds.S
>+++ b/arch/avr32/kernel/vmlinux.lds.S
>@@ -49,7 +49,6 @@ SECTIONS
> _stext = .;
> *(.ex.text)
> *(.irq.text)
>- KPROBES_TEXT
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>diff --git a/arch/blackfin/kernel/vmlinux.lds.S b/arch/blackfin/kernel/vmlinux.lds.S
>index c9eec84aa258..8a193fad4c5d 100644
>--- a/arch/blackfin/kernel/vmlinux.lds.S
>+++ b/arch/blackfin/kernel/vmlinux.lds.S
>@@ -35,7 +35,6 @@ SECTIONS
> #endif
> LOCK_TEXT
> IRQENTRY_TEXT
>- KPROBES_TEXT
> #ifdef CONFIG_ROMKERNEL
> __sinittext = .;
> INIT_TEXT
>diff --git a/arch/c6x/kernel/vmlinux.lds.S b/arch/c6x/kernel/vmlinux.lds.S
>index 5a6e141d1641..a23bed62cec3 100644
>--- a/arch/c6x/kernel/vmlinux.lds.S
>+++ b/arch/c6x/kernel/vmlinux.lds.S
>@@ -72,7 +72,6 @@ SECTIONS
> SCHED_TEXT
> LOCK_TEXT
> IRQENTRY_TEXT
>- KPROBES_TEXT
> *(.fixup)
> *(.gnu.warning)
> }
>diff --git a/arch/hexagon/kernel/vmlinux.lds.S b/arch/hexagon/kernel/vmlinux.lds.S
>index 5f268c1071b3..a358b699ec64 100644
>--- a/arch/hexagon/kernel/vmlinux.lds.S
>+++ b/arch/hexagon/kernel/vmlinux.lds.S
>@@ -51,7 +51,6 @@ SECTIONS
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> *(.fixup)
> }
> _etext = .;
>diff --git a/arch/ia64/kernel/jprobes.S b/arch/ia64/kernel/jprobes.S
>index f69389c7be1d..c6c23a3e92fb 100644
>--- a/arch/ia64/kernel/jprobes.S
>+++ b/arch/ia64/kernel/jprobes.S
>@@ -50,7 +50,7 @@
> /*
> * void jprobe_break(void)
> */
>- .section .kprobes.text, "ax"
>+ .section .text.tbl.kprobes.all, "ax"
> ENTRY(jprobe_break)
> break.m __IA64_BREAK_JPROBE
> END(jprobe_break)
>diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
>index dc506b05ffbd..884f36d38989 100644
>--- a/arch/ia64/kernel/vmlinux.lds.S
>+++ b/arch/ia64/kernel/vmlinux.lds.S
>@@ -47,7 +47,6 @@ SECTIONS {
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> *(.gnu.linkonce.t*)
> }
>
>diff --git a/arch/ia64/lib/flush.S b/arch/ia64/lib/flush.S
>index 1d8c88860063..7f257810e858 100644
>--- a/arch/ia64/lib/flush.S
>+++ b/arch/ia64/lib/flush.S
>@@ -20,7 +20,7 @@
> *
> * Note: "in0" and "in1" are preserved for debugging purposes.
> */
>- .section .kprobes.text,"ax"
>+ .section .text.tbl.kprobes.all,"ax"
> GLOBAL_ENTRY(flush_icache_range)
>
> .prologue
>@@ -72,7 +72,7 @@ END(flush_icache_range)
> *
> * Note: "in0" and "in1" are preserved for debugging purposes.
> */
>- .section .kprobes.text,"ax"
>+ .section .text.tbl.kprobes.all,"ax"
> GLOBAL_ENTRY(clflush_cache_range)
>
> .prologue
>diff --git a/arch/metag/kernel/vmlinux.lds.S b/arch/metag/kernel/vmlinux.lds.S
>index e12055e88bfe..da1689c85bc8 100644
>--- a/arch/metag/kernel/vmlinux.lds.S
>+++ b/arch/metag/kernel/vmlinux.lds.S
>@@ -22,7 +22,6 @@ SECTIONS
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> IRQENTRY_TEXT
> *(.text.*)
> *(.gnu.warning)
>diff --git a/arch/microblaze/kernel/vmlinux.lds.S b/arch/microblaze/kernel/vmlinux.lds.S
>index be9488d69734..94c1c5574a77 100644
>--- a/arch/microblaze/kernel/vmlinux.lds.S
>+++ b/arch/microblaze/kernel/vmlinux.lds.S
>@@ -34,7 +34,6 @@ SECTIONS {
> EXIT_CALL
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> IRQENTRY_TEXT
> . = ALIGN (4) ;
> _etext = . ;
>diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
>index 0a93e83cd014..9183e9235651 100644
>--- a/arch/mips/kernel/vmlinux.lds.S
>+++ b/arch/mips/kernel/vmlinux.lds.S
>@@ -56,7 +56,6 @@ SECTIONS
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> IRQENTRY_TEXT
> *(.text.*)
> *(.fixup)
>diff --git a/arch/mn10300/kernel/vmlinux.lds.S b/arch/mn10300/kernel/vmlinux.lds.S
>index 13c4814c29f8..ead5efc01802 100644
>--- a/arch/mn10300/kernel/vmlinux.lds.S
>+++ b/arch/mn10300/kernel/vmlinux.lds.S
>@@ -31,7 +31,6 @@ SECTIONS
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> *(.fixup)
> *(.gnu.warning)
> } = 0xcb
>diff --git a/arch/nios2/kernel/vmlinux.lds.S b/arch/nios2/kernel/vmlinux.lds.S
>index 326fab40a9de..dc8a84183700 100644
>--- a/arch/nios2/kernel/vmlinux.lds.S
>+++ b/arch/nios2/kernel/vmlinux.lds.S
>@@ -39,7 +39,6 @@ SECTIONS
> SCHED_TEXT
> LOCK_TEXT
> IRQENTRY_TEXT
>- KPROBES_TEXT
> } =0
> _etext = .;
>
>diff --git a/arch/openrisc/kernel/vmlinux.lds.S b/arch/openrisc/kernel/vmlinux.lds.S
>index 2d69a853b742..b010cb75edc4 100644
>--- a/arch/openrisc/kernel/vmlinux.lds.S
>+++ b/arch/openrisc/kernel/vmlinux.lds.S
>@@ -48,7 +48,6 @@ SECTIONS
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> IRQENTRY_TEXT
> *(.fixup)
> *(.text.__*)
>diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
>index 308f29081d46..9d9dc4984465 100644
>--- a/arch/parisc/kernel/vmlinux.lds.S
>+++ b/arch/parisc/kernel/vmlinux.lds.S
>@@ -70,7 +70,6 @@ SECTIONS
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> IRQENTRY_TEXT
> *(.text.do_softirq)
> *(.text.sys_exit)
>diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
>index 499d9f89435a..4e36e86338f3 100644
>--- a/arch/powerpc/include/asm/ppc_asm.h
>+++ b/arch/powerpc/include/asm/ppc_asm.h
>@@ -218,7 +218,7 @@ name: \
> .localentry name,.-name
>
> #define _KPROBE(name) \
>- .section ".kprobes.text","a"; \
>+ .section ".text.tbl.kprobes.all","a"; \
> .align 2 ; \
> .type name,@function; \
> .globl name; \
>@@ -248,7 +248,7 @@ GLUE(.,name):
> #define _GLOBAL_TOC(name) _GLOBAL(name)
>
> #define _KPROBE(name) \
>- .section ".kprobes.text","a"; \
>+ .section ".text.tbl.kprobes.all","a"; \
> .align 2 ; \
> .globl name; \
> .globl GLUE(.,name); \
>@@ -280,7 +280,7 @@ n:
> #define _GLOBAL_TOC(name) _GLOBAL(name)
>
> #define _KPROBE(n) \
>- .section ".kprobes.text","a"; \
>+ .section ".text.tbl.kprobes.all","a"; \
> .globl n; \
> n:
>
>diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
>index d41fd0af8980..8779ae180783 100644
>--- a/arch/powerpc/kernel/vmlinux.lds.S
>+++ b/arch/powerpc/kernel/vmlinux.lds.S
>@@ -53,7 +53,6 @@ SECTIONS
> *(.text .fixup __ftr_alt_* .ref.text)
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> IRQENTRY_TEXT
>
> #ifdef CONFIG_PPC32
>diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
>index cd5a191381b9..b09aa9ab5a1f 100644
>--- a/arch/s390/kernel/entry.S
>+++ b/arch/s390/kernel/entry.S
>@@ -162,7 +162,7 @@ _PIF_WORK = (_PIF_PER_TRAP)
> tm off+\addr, \mask
> .endm
>
>- .section .kprobes.text, "ax"
>+ .section .text.tbl.kprobes.all, "ax"
>
> /*
> * Scheduler resume function, called by switch_to
>@@ -965,7 +965,7 @@ ENTRY(restart_int_handler)
> brc 2,2b
> 3: j 3b
>
>- .section .kprobes.text, "ax"
>+ .section .text.tbl.kprobes.all, "ax"
>
> #ifdef CONFIG_CHECK_STACK
> /*
>diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
>index 250f5972536a..376d4bd487c5 100644
>--- a/arch/s390/kernel/kprobes.c
>+++ b/arch/s390/kernel/kprobes.c
>@@ -288,7 +288,7 @@ static void kprobe_reenter_check(struct kprobe_ctlblk *kcb, struct kprobe *p)
> default:
> /*
> * A kprobe on the code path to single step an instruction
>- * is a BUG. The code path resides in the .kprobes.text
>+ * is a BUG. The code path resides in the .text.tbl.kprobes.all
> * section and is executed with interrupts disabled.
> */
> printk(KERN_EMERG "Invalid kprobe detected at %p.\n", p->addr);
>diff --git a/arch/s390/kernel/mcount.S b/arch/s390/kernel/mcount.S
>index e499370fbccb..4572045b968e 100644
>--- a/arch/s390/kernel/mcount.S
>+++ b/arch/s390/kernel/mcount.S
>@@ -10,7 +10,7 @@
> #include <asm/ftrace.h>
> #include <asm/ptrace.h>
>
>- .section .kprobes.text, "ax"
>+ .section .text.tbl.kprobes.all, "ax"
>
> ENTRY(ftrace_stub)
> br %r14
>diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S
>index 445657fe658c..4614b5bcab5e 100644
>--- a/arch/s390/kernel/vmlinux.lds.S
>+++ b/arch/s390/kernel/vmlinux.lds.S
>@@ -26,7 +26,6 @@ SECTIONS
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> IRQENTRY_TEXT
> *(.fixup)
> *(.gnu.warning)
>diff --git a/arch/score/kernel/vmlinux.lds.S b/arch/score/kernel/vmlinux.lds.S
>index 7274b5c4287e..36ebcb3b1215 100644
>--- a/arch/score/kernel/vmlinux.lds.S
>+++ b/arch/score/kernel/vmlinux.lds.S
>@@ -41,7 +41,6 @@ SECTIONS
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> *(.text.*)
> *(.fixup)
> . = ALIGN (4) ;
>diff --git a/arch/sh/kernel/vmlinux.lds.S b/arch/sh/kernel/vmlinux.lds.S
>index db88cbf9eafd..af4f37375345 100644
>--- a/arch/sh/kernel/vmlinux.lds.S
>+++ b/arch/sh/kernel/vmlinux.lds.S
>@@ -37,7 +37,6 @@ SECTIONS
> EXTRA_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> IRQENTRY_TEXT
> *(.fixup)
> *(.gnu.warning)
>diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S
>index f1a2f688b28a..a1c8e3a3ebb6 100644
>--- a/arch/sparc/kernel/vmlinux.lds.S
>+++ b/arch/sparc/kernel/vmlinux.lds.S
>@@ -46,7 +46,6 @@ SECTIONS
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> IRQENTRY_TEXT
> *(.gnu.warning)
> } = 0
>diff --git a/arch/sparc/mm/ultra.S b/arch/sparc/mm/ultra.S
>index b4f4733abc6e..a08fb40656ac 100644
>--- a/arch/sparc/mm/ultra.S
>+++ b/arch/sparc/mm/ultra.S
>@@ -148,7 +148,7 @@ __spitfire_flush_tlb_mm_slow:
> /*
> * The following code flushes one page_size worth.
> */
>- .section .kprobes.text, "ax"
>+ .section .text.tbl.kprobes.all, "ax"
> .align 32
> .globl __flush_icache_page
> __flush_icache_page: /* %o0 = phys_page */
>diff --git a/arch/tile/kernel/vmlinux.lds.S b/arch/tile/kernel/vmlinux.lds.S
>index 0e059a0101ea..0f04268fc394 100644
>--- a/arch/tile/kernel/vmlinux.lds.S
>+++ b/arch/tile/kernel/vmlinux.lds.S
>@@ -43,7 +43,6 @@ SECTIONS
> HEAD_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> IRQENTRY_TEXT
> __fix_text_end = .; /* tile-cpack won't rearrange before this */
> ALIGN_FUNCTION();
>diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
>index 1deffe6cc873..dde4ec0e0185 100644
>--- a/arch/x86/kernel/kprobes/core.c
>+++ b/arch/x86/kernel/kprobes/core.c
>@@ -577,7 +577,10 @@ static int reenter_kprobe(struct kprobe *p, struct pt_regs *regs,
> case KPROBE_REENTER:
> /* A probe has been hit in the codepath leading up to, or just
> * after, single-stepping of a probed instruction. This entire
>- * codepath should strictly reside in .kprobes.text section.
>+ * codepath should strictly reside in the kprobes section:
>+ *
>+ * SECTION_TBL(SECTION_TEXT, kprobes, all)
>+ *
> * Raise a BUG or we'll continue in an endless reentering loop
> * and eventually a stack overflow.
> */
>@@ -1114,10 +1117,9 @@ NOKPROBE_SYMBOL(longjmp_break_handler);
>
> bool arch_within_kprobe_blacklist(unsigned long addr)
> {
>- return (addr >= (unsigned long)__kprobes_text_start &&
>- addr < (unsigned long)__kprobes_text_end) ||
>+ return (LINKTABLE_ADDR_WITHIN(kprobes, addr) ||
> (addr >= (unsigned long)__entry_text_start &&
>- addr < (unsigned long)__entry_text_end);
>+ addr < (unsigned long)__entry_text_end));
> }
>
> int __init arch_init_kprobes(void)
>diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
>index 74e4bf11f562..80a9f9106d2a 100644
>--- a/arch/x86/kernel/vmlinux.lds.S
>+++ b/arch/x86/kernel/vmlinux.lds.S
>@@ -99,7 +99,6 @@ SECTIONS
> TEXT_TEXT
> SCHED_TEXT
> LOCK_TEXT
>- KPROBES_TEXT
> ENTRY_TEXT
> IRQENTRY_TEXT
> *(.fixup)
>diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
>index f5ea98bd85d2..0438aab5cb58 100644
>--- a/include/asm-generic/sections.h
>+++ b/include/asm-generic/sections.h
>@@ -24,7 +24,7 @@
> * Following global variables are optional and may be unavailable on some
> * architectures and/or kernel configurations.
> * _text, _data
>- * __kprobes_text_start, __kprobes_text_end
>+ * LINKTABLE_START(kprobes), LINKTABLE_END(kprobes)
> * __entry_text_start, __entry_text_end
> * __ctors_start, __ctors_end
> */
>@@ -35,7 +35,7 @@ extern char __init_begin[], __init_end[];
> extern char _sinittext[], _einittext[];
> extern char _end[];
> extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[];
>-extern char __kprobes_text_start[], __kprobes_text_end[];
>+DECLARE_LINKTABLE_TEXT(char, kprobes);
> extern char __entry_text_start[], __entry_text_end[];
> extern char __start_rodata[], __end_rodata[];
>
>diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
>index c5fcac902cbe..f1420714a549 100644
>--- a/include/asm-generic/vmlinux.lds.h
>+++ b/include/asm-generic/vmlinux.lds.h
>@@ -112,15 +112,6 @@
> #define BRANCH_PROFILE()
> #endif
>
>-#ifdef CONFIG_KPROBES
>-#define KPROBE_BLACKLIST() . = ALIGN(8); \
>- VMLINUX_SYMBOL(__start_kprobe_blacklist) = .; \
>- *(_kprobe_blacklist) \
>- VMLINUX_SYMBOL(__stop_kprobe_blacklist) = .;
>-#else
>-#define KPROBE_BLACKLIST()
>-#endif
>-
> #ifdef CONFIG_EVENT_TRACING
> #define FTRACE_EVENTS() . = ALIGN(8); \
> VMLINUX_SYMBOL(__start_ftrace_events) = .; \
>@@ -433,12 +424,6 @@
> *(.spinlock.text) \
> VMLINUX_SYMBOL(__lock_text_end) = .;
>
>-#define KPROBES_TEXT \
>- ALIGN_FUNCTION(); \
>- VMLINUX_SYMBOL(__kprobes_text_start) = .; \
>- *(.kprobes.text) \
>- VMLINUX_SYMBOL(__kprobes_text_end) = .;
>-
> #define ENTRY_TEXT \
> ALIGN_FUNCTION(); \
> VMLINUX_SYMBOL(__entry_text_start) = .; \
>@@ -504,7 +489,6 @@
> *(.init.rodata) \
> FTRACE_EVENTS() \
> TRACE_SYSCALLS() \
>- KPROBE_BLACKLIST() \
> MEM_DISCARD(init.rodata) \
> CLK_OF_TABLES() \
> RESERVEDMEM_OF_TABLES() \
>diff --git a/include/linux/compiler.h b/include/linux/compiler.h
>index 00b042c49ccd..8e33fc1ffd3c 100644
>--- a/include/linux/compiler.h
>+++ b/include/linux/compiler.h
>@@ -546,7 +546,8 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
>
> /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
> #ifdef CONFIG_KPROBES
>-# define __kprobes __attribute__((__section__(".kprobes.text")))
>+#include <linux/sections.h>
>+# define __kprobes __attribute__((__section__(SECTION_TBL(SECTION_TEXT, kprobes, all))))
> # define nokprobe_inline __always_inline
> #else
> # define __kprobes
>diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
>index 8f6849084248..544eb59cdbb9 100644
>--- a/include/linux/kprobes.h
>+++ b/include/linux/kprobes.h
>@@ -42,8 +42,12 @@
> #include <linux/ftrace.h>
>
> #ifdef CONFIG_KPROBES
>+#include <linux/tables.h>
> #include <asm/kprobes.h>
>
>+DECLARE_LINKTABLE_TEXT(char, kprobes);
>+DECLARE_LINKTABLE_INIT_DATA(unsigned long, _kprobe_blacklist);
>+
> /* kprobe_status settings */
> #define KPROBE_HIT_ACTIVE 0x00000001
> #define KPROBE_HIT_SS 0x00000002
>@@ -487,8 +491,7 @@ static inline int enable_jprobe(struct jprobe *jp)
> * by using this macro.
> */
> #define __NOKPROBE_SYMBOL(fname) \
>-static unsigned long __used \
>- __attribute__((section("_kprobe_blacklist"))) \
>+static LINKTABLE_INIT_DATA(_kprobe_blacklist, all) \
> _kbl_addr_##fname = (unsigned long)fname;
> #define NOKPROBE_SYMBOL(fname) __NOKPROBE_SYMBOL(fname)
> #else
>diff --git a/kernel/kprobes.c b/kernel/kprobes.c
>index d10ab6b9b5e0..d816c659f358 100644
>--- a/kernel/kprobes.c
>+++ b/kernel/kprobes.c
>@@ -1328,8 +1328,7 @@ out:
> bool __weak arch_within_kprobe_blacklist(unsigned long addr)
> {
> /* The __kprobes marked functions and entry code must not be probed */
>- return addr >= (unsigned long)__kprobes_text_start &&
>- addr < (unsigned long)__kprobes_text_end;
>+ return LINKTABLE_ADDR_WITHIN(kprobes, addr);
> }
>
> bool within_kprobe_blacklist(unsigned long addr)
>@@ -2054,14 +2053,13 @@ NOKPROBE_SYMBOL(dump_kprobe);
> * since a kprobe need not necessarily be at the beginning
> * of a function.
> */
>-static int __init populate_kprobe_blacklist(unsigned long *start,
>- unsigned long *end)
>+static int __init populate_kprobe_blacklist(void)
> {
> unsigned long *iter;
> struct kprobe_blacklist_entry *ent;
> unsigned long entry, offset = 0, size = 0;
>
>- for (iter = start; iter < end; iter++) {
>+ LINKTABLE_FOR_EACH(iter, _kprobe_blacklist) {
> entry = arch_deref_entry_point((void *)*iter);
>
> if (!kernel_text_address(entry) ||
>@@ -2126,8 +2124,9 @@ static struct notifier_block kprobe_module_nb = {
> };
>
> /* Markers of _kprobe_blacklist section */
>-extern unsigned long __start_kprobe_blacklist[];
>-extern unsigned long __stop_kprobe_blacklist[];
>+DEFINE_LINKTABLE_INIT_DATA(unsigned long, _kprobe_blacklist);
>+/* Actual kprobes linker table */
>+DEFINE_LINKTABLE_TEXT(char, kprobes);
>
> static int __init init_kprobes(void)
> {
>@@ -2141,8 +2140,7 @@ static int __init init_kprobes(void)
> raw_spin_lock_init(&(kretprobe_table_locks[i].lock));
> }
>
>- err = populate_kprobe_blacklist(__start_kprobe_blacklist,
>- __stop_kprobe_blacklist);
>+ err = populate_kprobe_blacklist();
> if (err) {
> pr_err("kprobes: failed to populate blacklist: %d\n", err);
> pr_err("Please take care of using kprobes.\n");
>diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
>index 48958d3cec9e..b0a8f519efb8 100644
>--- a/scripts/mod/modpost.c
>+++ b/scripts/mod/modpost.c
>@@ -22,6 +22,7 @@
> #include "../../include/generated/autoconf.h"
> #include "../../include/linux/license.h"
> #include "../../include/linux/export.h"
>+#include "../../include/linux/sections.h"
>
> /* Are we using CONFIG_MODVERSIONS? */
> static int modversions = 0;
>@@ -888,7 +889,7 @@ static void check_section(const char *modname, struct elf_info *elf,
>
> #define DATA_SECTIONS ".data", ".data.rel"
> #define TEXT_SECTIONS ".text", ".text.unlikely", ".sched.text", \
>- ".kprobes.text"
>+ SECTION_TBL(SECTION_TEXT, kprobes, all)
> #define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \
> ".fixup", ".entry.text", ".exception.text", ".text.*", \
> ".coldtext"
>diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
>index e167592793a7..f37dac17f033 100644
>--- a/scripts/recordmcount.c
>+++ b/scripts/recordmcount.c
>@@ -32,6 +32,7 @@
> #include <stdlib.h>
> #include <string.h>
> #include <unistd.h>
>+#include "../../include/linux/sections.h"
>
> #ifndef EM_METAG
> /* Remove this when these make it to the standard system elf.h. */
>@@ -356,7 +357,7 @@ is_mcounted_section_name(char const *const txtname)
> strcmp(".sched.text", txtname) == 0 ||
> strcmp(".spinlock.text", txtname) == 0 ||
> strcmp(".irqentry.text", txtname) == 0 ||
>- strcmp(".kprobes.text", txtname) == 0 ||
>+ strcmp(SECTION_TBL(SECTION_TEXT, kprobe, all), txtname) == 0 ||
> strcmp(".text.unlikely", txtname) == 0;
> }
>
>diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
>index 96e2486a6fc4..63e13009dda9 100755
>--- a/scripts/recordmcount.pl
>+++ b/scripts/recordmcount.pl
>@@ -134,7 +134,7 @@ my %text_sections = (
> ".sched.text" => 1,
> ".spinlock.text" => 1,
> ".irqentry.text" => 1,
>- ".kprobes.text" => 1,
>+ ".text.tbl.kprobes.all" => 1,
> ".text.unlikely" => 1,
> );
>
>--
>2.7.0
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-02-19 21:30 +0100 |
| Message-ID | <r3ZQC-2mP-15@gated-at.bofh.it> |
| In reply to | #1338193 |
On 02/19/2016 05:45 AM, Luis R. Rodriguez wrote: > This is my v2 of the original linker table work [0], now with > six proof of concepts ports of existing code using custom section > with custom linker script modifications: > > * DEFINE_LINKTABLE_TEXT(char, kprobes); > * DEFINE_LINKTABLE_DATA(struct jump_entry, __jump_table); > * DEFINE_LINKTABLE_DATA(struct _ddebug, __verbose); > * DEFINE_LINKTABLE_RO(struct builtin_fw, builtin_fw); > * DEFINE_LINKTABLE_INIT(struct x86_init_fn, x86_init_fns); > * DEFINE_LINKTABLE_INIT_DATA(unsigned long, _kprobe_blacklist); > > I've tested all except jump tables, I'd appreaciate some help with that. > We should add support for read-mostly, probably. In fact, some of these probably *are* read-mostly. -hpa
[toc] | [prev] | [next] | [standalone]
| From | "Luis R. Rodriguez" <mcgrof@kernel.org> |
|---|---|
| Date | 2016-02-19 22:30 +0100 |
| Message-ID | <r40MG-332-35@gated-at.bofh.it> |
| In reply to | #1338439 |
On Fri, Feb 19, 2016 at 12:16:29PM -0800, H. Peter Anvin wrote: > On 02/19/2016 05:45 AM, Luis R. Rodriguez wrote: > > This is my v2 of the original linker table work [0], now with > > six proof of concepts ports of existing code using custom section > > with custom linker script modifications: > > > > * DEFINE_LINKTABLE_TEXT(char, kprobes); > > * DEFINE_LINKTABLE_DATA(struct jump_entry, __jump_table); > > * DEFINE_LINKTABLE_DATA(struct _ddebug, __verbose); > > * DEFINE_LINKTABLE_RO(struct builtin_fw, builtin_fw); > > * DEFINE_LINKTABLE_INIT(struct x86_init_fn, x86_init_fns); > > * DEFINE_LINKTABLE_INIT_DATA(unsigned long, _kprobe_blacklist); > > > > I've tested all except jump tables, I'd appreaciate some help with that. > > > > We should add support for read-mostly, probably. Sure, any candidate in mind? I actually don't see any hacks built on top of READ_MOSTLY_DATA include/asm-generic/vmlinux.lds.h so pointers appreciated for a case I could try. > In fact, some of these probably *are* read-mostly. To avoid regressions I made sure to use the same exact section that these original solutions came from, do we want to move some? If so I think perhaps that's best done as a separate atomic patch and it may be easier to read and review once ported on linker tables? Luis
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2016-02-19 21:40 +0100 |
| Subject | Re: [RFC v2 2/7] tables.h: add linker table support |
| Message-ID | <r400h-2qQ-7@gated-at.bofh.it> |
| In reply to | #1338193 |
On 02/19/2016 05:45 AM, Luis R. Rodriguez wrote: > + > +/** > + * DOC: Regular linker linker table constructors > + * > + * Regular constructors are expected to be used for valid linker table entries. > + * Valid uses of weak entries other than the beginning and is currently > + * untested but should in theory work. > + */ > + > +/** > + * LINKTABLE_TEXT - Declares a linker table entry for execution > + * > + * @name: linker table name > + * @level: order level > + * > + * Declares a linker table to be used for execution. > + */ > +#define LINKTABLE_TEXT(name, level) \ > + __typeof__(name[0]) \ > + __attribute__((used, \ > + __aligned__(LINKTABLE_ALIGNMENT(name)), \ > + section(SECTION_TBL(SECTION_TEXT, name, level)))) I'm really confused by this. Text should obviously be readonly, but I'm not at all clear how this works here. The issue with linktables for text is kind of confusing if nothing else; Russel is right about that. It doesn't prevent us from doing something similar, but perhaps it ought to have a different name. For one thing, priority level is meaningless for text, since it is not a table that can be indexed into. -hpa
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web