linux: generalize sections, ranges and linker tables
Subsystems (32)
Luis R. Rodriguez
maintainerPATCH v7 8/14 jump_label: move guard #endif down where it belongs
In reply to Luis R. RodriguezThe ending header guard is misplaced. This has no
functional change, this is just an eye-sore.
--- include/linux/jump_label.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/jump_label.h +2 -2
@@ -402,6 +402,6 @@ extern bool ____wrong_branch_error(void);#define static_branch_enable (x) static_key_enable(&(x)->key)#define static_branch_disable (x) static_key_disable(&(x)->key) -#endif /* _LINUX_JUMP_LABEL_H */ -#endif /* __ASSEMBLY__ */ + +#endif /* _LINUX_JUMP_LABEL_H */
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerPATCH v7 9/14 jump_label: port __jump_table to linker tables
In reply to Luis R. RodriguezMove 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 linker table and of the shared asm call push_section_tbl().
Built-in kernel functionality was tested with CONFIG_STATIC_KEYS_SELFTEST. Moduler kernel functionality was tested with CONFIG_TEST_STATIC_KEYS. Both work as expected.
Since __jump_table sections are also supported per module this also required expanding module-common.lds.S to capture and fold all .data.tlb.__jump_table.* onto the the section __jump_table -- in this case for modules need to keep a reference in place, given the alternative is to use DEFINE_LINKTABLE(struct jump_entry, __jump_table) per module -- and later through macro hacks instantiate the jump entries per module upon init. This is doable but we'd loose out on the sorting of the table using the linker, to sort we'd always still need to expand the module common linker script. An alternative mechanism is possible which would make these custom module sections extensions dynamic without requiring manual changes, this however is best done later through a separate evolution once linker tables are in place.
A careful reviewer may note that some architectures use "\n\t" to separate asm code, while others just use a new line. Upon review last time it was deemed reasonable to for all architectures to just use "\n", this is defined as ASM_CMD_SEP, and if an architecture needs to override they can do so on their architecture sections.h prior to including asm-generic/sections.h
v6: rename table macro as suggested by Andy Shevchenko
v5:
o Use ..tbl instead of .tbl as suggested by Nicholas Piggin. This is the typical way to avoid clash with compiler generated section.
o Replace section macros with section names
o Use LINKTABLE_START() and LINKTABLE_END()
o fixed tile jump label port -- tile got jump label support as of commit 65a792e84f25d1 ("tile/jump_label: add jump label support for TILE-Gx"), as such we just needed to adjust the asm to account for the new linker table API use. This commit was merged as of v4.5-rc1.
v4:
o Some architectures allow linker scripts to follow including header files, some others do not, so if you need a helper on a linker script you need to explicitly include it. So for instance although scripts/module-common.lds.S includes <asm/tables.h> and this file includes <asm/section-core.h>, you still need to explicitly include it on the linker script. This issue is present on ARM.
o as per Josh Poimboeuf open code the section table name instead of including the kernel section headers, the simplicity and independence from the kernel is preferred.
v3:
o More elaborate tests performed
o first modular support use case, module tested was CONFIG_TEST_STATIC_KEYS (lib/test_static_keys.ko), this required us to extend module-common.lds.S
o use generic push_section_tbl_any() for all architectures
o Makes use of ASM_CMD_SEP to enable architectures to override later if needed
o guard tables.h inclusion and table definition with __KERNEL__
v2: introduced in this series
--- arch/arm/include/asm/jump_label.h | 6 ++++-- arch/arm64/include/asm/jump_label.h | 6 ++++-- arch/mips/include/asm/jump_label.h | 6 ++++-- arch/powerpc/include/asm/jump_label.h | 8 +++++--- arch/s390/include/asm/jump_label.h | 6 ++++-- arch/sparc/include/asm/jump_label.h | 6 ++++-- arch/tile/include/asm/jump_label.h | 5 +++-- arch/x86/include/asm/jump_label.h | 10 ++++++---- include/asm-generic/vmlinux.lds.h | 5 ----- include/linux/jump_label.h | 4 ++-- kernel/jump_label.c | 17 ++++++++++------- scripts/module-common.lds | 1 + tools/objtool/special.c | 2 +- 13 files changed, 48 insertions(+), 34 deletions(-)
arch/arm/include/asm/jump_label.h +4 -2
@@ -1,6 +1,8 @@#ifndef _ASM_ARM_JUMP_LABEL_H#define _ASM_ARM_JUMP_LABEL_H +#include <asm/tables.h> +#ifndef __ASSEMBLY__#include <linux/types.h>
@@ -12,7 +14,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_any(.data, __jump_table, aw) ".word 1b, %l[l_yes], %c0\n\t" ".popsection\n\t" : : "i" (&((char *)key)[branch]) : : l_yes);
@@ -26,7 +28,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_any(.data, __jump_table, aw) ".word 1b, %l[l_yes], %c0\n\t" ".popsection\n\t" : : "i" (&((char *)key)[branch]) : : l_yes);
arch/arm64/include/asm/jump_label.h +4 -2
@@ -19,6 +19,8 @@#ifndef __ASM_JUMP_LABEL_H#define __ASM_JUMP_LABEL_H +#include <asm/tables.h> +#ifndef __ASSEMBLY__#include <linux/types.h>
@@ -29,7 +31,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_any(.data, __jump_table, aw)".align 3\n\t" ".quad 1b, %l[l_yes], %c0\n\t" ".popsection\n\t"
@@ -43,7 +45,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran 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_any(.data, __jump_table, aw)".align 3\n\t" ".quad 1b, %l[l_yes], %c0\n\t" ".popsection\n\t"
arch/mips/include/asm/jump_label.h +4 -2
@@ -8,6 +8,8 @@#ifndef _ASM_MIPS_JUMP_LABEL_H#define _ASM_MIPS_JUMP_LABEL_H +#include <asm/tables.h> +#ifndef __ASSEMBLY__#include <linux/types.h>
@@ -30,7 +32,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_any(.data, __jump_table, aw) WORD_INSN " 1b, %l[l_yes], %0\n\t" ".popsection\n\t" : : "i" (&((char *)key)[branch]) : : l_yes);
@@ -44,7 +46,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_any(.data, __jump_table, aw) WORD_INSN " 1b, %l[l_yes], %0\n\t" ".popsection\n\t" : : "i" (&((char *)key)[branch]) : : l_yes);
arch/powerpc/include/asm/jump_label.h +5 -3
@@ -10,6 +10,8 @@* 2 of the License, or (at your option) any later version. */ +#include <asm/tables.h> +#ifndef __ASSEMBLY__#include <linux/types.h>
@@ -23,7 +25,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran { asm_volatile_goto("1:\n\t" "nop # arch_static_branch\n\t" - ".pushsection __jump_table, \"aw\"\n\t" + push_section_tbl_any(.data, __jump_table, aw) JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t" ".popsection \n\t" : : "i" (&((char *)key)[branch]) : : l_yes);
@@ -37,7 +39,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool { asm_volatile_goto("1:\n\t" "b %l[l_yes] # arch_static_branch_jump\n\t" - ".pushsection __jump_table, \"aw\"\n\t" + push_section_tbl_any(.data, __jump_table, aw) JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t" ".popsection \n\t" : : "i" (&((char *)key)[branch]) : : l_yes);
@@ -62,7 +64,7 @@ struct jump_entry {#else #define ARCH_STATIC_BRANCH (LABEL ,KEY ) \ 1098: nop; \ - .pushsection __jump_table, "aw"; \ + push_section_tbl_any(.data, __jump_table, aw); \ FTR_ENTRY_LONG 1098b, LABEL, KEY; \ .popsection#endif
arch/s390/include/asm/jump_label.h +4 -2
@@ -1,6 +1,8 @@#ifndef _ASM_S390_JUMP_LABEL_H#define _ASM_S390_JUMP_LABEL_H +#include <asm/tables.h> +#ifndef __ASSEMBLY__#include <linux/types.h>
@@ -16,7 +18,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" + push_section_tbl_any(.data, __jump_table, aw)".balign 8\n" ".quad 0b, %l[label], %0\n" ".popsection\n"
@@ -30,7 +32,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran 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" + push_section_tbl_any(.data, __jump_table, aw)".balign 8\n" ".quad 0b, %l[label], %0\n" ".popsection\n"
arch/sparc/include/asm/jump_label.h +4 -2
@@ -1,6 +1,8 @@#ifndef _ASM_SPARC_JUMP_LABEL_H#define _ASM_SPARC_JUMP_LABEL_H +#include <asm/tables.h> +#ifndef __ASSEMBLY__#include <linux/types.h>
@@ -12,7 +14,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_any(.data, __jump_table, aw)".align 4\n\t" ".word 1b, %l[l_yes], %c0\n\t" ".popsection \n\t"
@@ -28,7 +30,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_any(.data, __jump_table, aw)".align 4\n\t" ".word 1b, %l[l_yes], %c0\n\t" ".popsection \n\t"
arch/tile/include/asm/jump_label.h +3 -2
@@ -16,6 +16,7 @@#define _ASM_TILE_JUMP_LABEL_H#include <arch/opcode.h> +#include <asm/tables.h> #define JUMP_LABEL_NOP_SIZE TILE_BUNDLE_SIZE_IN_BYTES
@@ -24,7 +25,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, { asm_volatile_goto("1:\n\t" "nop" "\n\t" -".pushsection __jump_table, \"aw\"\n\t" + push_section_tbl_any(.data, __jump_table, aw) ".quad 1b, %l[l_yes], %0 + %1 \n\t" ".popsection\n\t" : : "i" (key), "i" (branch) : : l_yes);
@@ -38,7 +39,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, { asm_volatile_goto("1:\n\t" "j %l[l_yes]" "\n\t" -".pushsection __jump_table, \"aw\"\n\t" + push_section_tbl_any(.data, __jump_table, aw) ".quad 1b, %l[l_yes], %0 + %1 \n\t" ".popsection\n\t" : : "i" (key), "i" (branch) : : l_yes);
arch/x86/include/asm/jump_label.h +6 -4
@@ -1,6 +1,8 @@#ifndef _ASM_X86_JUMP_LABEL_H#define _ASM_X86_JUMP_LABEL_H +#include <asm/tables.h> +#ifndef HAVE_JUMP_LABEL /* * For better or for worse, if jump labels (the gcc extension) are missing,
@@ -34,7 +36,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran { asm_volatile_goto("1:" ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t" -".pushsection __jump_table, \"aw\" \n\t" + push_section_tbl_any(.data, __jump_table, aw) _ASM_ALIGN"\n\t" _ASM_PTR"1b, %l[l_yes], %c0 + %c1 \n\t" ".popsection \n\t"
@@ -50,7 +52,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_any(.data, __jump_table, aw) _ASM_ALIGN"\n\t" _ASM_PTR"1b, %l[l_yes], %c0 + %c1 \n\t" ".popsection \n\t"
@@ -85,7 +87,7 @@ struct jump_entry { .else .byte STATIC_KEY_INIT_NOP .endif - .pushsection __jump_table, "aw" + push_section_tbl_any(.data, __jump_table, aw) _ASM_ALIGN _ASM_PTR .Lstatic_jump_\@, \target, \key .popsection
@@ -101,7 +103,7 @@ struct jump_entry { .long \target - .Lstatic_jump_after_\@ .Lstatic_jump_after_\@: .endif - .pushsection __jump_table, "aw" + push_section_tbl_any(.data, __jump_table, aw) _ASM_ALIGN _ASM_PTR .Lstatic_jump_\@, \target, \key + 1 .popsection
include/asm-generic/vmlinux.lds.h +0 -5
@@ -216,11 +216,6 @@ *(.data.unlikely) \STRUCT_ALIGN (); \ *(__tracepoints) \ -/* implement dynamic printk debug */ \ - . = ALIGN(8); \ - VMLINUX_SYMBOL(__start___jump_table) = .; \ - KEEP(*(__jump_table)) \ - VMLINUX_SYMBOL(__stop___jump_table) = .; \ . = ALIGN(8); \ VMLINUX_SYMBOL(__start___verbose) = .; \KEEP (*(__verbose)) \
include/linux/jump_label.h +2 -2
@@ -117,6 +117,7 @@ enum jump_label_type {struct module ;#ifdef HAVE_JUMP_LABEL +#include <linux/tables.h> #define JUMP_TYPE_FALSE 0UL#define JUMP_TYPE_TRUE 1UL
@@ -132,8 +133,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(struct jump_entry, __jump_table);extern void jump_label_init (void );extern void jump_label_lock (void );
kernel/jump_label.c +10 -7
@@ -15,9 +15,12 @@#include <linux/static_key.h> #include <linux/jump_label_ratelimit.h> #include <linux/bug.h> +#include <linux/tables.h> #ifdef HAVE_JUMP_LABEL +DEFINE_LINKTABLE(struct jump_entry, __jump_table); +/* mutex to protect coming/going of the the jump_label table */ static DEFINE_MUTEX (jump_label_mutex);
@@ -274,8 +277,6 @@ 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;
@@ -292,9 +293,10 @@ void __init jump_label_init(void)return ;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 */
@@ -539,8 +541,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;
@@ -553,7 +556,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;
scripts/module-common.lds +1 -0
@@ -16,6 +16,7 @@ SECTIONS { __kcrctab_unused 0 : { *(SORT(___kcrctab_unused+*)) } __kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) } __kcrctab_gpl_future 0 : { *(SORT(___kcrctab_gpl_future+*)) } + __jump_table 0 : { *(SORT(.data..tbl.__jump_table.*)) } . = ALIGN(8); .init_array 0 : { *(SORT(.init_array.*)) *(.init_array) }
tools/objtool/special.c +1 -1
@@ -63,7 +63,7 @@ struct special_entry entries[] = { .feature = ALT_FEATURE_OFFSET, }, { - .sec = "__jump_table", + .sec = ".data..tbl.__jump_table.any", .jump_or_nop = true, .size = JUMP_ENTRY_SIZE, .orig = JUMP_ORIG_OFFSET,
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerPATCH v7 10/14 dynamic_debug: port to use linker tables
In reply to Luis R. RodriguezThis removes the custom vmlinux.lds.h hacks and uses the generalized solution for .data entries.
There is much more potential for further fine tuning here in the future though. 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. We can work on this later to make this change easier to review.
Tested dynamic debug with dyndbg query and debugfs control and it works as expected, for both built-in code and modules.
v6: rename table macro as suggested by Andy Shevchenko
v5:
o Use ..tbl instead of .tbl as suggested by Nicholas Piggin. This is the typical way to avoid clash with compiler generated section.
o Replace section macros with section names,
use LINKTABLE_EMPTY(), LINKTABLE_START()
v4: fix compilation on blackfin
v3: added modular support
v2: introduced this patch into the series
--- include/asm-generic/vmlinux.lds.h | 4 ---- include/linux/dynamic_debug.h | 5 +++-- lib/dynamic_debug.c | 13 ++++++------- scripts/module-common.lds | 1 + 4 files changed, 10 insertions(+), 13 deletions(-)
include/asm-generic/vmlinux.lds.h +0 -4
@@ -216,10 +216,6 @@ *(.data.unlikely) \STRUCT_ALIGN (); \ *(__tracepoints ) \ - . = ALIGN(8); \ - VMLINUX_SYMBOL(__start___verbose) = .; \ - KEEP(*(__verbose)) \ - VMLINUX_SYMBOL(__stop___verbose) = .; \ LIKELY_PROFILE() \ BRANCH_PROFILE() \TRACE_PRINTKS () \
include/linux/dynamic_debug.h +3 -2
@@ -4,6 +4,7 @@#if defined(CC_HAVE_ASM_GOTO ) && defined(CONFIG_JUMP_LABEL )#include <linux/jump_label.h> #endif +#include <linux/tables.h> /* * An instance of this structure is created in a special
@@ -50,6 +51,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, const char *modname);#if defined(CONFIG_DYNAMIC_DEBUG ) +DECLARE_LINKTABLE(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, ...);
@@ -71,8 +73,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, const char *fmt, ...);#define DEFINE_DYNAMIC_DEBUG_METADATA_KEY (name, fmt, key, init) \ - static struct _ddebug __aligned(8) \ - __attribute__((section("__verbose"))) name = { \ + static LINKTABLE(__verbose, SECTION_ORDER_ANY) name = { \ .modname = KBUILD_MODNAME, \ .function = __func__, \ .filename = __FILE__, \
lib/dynamic_debug.c +6 -7
@@ -37,8 +37,7 @@#include <linux/device.h> #include <linux/netdevice.h> -extern struct _ddebug __start___verbose[]; -extern struct _ddebug __stop___verbose[]; +DEFINE_LINKTABLE(struct _ddebug, __verbose);struct ddebug_table {struct list_head link;
@@ -978,14 +977,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);
@@ -1008,7 +1007,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' ) {
scripts/module-common.lds +1 -0
@@ -17,6 +17,7 @@ SECTIONS { __kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) } __kcrctab_gpl_future 0 : { *(SORT(___kcrctab_gpl_future+*)) } __jump_table 0 : { *(SORT(.data..tbl.__jump_table.*)) } + __verbose 0 : { *(SORT(.data..tbl.__verbose.*)) } . = ALIGN(8); .init_array 0 : { *(SORT(.init_array.*)) *(.init_array) }
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerPATCH v7 11/14 kprobes: move kprobe declarations to asm-generic/kprobes.h
In reply to Luis R. RodriguezOften all is needed is these small helpers, instead of compiler.h or a full kprobes.h. This is important for asm helpers, in fact even some asm/kprobes.h make use of these helpers... instead just keep a generic asm file with helpers useful for asm code with the least amount of clutter as possible.
Likewise we need now to also address what to do about this file for both when architectures have CONFIG_HAVE_KPROBES, and when they do not. Then for when architectures have CONFIG_HAVE_KPROBES but have disabled CONFIG_KPROBES.
Right now most asm/kprobes.h do not have guards against CONFIG_KPROBES, this means most architecture code cannot include asm/kprobes.h safely. Correct this and add guards for architectures missing them. Additionally provide architectures that not have kprobes support with the default asm-generic solution. This lets us force asm/kprobes.h on the header include/linux/kprobes.h always, but most importantly we can now safely include just asm/kprobes.h on architecture code without bringing the full kitchen sink of header files.
Two architectures already provided a guard against CONFIG_KPROBES on its kprobes.h: sh, arch. The rest of the architectures needed gaurds added. We avoid including any not-needed headers on asm/kprobes.h unless kprobes have been enabled.
In a subsequent atomic change we can try now to remove compiler.h from include/linux/kprobes.h.
During this sweep I've also identified a few architectures defining a common macro needed for both kprobes and ftrace, that of the definition of the breakput instruction up. Some refer to this as BREAKPOINT_INSTRUCTION. This must be kept outside of the #ifdef CONFIG_KPROBES guard.
v5:
o fix BREAKPOINT_INSTRUCTION dependency with kernel architecture ftrace implementations: Although its correct to #ifdef CONFIG_KPROBES on the architecture arch/$(ARCH)/include/asm/kprobes.h when architectures support ftrace they will rely on the BREAKPOINT_INSTRUCTION definition, this needs to be kept out from CONFIG_KPROBES as ftrace can be enabled without kprobes. This fixes compilation on x86 where kprobes is disabled but ftrace is left enabled.
o include <asm/kprobes.h> on arch/arm64/kernel/probes/decode-insn.h
v4: introduced this patch into the series
--- MAINTAINERS | 1 + arch/alpha/include/asm/Kbuild | 1 + arch/arc/include/asm/kprobes.h | 6 ++++-- arch/arm/include/asm/kprobes.h | 4 ++++ arch/arm/probes/decode.h | 1 + arch/arm64/include/asm/kprobes.h | 4 ++++ arch/arm64/kernel/insn.c | 1 + arch/arm64/kernel/probes/decode-insn.h | 2 ++ arch/avr32/include/asm/kprobes.h | 7 ++++++- arch/blackfin/include/asm/Kbuild | 1 + arch/c6x/include/asm/Kbuild | 1 + arch/cris/include/asm/Kbuild | 1 + arch/frv/include/asm/Kbuild | 1 + arch/h8300/include/asm/Kbuild | 1 + arch/hexagon/include/asm/Kbuild | 1 + arch/ia64/include/asm/kprobes.h | 12 +++++++++--- arch/m32r/include/asm/Kbuild | 1 + arch/m68k/include/asm/Kbuild | 1 + arch/metag/include/asm/Kbuild | 1 + arch/microblaze/include/asm/Kbuild | 1 + arch/mips/include/asm/kprobes.h | 6 +++++- arch/mn10300/include/asm/kprobes.h | 7 ++++++- arch/nios2/include/asm/Kbuild | 1 + arch/openrisc/include/asm/Kbuild | 1 + arch/parisc/include/asm/Kbuild | 1 + arch/powerpc/include/asm/kprobes.h | 3 +++ arch/s390/include/asm/kprobes.h | 7 ++++++- arch/score/include/asm/Kbuild | 1 + arch/sh/include/asm/kprobes.h | 5 ++++- arch/sparc/include/asm/kprobes.h | 10 ++++++++-- arch/tile/include/asm/kprobes.h | 6 +++++- arch/um/include/asm/Kbuild | 1 + arch/unicore32/include/asm/Kbuild | 1 + arch/x86/include/asm/kprobes.h | 9 ++++++++- arch/xtensa/include/asm/Kbuild | 1 + include/asm-generic/kprobes.h | 25 +++++++++++++++++++++++++ include/linux/compiler.h | 8 -------- include/linux/kprobes.h | 19 +++---------------- 38 files changed, 123 insertions(+), 38 deletions(-) create mode 100644 include/asm-generic/kprobes.h
MAINTAINERS +1 -0
@@ -7250,6 +7250,7 @@ M: Masami Hiramatsu <[email protected]> S: Maintained F: Documentation/kprobes.txt F: include/linux/kprobes.h +F: include/asm-generic/kprobes.h F: kernel/kprobes.c KS0108 LCD CONTROLLER DRIVER
arch/alpha/include/asm/Kbuild +1 -0
@@ -13,3 +13,4 @@ generic-y += trace_clock.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/arc/include/asm/kprobes.h +4 -2
@@ -9,6 +9,8 @@#ifndef _ARC_KPROBES_H#define _ARC_KPROBES_H +#include <asm-generic/kprobes.h> +#ifdef CONFIG_KPROBES typedef u16 kprobe_opcode_t ;
@@ -55,6 +57,6 @@ void trap_is_kprobe(unsigned long address, struct pt_regs *regs);static void trap_is_kprobe (unsigned long address,struct pt_regs *regs) { } -#endif +#endif /* CONFIG_KPROBES */ -#endif +#endif /* _ARC_KPROBES_H */
arch/arm/include/asm/kprobes.h +4 -0
@@ -16,6 +16,9 @@#ifndef _ARM_KPROBES_H#define _ARM_KPROBES_H +#include <asm-generic/kprobes.h> + +#ifdef CONFIG_KPROBES #include <linux/types.h> #include <linux/ptrace.h> #include <linux/notifier.h>
@@ -83,4 +86,5 @@ struct arch_optimized_insn {*/ }; +#endif /* CONFIG_KPROBES */ #endif /* _ARM_KPROBES_H */
arch/arm/probes/decode.h +1 -0
@@ -22,6 +22,7 @@#include <linux/types.h> #include <linux/stddef.h> #include <asm/probes.h> +#include <asm/kprobes.h> void __init arm_probes_decode_init (void );
arch/arm64/include/asm/kprobes.h +4 -0
@@ -16,6 +16,9 @@#ifndef _ARM_KPROBES_H#define _ARM_KPROBES_H +#include <asm-generic/kprobes.h> + +#ifdef CONFIG_KPROBES #include <linux/types.h> #include <linux/ptrace.h> #include <linux/percpu.h>
@@ -57,4 +60,5 @@ int kprobe_single_step_handler(struct pt_regs *regs, unsigned int esr);void kretprobe_trampoline (void );void __kprobes *trampoline_probe_handler (struct pt_regs *regs); +#endif /* CONFIG_KPROBES */ #endif /* _ARM_KPROBES_H */
arch/arm64/kernel/insn.c +1 -0
@@ -31,6 +31,7 @@#include <asm/debug-monitors.h> #include <asm/fixmap.h> #include <asm/insn.h> +#include <asm/kprobes.h> #define AARCH64_INSN_SF_BIT BIT(31)#define AARCH64_INSN_N_BIT BIT(22)
arch/arm64/kernel/probes/decode-insn.h +2 -0
@@ -16,6 +16,8 @@#ifndef _ARM_KERNEL_KPROBES_ARM64_H#define _ARM_KERNEL_KPROBES_ARM64_H +#include <asm/kprobes.h> +/* * ARM strongly recommends a limit of 128 bytes between LoadExcl and * StoreExcl instructions in a single thread of execution. So keep the
arch/avr32/include/asm/kprobes.h +6 -1
@@ -11,10 +11,14 @@#ifndef __ASM_AVR32_KPROBES_H#define __ASM_AVR32_KPROBES_H +#include <asm-generic/kprobes.h> + +#define BREAKPOINT_INSTRUCTION 0xd673/* breakpoint */ + +#ifdef CONFIG_KPROBES #include <linux/types.h> typedef u16 kprobe_opcode_t ; -#define BREAKPOINT_INSTRUCTION 0xd673/* breakpoint */ #define MAX_INSN_SIZE 2#define MAX_STACK_SIZE 64/* 32 would probably be OK */
@@ -46,4 +50,5 @@ extern int kprobe_exceptions_notify(struct notifier_block *self,#define flush_insn_slot (p) do { } while (0) +#endif /* CONFIG_KPROBES */ #endif /* __ASM_AVR32_KPROBES_H */
arch/blackfin/include/asm/Kbuild +1 -0
@@ -50,3 +50,4 @@ generic-y += xor.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/c6x/include/asm/Kbuild +1 -0
@@ -64,3 +64,4 @@ generic-y += word-at-a-time.h generic-y += xor.h generic-y += section-core.h generic-y += ranges.h +generic-y += kprobes.h
arch/cris/include/asm/Kbuild +1 -0
@@ -48,3 +48,4 @@ generic-y += xor.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/frv/include/asm/Kbuild +1 -0
@@ -11,3 +11,4 @@ generic-y += word-at-a-time.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/h8300/include/asm/Kbuild +1 -0
@@ -78,3 +78,4 @@ generic-y += xor.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/hexagon/include/asm/Kbuild +1 -0
@@ -63,3 +63,4 @@ generic-y += xor.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/ia64/include/asm/kprobes.h +9 -3
@@ -23,14 +23,19 @@* 2005-Apr Rusty Lynch <[email protected]> and Anil S Keshavamurthy * <[email protected]> adapted from i386 */ +#include <asm-generic/kprobes.h> +#include <asm/break.h> + +#define BREAK_INST (long)(__IA64_BREAK_KPROBE << 6) + +#ifdef CONFIG_KPROBES +#include <linux/types.h> #include <linux/ptrace.h> #include <linux/percpu.h> -#include <asm/break.h> #define __ARCH_WANT_KPROBES_INSN_SLOT#define MAX_INSN_SIZE 2/* last half is for kprobe-booster */ -#define BREAK_INST (long)(__IA64_BREAK_KPROBE << 6)#define NOP_M_INST (long)(1<<27)#define BRL_INST (i1, i2) ((long)((0xcL << 37) |/* brl */ \ (0x1L << 12) | /* many */ \
@@ -124,4 +129,5 @@ extern void invalidate_stacked_regs(void);extern void flush_register_stack (void );extern void arch_remove_kprobe (struct kprobe *p); -#endif /* _ASM_KPROBES_H */ +#endif /* CONFIG_KPROBES */ +#endif /* _ASM_KPROBES_H */
arch/m32r/include/asm/Kbuild +1 -0
@@ -15,3 +15,4 @@ generic-y += word-at-a-time.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/m68k/include/asm/Kbuild +1 -0
@@ -37,3 +37,4 @@ generic-y += xor.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/metag/include/asm/Kbuild +1 -0
@@ -58,3 +58,4 @@ generic-y += xor.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/microblaze/include/asm/Kbuild +1 -0
@@ -14,3 +14,4 @@ generic-y += word-at-a-time.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/mips/include/asm/kprobes.h +5 -1
@@ -22,6 +22,9 @@#ifndef _ASM_KPROBES_H#define _ASM_KPROBES_H +#include <asm-generic/kprobes.h> + +#ifdef CONFIG_KPROBES #include <linux/ptrace.h> #include <linux/types.h>
@@ -94,4 +97,5 @@ struct kprobe_ctlblk {extern int kprobe_exceptions_notify (struct notifier_block *self,unsigned long val,void *data); -#endif /* _ASM_KPROBES_H */ +#endif /* CONFIG_KPROBES */ +#endif /* _ASM_KPROBES_H */
arch/mn10300/include/asm/kprobes.h +6 -1
@@ -21,13 +21,17 @@#ifndef _ASM_KPROBES_H#define _ASM_KPROBES_H +#include <asm-generic/kprobes.h> + +#define BREAKPOINT_INSTRUCTION 0xff + +#ifdef CONFIG_KPROBES #include <linux/types.h> #include <linux/ptrace.h> struct kprobe ;typedef unsigned char kprobe_opcode_t ; -#define BREAKPOINT_INSTRUCTION 0xff#define MAX_INSN_SIZE 8#define MAX_STACK_SIZE 128
@@ -47,4 +51,5 @@ extern int kprobe_exceptions_notify(struct notifier_block *self,extern void arch_remove_kprobe (struct kprobe *p); +#endif /* CONFIG_KPROBES */ #endif /* _ASM_KPROBES_H */
arch/nios2/include/asm/Kbuild +1 -0
@@ -66,3 +66,4 @@ generic-y += xor.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/openrisc/include/asm/Kbuild +1 -0
@@ -74,3 +74,4 @@ generic-y += xor.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/parisc/include/asm/Kbuild +1 -0
@@ -31,3 +31,4 @@ generic-y += xor.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/powerpc/include/asm/kprobes.h +3 -0
@@ -1,5 +1,8 @@#ifndef _ASM_POWERPC_KPROBES_H#define _ASM_POWERPC_KPROBES_H + +#include <asm-generic/kprobes.h> +#ifdef __KERNEL__/* * Kernel Probes (KProbes)
arch/s390/include/asm/kprobes.h +6 -1
@@ -27,6 +27,11 @@* 2005-Dec Used as a template for s390 by Mike Grundy * <[email protected]> */ +#include <asm-generic/kprobes.h> + +#define BREAKPOINT_INSTRUCTION 0x0002 + +#ifdef CONFIG_KPROBES #include <linux/types.h> #include <linux/ptrace.h> #include <linux/percpu.h>
@@ -37,7 +42,6 @@ struct pt_regs;struct kprobe ;typedef u16 kprobe_opcode_t ; -#define BREAKPOINT_INSTRUCTION 0x0002/* Maximum instruction size is 3 (16bit) halfwords: */ #define MAX_INSN_SIZE 0x0003
@@ -91,4 +95,5 @@ int probe_is_insn_relative_long(u16 *insn);#define flush_insn_slot (p) do { } while (0) +#endif /* CONFIG_KPROBES */ #endif /* _ASM_S390_KPROBES_H */
arch/score/include/asm/Kbuild +1 -0
@@ -17,3 +17,4 @@ generic-y += word-at-a-time.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/sh/include/asm/kprobes.h +4 -1
@@ -1,13 +1,16 @@#ifndef __ASM_SH_KPROBES_H#define __ASM_SH_KPROBES_H +#include <asm-generic/kprobes.h> + +#define BREAKPOINT_INSTRUCTION 0xc33a +#ifdef CONFIG_KPROBES #include <linux/types.h> #include <linux/ptrace.h> typedef insn_size_t kprobe_opcode_t ; -#define BREAKPOINT_INSTRUCTION 0xc33a#define MAX_INSN_SIZE 16#define MAX_STACK_SIZE 64
arch/sparc/include/asm/kprobes.h +8 -2
@@ -1,13 +1,17 @@#ifndef _SPARC64_KPROBES_H#define _SPARC64_KPROBES_H +#include <asm-generic/kprobes.h> + +#define BREAKPOINT_INSTRUCTION 0x91d02070/* ta 0x70 */ +#define BREAKPOINT_INSTRUCTION_2 0x91d02071/* ta 0x71 */ + +#ifdef CONFIG_KPROBES #include <linux/types.h> #include <linux/percpu.h> typedef u32 kprobe_opcode_t ; -#define BREAKPOINT_INSTRUCTION 0x91d02070/* ta 0x70 */ -#define BREAKPOINT_INSTRUCTION_2 0x91d02071/* ta 0x71 */ #define MAX_INSN_SIZE 2#define kretprobe_blacklist_size 0
@@ -48,4 +52,6 @@ int kprobe_exceptions_notify(struct notifier_block *self,int kprobe_fault_handler (struct pt_regs *regs,int trapnr); asmlinkage void __kprobes kprobe_trap(unsigned long trap_level,struct pt_regs *regs); + +#endif /* CONFIG_KPROBES */ #endif /* _SPARC64_KPROBES_H */
arch/tile/include/asm/kprobes.h +5 -1
@@ -17,10 +17,13 @@#ifndef _ASM_TILE_KPROBES_H#define _ASM_TILE_KPROBES_H +#include <asm-generic/kprobes.h> + +#ifdef CONFIG_KPROBES +#include <linux/types.h> #include <linux/ptrace.h> #include <linux/percpu.h> -#include <arch/opcode.h> #define __ARCH_WANT_KPROBES_INSN_SLOT
@@ -76,4 +79,5 @@ void arch_remove_kprobe(struct kprobe *);extern int kprobe_exceptions_notify (struct notifier_block *self,unsigned long val,void *data); +#endif /* CONFIG_KPROBES */ #endif /* _ASM_TILE_KPROBES_H */
arch/um/include/asm/Kbuild +1 -0
@@ -29,3 +29,4 @@ generic-y += xor.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/unicore32/include/asm/Kbuild +1 -0
@@ -63,3 +63,4 @@ generic-y += word-at-a-time.h generic-y += xor.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
arch/x86/include/asm/kprobes.h +8 -1
@@ -21,6 +21,12 @@* * See arch/x86/kernel/kprobes.c for x86 kprobes history. */ + +#include <asm-generic/kprobes.h> + +#define BREAKPOINT_INSTRUCTION 0xcc + +#ifdef CONFIG_KPROBES #include <linux/types.h> #include <linux/ptrace.h> #include <linux/percpu.h>
@@ -32,7 +38,6 @@ struct pt_regs;struct kprobe ;typedef u8 kprobe_opcode_t ; -#define BREAKPOINT_INSTRUCTION 0xcc#define RELATIVEJUMP_OPCODE 0xe9#define RELATIVEJUMP_SIZE 5#define RELATIVECALL_OPCODE 0xe8
@@ -116,4 +121,6 @@ extern int kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *data);extern int kprobe_int3_handler (struct pt_regs *regs);extern int kprobe_debug_handler (struct pt_regs *regs); + +#endif /* CONFIG_KPROBES */ #endif /* _ASM_X86_KPROBES_H */
arch/xtensa/include/asm/Kbuild +1 -0
@@ -35,3 +35,4 @@ generic-y += xor.h generic-y += section-core.h generic-y += ranges.h generic-y += tables.h +generic-y += kprobes.h
include/asm-generic/kprobes.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef _ASM_GENERIC_KPROBES_H +#define _ASM_GENERIC_KPROBES_H + +#if defined(__KERNEL__) && !defined(__ASSEMBLY__) +#ifdef CONFIG_KPROBES +/* +* Blacklist ganerating macro. Specify functions which is not probed +* by using this macro. +*/ +# define __NOKPROBE_SYMBOL (fname) \ +static unsigned long __used \ + __attribute__((__section__("_kprobe_blacklist"))) \ + _kbl_addr_##fname = (unsigned long)fname; +# define NOKPROBE_SYMBOL (fname) __NOKPROBE_SYMBOL(fname) +/* Use this to forbid a kprobes attach on very low level functions */ +# define __kprobes __attribute__((__section__(".kprobes.text"))) +# define nokprobe_inline __always_inline +#else +# define NOKPROBE_SYMBOL (fname) +# define __kprobes +# define nokprobe_inline inline +#endif +#endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */ + +#endif /* _ASM_GENERIC_KPROBES_H */
include/linux/compiler.h +0 -8
@@ -566,12 +566,4 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s (_________p1); \ }) -/* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */ -#ifdef CONFIG_KPROBES -# define __kprobes __attribute__((__section__(".kprobes.text"))) -# define nokprobe_inline __always_inline -#else -# define __kprobes -# define nokprobe_inline inline -#endif #endif /* __LINUX_COMPILER_H */
include/linux/kprobes.h +3 -16
@@ -29,7 +29,7 @@* <[email protected]> and Prasanna S Panchamukhi * <[email protected]> added function-return probes. */ -#include <linux/compiler.h> /* for __kprobes */ +#include <linux/compiler.h> #include <linux/linkage.h> #include <linux/list.h> #include <linux/notifier.h>
@@ -40,9 +40,9 @@#include <linux/rcupdate.h> #include <linux/mutex.h> #include <linux/ftrace.h> +#include <asm/kprobes.h> #ifdef CONFIG_KPROBES -#include <asm/kprobes.h> /* kprobe_status settings */ #define KPROBE_HIT_ACTIVE 0x00000001
@@ -51,6 +51,7 @@ #define KPROBE_HIT_SSDONE 0x00000008 #else /* CONFIG_KPROBES */ +#include <asm-generic/kprobes.h> typedef int kprobe_opcode_t; struct arch_specific_insn { int dummy;
@@ -481,18 +482,4 @@ static inline int enable_jprobe(struct jprobe *jp) return enable_kprobe(&jp->kp); } -#ifdef CONFIG_KPROBES -/* -* Blacklist ganerating macro. Specify functions which is not probed -* by using this macro. -*/ -#define __NOKPROBE_SYMBOL (fname) \ -static unsigned long __used \ - __attribute__((section("_kprobe_blacklist"))) \ - _kbl_addr_##fname = (unsigned long)fname; -#define NOKPROBE_SYMBOL (fname) __NOKPROBE_SYMBOL(fname) -#else -#define NOKPROBE_SYMBOL (fname) -#endif -#endif /* _LINUX_KPROBES_H */
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerPATCH v7 12/14 kprobes: port .kprobes.text to section range
In reply to Luis R. Rodriguezkprobe makes use of two custom sections, each custom section is folded into one of the standard Linux sections types as follows, it currently relies on the linker script to fold the custom section onto the respective Linux section:
type Linux-section custom section name begin end table .init.data _kprobe_blacklist __start_kprobe_blacklist __stop_kprobe_blacklist range .text .kprobes.text __kprobes_text_start __kprobes_text_end
This ports the .kprobes.text custom section to the standard Linux ranges API allowing us remove all the custom kprobe section declarations from 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.
Also ran ./ftracetest with no issues:
sudo ./ftracetest
=== Ftrace unit tests ===
[1] Basic trace file check [PASS]
[2] Basic test for tracers [PASS]
[3] Basic trace clock test [PASS]
[4] Basic event tracing check [PASS]
[5] event tracing - enable/disable with event level files [PASS]
[6] event tracing - restricts events based on pid [PASS]
[7] event tracing - enable/disable with subsystem level files [PASS]
[8] event tracing - enable/disable with top level files [PASS]
[9] ftrace - function graph filters with stack tracer [PASS]
[10] ftrace - function graph filters [PASS]
[11] ftrace - function glob filters [PASS]
[12] ftrace - function profiler with function tracing [PASS]
[13] Test creation and deletion of trace instances while setting an event [PASS]
[14] Test creation and deletion of trace instances [PASS]
[15] Kprobe dynamic event - adding and removing [PASS]
[16] Kprobe dynamic event - busy event check [PASS]
[17] Kprobe dynamic event with arguments [PASS]
[18] Kprobes event arguments with types [PASS]
[19] Kprobe dynamic event with function tracer [PASS]
[20] Kretprobe dynamic event with arguments [PASS]
[21] event trigger - test event enable/disable trigger [PASS]
[22] event trigger - test trigger filter [PASS]
[23] event trigger - test histogram modifiers [PASS]
[24] event trigger - test histogram trigger [PASS]
[25] event trigger - test multiple histogram triggers [PASS]
[26] event trigger - test snapshot-trigger [PASS]
[27] event trigger - test stacktrace-trigger [PASS]
[28] event trigger - test traceon/off trigger [PASS]
v5:
o Use ..rng.* instead of .rng.* as suggested by Nicholas Piggin. This is the typical way to avoid clash with compiler generated section.
o Replace section macros with section names
v4:
o arm64 build fixes with allmodconfig
o build fix suggested for avr32 with allnoconfig, otherwise we end up with:
arch/avr32/kernel/built-in.o: In function `save_full_context_ex':
(.ex.text+0x1c4): relocation truncated to fit: R_AVR32_16N_PCREL against symbol `debug_trampoline' defined in .text.rng.kprobes.any section in arch/avr32/kernel/built-in.oarch/avr32/kernel/built-in.o: In function `debug_exit_work':
(.text.rng.kprobes.any+0xa8): relocation truncated to fit:R_AVR32_16N_PCREL against `.ex.text'+3aa
make: *** [Makefile:953: vmlinux] Error 1
o open-code section use on scripts/ code -- folks to prefer the simplicity over dealing with having more tool code access kernel headers.
o NOPE: include #include <asm-generic/ranges.h> on compiler.h -- solves a few 0-day compilation issues
v3:
o after v2 arch/arm/kernel/vmlinux-xip.lds.S got kprobe support, this just removes the custom linker script reference to kprobes as that is no longer needed with linker tables.
o split kprobe linker table and kprobe section ranges use into two separate patches. This should make it easier to review and also demos both distinct use types, one a linker table another a simple section range.
v2: introduced this patch in this series
--- arch/arc/kernel/vmlinux.lds.S | 1 - arch/arm/kernel/entry-armv.S | 3 ++- arch/arm/kernel/vmlinux-xip.lds.S | 1 - arch/arm/kernel/vmlinux.lds.S | 1 - arch/arm64/kernel/armv8_deprecated.c | 1 + arch/arm64/kernel/probes/kprobes.c | 4 ++-- arch/arm64/kernel/vmlinux.lds.S | 1 - arch/avr32/kernel/entry-avr32b.S | 13 +++++++++++-- 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 | 3 ++- arch/ia64/kernel/vmlinux.lds.S | 1 - arch/ia64/lib/flush.S | 6 +++--- 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 | 1 + arch/powerpc/kernel/vmlinux.lds.S | 1 - arch/s390/kernel/entry.S | 5 +++-- arch/s390/kernel/kprobes.c | 6 +++--- arch/s390/kernel/mcount.S | 3 ++- 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 | 3 ++- arch/tile/kernel/vmlinux.lds.S | 1 - arch/x86/kernel/kprobes/core.c | 11 +++++------ arch/x86/kernel/vmlinux.lds.S | 1 - include/asm-generic/kprobes.h | 3 ++- include/asm-generic/sections.h | 2 -- include/asm-generic/vmlinux.lds.h | 2 +- include/linux/kprobes.h | 3 +++ kernel/kprobes.c | 6 ++++-- scripts/mod/modpost.c | 2 +- scripts/recordmcount.c | 2 +- scripts/recordmcount.pl | 2 +- 43 files changed, 50 insertions(+), 54 deletions(-)
arch/arc/kernel/vmlinux.lds.S +0 -1
@@ -91,7 +91,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT *(.fixup) *(.gnu.warning) }
arch/arm/kernel/entry-armv.S +2 -1
@@ -34,6 +34,7 @@ #include "entry-header.S" #include <asm/entry-macro-multi.S> #include <asm/probes.h> +#include <asm/ranges.h> /* * Interrupt handling.
@@ -83,7 +84,7 @@ .endm #ifdef CONFIG_KPROBES - .section .kprobes.text,"ax",%progbits + set_section_rng_type(.text, kprobes, ax, %progbits) #else .text #endif
arch/arm/kernel/vmlinux-xip.lds.S +0 -1
@@ -103,7 +103,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT *(.gnu.warning) *(.glue_7) *(.glue_7t)
arch/arm/kernel/vmlinux.lds.S +0 -1
@@ -114,7 +114,6 @@ SECTIONS CPUIDLE_TEXT LOCK_TEXT HYPERVISOR_TEXT - KPROBES_TEXT *(.gnu.warning) *(.glue_7) *(.glue_7t)
arch/arm64/kernel/armv8_deprecated.c +1 -0
@@ -21,6 +21,7 @@#include <asm/traps.h> #include <linux/uaccess.h> #include <asm/cpufeature.h> +#include <asm/kprobes.h> #define CREATE_TRACE_POINTS #include "trace-events-emulation.h"
arch/arm64/kernel/probes/kprobes.c +2 -2
@@ -23,6 +23,7 @@#include <linux/slab.h> #include <linux/stop_machine.h> #include <linux/stringify.h> +#include <linux/ranges.h> #include <asm/traps.h> #include <asm/ptrace.h> #include <asm/cacheflush.h>
@@ -540,8 +541,7 @@ int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)bool arch_within_kprobe_blacklist (unsigned long addr) { - if ((addr >= (unsigned long)__kprobes_text_start && - addr < (unsigned long)__kprobes_text_end) || + if (SECTION_RANGE_ADDR_WITHIN(kprobes, addr) || (addr >= (unsigned long)__entry_text_start && addr < (unsigned long)__entry_text_end) || (addr >= (unsigned long)__idmap_text_start &&
arch/arm64/kernel/vmlinux.lds.S +0 -1
@@ -124,7 +124,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT HYPERVISOR_TEXT IDMAP_TEXT HIBERNATE_TEXT
arch/avr32/kernel/entry-avr32b.S +11 -2
@@ -23,6 +23,7 @@ #include <asm/sysreg.h> #include <asm/thread_info.h> #include <asm/unistd.h> +#include <asm/ranges.h> #ifdef CONFIG_PREEMPT # define preempt_stop mask_interrupts
@@ -605,7 +606,11 @@ fault_exit_work: brcc fault_resume_user rjmp enter_monitor_mode - .section .kprobes.text, "ax", @progbits +#ifdef CONFIG_KPROBES + set_section_rng_type(.text, kprobes, ax, @progbits) +#else + .text +#endif .type handle_debug, @function handle_debug: sub sp, 4 /* r12_orig */
@@ -826,7 +831,11 @@ irq_level\level: IRQ_LEVEL 2 IRQ_LEVEL 3 - .section .kprobes.text, "ax", @progbits +#ifdef CONFIG_KPROBES + set_section_rng_type(.text, kprobes, ax, @progbits) +#else + .text +#endif .type enter_monitor_mode, @function enter_monitor_mode: /*
arch/avr32/kernel/vmlinux.lds.S +0 -1
@@ -49,7 +49,6 @@ SECTIONS _stext = .; *(.ex.text) *(.irq.text) - KPROBES_TEXT TEXT_TEXT SCHED_TEXT CPUIDLE_TEXT
arch/blackfin/kernel/vmlinux.lds.S +0 -1
@@ -37,7 +37,6 @@ SECTIONS LOCK_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT - KPROBES_TEXT #ifdef CONFIG_ROMKERNEL __sinittext = .; INIT_TEXT
arch/c6x/kernel/vmlinux.lds.S +0 -1
@@ -74,7 +74,6 @@ SECTIONS LOCK_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT - KPROBES_TEXT *(.fixup) *(.gnu.warning) }
arch/hexagon/kernel/vmlinux.lds.S +0 -1
@@ -52,7 +52,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT *(.fixup) } _etext = .;
arch/ia64/kernel/jprobes.S +2 -1
@@ -46,11 +46,12 @@ */ #include <asm/asmmacro.h> #include <asm/break.h> +#include <asm/ranges.h> /* * void jprobe_break(void) */ - .section .kprobes.text, "ax" + set_section_rng(.text, kprobes, ax) ENTRY(jprobe_break) break.m __IA64_BREAK_JPROBE END(jprobe_break)
arch/ia64/kernel/vmlinux.lds.S +0 -1
@@ -48,7 +48,6 @@ SECTIONS { SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT *(.gnu.linkonce.t*) }
arch/ia64/lib/flush.S +3 -3
@@ -9,7 +9,7 @@ #include <asm/asmmacro.h> #include <asm/export.h> - +#include <asm/ranges.h> /* * flush_icache_range(start,end)
@@ -21,7 +21,7 @@ * * Note: "in0" and "in1" are preserved for debugging purposes. */ - .section .kprobes.text,"ax" + set_section_rng(.text, kprobes, ax) GLOBAL_ENTRY(flush_icache_range) .prologue
@@ -74,7 +74,7 @@ EXPORT_SYMBOL_GPL(flush_icache_range) * * Note: "in0" and "in1" are preserved for debugging purposes. */ - .section .kprobes.text,"ax" + set_section_rng(.text, kprobes, ax) GLOBAL_ENTRY(clflush_cache_range) .prologue
arch/metag/kernel/vmlinux.lds.S +0 -1
@@ -23,7 +23,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT *(.text.*)
arch/microblaze/kernel/vmlinux.lds.S +0 -1
@@ -35,7 +35,6 @@ SECTIONS { SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT . = ALIGN (4) ;
arch/mips/kernel/vmlinux.lds.S +0 -1
@@ -57,7 +57,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT *(.text.*)
arch/mn10300/kernel/vmlinux.lds.S +0 -1
@@ -32,7 +32,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT *(.fixup) *(.gnu.warning) } = 0xcb
arch/nios2/kernel/vmlinux.lds.S +0 -1
@@ -41,7 +41,6 @@ SECTIONS LOCK_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT - KPROBES_TEXT } =0 _etext = .;
arch/openrisc/kernel/vmlinux.lds.S +0 -1
@@ -57,7 +57,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT *(.fixup)
arch/parisc/kernel/vmlinux.lds.S +0 -1
@@ -71,7 +71,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT *(.text.do_softirq)
arch/powerpc/include/asm/ppc_asm.h +1 -0
@@ -9,6 +9,7 @@#include <asm/processor.h> #include <asm/ppc-opcode.h> #include <asm/firmware.h> +#include <asm/ranges.h> #ifdef __ASSEMBLY__
arch/powerpc/kernel/vmlinux.lds.S +0 -1
@@ -112,7 +112,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT MEM_KEEP(init.text)
arch/s390/kernel/entry.S +3 -2
@@ -24,6 +24,7 @@ #include <asm/setup.h> #include <asm/nmi.h> #include <asm/export.h> +#include <asm/ranges.h> __PT_R0 = __PT_GPRS __PT_R1 = __PT_GPRS + 8
@@ -169,7 +170,7 @@ _PIF_WORK = (_PIF_PER_TRAP) tm off+\addr, \mask .endm - .section .kprobes.text, "ax" + set_section_rng(.text, kprobes, ax) .Ldummy: /* * This nop exists only in order to avoid that __switch_to starts at
@@ -986,7 +987,7 @@ ENTRY(restart_int_handler) brc 2,2b 3: j 3b - .section .kprobes.text, "ax" + set_section_rng(.text, kprobes, ax) #ifdef CONFIG_CHECK_STACK /*
arch/s390/kernel/kprobes.c +3 -3
@@ -289,9 +289,9 @@ static void kprobe_reenter_check(struct kprobe_ctlblk *kcb, struct kprobe *p)case KPROBE_REENTER :default :/* -* A kprobe on the code path to single step an instruction -* is a BUG. The code path resides in the .kprobes.text -* section and is executed with interrupts disabled. +* A kprobe on the code path to single step an instruction is a +* BUG. The code path resides in the kprobes section range and +* is executed with interrupts disabled. */ printk (KERN_EMERG "Invalid kprobe detected at %p.\n" , p->addr);dump_kprobe (p);
arch/s390/kernel/mcount.S +2 -1
@@ -10,8 +10,9 @@ #include <asm/ftrace.h> #include <asm/ptrace.h> #include <asm/export.h> +#include <asm/ranges.h> - .section .kprobes.text, "ax" + set_section_rng(.text, kprobes, ax) ENTRY(ftrace_stub) br %r14
arch/s390/kernel/vmlinux.lds.S +0 -1
@@ -37,7 +37,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT *(.fixup)
arch/score/kernel/vmlinux.lds.S +0 -1
@@ -42,7 +42,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT *(.text.*) *(.fixup) . = ALIGN (4) ;
arch/sh/kernel/vmlinux.lds.S +0 -1
@@ -38,7 +38,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT *(.fixup)
arch/sparc/kernel/vmlinux.lds.S +0 -1
@@ -51,7 +51,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT *(.gnu.warning)
arch/sparc/mm/ultra.S +2 -1
@@ -16,6 +16,7 @@ #include <asm/cacheflush.h> #include <asm/hypervisor.h> #include <asm/cpudata.h> +#include <asm/ranges.h> /* Basically, most of the Spitfire vs. Cheetah madness * has to do with the fact that Cheetah does not support
@@ -185,7 +186,7 @@ __spitfire_flush_tlb_mm_slow: /* * The following code flushes one page_size worth. */ - .section .kprobes.text, "ax" + set_section_rng(.text, kprobes, ax) .align 32 .globl __flush_icache_page __flush_icache_page: /* %o0 = phys_page */
arch/tile/kernel/vmlinux.lds.S +0 -1
@@ -44,7 +44,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT __fix_text_end = .; /* tile-cpack won't rearrange before this */
arch/x86/kernel/kprobes/core.c +5 -6
@@ -580,9 +580,9 @@ 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. -* Raise a BUG or we'll continue in an endless reentering loop -* and eventually a stack overflow. +* codepath should strictly reside in the kprobes section +* range. Raise a BUG or we'll continue in an endless +* reentering loop and eventually a stack overflow. */ printk (KERN_WARNING "Unrecoverable kprobe detected at %p.\n" , p->addr);
@@ -1133,10 +1133,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 (SECTION_RANGE_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 )
arch/x86/kernel/vmlinux.lds.S +0 -1
@@ -99,7 +99,6 @@ SECTIONS SCHED_TEXT CPUIDLE_TEXT LOCK_TEXT - KPROBES_TEXT ENTRY_TEXT IRQENTRY_TEXT SOFTIRQENTRY_TEXT
include/asm-generic/kprobes.h +2 -1
@@ -3,6 +3,7 @@#if defined(__KERNEL__) && !defined(__ASSEMBLY__)#ifdef CONFIG_KPROBES +#include <asm/ranges.h> /* * Blacklist ganerating macro. Specify functions which is not probed * by using this macro.
@@ -13,7 +14,7 @@ static unsigned long __used \ _kbl_addr_##fname = (unsigned long)fname;# define NOKPROBE_SYMBOL (fname) __NOKPROBE_SYMBOL(fname)/* Use this to forbid a kprobes attach on very low level functions */ -# define __kprobes __attribute__((__section__(".kprobes.text"))) +# define __kprobes __LINUX_RANGE(.text, kprobes)# define nokprobe_inline __always_inline#else # define NOKPROBE_SYMBOL (fname)
include/asm-generic/sections.h +0 -2
@@ -26,7 +26,6 @@* Following global variables are optional and may be unavailable on some * architectures and/or kernel configurations. * _text, _data -* __kprobes_text_start, __kprobes_text_end * __entry_text_start, __entry_text_end * __ctors_start, __ctors_end */
@@ -38,7 +37,6 @@ extern char _sinittext[], _einittext[];extern char __start_data_ro_after_init[], __end_data_ro_after_init[];extern char _end[];extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[]; -extern char __kprobes_text_start[], __kprobes_text_end[];extern char __entry_text_start[], __entry_text_end[];extern char __start_rodata[], __end_rodata[];
include/asm-generic/vmlinux.lds.h +1 -1
@@ -471,7 +471,7 @@#define KPROBES_TEXT \ ALIGN_FUNCTION(); \ VMLINUX_SYMBOL(__kprobes_text_start) = .; \ - *(.kprobes.text) \ + *(.text..rng.kprobes.any) \ VMLINUX_SYMBOL(__kprobes_text_end) = .;#define ENTRY_TEXT \
include/linux/kprobes.h +3 -0
@@ -43,6 +43,9 @@#include <asm/kprobes.h> #ifdef CONFIG_KPROBES +#include <linux/ranges.h> + +DECLARE_SECTION_RANGE (kprobes);/* kprobe_status settings */ #define KPROBE_HIT_ACTIVE 0x00000001
kernel/kprobes.c +4 -2
@@ -1328,8 +1328,7 @@ static int register_aggr_kprobe(struct kprobe *orig_p, struct kprobe *p)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 SECTION_RANGE_ADDR_WITHIN (kprobes, addr); }bool within_kprobe_blacklist (unsigned long addr)
@@ -2129,6 +2128,9 @@ static struct notifier_block kprobe_module_nb = {extern unsigned long __start_kprobe_blacklist[];extern unsigned long __stop_kprobe_blacklist[]; +/* Actual kprobes section range */ +DEFINE_SECTION_RANGE(kprobes, .text); +static int __init init_kprobes (void ) {int i, err =0 ;
scripts/mod/modpost.c +1 -1
@@ -894,7 +894,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", ".cpuidle.text" + ".text..rng.kprobes.any", ".cpuidle.text"#define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \ ".fixup", ".entry.text", ".exception.text", ".text.*", \ ".coldtext"
scripts/recordmcount.c +1 -1
@@ -417,7 +417,7 @@ is_mcounted_section_name(char const *const txtname)strcmp (".spinlock.text" , txtname) ==0 ||strcmp (".irqentry.text" , txtname) ==0 ||strcmp (".softirqentry.text" , txtname) ==0 || -strcmp (".kprobes.text" , txtname) ==0 || +strcmp (".text..rng.kprobes.any" , txtname) ==0 ||strcmp (".cpuidle.text" , txtname) ==0 ||strcmp (".text.unlikely" , txtname) ==0 ; }
scripts/recordmcount.pl +1 -1
@@ -135,7 +135,7 @@ my %text_sections = ( ".spinlock.text" => 1, ".irqentry.text" => 1, ".softirqentry.text" => 1, - ".kprobes.text" => 1, + ".text..rng.kprobes.any" => 1, ".cpuidle.text" => 1, ".text.unlikely" => 1, );
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerPATCH v7 13/14 kprobes: port blacklist kprobes to linker table
In reply to Luis R. Rodriguezkprobe makes use of two sections, the one dealing with the actual kprobes was recently ported using the standard section range API. The blacklist functionality of kprobes is still using a custom section and declaring its custom section using the linker script as follows:
type Linux-section custom section name begin end
table .init.data _kprobe_blacklist __start_kprobe_blacklist __stop_kprobe_blacklist
This ports the _kprobe_blacklist custom section to the standard Linux linker table API allowing us remove all the custom blacklist kprobe section declarations from the linker script.
This has been tested by trying to register a kprobe on a blacklisted symbol (these are declared with NOKPROBE_SYMBOL()), and confirms that this fails to work as expected. This was tested with:
# insmod samples/kprobes/kprobe_example.ko symbol="get_kprobe"
This fails to load as expected with:
insmod: ERROR: could not insert module samples/kprobes/kprobe_example.ko: Invalid parameters
v5: Use push_section_tbl() for _ASM_NOKPROBE() for x86, and
_ASM_NOKPROBE_SYMBOL() on powerpc
v4: ported over _ASM_NOKPROBE_SYMBOL() on powerpc and
ASM_NOKPROBE() on x86
v3: this patch was introduced in this series
--- arch/powerpc/include/asm/ppc_asm.h | 4 ++-- arch/x86/include/asm/asm.h | 4 +++- include/asm-generic/kprobes.h | 4 ++-- include/asm-generic/vmlinux.lds.h | 10 ---------- include/linux/kprobes.h | 2 ++ kernel/kprobes.c | 11 ++++------- 6 files changed, 13 insertions(+), 22 deletions(-)
arch/powerpc/include/asm/ppc_asm.h +2 -2
@@ -9,7 +9,7 @@#include <asm/processor.h> #include <asm/ppc-opcode.h> #include <asm/firmware.h> -#include <asm/ranges.h> +#include <asm/tables.h> #ifdef __ASSEMBLY__
@@ -266,7 +266,7 @@ GLUE(.,name):*/ #ifdef CONFIG_KPROBES #define _ASM_NOKPROBE_SYMBOL (entry) \ - .pushsection "_kprobe_blacklist","aw"; \ + push_section_tbl(.init.data, _kprobe_blacklist, any, aw); \ PPC_LONG (entry) ; \ .popsection#else
arch/x86/include/asm/asm.h +3 -1
@@ -1,6 +1,8 @@#ifndef _ASM_X86_ASM_H#define _ASM_X86_ASM_H +#include <asm/tables.h> +#ifdef __ASSEMBLY__# define __ASM_FORM (x) x# define __ASM_FORM_RAW (x) x
@@ -74,7 +76,7 @@ _ASM_EXTABLE_HANDLE(from, to, ex_handler_ext)# define _ASM_NOKPROBE (entry) \ - .pushsection "_kprobe_blacklist","aw" ; \ + push_section_tbl_any(.init.data, _kprobe_blacklist, aw);\ _ASM_ALIGN ; \ _ASM_PTR (entry); \ .popsection
include/asm-generic/kprobes.h +2 -2
@@ -3,14 +3,14 @@#if defined(__KERNEL__) && !defined(__ASSEMBLY__)#ifdef CONFIG_KPROBES +#include <linux/tables.h> #include <asm/ranges.h> /* * Blacklist ganerating macro. Specify functions which is not probed * 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)/* Use this to forbid a kprobes attach on very low level functions */
include/asm-generic/vmlinux.lds.h +0 -10
@@ -114,15 +114,6 @@#define BRANCH_PROFILE ()#endif -#ifdef CONFIG_KPROBES -#define KPROBE_BLACKLIST () . = ALIGN(8); \ - VMLINUX_SYMBOL(__start_kprobe_blacklist) = .; \ - KEEP(*(_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) = .; \
@@ -551,7 +542,6 @@ *(.init.rodata) \ FTRACE_EVENTS() \ TRACE_SYSCALLS() \ - KPROBE_BLACKLIST() \ MEM_DISCARD(init.rodata) \ CLK_OF_TABLES() \RESERVEDMEM_OF_TABLES () \
include/linux/kprobes.h +2 -0
@@ -44,8 +44,10 @@#ifdef CONFIG_KPROBES #include <linux/ranges.h> +#include <linux/tables.h> DECLARE_SECTION_RANGE (kprobes); +DECLARE_LINKTABLE(unsigned long, _kprobe_blacklist);/* kprobe_status settings */ #define KPROBE_HIT_ACTIVE 0x00000001
kernel/kprobes.c +4 -7
@@ -2053,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) ||
@@ -2125,8 +2124,7 @@ 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 section range */ DEFINE_SECTION_RANGE(kprobes, .text);
@@ -2143,8 +2141,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" );
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Luis R. Rodriguez
maintainerPATCH v7 14/14 lib: add linker tables test driver
In reply to Luis R. RodriguezAdd a test drivers for linker tables.
v7: address ./scripts/checkpatch.pl --codespell issues
v6: rename table macro as suggested by Andy Shevchenko
v5: added this commit for the first time in this series.
--- lib/Kconfig.debug | 6 + lib/Makefile | 1 + lib/test_linktables/Makefile | 13 + lib/test_linktables/test-linktables-00.c | 27 ++ lib/test_linktables/test-linktables-01.c | 27 ++ lib/test_linktables/test-linktables-02.c | 27 ++ lib/test_linktables/test-linktables-03.c | 27 ++ lib/test_linktables/test-linktables-04.c | 27 ++ lib/test_linktables/test-linktables.c | 801 +++++++++++++++++++++++++++++++ lib/test_linktables/test-linktables.h | 48 ++ 10 files changed, 1004 insertions(+) create mode 100644 lib/test_linktables/Makefile create mode 100644 lib/test_linktables/test-linktables-00.c create mode 100644 lib/test_linktables/test-linktables-01.c create mode 100644 lib/test_linktables/test-linktables-02.c create mode 100644 lib/test_linktables/test-linktables-03.c create mode 100644 lib/test_linktables/test-linktables-04.c create mode 100644 lib/test_linktables/test-linktables.c create mode 100644 lib/test_linktables/test-linktables.h
lib/Kconfig.debug +6 -0
@@ -1839,6 +1839,12 @@ config TEST_HASH This is intended to help people writing architecture-specific optimized versions. If unsure, say N. +config TEST_LINKTABLES + bool "Test linker table functionality" + default n + help + Enable this option to test the kernel's linker table functionality. + endmenu # runtime tests config PROVIDE_OHCI1394_DMA_INIT
lib/Makefile +1 -0
@@ -56,6 +56,7 @@ obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o obj-$(CONFIG_TEST_PRINTF) += test_printf.o obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o obj-$(CONFIG_TEST_UUID) += test_uuid.o +obj-$(CONFIG_TEST_LINKTABLES) += test_linktables/ ifeq ($(CONFIG_DEBUG_KOBJECT),y) CFLAGS_kobject.o += -DDEBUG
lib/test_linktables/Makefile new file +13 -0
@@ -0,0 +1,13 @@ +__LINKTABLE_TESTS := $(shell find ./ -name test-linktables-\*.c | wc -l) +ccflags-y += -D__LINKTABLE_TESTS=$(__LINKTABLE_TESTS) + +# Keep these disorganized, if linker tables did not work then +# things would not be ordered for us automatically at link time. +# Linker tables grants us the ability to be explicit about +# order. +obj-$(CONFIG_TEST_LINKTABLES) += test-linktables-04.o +obj-$(CONFIG_TEST_LINKTABLES) += test-linktables-02.o +obj-$(CONFIG_TEST_LINKTABLES) += test-linktables-01.o +obj-$(CONFIG_TEST_LINKTABLES) += test-linktables-03.o +obj-$(CONFIG_TEST_LINKTABLES) += test-linktables-00.o +obj-$(CONFIG_TEST_LINKTABLES) += test-linktables.o
lib/test_linktables/test-linktables-00.c new file +27 -0
@@ -0,0 +1,27 @@ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt + +#include <linux/tables.h> +#include <linux/printk.h> + +#include "test-linktables.h" + +static int __init test_linktable_00_init (int input) +{ +return 0 * input; +} + +static int __initdata test_linktable_00_init_data (int input) +{ +return 0 * input; +} + +static int test_linktable_00 (int input) +{ +return 0 * input; +} + +test_linktable_init_data (00 , test_linktable_00_init_data);/* .init.data */ +test_linktable_init_text (00 , test_linktable_00_init);/* .init.text */ +test_linktable (00 , test_linktable_00);/* .data */ +test_linktable_text (00 , test_linktable_00);/* .text */ +test_linktable_rodata (00 , test_linktable_00);/* .rodata */
lib/test_linktables/test-linktables-01.c new file +27 -0
@@ -0,0 +1,27 @@ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt + +#include <linux/tables.h> +#include <linux/printk.h> + +#include "test-linktables.h" + +static int __init test_linktable_01_init (int input) +{ +return 1 * input; +} + +static int __initdata test_linktable_01_init_data (int input) +{ +return 1 * input; +} + +static int test_linktable_01 (int input) +{ +return 1 * input; +} + +test_linktable_init_data (01 , test_linktable_01_init_data);/* .init.data */ +test_linktable_init_text (01 , test_linktable_01_init);/* .init.text */ +test_linktable (01 , test_linktable_01);/* .data */ +test_linktable_text (01 , test_linktable_01);/* .text */ +test_linktable_rodata (01 , test_linktable_01);/* .rodata */
lib/test_linktables/test-linktables-02.c new file +27 -0
@@ -0,0 +1,27 @@ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt + +#include <linux/tables.h> +#include <linux/printk.h> + +#include "test-linktables.h" + +static int __init test_linktable_02_init (int input) +{ +return 2 * input; +} + +static int __initdata test_linktable_02_init_data (int input) +{ +return 2 * input; +} + +static int test_linktable_02 (int input) +{ +return 2 * input; +} + +test_linktable_init_data (02 , test_linktable_02_init_data);/* .init.data */ +test_linktable_init_text (02 , test_linktable_02_init);/* .init.text */ +test_linktable (02 , test_linktable_02);/* .data */ +test_linktable_text (02 , test_linktable_02);/* .text */ +test_linktable_rodata (02 , test_linktable_02);/* .rodata */
lib/test_linktables/test-linktables-03.c new file +27 -0
@@ -0,0 +1,27 @@ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt + +#include <linux/tables.h> +#include <linux/printk.h> + +#include "test-linktables.h" + +static int __init test_linktable_03_init (int input) +{ +return 3 * input; +} + +static int __initdata test_linktable_03_init_data (int input) +{ +return 3 * input; +} + +static int test_linktable_03 (int input) +{ +return 3 * input; +} + +test_linktable_init_data (03 , test_linktable_03_init_data);/* .init.data */ +test_linktable_init_text (03 , test_linktable_03_init);/* .init.text */ +test_linktable (03 , test_linktable_03);/* .data */ +test_linktable_text (03 , test_linktable_03);/* .text */ +test_linktable_rodata (03 , test_linktable_03);/* .rodata */
lib/test_linktables/test-linktables-04.c new file +27 -0
@@ -0,0 +1,27 @@ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt + +#include <linux/tables.h> +#include <linux/printk.h> + +#include "test-linktables.h" + +static int __init test_linktable_04_init (int input) +{ +return 4 * input; +} + +static int __initdata test_linktable_04_init_data (int input) +{ +return 4 * input; +} + +static int test_linktable_04 (int input) +{ +return 4 * input; +} + +test_linktable_init_data (04 , test_linktable_04_init_data);/* .init.data */ +test_linktable_init_text (04 , test_linktable_04_init);/* .init.text */ +test_linktable (04 , test_linktable_04);/* .data */ +test_linktable_text (04 , test_linktable_04);/* .text */ +test_linktable_rodata (04 , test_linktable_04);/* .rodata */
lib/test_linktables/test-linktables.c new file +801 -0
801 lines not on this page · raw message
lib/test_linktables/test-linktables.h new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerv4 cover tools: add linker table userspace sandbox
In reply to Luis R. RodriguezThis v4 also addresses some spelling / checkpatch comlplains. The remaining checkpatch complaints are not valid for the code in question. This applies after the series:
[PATCH v7 00/14] linux: generalize sections, ranges and linker tables
Luis R. Rodriguez (6):
tools: add a userspace tools bug.h
tools: add init.h for tools
tools: add __used and enable to override
tools: expand export.h with VMLINUX_SYMBOL()
tools: add __section() to compiler.h
tools: add userspace linker table sandbox
Documentation/sections/linker-tables.rst | 4 +- MAINTAINERS | 1 + include/linux/tables.h | 5 +- tools/Makefile | 3 +- .../arch/x86/include/generated/asm/section-core.h | 1 + tools/arch/x86/include/generated/ranges.h | 1 + tools/arch/x86/include/generated/tables.h | 1 + tools/include/asm-generic/bug.h | 26 + tools/include/asm-generic/ranges.h | 93 +++ tools/include/asm-generic/section-core.h | 348 +++++++++++ tools/include/asm-generic/tables.h | 48 ++ tools/include/linux/bug.h | 6 + tools/include/linux/compiler.h | 8 + tools/include/linux/export.h | 22 + tools/include/linux/init.h | 9 + tools/include/linux/kernel.h | 2 + tools/include/linux/ranges.h | 183 ++++++ tools/include/linux/sections.h | 87 +++ tools/include/linux/string.h | 1 + tools/include/linux/tables.h | 684 +++++++++++++++++++++ tools/linker-tables/.gitignore | 2 + tools/linker-tables/Makefile | 184 ++++++ tools/linker-tables/README | 114 ++++ tools/linker-tables/arch/x86/include/asm/asm.h | 17 + tools/linker-tables/arch/x86/include/asm/boot.h | 1 + .../linker-tables/arch/x86/include/asm/bootparam.h | 32 + tools/linker-tables/arch/x86/include/asm/kprobes.h | 7 + .../linker-tables/arch/x86/include/asm/ps_const.h | 23 + tools/linker-tables/arch/x86/include/asm/ranges.h | 6 + .../arch/x86/include/asm/section-core.h | 1 + tools/linker-tables/arch/x86/include/asm/setup.h | 6 + tools/linker-tables/arch/x86/include/asm/tables.h | 6 + tools/linker-tables/arch/x86/include/asm/x86.h | 4 + .../arch/x86/include/asm/x86_init_fn.h | 169 +++++ tools/linker-tables/arch/x86/kernel/alpha.c | 10 + tools/linker-tables/arch/x86/kernel/alternative.c | 31 + tools/linker-tables/arch/x86/kernel/beta.c | 10 + tools/linker-tables/arch/x86/kernel/head64.c | 58 ++ tools/linker-tables/arch/x86/kernel/init.c | 42 ++ tools/linker-tables/arch/x86/kernel/kasan.c | 11 + tools/linker-tables/arch/x86/kernel/kprobes.c | 51 ++ tools/linker-tables/arch/x86/kernel/vmlinux.lds.S | 277 +++++++++ tools/linker-tables/arch/x86/mm/init.c | 11 + tools/linker-tables/arch/x86/xen/init.c | 13 + tools/linker-tables/drivers/acme.c | 33 + tools/linker-tables/drivers/synth/common.c | 16 + tools/linker-tables/drivers/synth/common.h | 2 + tools/linker-tables/drivers/synth/main.c | 36 ++ tools/linker-tables/drivers/synth/or.S | 39 ++ tools/linker-tables/drivers/synth/synth.h | 2 + tools/linker-tables/drivers/xen-driver.c | 12 + .../include/asm-generic/arch_init_fn.h | 50 ++ tools/linker-tables/include/asm-generic/kprobes.h | 26 + tools/linker-tables/include/linux/bitops.h | 6 + tools/linker-tables/include/linux/init.h | 40 ++ tools/linker-tables/include/linux/kasan.h | 5 + tools/linker-tables/include/linux/kernel.h | 2 + tools/linker-tables/include/linux/kprobes.h | 11 + tools/linker-tables/include/linux/module.h | 14 + tools/linker-tables/include/linux/mutex.h | 17 + tools/linker-tables/include/linux/pci.h | 7 + tools/linker-tables/include/linux/printk.h | 26 + tools/linker-tables/include/linux/ps_const.h | 46 ++ tools/linker-tables/include/linux/sched.h | 9 + tools/linker-tables/include/linux/spinlock.h | 13 + tools/linker-tables/include/linux/start_kernel.h | 1 + tools/linker-tables/include/linux/types.h | 13 + tools/linker-tables/include/linux/workqueue.h | 51 ++ tools/linker-tables/include/xen/xen.h | 4 + tools/linker-tables/kernel/locking/mutex.c | 28 + tools/linker-tables/kernel/locking/spinlock.c | 26 + tools/linker-tables/kernel/main.c | 32 + tools/linker-tables/kernel/workqueue.c | 43 ++ tools/linker-tables/lib/string.c | 26 + tools/linker-tables/main.c | 20 + tools/linker-tables/pci-quirks.c | 14 + tools/linker-tables/pci.c | 30 + 77 files changed, 3314 insertions(+), 5 deletions(-) create mode 100644 tools/arch/x86/include/generated/asm/section-core.h create mode 100644 tools/arch/x86/include/generated/ranges.h create mode 100644 tools/arch/x86/include/generated/tables.h create mode 100644 tools/include/asm-generic/bug.h create mode 100644 tools/include/asm-generic/ranges.h create mode 100644 tools/include/asm-generic/section-core.h create mode 100644 tools/include/asm-generic/tables.h create mode 100644 tools/include/linux/bug.h create mode 100644 tools/include/linux/init.h create mode 100644 tools/include/linux/ranges.h create mode 100644 tools/include/linux/sections.h create mode 100644 tools/include/linux/tables.h create mode 100644 tools/linker-tables/.gitignore create mode 100644 tools/linker-tables/Makefile create mode 100644 tools/linker-tables/README create mode 100644 tools/linker-tables/arch/x86/include/asm/asm.h create mode 100644 tools/linker-tables/arch/x86/include/asm/boot.h create mode 100644 tools/linker-tables/arch/x86/include/asm/bootparam.h create mode 100644 tools/linker-tables/arch/x86/include/asm/kprobes.h create mode 100644 tools/linker-tables/arch/x86/include/asm/ps_const.h create mode 100644 tools/linker-tables/arch/x86/include/asm/ranges.h create mode 100644 tools/linker-tables/arch/x86/include/asm/section-core.h create mode 100644 tools/linker-tables/arch/x86/include/asm/setup.h create mode 100644 tools/linker-tables/arch/x86/include/asm/tables.h create mode 100644 tools/linker-tables/arch/x86/include/asm/x86.h create mode 100644 tools/linker-tables/arch/x86/include/asm/x86_init_fn.h create mode 100644 tools/linker-tables/arch/x86/kernel/alpha.c create mode 100644 tools/linker-tables/arch/x86/kernel/alternative.c create mode 100644 tools/linker-tables/arch/x86/kernel/beta.c create mode 100644 tools/linker-tables/arch/x86/kernel/head64.c create mode 100644 tools/linker-tables/arch/x86/kernel/init.c create mode 100644 tools/linker-tables/arch/x86/kernel/kasan.c create mode 100644 tools/linker-tables/arch/x86/kernel/kprobes.c create mode 100644 tools/linker-tables/arch/x86/kernel/vmlinux.lds.S create mode 100644 tools/linker-tables/arch/x86/mm/init.c create mode 100644 tools/linker-tables/arch/x86/xen/init.c create mode 100644 tools/linker-tables/drivers/acme.c create mode 100644 tools/linker-tables/drivers/synth/common.c create mode 100644 tools/linker-tables/drivers/synth/common.h create mode 100644 tools/linker-tables/drivers/synth/main.c create mode 100644 tools/linker-tables/drivers/synth/or.S create mode 100644 tools/linker-tables/drivers/synth/synth.h create mode 100644 tools/linker-tables/drivers/xen-driver.c create mode 100644 tools/linker-tables/include/asm-generic/arch_init_fn.h create mode 100644 tools/linker-tables/include/asm-generic/kprobes.h create mode 100644 tools/linker-tables/include/linux/bitops.h create mode 100644 tools/linker-tables/include/linux/init.h create mode 100644 tools/linker-tables/include/linux/kasan.h create mode 100644 tools/linker-tables/include/linux/kernel.h create mode 100644 tools/linker-tables/include/linux/kprobes.h create mode 100644 tools/linker-tables/include/linux/module.h create mode 100644 tools/linker-tables/include/linux/mutex.h create mode 100644 tools/linker-tables/include/linux/pci.h create mode 100644 tools/linker-tables/include/linux/printk.h create mode 100644 tools/linker-tables/include/linux/ps_const.h create mode 100644 tools/linker-tables/include/linux/sched.h create mode 100644 tools/linker-tables/include/linux/spinlock.h create mode 100644 tools/linker-tables/include/linux/start_kernel.h create mode 100644 tools/linker-tables/include/linux/types.h create mode 100644 tools/linker-tables/include/linux/workqueue.h create mode 100644 tools/linker-tables/include/xen/xen.h create mode 100644 tools/linker-tables/kernel/locking/mutex.c create mode 100644 tools/linker-tables/kernel/locking/spinlock.c create mode 100644 tools/linker-tables/kernel/main.c create mode 100644 tools/linker-tables/kernel/workqueue.c create mode 100644 tools/linker-tables/lib/string.c create mode 100644 tools/linker-tables/main.c create mode 100644 tools/linker-tables/pci-quirks.c create mode 100644 tools/linker-tables/pci.c
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerPATCH v4 1/6 tools: add a userspace tools bug.h
This will be used later by the userspace linker-tables sandbox. As a convenience, include bug.h on kernel.h -- this is not done on upstream kernel.h, however most header files do include bug.h eventually, if we were to only add the ones that need it we'd need to copy a lot of headers to tools for the only purpose of includeing bug.h. This simplifies that.
v4: address ./scripts/checkpatch.pl --codespell complaints
--- tools/include/asm-generic/bug.h | 26 ++++++++++++++++++++++++++ tools/include/linux/bug.h | 6 ++++++ tools/include/linux/kernel.h | 2 ++ 3 files changed, 34 insertions(+) create mode 100644 tools/include/asm-generic/bug.h create mode 100644 tools/include/linux/bug.h
tools/include/asm-generic/bug.h new file +26 -0
@@ -0,0 +1,26 @@ +#ifndef __TOOLS_ASM_GENERIC_BUG +#define __TOOLS_ASM_GENERIC_BUG + +#include <stdio.h> +#include <stdlib.h> + +#define BUG () do { \ + fprintf(stderr, "------------------------------------------n"); \ + fprintf(stderr, "BUG on %s at %s: %i\n", \ + __func__, __FILE__, __LINE__); \ + abort(); \ +} \ +while (0) + +#define BUG_ON (cond) do { if (cond) BUG(); } while (0) + +#define WARN_ON (__test) do { \ + if (__test) { \ + fprintf(stderr, "----------------------------------n"); \ + fprintf(stderr, "WARN_ON on %s at %s: %i\n", \ + __func__, __FILE__, __LINE__); \ + } \ +} \ +while (0) + +#endif /* __TOOLS_ASM_GENERIC_BUG */
tools/include/linux/bug.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef _TOOLS_LINUX_BUG_H +#define _TOOLS_LINUX_BUG_H + +#include <asm-generic/bug.h> + +#endif /* _TOOLS_LINUX_BUG_H */
tools/include/linux/kernel.h +2 -0
@@ -5,6 +5,8 @@#include <stddef.h> #include <assert.h> +#include <linux/bug.h> +#define DIV_ROUND_UP (n,d) (((n) + (d) - 1) / (d))#define PERF_ALIGN (x, a) __PERF_ALIGN_MASK(x, (typeof(x))(a)-1)
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerPATCH v4 2/6 tools: add init.h for tools
In reply to Luis R. RodriguezStart off with just __ref -- we enalbe you to override, if you do that then you can define your own. The way you'd use this, if you do override, is define your own __ref and then use include_next.
--- tools/include/linux/init.h | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tools/include/linux/init.h
tools/include/linux/init.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef _TOOLS_LINUX_INIT_H +#define _TOOLS_LINUX_INIT_H + +/* this means you can add your own to fit you own userspace needs */ +#ifndef __ref +#define __ref +#endif + +#endif /* _TOOLS_LINUX_INIT_H */
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerPATCH v4 3/6 tools: add __used and enable to override
In reply to Luis R. RodriguezThis adds __used, to be used later in the userspace linker-tables sandbox. If any userspace applicaiton wants to override they can add their own definition and then use include_next.
This definition should probably suffice for most uses cases though.
--- tools/include/linux/compiler.h | 6 ++++++ 1 file changed, 6 insertions(+)
tools/include/linux/compiler.h +6 -0
@@ -5,6 +5,12 @@/* The "volatile" is due to gcc bugs */ #define barrier () __asm__ __volatile__("": : :"memory") + +/* You can override as you see fit on your userspace tool */ +#ifndef __used +#define __used __attribute__((__used__)) +#endif +#ifndef __always_inline# define __always_inline inline __attribute__((always_inline))#endif
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerPATCH v4 4/6 tools: expand export.h with VMLINUX_SYMBOL()
In reply to Luis R. RodriguezThis will be used later by the linker-table userspace sandbox.
--- tools/include/linux/export.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
tools/include/linux/export.h +22 -0
@@ -1,6 +1,28 @@#ifndef _TOOLS_LINUX_EXPORT_H_#define _TOOLS_LINUX_EXPORT_H_ +/* +* Export symbols from the kernel to modules. Forked from module.h +* to reduce the amount of pointless cruft we feed to gcc when only +* exporting a simple symbol or two. +* +* Try not to add #includes here. It slows compilation and makes kernel +* hackers place grumpy comments in header files. +*/ + +/* Some toolchains use a `_' prefix for all user symbols. */ +#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX +#define __VMLINUX_SYMBOL (x) _##x +#define __VMLINUX_SYMBOL_STR (x) "_" #x +#else +#define __VMLINUX_SYMBOL (x) x +#define __VMLINUX_SYMBOL_STR (x) #x +#endif + +/* Indirect, so macros are expanded before pasting. */ +#define VMLINUX_SYMBOL (x) __VMLINUX_SYMBOL(x) +#define VMLINUX_SYMBOL_STR (x) __VMLINUX_SYMBOL_STR(x) +#define EXPORT_SYMBOL (sym)#define EXPORT_SYMBOL_GPL (sym)#define EXPORT_SYMBOL_GPL_FUTURE (sym)
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerPATCH v4 5/6 tools: add __section() to compiler.h
In reply to Luis R. RodriguezThis will be used later by the userspace linker table.
--- tools/include/linux/compiler.h | 2 ++ 1 file changed, 2 insertions(+)
tools/include/linux/compiler.h +2 -0
@@ -132,4 +132,6 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s#define WRITE_ONCE (x, val) \ ({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; __write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) +#define __section (S ) __attribute__ ((__section__(#S))) +#endif /* _TOOLS_LINUX_COMPILER_H */
Signature · 1 line
2.11.0
Luis R. Rodriguez
maintainerPATCH v4 6/6 tools: add userspace linker table sandbox
In reply to Luis R. RodriguezAdd a userspace sandbox to allow easy experimentation and test extensions with linker tables, section ranges and the new section core definitions.
The userspace sandbox tries to mimic the Linux kernel development flow as much as possible, it however relies on and uses libc. Support is currently only provided to x86_64.
Demo run:
cd tools/linker-tables
make clean; make;
./demo
Initializing x86 bare metal world
x86-init: Number of init entries: 8
Initializing memory ...
Completed initializing memory !
Initializing pci ...
PCI fixup size: 1
Demo: Using LINKTABLE_FOR_EACHfoo_fixup
Demo: Using LINKTABLE_RUN_ALLfoo_fixup
Completed initializing pci !
Number of init entries: 1
Initializing kprobes ...
== OK: test_kprobe_0001 within range!
== OK: test_kprobe_0002 not in range as expected! Completed initializing kprobes !
Initializing kasan ...
Early init for Kasan...
Completed initializing kasan !
Initializing beta ...
Completed initializing beta !
Initializing alpha ...
Completed initializing alpha !
Booting bare metal
Calling start_kernel()...
ACME: Initializing ...
ACME: Finished init ... !
Synthetics: synth_init_or(2) returns: 0xDEADBEEF
Synthetics: ps_shr(0xDEADBEEF, get_demo_shr) returns: 0x0000DEAD
v7: address ./scripts/checkpatch.pl --codespell complaints
v6: rename table macros as suggested by Andy Shevchenko
v5:
o Use ..rng.* instead of .rng.* as suggested by Nicholas Piggin. This is the typical way to avoid clashes with compiler generated sections.
o moves tools/include/linux/printk.h to tools linker-table/include/linux/printk.h -- we cannot generalize this just yet, more work is needed in terms of providing a namespace for headers for types of ports of kernel functionality to userspace.
o Adjust code according to the latest discussions for the linker tables API (section name macros are now gone).
o Give CONFIG_HAVE_ARCH_PS_CONST for x86 another good 'ol college try, still fails, but this is just a demo anyway. We can amend and fix make this more optimized for x86 later. Thanks Boris!
v4: this patch is new in this series -- added to the kenrel as
suggested by Boris, as otherwise it'd be really hard to keep an external userspace repository in sync.
--- Documentation/sections/linker-tables.rst | 4 +- MAINTAINERS | 1 + include/linux/tables.h | 5 +- tools/Makefile | 3 +- .../arch/x86/include/generated/asm/section-core.h | 1 + tools/arch/x86/include/generated/ranges.h | 1 + tools/arch/x86/include/generated/tables.h | 1 + tools/include/asm-generic/ranges.h | 93 +++ tools/include/asm-generic/section-core.h | 348 +++++++++++ tools/include/asm-generic/tables.h | 48 ++ tools/include/linux/ranges.h | 183 ++++++ tools/include/linux/sections.h | 87 +++ tools/include/linux/string.h | 1 + tools/include/linux/tables.h | 684 +++++++++++++++++++++ tools/linker-tables/.gitignore | 2 + tools/linker-tables/Makefile | 184 ++++++ tools/linker-tables/README | 114 ++++ tools/linker-tables/arch/x86/include/asm/asm.h | 17 + tools/linker-tables/arch/x86/include/asm/boot.h | 1 + .../linker-tables/arch/x86/include/asm/bootparam.h | 32 + tools/linker-tables/arch/x86/include/asm/kprobes.h | 7 + .../linker-tables/arch/x86/include/asm/ps_const.h | 23 + tools/linker-tables/arch/x86/include/asm/ranges.h | 6 + .../arch/x86/include/asm/section-core.h | 1 + tools/linker-tables/arch/x86/include/asm/setup.h | 6 + tools/linker-tables/arch/x86/include/asm/tables.h | 6 + tools/linker-tables/arch/x86/include/asm/x86.h | 4 + .../arch/x86/include/asm/x86_init_fn.h | 169 +++++ tools/linker-tables/arch/x86/kernel/alpha.c | 10 + tools/linker-tables/arch/x86/kernel/alternative.c | 31 + tools/linker-tables/arch/x86/kernel/beta.c | 10 + tools/linker-tables/arch/x86/kernel/head64.c | 58 ++ tools/linker-tables/arch/x86/kernel/init.c | 42 ++ tools/linker-tables/arch/x86/kernel/kasan.c | 11 + tools/linker-tables/arch/x86/kernel/kprobes.c | 51 ++ tools/linker-tables/arch/x86/kernel/vmlinux.lds.S | 277 +++++++++ tools/linker-tables/arch/x86/mm/init.c | 11 + tools/linker-tables/arch/x86/xen/init.c | 13 + tools/linker-tables/drivers/acme.c | 33 + tools/linker-tables/drivers/synth/common.c | 16 + tools/linker-tables/drivers/synth/common.h | 2 + tools/linker-tables/drivers/synth/main.c | 36 ++ tools/linker-tables/drivers/synth/or.S | 39 ++ tools/linker-tables/drivers/synth/synth.h | 2 + tools/linker-tables/drivers/xen-driver.c | 12 + .../include/asm-generic/arch_init_fn.h | 50 ++ tools/linker-tables/include/asm-generic/kprobes.h | 26 + tools/linker-tables/include/linux/bitops.h | 6 + tools/linker-tables/include/linux/init.h | 40 ++ tools/linker-tables/include/linux/kasan.h | 5 + tools/linker-tables/include/linux/kernel.h | 2 + tools/linker-tables/include/linux/kprobes.h | 11 + tools/linker-tables/include/linux/module.h | 14 + tools/linker-tables/include/linux/mutex.h | 17 + tools/linker-tables/include/linux/pci.h | 7 + tools/linker-tables/include/linux/printk.h | 26 + tools/linker-tables/include/linux/ps_const.h | 46 ++ tools/linker-tables/include/linux/sched.h | 9 + tools/linker-tables/include/linux/spinlock.h | 13 + tools/linker-tables/include/linux/start_kernel.h | 1 + tools/linker-tables/include/linux/types.h | 13 + tools/linker-tables/include/linux/workqueue.h | 51 ++ tools/linker-tables/include/xen/xen.h | 4 + tools/linker-tables/kernel/locking/mutex.c | 28 + tools/linker-tables/kernel/locking/spinlock.c | 26 + tools/linker-tables/kernel/main.c | 32 + tools/linker-tables/kernel/workqueue.c | 43 ++ tools/linker-tables/lib/string.c | 26 + tools/linker-tables/main.c | 20 + tools/linker-tables/pci-quirks.c | 14 + tools/linker-tables/pci.c | 30 + 71 files changed, 3241 insertions(+), 5 deletions(-) create mode 100644 tools/arch/x86/include/generated/asm/section-core.h create mode 100644 tools/arch/x86/include/generated/ranges.h create mode 100644 tools/arch/x86/include/generated/tables.h create mode 100644 tools/include/asm-generic/ranges.h create mode 100644 tools/include/asm-generic/section-core.h create mode 100644 tools/include/asm-generic/tables.h create mode 100644 tools/include/linux/ranges.h create mode 100644 tools/include/linux/sections.h create mode 100644 tools/include/linux/tables.h create mode 100644 tools/linker-tables/.gitignore create mode 100644 tools/linker-tables/Makefile create mode 100644 tools/linker-tables/README create mode 100644 tools/linker-tables/arch/x86/include/asm/asm.h create mode 100644 tools/linker-tables/arch/x86/include/asm/boot.h create mode 100644 tools/linker-tables/arch/x86/include/asm/bootparam.h create mode 100644 tools/linker-tables/arch/x86/include/asm/kprobes.h create mode 100644 tools/linker-tables/arch/x86/include/asm/ps_const.h create mode 100644 tools/linker-tables/arch/x86/include/asm/ranges.h create mode 100644 tools/linker-tables/arch/x86/include/asm/section-core.h create mode 100644 tools/linker-tables/arch/x86/include/asm/setup.h create mode 100644 tools/linker-tables/arch/x86/include/asm/tables.h create mode 100644 tools/linker-tables/arch/x86/include/asm/x86.h create mode 100644 tools/linker-tables/arch/x86/include/asm/x86_init_fn.h create mode 100644 tools/linker-tables/arch/x86/kernel/alpha.c create mode 100644 tools/linker-tables/arch/x86/kernel/alternative.c create mode 100644 tools/linker-tables/arch/x86/kernel/beta.c create mode 100644 tools/linker-tables/arch/x86/kernel/head64.c create mode 100644 tools/linker-tables/arch/x86/kernel/init.c create mode 100644 tools/linker-tables/arch/x86/kernel/kasan.c create mode 100644 tools/linker-tables/arch/x86/kernel/kprobes.c create mode 100644 tools/linker-tables/arch/x86/kernel/vmlinux.lds.S create mode 100644 tools/linker-tables/arch/x86/mm/init.c create mode 100644 tools/linker-tables/arch/x86/xen/init.c create mode 100644 tools/linker-tables/drivers/acme.c create mode 100644 tools/linker-tables/drivers/synth/common.c create mode 100644 tools/linker-tables/drivers/synth/common.h create mode 100644 tools/linker-tables/drivers/synth/main.c create mode 100644 tools/linker-tables/drivers/synth/or.S create mode 100644 tools/linker-tables/drivers/synth/synth.h create mode 100644 tools/linker-tables/drivers/xen-driver.c create mode 100644 tools/linker-tables/include/asm-generic/arch_init_fn.h create mode 100644 tools/linker-tables/include/asm-generic/kprobes.h create mode 100644 tools/linker-tables/include/linux/bitops.h create mode 100644 tools/linker-tables/include/linux/init.h create mode 100644 tools/linker-tables/include/linux/kasan.h create mode 100644 tools/linker-tables/include/linux/kernel.h create mode 100644 tools/linker-tables/include/linux/kprobes.h create mode 100644 tools/linker-tables/include/linux/module.h create mode 100644 tools/linker-tables/include/linux/mutex.h create mode 100644 tools/linker-tables/include/linux/pci.h create mode 100644 tools/linker-tables/include/linux/printk.h create mode 100644 tools/linker-tables/include/linux/ps_const.h create mode 100644 tools/linker-tables/include/linux/sched.h create mode 100644 tools/linker-tables/include/linux/spinlock.h create mode 100644 tools/linker-tables/include/linux/start_kernel.h create mode 100644 tools/linker-tables/include/linux/types.h create mode 100644 tools/linker-tables/include/linux/workqueue.h create mode 100644 tools/linker-tables/include/xen/xen.h create mode 100644 tools/linker-tables/kernel/locking/mutex.c create mode 100644 tools/linker-tables/kernel/locking/spinlock.c create mode 100644 tools/linker-tables/kernel/main.c create mode 100644 tools/linker-tables/kernel/workqueue.c create mode 100644 tools/linker-tables/lib/string.c create mode 100644 tools/linker-tables/main.c create mode 100644 tools/linker-tables/pci-quirks.c create mode 100644 tools/linker-tables/pci.c
Documentation/sections/linker-tables.rst +2 -2
@@ -11,11 +11,11 @@ About Linker tables .. kernel-doc:: include/linux/tables.h :doc: Introduction -Linker table provenance +Linker table provenance and userspace testing --------------------------------------------- .. kernel-doc:: include/linux/tables.h - :doc: Linker table provenance + :doc: Linker table provenance and userspace testing Benefits of using Linker tables ===============================
MAINTAINERS +1 -0
@@ -5429,6 +5429,7 @@ L: [email protected] S: Supported F: include/asm-generic/tables.h F: include/linux/tables.h +F: tools/linker-tables/ F: Documentation/sections/linker-tables.rst GENERIC PHY FRAMEWORK
include/linux/tables.h +3 -2
@@ -35,12 +35,13 @@*/ /** -* DOC: Linker table provenance +* DOC: Linker table provenance and userspace testing * * The Linux implementation of linker tables was inspired by the iPXE linker * table's solution (iPXE commit 67a10ef000cb7 "[contrib] Add rom-o-matic to * contrib "[0]). To see how this code evolved refer to the out of tree -* userspace linker-table tree [1]. +* userspace linker-table tree [1]. Linux has a similar userspace application +* in tools/linker-tables/ to help more easily test adding new extensions. * * Contrary to iPXE's solution which strives to force compilation of * everything using linker tables, Linux's solution allows for developers to be
tools/Makefile +2 -1
@@ -19,6 +19,7 @@ help: @echo ' kvm_stat - top-like utility for displaying kvm statistics' @echo ' leds - LEDs tools' @echo ' lguest - a minimal 32-bit x86 hypervisor' + @echo ' linker-tables - userspace liker table sandbox and related tools' @echo ' net - misc networking tools' @echo ' perf - Linux performance measurement and analysis tool' @echo ' selftests - various kernel selftests'
@@ -86,7 +87,7 @@ tmon: FORCE freefall: FORCE $(call descend,laptop/$@) -all: acpi cgroup cpupower gpio hv firewire lguest \ +all: acpi cgroup cpupower gpio hv firewire lguest linker-tables \ perf selftests turbostat usb \ virtio vm net x86_energy_perf_policy \ tmon freefall objtool
tools/arch/x86/include/generated/asm/section-core.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/section-core.h>
tools/arch/x86/include/generated/ranges.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/ranges.h>
tools/arch/x86/include/generated/tables.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/tables.h>
tools/include/asm-generic/ranges.h new file +93 -0
93 lines not on this page · raw message
tools/include/asm-generic/section-core.h new file +348 -0
348 lines not on this page · raw message
tools/include/asm-generic/tables.h new file +48 -0
48 lines not on this page · raw message
tools/include/linux/ranges.h new file +183 -0
183 lines not on this page · raw message
tools/include/linux/sections.h new file +87 -0
87 lines not on this page · raw message
tools/include/linux/string.h +1 -0
@@ -3,6 +3,7 @@#include <linux/types.h> /* for size_t */ +#include <string.h> void *memdup (const void *src,size_t len);
tools/include/linux/tables.h new file +684 -0
684 lines not on this page · raw message
tools/linker-tables/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +arch/x86/kernel/vmlinux.lds +demo
tools/linker-tables/Makefile new file +184 -0
184 lines not on this page · raw message
tools/linker-tables/README new file +114 -0
114 lines not on this page · raw message
tools/linker-tables/arch/x86/include/asm/asm.h new file +17 -0
@@ -0,0 +1,17 @@ +#ifndef _ASM_X86_ASM_H + +#ifdef __ASSEMBLY__ +# define __ASM_FORM (x) x +# define __ASM_FORM_RAW (x) x +# define __ASM_FORM_COMMA (x) x, +#else +# define __ASM_FORM (x) " " #x " " +# define __ASM_FORM_RAW (x) #x +# define __ASM_FORM_COMMA (x) " " #x "," +#endif + +# define __ASM_SEL (a,b) __ASM_FORM(b) +# define __ASM_SEL_RAW (a,b) __ASM_FORM_RAW(b) +#define _ASM_PTR __ASM_SEL(.long, .quad) + +#endif /* _ASM_X86_ASM_H */
tools/linker-tables/arch/x86/include/asm/boot.h new file +1 -0
@@ -0,0 +1 @@ +extern struct boot_params boot_params;
tools/linker-tables/arch/x86/include/asm/bootparam.h new file +32 -0
@@ -0,0 +1,32 @@ +#ifndef __BOOTPARAM_H +#define __BOOTPARAM_H + +#include <linux/types.h> + +struct setup_header { +__u32 hardware_subarch; +} __attribute__((packed)); + +struct boot_params { +struct setup_header hdr; +} __attribute__((packed)); + +enum { +X86_SUBARCH_PC =0 , +X86_SUBARCH_LGUEST , +X86_SUBARCH_XEN , +X86_SUBARCH_INTEL_MID , +X86_SUBARCH_CE4100 , +X86_NR_SUBARCHS , +}; + +#define X86_SUBARCH_ALL_SUBARCHS \ + ( \ + BIT(X86_SUBARCH_PC) | \ + BIT(X86_SUBARCH_LGUEST) | \ + BIT(X86_SUBARCH_XEN) | \ + BIT(X86_SUBARCH_INTEL_MID) | \ + BIT(X86_SUBARCH_CE4100) \ + ) + +#endif /* __BOOTPARAM_H */
tools/linker-tables/arch/x86/include/asm/kprobes.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef _SANDBOX_ASM_X86_KPROBES_H +#define _SANDBOX_ASM_X86_KPROBES_H + +/* This is all we need for the demo */ +#include <asm-generic/kprobes.h> + +#endif /* _SANDBOX_ASM_X86_KPROBES_H */
tools/linker-tables/arch/x86/include/asm/ps_const.h new file +23 -0
@@ -0,0 +1,23 @@ +#ifndef __X86_PS_CONST +#define __X86_PS_CONST + +#include <linux/stringify.h> +#include <linux/tables.h> +#include <asm/asm.h> + +#define ps_shr (in, _func) \ +({ \ + __typeof__(in) _count; \ + \ + asm volatile( \ + "shr %P[_in],%[_count]\n" \ + "1:\n" \ + push_section_tbl(.init.data, ps_set_const_table, 01,) \ + _ASM_PTR "1b-1, %P2, %P3\n" \ + ".popsection\n" \ + : [_count] "=g" (_count) \ + : [_in] "i" (in), "i" (SET_CONST_U8), "i" (_func)); \ + (_count); \ +}) + +#endif /* __X86_PS_CONST */
tools/linker-tables/arch/x86/include/asm/ranges.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef _ASM_X86_RANGES_H +#define _ASM_X86_RANGES_H + +#include <asm-generic/ranges.h> + +#endif /* _ASM_X86_RANGES_H */
tools/linker-tables/arch/x86/include/asm/section-core.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/section-core.h>
tools/linker-tables/arch/x86/include/asm/setup.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __LINUX_X86_USER_SETUP_H +#define __LINUX_X86_USER_SETUP_H + +/* I'm lazy */ + +#endif /* __LINUX_X86_USER_SETUP_H */
tools/linker-tables/arch/x86/include/asm/tables.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef _ASM_X86_TABLES_H +#define _ASM_X86_TABLES_H + +#include <asm-generic/tables.h> + +#endif /* _ASM_X86_RANGES_H */
tools/linker-tables/arch/x86/include/asm/x86.h new file +4 -0
@@ -0,0 +1,4 @@ +int startup_64 (void ); +int x86_64_start_reservations (void ); +void setup_arch (void ); +void late_init (void );
tools/linker-tables/arch/x86/include/asm/x86_init_fn.h new file +169 -0
169 lines not on this page · raw message
tools/linker-tables/arch/x86/kernel/alpha.c new file +10 -0
@@ -0,0 +1,10 @@ +#include <linux/kernel.h> +#include <asm/x86_init_fn.h> + +static void early_init_alpha (void ) +{ +pr_info ("Initializing alpha ...\n" ); +pr_info ("Completed initializing alpha !\n" ); +} + +x86_init_early_pc (early_init_alpha);
tools/linker-tables/arch/x86/kernel/alternative.c new file +31 -0
@@ -0,0 +1,31 @@ +#include <asm/x86_init_fn.h> + +#include <linux/kernel.h> +#include <linux/ps_const.h> + +void apply_alternatives_linker_tables (void ) +{ +unsigned int num_consts =LINKTABLE_SIZE (ps_set_const_table); +struct ps_set_const *ps_const; + +if (!num_consts) +return ; + +pr_debug ("Number of init entries: %d\n" , num_consts); + +linktable_for_each (ps_const, ps_set_const_table) { +switch (ps_const->type) { +case SET_CONST_U8 : + *ps_const->count = (__u8 ) ps_const->func (); +break ; +case SET_CONST_U16 : + *ps_const->count = (__u16 ) ps_const->func (); +break ; +case SET_CONST_U32 : + *ps_const->count = (__u16 ) ps_const->func (); +break ; + } + } +} + +x86_init_early_pc (apply_alternatives_linker_tables);
tools/linker-tables/arch/x86/kernel/beta.c new file +10 -0
@@ -0,0 +1,10 @@ +#include <linux/kernel.h> +#include <asm/x86_init_fn.h> + +static void early_init_beta (void ) +{ +pr_info ("Initializing beta ...\n" ); +pr_info ("Completed initializing beta !\n" ); +} + +x86_init_early_pc (early_init_beta);
tools/linker-tables/arch/x86/kernel/head64.c new file +58 -0
58 lines not on this page · raw message
tools/linker-tables/arch/x86/kernel/init.c new file +42 -0
42 lines not on this page · raw message
tools/linker-tables/arch/x86/kernel/kasan.c new file +11 -0
@@ -0,0 +1,11 @@ +#include <linux/kernel.h> +#include <asm/x86_init_fn.h> + +void kasan_early_init (void ) +{ +pr_info ("Initializing kasan ...\n" ); +pr_info ("Early init for Kasan...\n" ); +pr_info ("Completed initializing kasan !\n" ); +} + +x86_init_early_pc (kasan_early_init);
tools/linker-tables/arch/x86/kernel/kprobes.c new file +51 -0
51 lines not on this page · raw message
tools/linker-tables/arch/x86/kernel/vmlinux.lds.S new file +277 -0
277 lines not on this page · raw message
tools/linker-tables/arch/x86/mm/init.c new file +11 -0
@@ -0,0 +1,11 @@ +#include <linux/kernel.h> +#include <asm/x86_init_fn.h> + +static void early_init_memory (void ) +{ +pr_info ("Initializing memory ...\n" ); +sleep (1 ); +pr_info ("Completed initializing memory !\n" ); +} + +x86_init_early_all (early_init_memory);
tools/linker-tables/arch/x86/xen/init.c new file +13 -0
@@ -0,0 +1,13 @@ +#include <linux/kernel.h> +#include <linux/tables.h> +#include <asm/x86_init_fn.h> +#include <asm/x86.h> + +void startup_xen (void ) +{ +pr_info ("Initializing Xen guest\n" ); + +x86_init_fn_early_init (); + +x86_64_start_reservations (); +}
tools/linker-tables/drivers/acme.c new file +33 -0
@@ -0,0 +1,33 @@ +#define pr_fmt (fmt) "ACME: " fmt + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/workqueue.h> + +void *acme_todo (void *arg); +static DECLARE_WORK(acme_work, acme_todo); + +void *acme_todo (void *arg) +{ +pr_info ("Running scheduled work\n" ); +pthread_exit (NULL ); +} + +static int acme_init_driver (void ) +{ +pr_info ("Initializing ...\n" ); +sleep (2 ); +pr_info ("Finished init ... !\n" ); + +init_work (&acme_work); +schedule_work (&acme_work); + +return 0 ; +} +module_init (acme_init_driver); + +static void acme_exit (void ) +{ +cancel_work_sync (&acme_work); +}; +module_exit (acme_exit);
tools/linker-tables/drivers/synth/common.c new file +16 -0
@@ -0,0 +1,16 @@ +int demo_or_1 (int arg) +{ +switch (arg) { +case 1 : +return 0xDEA00000 ; +case 2 : +return 0X000D0000 ; +default : +return arg *2 ; + } +} + +int demo_or_2 (void ) +{ +return 0x0000BEEF ; +}
tools/linker-tables/drivers/synth/common.h new file +2 -0
@@ -0,0 +1,2 @@ +int demo_or_1 (int arg); +int demo_or_2 (void );
tools/linker-tables/drivers/synth/main.c new file +36 -0
@@ -0,0 +1,36 @@ +#define pr_fmt (fmt) "Synthetics: " fmt + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/ps_const.h> + +#include "common.h" +#include "synth.h" + +DEFINE_LINKTABLE_INIT_DATA(struct ps_set_const, ps_set_const_table); + +unsigned int get_demo_shr (void ) +{ +return 16 ; +} + +static int synth_init (void ) +{ +int synth_or; +int val =2 ; +const unsigned int reg =ps_shr (0xDEADBEEF , get_demo_shr); + + synth_or =synth_init_or (val); +pr_info ("synth_init_or(%d) returns: 0x%08X\n" , val, synth_or); + +pr_info ("ps_shr(0x%08X, get_demo_shr) returns: 0x%08X\n" , +0xDEADBEEF , reg); + +return 0 ; +} +module_init (synth_init); + +static void synth_exit (void ) +{ +} +module_exit (synth_exit);
tools/linker-tables/drivers/synth/or.S new file +39 -0
@@ -0,0 +1,39 @@ +#include <asm/ranges.h> + + DEFINE_SECTION_RANGE(.text, synth_init_or) + + push_section_rng_level(.text, synth_init_or, "01", ) + /* err = 0; */ + pushq %rbp + movq %rsp,%rbp + pushq %rbx + xorq %rbx,%rbx + .popsection + + push_section_rng_level(.text, synth_init_or, "99", ) + /* return err; */ + movq %rbx,%rax + popq %rbx + popq %rbp + retq + .popsection + + push_section_rng_level(.text, synth_init_or, "50", ) + /* err |= demo_or_1(1); */ + movl $1,%edi + call demo_or_1 + orq %rax,%rbx + .popsection + + push_section_rng_level(.text, synth_init_or, "50", ) + /* err |= demo_or_1(2); */ + movl $2,%edi + call demo_or_1 + orq %rax,%rbx + .popsection + + push_section_rng_level(.text, synth_init_or, "50", ) + /* err |= demo_or_2(); */ + call demo_or_2 + orq %rax,%rbx + .popsection
tools/linker-tables/drivers/synth/synth.h new file +2 -0
@@ -0,0 +1,2 @@ +/* Synthetic demos go here */ +int synth_init_or (int arg);
tools/linker-tables/drivers/xen-driver.c new file +12 -0
@@ -0,0 +1,12 @@ +#include <asm/x86_init_fn.h> +#include <linux/kernel.h> +#include <linux/pci.h> +#include <xen/xen.h> + +static void early_xen_init_driver (void ) +{ +pr_info ("Initializing xen driver\n" ); +sleep (2 ); +} + +x86_init_early_xen (early_xen_init_driver);
tools/linker-tables/include/asm-generic/arch_init_fn.h new file +50 -0
50 lines not on this page · raw message
tools/linker-tables/include/asm-generic/kprobes.h new file +26 -0
@@ -0,0 +1,26 @@ +#ifndef _SANDBOX_ASM_GENERIC_KPROBES_H +#define _SANDBOX_ASM_GENERIC_KPROBES_H + +#if defined(__KERNEL__) && !defined(__ASSEMBLY__) +#ifdef CONFIG_KPROBES +#include <linux/tables.h> +#include <asm/ranges.h> +/* +* Blacklist ganerating macro. Specify functions which is not probed +* by using this macro. +*/ +# define __NOKPROBE_SYMBOL (fname) \ +static LINKTABLE_INIT_DATA(_kprobe_blacklist, all) \ + _kbl_addr_##fname = (unsigned long)fname; +# define NOKPROBE_SYMBOL (fname) __NOKPROBE_SYMBOL(fname) +/* Use this to forbid a kprobes attach on very low level functions */ +# define __kprobes __LINUX_RANGE(.text, kprobes) +# define nokprobe_inline __always_inline +#else +# define NOKPROBE_SYMBOL (fname) +# define __kprobes +# define nokprobe_inline inline +#endif +#endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */ + +#endif /* _SANDBOX_ASM_GENERIC_KPROBES_H */
tools/linker-tables/include/linux/bitops.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef _LINUX_BITOPS_H +#define _LINUX_BITOPS_H + +#define BIT (nr) (1UL << (nr)) + +#endif /* _LINUX_BITOPS_H */
tools/linker-tables/include/linux/init.h new file +40 -0
@@ -0,0 +1,40 @@ +#ifndef _SANDBOX_LINUX_INIT_H +#define _SANDBOX_LINUX_INIT_H + +#include_next <linux/init.h> +#include <linux/types.h> +#include <linux/sections.h> + +#define __init __section(.init.text) +#define __exit __section(.exit.text) + +#ifndef __ASSEMBLY__ +#include <linux/tables.h> +typedef int (*initcall_t )(void ); +typedef void (*exitcall_t )(void ); + +DECLARE_LINKTABLE (initcall_t, init_calls); +DECLARE_LINKTABLE (exitcall_t, exit_calls); + +#define __define_initcall (fn, id) \ + static LINKTABLE_INIT_DATA(init_calls, id) \ + __initcall_##fn##id = fn + +#define pure_initcall (fn) __define_initcall(fn, 0) +#define core_initcall (fn) __define_initcall(fn, 1) +#define postcore_initcall (fn) __define_initcall(fn, 2) +#define arch_initcall (fn) __define_initcall(fn, 3) +#define subsys_initcall (fn) __define_initcall(fn, 4) +#define fs_initcall (fn) __define_initcall(fn, 5) +#define device_initcall (fn) __define_initcall(fn, 6) +#define late_initcall (fn) __define_initcall(fn, 7) + +#define __initcall (fn) device_initcall(fn) + +#define __exitcall (fn) \ + static LINKTABLE_INIT_DATA(exit_calls, any) \ + __exitcall_##fn = fn; + +#endif + +#endif /* _SANDBOX_LINUX_INIT_H */
tools/linker-tables/include/linux/kasan.h new file +5 -0
@@ -0,0 +1,5 @@ +#include <linux/types.h> + +void kasan_early_init (void ); +int kasan_init (void ); +bool is_kasan_setup (void );
tools/linker-tables/include/linux/kernel.h new file +2 -0
@@ -0,0 +1,2 @@ +#include_next <linux/kernel.h> +#include <linux/printk.h>
tools/linker-tables/include/linux/kprobes.h new file +11 -0
@@ -0,0 +1,11 @@ +#ifndef _SANDBOX_LINUX_KPROBES_H +#define _SANDBOX_LINUX_KPROBES_H + +#include <asm/kprobes.h> +#include <linux/ranges.h> + +#ifdef CONFIG_KPROBES +DECLARE_SECTION_RANGE (kprobes); +#endif + +#endif /* _SANDBOX_LINUX_KPROBES_H */
tools/linker-tables/include/linux/module.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef _LINUX_MODULE_H +#define _LINUX_MODULE_H + +#include <linux/init.h> + +#define module_init (x) __initcall(x); +#define module_exit (x) __exitcall(x); + +struct module { +int (*init)(void ); +void (*exit)(void ); +}; + +#endif /* _LINUX_MODULE_H */
tools/linker-tables/include/linux/mutex.h new file +17 -0
@@ -0,0 +1,17 @@ +#ifndef __LINUX_MUTEX_H +#define __LINUX_MUTEX_H + +#include <sys/types.h> +#include <linux/sched.h> +#include <pthread.h> + +struct mutex { +pthread_mutex_t lock; +}; + +void mutex_init (struct mutex *lock); +void mutex_destroy (struct mutex *lock); +void mutex_lock (struct mutex *lock); +void mutex_unlock (struct mutex *lock); + +#endif /* __LINUX_MUTEX_H */
tools/linker-tables/include/linux/pci.h new file +7 -0
@@ -0,0 +1,7 @@ +#include <linux/types.h> + +struct pci_fixup { +void (*hook)(void ); +}; + +bool detect_pci (void );
tools/linker-tables/include/linux/printk.h new file +26 -0
@@ -0,0 +1,26 @@ +#ifndef _SANDBOX_KERNEL_PRINTK +#define _SANDBOX_KERNEL_PRINTK + +#ifdef __KERNEL__ + +#include <stdio.h> + +#ifndef pr_fmt +#define pr_fmt (fmt) fmt +#endif + +#ifndef pr_info +#define pr_info (fmt, ...) printf(pr_fmt(fmt), ##__VA_ARGS__) +#endif + +#ifndef pr_err +#define pr_err (fmt, ...) printf(pr_fmt(fmt), ##__VA_ARGS__) +#endif + +#ifndef pr_debug +#define pr_debug (fmt, ...) printf(pr_fmt(fmt), ##__VA_ARGS__) +#endif + +#endif /* __KERNEL__ */ + +#endif /* _SANDBOX_KERNEL_PRINTK */
tools/linker-tables/include/linux/ps_const.h new file +46 -0
46 lines not on this page · raw message
tools/linker-tables/include/linux/sched.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef _LINUX_SCHED_H +#define _LINUX_SCHED_H + +#include <linux/ranges.h> + +DECLARE_SECTION_RANGE (sched_text); +#define __sched __LINUX_RANGE(.text, sched_text) + +#endif /* _LINUX_SCHED_H */
tools/linker-tables/include/linux/spinlock.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef __LINUX_SPINLOCK_H +#define __LINUX_SPINLOCK_H + +#include <pthread.h> + +#define spinlock_t pthread_spinlock_t + +void spin_lock_init (spinlock_t *lock); +void spin_lock_destroy (spinlock_t *lock); +void spin_lock (spinlock_t *lock); +void spin_unlock (spinlock_t *lock); +
Lines of this file are not shown. View the raw message.
tools/linker-tables/include/linux/start_kernel.h new file +1 -0
Lines of this file are not shown. View the raw message.
tools/linker-tables/include/linux/types.h new file +13 -0
Lines of this file are not shown. View the raw message.
tools/linker-tables/include/linux/workqueue.h new file +51 -0
51 lines not on this page · raw message
tools/linker-tables/include/xen/xen.h new file +4 -0
Lines of this file are not shown. View the raw message.
tools/linker-tables/kernel/locking/mutex.c new file +28 -0
Lines of this file are not shown. View the raw message.
tools/linker-tables/kernel/locking/spinlock.c new file +26 -0
Lines of this file are not shown. View the raw message.
tools/linker-tables/kernel/main.c new file +32 -0
Lines of this file are not shown. View the raw message.
tools/linker-tables/kernel/workqueue.c new file +43 -0
43 lines not on this page · raw message
tools/linker-tables/lib/string.c new file +26 -0
Lines of this file are not shown. View the raw message.
tools/linker-tables/pci-quirks.c new file +14 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.11.0
Part of the diff is not shown here. View the raw message.
Borislav Petkov
maintainerRe: [PATCH v6 01/14] generic-sections: add section core helpers
In reply to Luis R. RodriguezQuoted 2 lines · Luis R. Rodriguez
Linux makes extensive use of custom ELF header sections, documentation for these are well scatterred. Unify this
is
Quoted 2 lines
documentation in a central place and provide helpers to build custom Linux sections.
This patch contains at least three logical changes and needs splitting:
* unify documentation
* adding helpers
* MAINTAINERS addition
Documentation and MAINTAINERS changes should go last in the patchset.
Accordingly, the huuge commit message below should be spread around those three patches.
Quoted 42 lines
This also generalizes sections code to enable avoiding modifying the linker scripts when we want to add new custom Linux sections. In order to make this generally useful we need to ensure all architectures can make use of core section helpers but that they can also override should this be needed. Instead of relying on
section.hthis adds asections-core.hsince this will be targetted to be safe to be used on asm code, linker scripts and C code.v5:
o Huge documentation revamp based on a careful review of the ELF specifications. Includes documentation now also about usage of two dots (..) when prefixing ELF program specific sections.
o Replace macros for sections names in favor of just using the section names explicitly in the linker script. This is perhaps more work to grep but this is what folks seem to currently prefer.
o Fix .text and .rodata documentation to explain memory protection strategies which architectures can embrace upon initialization (documents
CONFIG_DEBUG_RODATAandmark_rodata_ro())o Skip the 'Linux section ordering' documentation section, we'll instead add this on subsequent patch which will expand on it considerably
o Dropped tree on
MAINTAINERS-- as per discussions with Arnd, hpa and Josh, its easier to just let changes for sections go in through the respective tree that needs the changes.o Fix typos on documentation
o Dropped
SECTION_ALL(),__SECTION_CORE(),SECTION_CORE_ALL()macros since we are favoring using explicit section names. These are useless if we are being explicit.o Drop
LINUX_SECTION_SIZE(),LINUX_SECTION_EMPTY()in favor of having section ranges and linker tables define their own, to avoid confusion and make code more readable.
Quoted 7 lines
o Add
__define_initcall()documentation and a small section describing our current initcall levels. This should help also clarify what was meant about keeping backward compatiblity.v4:
o Port to shiny new sphinx documentation format
This looks like a 4th patch ontop of the unifying documentation one.
Quoted 11 lines
o fix a unicore32 build, turns out this actually fixes unicore32 defconfig builds which were failing for a long while. unicore32 does not seem to grok well the type passed on a section declaration, this ignores it.
o Use
VMLINUX_SYMBOL()in more user symbols (extern C code), not doing this was causing final linker issues with blackfin -- this is aCONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX=yarchitecture. The other one being metatag. metatag is not supported on 0-day so I cannot confirm compilation there.
...
Quoted 21 lines
+++
b/Documentation/sections/background.rstDocumentation/sections/background.rst new file +19
-0@@ -0,0 +1,105 @@ +====================== +ELF section background +====================== + +About +===== + +The purpose of this chapter is to help those not familiar with ELF to brush up +the latest ELF specifications in order to help understand how Linux uses and +defines its own ELF sections. + +Standardized ELF +================ + +The first publication documenting ELF was UNIX System Laboratories' (USL) +*System V Release 4 Application Binary Interface* (`SRV4 ABI`_) specification. +Originally ELF was only a small part of the SRV4 ABI, with time however new +specifications only put focus on ELF, such was the case of the *TIS Portable +Formats Specification version 1.2* (`TIS 1.2`_). As of TIS 1.2, ELF was
Documentation/sections/background.rst line 29
Quoted 10 lines
Documentation/sections/background.rst new file +10
-0+supplemented with processor specific ELF addendums, available on the *Linux +Foundation referenced specification page* (`LF ref page`_). The latest ELF +specification is the *System V Application Binary Interface - DRAFT - 24 April +2001* (`gabi4`_). + +.. _SRV4 ABI: http://www.sco.com/developers/devspecs/gabi41.pdf +.. _TIS 1.2: https://refspecs.linuxbase.org/elf/elf.pdf +.. _LF ref page: https://refspecs.linuxbase.org/ +.. _gabi4: https://refspecs.linuxbase.org/elf/gabi4+/contents.html +
A pointer to the wikipedia page would suffice instead of us repeating ELF history here.
Documentation/sections/background.rst line 37
Quoted 8 lines
Documentation/sections/background.rst new file +8
-0+ELF views on Linux +================== + +There are two views which can be used for inspecting data in an ELF file, a +Linking view, and an Execution view. A Section Header Table enables one to +describe an object using the Linking view while a Program Header Table enables +one to describe an object using the Execution view. The views are not mutually +exclusive. For intance, vmlinux can be viewed under both views, ``readelf -S
s/intance/instance/
Documentation/sections/background.rst line 41
Quoted 4 lines
Documentation/sections/background.rst new file +4
-0+vmlinux`` for the Linking view, and ``readelf -l vmlinux`` for the Execution +view. In Linux only the vmlinux file will have an Execution view, even modules +lack an Execution view given that vmlinux is the only file that describes how +the the kernel runs from the start. All other Linux kernel object files have
s/the //
Documentation/sections/background.rst line 42
Quoted 1 line
Documentation/sections/background.rst new file +1
-0+an available Linking view.
s/n available// - "have a Linking view" is fine.
Documentation/sections/background.rst
Quoted 5 lines
Documentation/sections/background.rst new file +5
-0+ +Under the Linking view, the Section Header Table describes all available +sections. The Section Header Table is an array of ELF section header data +structures. If on a 32-bit system this is ``struct elf32_shd``, if on a 64-bit +this is ``struct elf64_shdr``.
"If on ... if on" doesn't work as a sentence.
Quoted 1 line
Sections are only visible on object files that
s/on/in/
Documentation/sections/background.rst line 49
Quoted 2 lines
Documentation/sections/background.rst new file +2
-0+have a Linking view, since all Linux kernel files have Linking view, all kernel +objects have ELF sections.
Btw, that last sentence is kinda funny and not really needed. Or do you wanna say that everything-code is in a section?
Review
Quoted 2 lines
(quoted diff) +2
-0+ +Limitations on ELF sections
ELF sections limitations
Review
Quoted 3 lines
+===========================
(quoted diff) +2
-0+ +We provide a summary on the limitations of ELF sections.
Kill that sentence.
Documentation/sections/background.rst line 56
Quoted 3 lines
Refer to the public
Documentation/sections/background.rst new file +2
-0+ELF specifications for details. Note that 64-bit limitations may depend +on processor specific section attributes to be used, refer to your processsor
"processsor" - the 's' button stuck? :-)
Quoted 1 line
+specification if unsure.
Better yet, kill that whole paragraph.
Review
Quoted 2 lines
(quoted diff) +2
-0+ +Its worth ellaborating on the limitations on the name of an ELF section:
"elaborating"
Quoted 17 lines
Documentation/sections/background.rst new file +17
-0+ELF section names are stored as strings as per the ELF specification, and +as can be expected, these don't have explicit limitations. The implicit +limitation then depends on the size of an ELF object file and ELF section. + +If using really large kernels or objects with large amounts of sections one +would still need to be sure that ELF loader in charge of loading the Linux +kernel is properly updated to handle coping with the latest ELF extensions. + + .. flat-table:: Limitations on ELF Sections + + * - Section attribute + - 32-bit + - 64-bit + + * - ELF section name + - Size of an ELF section + - Size of an ELF section
Documentation/sections/background.rst line 86
Quoted 10 lines
Documentation/sections/background.rst new file +10
-0+ + * - Size of an ELF section + - 4 GiB + - 16 EiB + + * - Max number of sections in an object file + - 4 GiEntries (4294967296) + - 16 EiEntries (18446744073709551616) + +Program specific ELF sections
Program-specific
Documentation/sections/background.rst line 90
Quoted 4 lines
+=============================
Documentation/sections/background.rst new file +3
-0+ +The ELF specification allows for a section type to be specified as +*Program specific section*, defined as ``SHT_PROGBITS``. This sections type
section
Quoted 1 line
+enables programs to customize sections for their own use. In assembly this
^ is
Quoted 1 line
+specified ``@progbits`` on most architectures, on ARM this is ``%progbits``.
^ ^ with the flag s/this is/it is called/
Quoted 29 lines
Documentation/sections/background.rst new file +13
-0+ +``SHT_PROGBITS`` is used by Linux for defining and using Linux ELF sections. + +Special ELF Sections +==================== + +The ELF specification defines *Special ELF Sections* on chapter 4 (`gabi4 +ch4`_). These are defined as sections which hold program and control +information. Of these sections, a few have the section type as +``SHT_PROGBITS``. This enables Linux to *further customize* use of the section +beyond what the ELF specification suggests. + +.. _gabi4 ch4: https://refspecs.linuxbase.org/elf/gabi4+/ch4.sheader.html#special_sectionsDocumentation/sections/conf.py new file +4
-0@@ -0,0 +1,4 @@ +# -*- coding: utf-8; mode: python -*- + +project = 'Linux Kernel ELF sections' +html_search_language = 'en'Documentation/sections/index.rst new file +0
-0
Documentation/sections/index.rst line 5
Quoted 5 lines
Documentation/sections/index.rst new file +5
-0@@ -0,0 +1,17 @@ +========================= +Linux Kernel ELF sections +========================= + +This book documents the different ELF sections used on the Linux kernel.
in
Documentation/sections/index.rst line 11
Quoted 6 lines
Documentation/sections/index.rst new file +6
-0+We start off by providing references to how ELF was standardized, references +to the standards on ELF sections, review limitations of ELF sections, and +finally how Linux uses ELF sections in the Linux kernel. Certain important +Linux ELF sections are documented carefully: we describe the goal of the +ELF section, and address concurrency considerations when applicable. A few +common a set of Linux helpers for ELF sections are also documented.
s/few common a //
Quoted 6 lines
Documentation/sections/index.rst new file +6
-0+ +.. toctree:: + :maxdepth: 4 + + background + section-core
...
Quoted 6 lines
arch/unicore32/include/asm/section-core.h new file +0
-0
arch/unicore32/include/asm/section-core.h line 8
Quoted 8 lines
arch/unicore32/include/asm/section-core.h new file +8
-0@@ -0,0 +1,19 @@ +#ifndef __UNICORE_SECTION_CORE_ASM_H__ +#define __UNICORE_SECTION_CORE_ASM_H__ +/* +* Copyright (C) 2016 Luis R. Rodriguez <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of copyleft-next (version 0.3.1 or later) as published +* at http://copyleft-next.org/.
Isn't all kernel code GPLv2?
Quoted 35 lines
arch/unicore32/include/asm/section-core.h new file +11
-0+*/ + +/* Unicore32 has known to not work properly with the type set, so ignore it */ + +#define __set_section_core_type (___section, ___core, ___name, \ + ___level, ___flags, ___type) \ + .section ___section..___core.___name.___level, ___flags + +#include <asm-generic/section-core.h> + +#endif /* __UNICORE_SECTION_CORE_ASM_H__ */ arch/x86/include/asm/Kbuild +1
-0@@ -12,3 +12,4 @@ generic-y += dma-contiguous.h generic-y += early_ioremap.h generic-y += mcs_spinlock.h generic-y += mm-arch-hooks.h +generic-y += section-core.harch/xtensa/include/asm/Kbuild +1
-0@@ -32,3 +32,4 @@ generic-y += topology.h generic-y += trace_clock.h generic-y += word-at-a-time.h generic-y += xor.h +generic-y += section-core.hinclude/asm-generic/section-core.h new file +0
-0
include/asm-generic/section-core.h line 10
Quoted 10 lines
include/asm-generic/section-core.h new file +10
-0@@ -0,0 +1,307 @@ +#ifndef _ASM_GENERIC_SECTION_CORE_H_ +#define _ASM_GENERIC_SECTION_CORE_H_ +/* +* Linux section core definitions +* +* Copyright (C) 2016 Luis R. Rodriguez <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of copyleft-next (version 0.3.1 or later) as published +* at http://copyleft-next.org/.
Ditto.
include/asm-generic/section-core.h
Quoted 6 lines
include/asm-generic/section-core.h new file +6
-0+*/ + +/** +* DOC: Linux ELF program specific sections +* +* Linux makes extensive use of ``SHT_PROGBITS`` to both extend use and definition
^^^^^^^^^^^^^^^^^^^^^^^^ needs rewording
Quoted 2 lines
of *Special ELF Sections* (
gabi4 ch4_) and to define its own
+ * sections. This chaper is dedicated to documenting Linux program specific
"chapter"
Please spellcheck the whole patchset before next submission.
Quoted 2 lines
+ * sections and helpers available to make use of these easier to implement and
+ * use.
Huh, come again? This sentence is funny.
include/asm-generic/section-core.h line 30
Quoted 10 lines
+ *
+ * .._gabi4ch4: https://refspecs.linuxbase.org/elf/gabi4+/ch4.sheader.html#special_sections
+ */include/asm-generic/section-core.h new file +7
-0+ +/** +* DOC: Linux linker script +* +* Linux uses a custom linker script to build the vmlinux binary, it uses it to +* strategically place and define Linux ELF sections. Each architecture needs +* to implement its own linker script, it is expected to reside in
... script which is expected ...
Quoted 8 lines
+ * ``arch/$(ARCH)/kernel/vmlinux.lds.S``. Architecture Linux linker scripts in
+ * turn include and use definitions from ``include/asm-generic/vmlinux.lds.h``,
+ * as well as some helpers documented in this chapter.
+ *
+ * In assembly it is common practice to use dots (``.``) in labels to avoid
+ * clashes with C symbols. Similarly, a dot (``.``) can be part of a section
+ * name but not a C symbol. Historically then, two dots are used (``..``)
+ * have been used in linker scripts when adding program specific sections
are used .. have been used?
Quoted 1 line
+ * when there are concerns to avoid clashes with compiler generated sections.
This last sentence needs simplifying.
include/asm-generic/section-core.h line 47
Quoted 8 lines
+ */
include/asm-generic/section-core.h new file +7
-0+ +/** +* DOC: Memory protection +* +* Linux allows architectures which support memory protection features to +* take advantage of them by letting architectures define and enable +* ``CONFIG_DEBUG_RODATA`` and implement a mark_rodata_ro() call.
Simplify: "Architectures with memory protection features can define and enable CONFIG_DEBUG_RODATA... "
Quoted 1 line
+ *
mark_rodata_ro()can be used for instance to mark specific sections as
, for instance,
Quoted 4 lines
+ * read-only or non-executable.
+ *
+ * Linux typically follows a convention to have the .rodata ELF section follow
+ * after the .text ELF section, it does this to help architectures which
. It does this...
Quoted 63 lines
+ * support memory protection to mark both .text and .rodata as read-only in
+ * one shot.
+ *
+ * For more details refer tomark_rodata_ro().
+ */include/asm-generic/section-core.h new file +58
-0+ +/** +* DOC: .rodata +* +* ELF section used for data which must be protected from write access. +*/ + +/** +* DOC: .text +* +* ELF section name used for code (functions) used during regular +* kernel run time. +*/ + +/** +* DOC: .data +* +* ELF section used for read-write 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. +*/ + +/** +* DOC: .init.text +* +* ELF section for code (functions) used only during boot or driver +* initialization. +* +*/ + +/** +* DOC: .init.data +* +* ELF section used for data structures used only during boot or driver +* initialization. +*/ + +/** +* DOC: .init.rodata +* +* ELF section used for read-only code (functions) used only during boot +* or driver initialization. +*/ + +/** +* DOC: .initcall
include/asm-generic/section-core.h line 125
Quoted 10 lines
include/asm-generic/section-core.h new file +10
-0+* +* ELF section used for subsystem init calls. There are init levels +* representing different functionality in the kernel. For more details +* refer to __define_initcall(). +*/ + +/** +* DOC: Linux exit sections +* +* These sections are used to declare a functions and data structures which
s/a //
Quoted 30 lines
+ * 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.
+ */include/asm-generic/section-core.h new file +25
-0+ +/** +* DOC: .exit.text +* +* ELF section used to for code (functions) used only during module unload. +*/ + +/** +* DOC: .exit.data +* +* ELF section used to for data structures used only during module +* unload. +*/ + +/** +* DOC: .exitcall.exit +* +* ELF section used for exit routines, order is important and maintained by +* link order. +*/ + +/** +* DOC: Linux references to init sections +* +* These sections are used to teach modpost to not warn about possible
include/asm-generic/section-core.h line 165
Quoted 10 lines
include/asm-generic/section-core.h new file +10
-0+* 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. +*/ + +/** +* DOC: .ref.text +* +* ELF section used to annotate code (functions) which has been vetteed as
vetted?
include/asm-generic/section-core.h line 173
Quoted 8 lines
+ * valid for its reference or use of other code (functions) or data structures
+ * which are part of the init sections.
+ */include/asm-generic/section-core.h new file +5
-0+ +/** +* DOC: .ref.data +* +* ELF section used for data structures which have been vetteed for its
ditto.
include/asm-generic/section-core.h line 182
Quoted 9 lines
+ * reference or use of other code (functions) or data structures part of the
+ * init sections.
+ */include/asm-generic/section-core.h new file +6
-0+ +/** +* DOC: .ref.rodata +* +* ELF section used to annotate const code (functions) const data structures +* which has been vetteed for its reference or use of other code (functions)
ditto.
include/asm-generic/section-core.h line 186
Quoted 4 lines
+ * or data structures part of the init sections.
+ */include/asm-generic/section-core.h new file +2
-0+ +/* Can be used on foo.S for instance */
What does that comment mean?
include/asm-generic/section-core.h line 190
Quoted 4 lines
include/asm-generic/section-core.h new file +4
-0+#ifndef __set_section_core_type +# define __set_section_core_type (___section, ___core, ___name, \ + ___level, ___flags, ___type) \ + .section ___section..___core.___name.___level, ___flags, ___type
Are you sure we need 4 levels of hierarchy?
If so, we should document what all those section, core, name and level mean and how the whole sections hierarchy is supposed to look like.
Quoted 36 lines
include/asm-generic/section-core.h new file +36
-0+#endif + +#ifndef __set_section_core +# define __set_section_core (___section, ___core, ___name, ___level, ___flags) \ + .section ___section..___core.___name.___level, ___flags +#endif + +#ifndef __push_section_core +# define __push_section_core (__section, __core, __name, __level, __flags) \ + .pushsection __section..__core.__name.__level, __flags +#endif + +#ifdef __KERNEL__ +#include <linux/stringify.h> +#endif + +#if defined(__ASSEMBLER__) || defined(__ASSEMBLY__) + +# ifndef LINKER_SCRIPT + +# ifndef push_section_core +# define push_section_core (__section, __core, __name, __level, __flags) \ + __push_section_core(__section, __core, __name, \ + __level, __stringify(__flags)) +# endif + +# ifndef set_section_core +# define set_section_core (__section, __core, __name, \ + __level, __flags) \ + __set_section_core(__section, __core, __name, \ + __level, __stringify(__flags)) +# endif + +# ifndef set_section_core_type +# define set_section_core_type (__section, __core, __name, \ + __level, __flags, __type) \
include/asm-generic/section-core.h line 236
Quoted 10 lines
include/asm-generic/section-core.h new file +10
-0+__set_section_core_type (__section, __core, __name, __level, \ + __stringify(__flags), __type) +# endif + +# endif /* LINKER_SCRIPT */ +#else /* defined(__ASSEMBLER__) || defined(__ASSEMBLY__) */ + +/* +* As per gcc's documentation a common asm separator is a new line followed +* by tab [0], it however seems possible to also just use a newline as its
. It, however, seems ...
Quoted 101 lines
+ * the most commonly empirically observed semantic and folks seem to agree
+ * this even works on S390. In case your architecture disagrees you may
+ * override this and define your own and keep the rest of the macros.
+ *
+ * [0] https://gcc.gnu.org/onlinedocs/gcc/Basic-Asm.html#Basic-Asm
+ */include/asm-generic/section-core.h new file +65
-0+# ifndef ASM_CMD_SEP +# define ASM_CMD_SEP "\n" +# endif + +# ifndef set_section_core +# define set_section_core (__section, __core, __name, __level, __flags) \ + __stringify(__set_section_core_type(__section, __core, __name, \ + __level, __stringify(__flags))) \ + ASM_CMD_SEP +# endif + +/* +* Some architectures (arm, and avr32 are two examples on kprobes) seem +* currently explicitly specify the type [0] -- this can be any of the +* optional constants on ELF: +* +* @progbits - section contains data +* @nobits - section does not contain data (i.e., section only occupies space) +* @note - section contains data which is used by things other than the program +* @init_array - section contains an array of pointers to init functions +* @fini_array - section contains an array of pointers to finish functions +* @preinit_array - section contains an array of pointers to pre-init functions +* +* ARM requires % instead of @. +* +* At least as per nasm (x86/x86_64 only), in the absence of qualifiers the +* defaults are as follows: +* +* section .text progbits alloc exec nowrite align=16 +* section .rodata progbits alloc noexec nowrite align=4 +* section .lrodata progbits alloc noexec nowrite align=4 +* section .data progbits alloc noexec write align=4 +* section .ldata progbits alloc noexec write align=4 +* section .bss nobits alloc noexec write align=4 +* section .lbss nobits alloc noexec write align=4 +* section .tdata progbits alloc noexec write align=4 tls +* section .tbss nobits alloc noexec write align=4 tls +* section .comment progbits noalloc noexec nowrite align=1 +* section other progbits alloc noexec nowrite align=1 +* +* gas should have sensible defaults for architectures... +* +* [0] http://www.nasm.us/doc/nasmdoc7.html +*/ +# ifndef set_section_core_type +# define set_section_core_type (__section, __core, __name, __level, \ + __flags, __type) \ + __stringify(__set_section_core_type(__section, __core, \ + __name, __level, \ + __stringify(__flags), \ + __type)) \ + ASM_CMD_SEP +# endif + +# ifndef push_section_core +# define push_section_core (__section, __core, __name, \ + __level, __flags) \ + __stringify(__push_section_core(__section, __core, \ + __name, __level, \ + __stringify(__flags))) \ + ASM_CMD_SEP +# endif + +#endif /* defined(__ASSEMBLER__) || defined(__ASSEMBLY__) */ +#endif /* _ASM_GENERIC_SECTION_CORE_H_ */ include/asm-generic/sections.h +2
-0@@ -1,6 +1,8 @@#ifndef _ASM_GENERIC_SECTIONS_H_#define _ASM_GENERIC_SECTIONS_H_ +#include <asm/section-core.h> +/* References to section boundaries */ #include <linux/compiler.h> include/asm-generic/vmlinux.lds.h +1
-0@@ -55,6 +55,7 @@#endif #include <linux/export.h> +#include <asm/section-core.h> /* Align . to a 8 byte boundary equals to maximum function alignment. */ #define ALIGN_FUNCTION () . = ALIGN(8)include/linux/init.h +0
-0
include/linux/init.h int __init init_rootfs(void); · line 137
Quoted 8 lines
include/linux/init.h +5
-0@@ -130,6 +130,24 @@ int __init init_rootfs(void);extern bool rodata_enabled;#endif #ifdef CONFIG_DEBUG_RODATA +/** +* mark_rodata_ro - implemement memory protection for ELF sections +* +* Architectures which support memory protection define a kernel configuration +* entry for CONFIG_DEBUG_RODATA,
That's just too many words for nothing. You can just as well say:
"Architectures which support memory protection enable CONFIG_DEBUG_RODATA and implement mark_rodata_ro()."
Quoted 3 lines
enable it in and implement
mark_rodata_ro().
+ *mark_rodata_ro()should strive to adjust the .rodata and .text ELF sections
+ * with read-only memory protection to prevent modifications of these sections
"mark_rodata_ro() marks .rodata and .text section read-only..."
Simple.
Quoted 6 lines
+ * after bootup. It can also try to use memory protection to prevent execution
+ * on the .rodata ELF section.
+ *
+ * In order to help architectures set both .text and .rodata as read-only with
+ * memory protections in one shot Linux has typically followed the convention
+ * to have the .rodata ELF section follow the .text ELF section on the vmlinux
in
Quoted 4 lines
+ * linker script.
+ *
+ * Linux callsmark_rodata_ro()after freeing .init code and prior to calling
+ * the first init userspace process.
"first init userspace process" either say "prior to calling init" or "prior to calling the first userspace process" but both is jambalayed into something confusing.
include/linux/init.h extern bool initcall_debug; · line 164
Quoted 12 lines
+ */
voidmark_rodata_ro(void);
#endifinclude/linux/init.h +4
-0@@ -140,25 +158,70 @@ extern bool initcall_debug;#endif #ifndef MODULE +/** +* DOC: Initcall levels +* +* When Linux boots the kernel do_initcalls() iterates over each Linux
When Linux boots the kernel?!? You're joking, right?
Just do "During boot, do_initcalls() ..."
include/linux/init.h extern bool initcall_debug; · line 171
Quoted 7 lines
include/linux/init.h +7
-0+* initialization level ID and calls all routines embedded on each level ID. +* Prior to v2.5.2.3 Linux had only one init level onto which all init +* functions folded onto using __initcall(). After v2.5.2.4 Linux split up +* initcalls into 7 separate initcall subsection levels, each level describing +* different functionality part of the kernel (commit `9d6ba121b7e17085`_ +* (v2.5.2.3 -> v2.5.2.4)). In order to remain backward compatible __initcall() +* calls were left mapped to device_initcall().
And why do we need all that git archeology here?
include/linux/init.h extern bool initcall_debug; · line 174
Quoted 2 lines
include/linux/init.h +2
-0+* Each init level consists of a dedicated ELF section, init functions are +* associated to an init level by linking it into the respective level's
with
include/linux/init.h extern bool initcall_debug; · line 178
Quoted 4 lines
include/linux/init.h +4
-0+* ELF section. +* +* Lower order init levels run prior to higher order init levels. Ordering +* inside each initcall level is determined by respective link order.
Those last two sentences are enough.
include/linux/init.h extern bool initcall_debug; · line 180
Quoted 2 lines
include/linux/init.h +2
-0+* +* .. _9d6ba121b7e17085: https://git.kernel.org/cgit/linux/kernel/git/history/history.git/commit/?id=9d6ba121b7e17085c95139233686b27a4d4c650e
That's one ugly footnote. Also, the git commit id suffices, you don't need the URL.
include/linux/init.h extern bool initcall_debug; · line 186
Quoted 12 lines
include/linux/init.h +3
-6+*/ #ifndef __ASSEMBLY__ -/* -* initcalls are now grouped by functionality into separate -* subsections. Ordering inside the subsections is determined -* by link order. -* For backwards compatibility, initcall() puts the call in -* the device init subsection. +/** +* __define_initcall - wrapper for definiting init levels
()
also s/definiting/defining/
Also, this is not what __define_initcall() does. It is not defining init levels.
include/linux/init.h extern bool initcall_debug; · line 193
Quoted 13 lines
include/linux/init.h +5
-6* -* The `id' arg to __define_initcall() is needed so that multiple initcalls -* can point at the same handler without causing duplicate-symbol build errors. +* @fn: init routine +* @id: init level * -* Initcalls are run by placing pointers in initcall sections that the -* kernel iterates at runtime. The linker can do dead code / data elimination -* and remove that completely, so the initcall sections have to be marked -* as KEEP() in the linker script. +* Defines a kernel initialization level. A respective linker script entry +* is required to ensure the init level is accounted for and to ensure symbols +* exist for iterating over all functions in the init level. A init level
An
include/linux/init.h extern bool initcall_debug; · line 194
Quoted 1 line
include/linux/init.h +1
-0+* represents a series of functionality in the kernel.
That sounds yucky.
An init level is a bunch of functions which are called after init_level
- 1 and before init_level + 1.
Quoted 16 lines
include/linux/init.h +16
-0+* +* Ordering within an initialization level is determined by link order, so +* for instance if a Makefile had:: +* +* obj-y += foo.o +* obj-y += bar.o +* +* And foo.c:: +* +* subsys_initcall(foo_init); +* +* And bar.c had:: +* +* subsys_initcall(bar_init); +* +* foo_init() would be called prior to bar_init().
include/linux/init.h extern bool initcall_debug;
Quoted 10 lines
include/linux/init.h +10
-0+* +* Note that @id in __define_initcall() also enables multiple initcalls +* to be created using the same handler for different init levels without +* causing duplicate-symbol build errors. +* +* Initcalls are run by placing start symbols to initcall levels inside ELF +* sections, the kernel in turn uses these symbols to iterate over each init +* level at runtime with do_initcall_level(). The end of each init level is +* marked by the subsequent's symbol's start address until we reach the symbol +* ``__initcall_end``.
Needlessly complex, simplify.
Quoted 2 lines
The linker can do dead code / data elimination and each
+ * init level start symbol could be removed completely in this process, to
. To <-- new sentence
Quoted 13 lines
+ * avoid this each init level start symbols must be marked as '
KEEP()' in the
+ * linker script to avoid any linker optimization heuristic on initcalls. */include/linux/init.h +0
-1-#define __define_initcall (fn, id) \ static initcall_t __initcall_##fn##id __used \ __attribute__((__section__(".initcall" #id ".init"))) = fn;include/linux/sections.h new file +0
-0
include/linux/sections.h line 4
Quoted 4 lines
include/linux/sections.h new file +4
-0@@ -0,0 +1,87 @@ +#ifndef _LINUX_SECTIONS_H +#define _LINUX_SECTIONS_H +/* +* Linux de-facto sections
Useless.
Quoted 7 lines
include/linux/sections.h new file +7
-0+* +* Copyright (C) 2016 Luis R. Rodriguez <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of copyleft-next (version 0.3.1 or later) as published +* at http://copyleft-next.org/. +*/
include/linux/sections.h line 21
Quoted 10 lines
include/linux/sections.h new file +10
-0+ +#include <asm/section-core.h> +#include <linux/export.h> + +#ifndef __ASSEMBLY__ + +/** +* DOC: Introduction +* +* Linux defines a set of common helpers which can be used to against its use
^^^^^^^^^^^^^^^^^^^^^^^^^^
??
include/linux/sections.h line 22
Quoted 1 line
include/linux/sections.h new file +1
-0+* of standard or custom Linux sections, this section is dedicated to these
this section is talking about sections, that's too much.
include/linux/sections.h line 33
Quoted 11 lines
include/linux/sections.h new file +11
-0+* helpers. +*/ + +/** +* LINUX_SECTION_ALIGNMENT - get section alignment +* +* @name: section name +* +* Gives you the alignment for the section. +*/ +#define LINUX_SECTION_ALIGNMENT (name) __alignof__(*VMLINUX_SYMBOL(name))
Eeww, too long and it is a getter but doesn't have "GET" in its name.
How about GET_SECTION_ALIGN() ?
And what's with the "LINUX_" prefix - that's like useless use of screen real estate.
include/linux/sections.h line 36
Quoted 3 lines
include/linux/sections.h new file +3
-0+ +/** +* LINUX_SECTION_START - get address of start of section
GET_SECTION_START() - get address of section start
include/linux/sections.h line 41
Quoted 5 lines
include/linux/sections.h new file +5
-0+* +* @name: section name +* +* This gives you the start address of the section. +* This should give you the address of the first entry.
Huh?
include/linux/sections.h line 44
Quoted 3 lines
include/linux/sections.h new file +3
-0+* +*/ +#define LINUX_SECTION_START (name) VMLINUX_SYMBOL(name)
Ditto.
Quoted 5 lines
include/linux/sections.h new file +5
-0+ +/** +* LINUX_SECTION_END - get address of end of the section +* +* @name: section name
include/linux/sections.h line 59
Quoted 10 lines
include/linux/sections.h new file +10
-0+* +* This gives you the end address of the section. +* This should give you the address of the end of the +* section. This will match the start address if the +* section is empty. +*/ +#define LINUX_SECTION_END (name) VMLINUX_SYMBOL(name##__end) + +/** +* DECLARE_LINUX_SECTION - Declares a custom Linux section
DECLARE_SECTION() is perfectly fine IMO.
include/linux/sections.h line 71
Quoted 12 lines
include/linux/sections.h new file +12
-0+* +* @type: type of custom Linux section +* @name: custom section name +* +* Declares a read-write custom Linux section +*/ +#define DECLARE_LINUX_SECTION (type, name) \ + extern type VMLINUX_SYMBOL(name)[], \ + VMLINUX_SYMBOL(name##__end)[] + +/** +* DECLARE_LINUX_SECTION_RO - Declares a read-only custom Linux section
DECLARE_SECTION_RO()
Quoted 17 lines
include/linux/sections.h new file +16
-0+* +* @type: type of custom Linux section +* @name: custom section name +* +* Declares a read-only custom Linux section +*/ +#define DECLARE_LINUX_SECTION_RO (type, name) \ + extern const type VMLINUX_SYMBOL(name)[], \ + VMLINUX_SYMBOL(name##__end)[] + +#define __SECTION_CORE (section, core, name, level) \ + #section ".." #core "." #name "." #level + +#endif /* __ASSEMBLY__ */ + +#endif /* _LINUX_SECTIONS_H */
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v7 02/14] xtensa: skip adding literal when SORT() is used
In reply to Luis R. RodriguezQuoted 4 lines · Luis R. Rodriguez
When
SORT(foo.*)is used the current sed replacements addSORT(foo.literal foo.*), this breaks linking. Avoid adding literals for SORT globs, if needed, these need to be added manually.
Please rewrite this commit message by breaking into separate sentences, adding punctuation, etc.
Also, "the current sed replacements add" sounds really strange and makes me wonder what do you mean. What are "sed replacements"? I think you mean the "sed regex adds" from looking at the diff.
Signature · 10 lines
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-develGreg KH
maintainerRe: [PATCH v4 1/6] tools: add a userspace tools bug.h
In reply to Luis R. RodriguezQuoted 1 line · Luis R. Rodriguez
This will be used later by the userspace linker-tables sandbox.
What is that?
Quoted 5 lines
As a convenience, include
bug.honkernel.h-- this is not done on upstreamkernel.h, however most header files do includebug.heventually, if we were to only add the ones that need it we'd need to copy a lot of headers to tools for the only purpose of includeingbug.h.
I can't parse this sentance at all, please simplify or clarify or something so that I understand what is going on here.
Quoted 1 line
This simplifies that.
What is "that"? You can't do that for such a complex previous sentence.
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH v4 2/6] tools: add init.h for tools
In reply to Luis R. RodriguezQuoted 2 lines · Luis R. Rodriguez
Start off with just
__ref-- we enalbe you to override, if you do that then you can define your own.
I have no idea what this means, do you?
Quoted 2 lines
The way you'd use this, if you
do override, is define your own__refand then useinclude_next.
Huh?
Again, please be more specific or clear or something, I have no idea again what this patch is for.
thanks,
greg k-h
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Greg KH
maintainerRe: [PATCH v4 3/6] tools: add __used and enable to override
In reply to Luis R. RodriguezQuoted 3 lines · Luis R. Rodriguez
This adds
__used, to be used later in the userspace linker-tables sandbox. If any userspace applicaiton wants to override they can add their own definition and then useinclude_next.
I think you need a spell checker :(
Greg KH
maintainerRe: [PATCH v4 4/6] tools: expand export.h with VMLINUX_SYMBOL()
In reply to Luis R. RodriguezQuoted 1 line · Luis R. Rodriguez
This will be used later by the linker-table userspace sandbox.
That does not explan what this is, why it is needed, or anything at all :(
Greg KH
maintainerRe: [PATCH v4 4/6] tools: expand export.h with VMLINUX_SYMBOL()
In reply to Luis R. RodriguezQuoted 12 lines · Luis R. Rodriguez
This will be used later by the linker-table userspace sandbox.
Signed-off-by Luis R. Rodriguez <[email protected]>--- tools/include/linux/export.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)tools/include/linux/export.h +0
-0
tools/include/linux/export.h line 7
Quoted 7 lines
tools/include/linux/export.h +4
-0@@ -1,6 +1,28 @@#ifndef _TOOLS_LINUX_EXPORT_H_#define _TOOLS_LINUX_EXPORT_H_ +/* +* Export symbols from the kernel to modules. Forked from module.h +* to reduce the amount of pointless cruft we feed to gcc when only +* exporting a simple symbol or two.
You copied it, yet did not remove it from the original?
tools/include/linux/export.h line 10
Quoted 3 lines
tools/include/linux/export.h +3
-0+* +* Try not to add #includes here. It slows compilation and makes kernel +* hackers place grumpy comments in header files.
Define "slows" please. I doubt it is measurable, and so, why even mention it here?
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH v4 5/6] tools: add __section() to compiler.h
In reply to Luis R. RodriguezQuoted 1 line · Luis R. Rodriguez
This will be used later by the userspace linker table.
same comment as the last time you used this sentence as a changelog text...
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH v4 6/6] tools: add userspace linker table sandbox
In reply to Luis R. RodriguezQuoted 7 lines · Luis R. Rodriguez
Add a userspace sandbox to allow easy experimentation and test extensions with linker tables, section ranges and the new section core definitions.
The userspace sandbox tries to mimic the Linux kernel development flow as much as possible, it however relies on and uses libc. Support is currently only provided to
x86_64.
Why is x86_64 a requirement?
Quoted 27 lines
Demo run:
cd
tools/linker-tables
make clean; make;
./demo
Initializing x86 bare metal world
x86-init: Number of init entries: 8
Initializing memory ...
Completed initializing memory !
Initializing pci ...
PCI fixup size: 1
Demo: UsingLINKTABLE_FOR_EACHfoo_fixup
Demo: UsingLINKTABLE_RUN_ALLfoo_fixup
Completed initializing pci !
Number of init entries: 1
Initializing kprobes ...
== OK:test_kprobe_0001within range!
== OK:test_kprobe_0002not in range as expected!
Completed initializing kprobes !
Initializing kasan ...
Early init for Kasan...
Completed initializing kasan !
Initializing beta ...
Completed initializing beta !
Quoted 8 lines
Initializing alpha ...
Completed initializing alpha !
Booting bare metal
Callingstart_kernel()...
ACME: Initializing ...
ACME: Finished init ... !
Synthetics:synth_init_or(2)returns:0xDEADBEEF
Synthetics:ps_shr(0xDEADBEEF, get_demo_shr)returns:0x0000DEAD
Why isn't this tied into the kernel testing framework?
thanks,
greg k-h
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Greg KH
maintainerRe: [PATCH v7 01/14] generic-sections: add section core helpers
In reply to Luis R. RodriguezQuoted 6 lines · Luis R. Rodriguez
Linux makes extensive use of custom ELF header sections, documentation for these are well scattered. Unify this documentation in a central place and provide helpers to build custom Linux sections.
This also generalizes sections code to enable avoiding
When you say "also" in a changelog, that's a huge flag you need to split this up. There's no reason the documentation for elf header sections has to be in the same patch as code. Please break it up.
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH v7 03/14] ranges.h: add helpers to build and identify Linux section ranges
In reply to Luis R. RodriguezQuoted 2 lines · Luis R. Rodriguez
Section ranges are on one of the types of custom sections types used in Linux.
Argh, come on, proof-read your changelog text please!
Quoted 4 lines
This provides a series of helpers for
defining them and using them. Most importantly this also enables us to avoid modifying the linker script when we add a new section range.
Also pick a line width and stick to it!
Quoted 6 lines
It turns out a lot of custom sections are actually section ranges, and these are typically spelled out in their architecture specific
asm/sections.hfile -- we enable architectures to override what asm is used for section ranges but start by default trusting the asm-generic version all around.
Quoted 12 lines
Although typically you will not want to have section ranges ordered we must use
SORT()onvmlinux.lds.Sfor section ranges to enable us to extend a section range without modifying the linker script. To accomplish this we use a special order string for the first element of a section range -- the empty string "" (refer to__SECTION_RANGE_BEGIN()), then "~" for the last element (refer to__SECTION_RANGE_BEGIN()). If you use the "any" order for elements in between and useSORT()you end up keeping any added element in between and a reference to the beginning and end of the section range without requiring custom linker script modifications. Specific order annotations are also supported to help construct synthetic functions, a demo for which will be provided later.
Again, split your documentation from your coding changes to make it easier to review one or the other.
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH v7 04/14] tables.h: add linker table support
In reply to Luis R. RodriguezQuoted 8 lines · Luis R. Rodriguez
A linker table is a data structure that is stitched together from items in multiple object files. Linux has historically implicitly used linker tables for ages, however they were all built in an adhoc manner which requires linker script modifications, per architecture. This adds a general linker table solution so that a new linker table can be implemented by changing C code only. The Linux linker table was inspired by Michael Brown's iPXE's linker table solution, it has been been completely re-written and adapted for integration and use on Linux.
Ok, I understand that, but then you say:
Quoted 1 line
The same philosophy is borrowed, extended and further simplified:
This line made no sense :(
Quoted 6 lines
Linker tables enable an extremely light weight linker build time solution for feature ordering and selection, this can help to both simplify init sequences in a generic fashion and helps avoiding code bit-rotting when desirable. Further changes will be added later which will make more evident how code bit rot can be avoided using linker tables.
I have no idea why this is needed, nor what it means. I fail to understand the bit-rot reference.
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH v7 05/14] kbuild: enable option to force compile force-obj-y and force-lib-y
In reply to Luis R. RodriguezQuoted 11 lines · Luis R. Rodriguez
Linux provides a rich array of features, enabling each feature however increases the size of the kernel and there are many features which users often want disabled. The traditional solution to this problem is for each feature to have its own
Kconfigsymbol, followed by a series of #ifdef statements in C code and header files, allowing the feature to be compiled only when desirable. As the variability of Linux increases build tests can and are often done with random kernel configurations, allyesconfig, and allmodconfig to help find code issues. This however doesn't catch all errors and as a consequence code that is typically not enabled often can suffer from bit-rot over time.
Really? How do you know this, our test-build infrastructure is really good, what has rotted with it?
And again, pick a column width and stick with it in the whole changelog...
Quoted 10 lines
An alternative approach for subsystems, which refer to as the 'build-all link-selectively philosophy' is to keep the
Kconfigsymbols, replace the #ifdef approach by having each feature implemented it its own C file, and force compilation for all features to avoid the code bit-rot problem. With this strategy only features that are enabled viaKconfigget linked into the kernel, so the forced compilation has no size impact on the kernel. The practice of having each feature implemented in its own C file is already prevalent in many subsystems, however #ifdefs are still typically required during feature initialization. For instance in:
Quoted 3 lines
#ifdef CONFIG_FOO foo_init(); #endif
That's horrid kernel code, and shouldn't be an example of anything other than what NOT to do. You know better than this, put the #ifdef in a .h file.
Quoted 3 lines
We cannot remove the #ifdef and leave
foo_init()as we'd either need to always enable the feature or add a respective #ifdef in afoo.hwhich makesfoo_init()do nothing whenCONFIG_FOOis disabled.
Yes, and what's wrong with that?
Quoted 10 lines
Linker tables enable lifting the requirement to use of #ifdefs during initialization. With linker tables initialization sequences can instead be aggregated into a custom ELF section at link time, during run time the table can be iterated over and each init sequence enabled can be called. A feature's init routine is only added to a table when its respective
Kconfigsymbols has been enabled and therefore linked in. Linker tables enable subsystems to completely do away with #ifdefs if one is comfortable in accepting all subsystem's feature's structural size implications.
Quoted 8 lines
Subsystems which want to follow the 'build-all link-selectively philosophy' still need a way to easily express and annotate that they wish for all code to always be compiled to help avoid code bit rot, as such two new targets force-obj-y and force-lib-y are provided to help with this. Its not fair to require everyone to force compilation of all features of a subsystem though, so as a compromise, the new targets only force compilation when
CONFIG_BUILD_AVOID_BITROTis enabled.
You do know about COMPILE_TEST, right? What's wrong with that? Why not use that as-is today and not add a new configuration option?
Quoted 3 lines
Only built-in features are supported at the moment. Module support is expected to be added after a generic solution to add linker tables to modules more easily is developed.
Ok, you are talking about majorly changing how the kernel build system works. What do the kbuild developers/maintainers say about this?
Quoted 194 lines
v4: this patch was added to this series, it was split off from the
linker tables addition due to the confusion over the code bit rot alternatives that are possible with linker tables.Signed-off-by Luis R. Rodriguez <[email protected]>--- Documentation/kbuild/makefiles.txt | 36 ++++++++++++++++ Documentation/sections/linker-tables.rst | 15 +++++++ include/linux/tables.h | 71 ++++++++++++++++++++++++++++++++ init/Kconfig | 22 ++++++++++ scripts/Makefile.build | 7 ++-- scripts/Makefile.clean | 2 + scripts/Makefile.lib | 11 +++++ 7 files changed, 161 insertions(+), 3 deletions(-)Documentation/kbuild/makefiles.txt +36
-0@@ -1090,6 +1090,42 @@ When kbuild executes, the following steps are followed (roughly): In this example, extra-y is used to list object files that shall be built, but shall not be linked as part of built-in.o. + force-obj-y force-lib-y + + When CONFIG_BUILD_AVOID_BITROT is enabled using these targets for your + kconfig symbols forces compilation of the associated objects if the + kconfig's symbol's dependencies are met, the objects however are only + linked into to the kernel if and only if the kconfig symbol was + enabled. If CONFIG_BUILD_AVOID_BITROT is disabled the force-obj-y and + force-lib-y targets are functionally equilvalent to obj-y and lib-y + respectively. + + Using force-obj-y and force-lib-y are part of a code architecture and + build philosophy further enabled by linker tables, for more details + refer to the documention in include/linux/tables.h, refer to the + sections: + + o The code bit-rot problem + o The build-all selective-link philosophy + o Avoiding the code bit-rot problem with linker tables + o Linker table module support + + Modules support is expected to be enhanced in the future, so for now + only built-in features are supported. + + Example use: + + force-obj-$(CONFIG_FEATURE_FOO) += foo.o + + An alternative to using force-obj-y, is to use extra-y followed by the + respective obj-y: + + extra-y += foo.o + obj-$(CONFIG_FEATURE_FOO) += foo.o + + Using force-obj-y and force-lib-y can be used to help annotate the + targets follow the 'build-all selective-link philosophy' further + enabled by linker tables. --- 6.7 Commands useful for building a boot imageDocumentation/sections/linker-tables.rst +15
-0@@ -30,6 +30,21 @@ How linker tables simplify initialization code .. kernel-doc:: include/linux/tables.h :doc: How linker tables simplify initialization code +The code bit-rot problem +------------------------ +.. kernel-doc:: include/linux/tables.h + :doc: The code bit-rot problem + +The build-all selective-link philosophy +--------------------------------------- +.. kernel-doc:: include/linux/tables.h + :doc: The build-all selective-link philosophy + +Avoiding the code bit-rot problem with linker tables +---------------------------------------------------- +.. kernel-doc:: include/linux/tables.h + :doc: Avoiding the code bit-rot problem with linker tables + Using linker tables in Linux ============================include/linux/tables.h +71
-0@@ -169,6 +169,77 @@*/ /** +* DOC: The code bit-rot problem +* +* Linux provides a rich array of features, enabling each feature +* however increases the size of the kernel and there are many +* features which users often want disabled. The traditional +* solution to this problem is for each feature to have its own +* Kconfig symbol, followed by a series of #ifdef statements +* in C code and header files, allowing the feature to be compiled +* only when desirable. As the variability of Linux increases build +* tests can and are often done with random kernel configurations, +* allyesconfig, and allmodconfig to help find code issues. This +* however doesn't catch all errors and as a consequence code that +* is typically not enabled often can suffer from bit-rot over time. +*/ + +/** +* DOC: The build-all selective-link philosophy +* +* A code architecture philosophy to help avoid code bit-rot consists +* of using Kconfig symbols for each subsystem feature, replace all #ifdefs +* by instead having each feature implemented it its own C file, and force +* compilation for all features. Only features that are enabled get linked in, +* the forced compilation therefore has no size impact on the final result of +* the kernel. The practice of having each feature implemented in its own C +* file is already prevalent in many subsystems, however #ifdefs are still +* typically required during feature initialization. For instance in:: +* +* #ifdef CONFIG_FOO +* foo_init(); +* #endif +* +* We cannot remove the #ifdef and leave foo_init() as we'd either +* need to always enable the feature or add a respective #ifdef in a +* foo.h which makes foo_init() do nothing when ``CONFIG_FOO`` is disabled. +*/ + +/** +* DOC: Avoiding the code bit-rot problem with linker tables +* +* Linker tables can be used to further help avoid the code bit-rot problem +* when embracing the 'build-all selective-link philosophy' by lifting the +* requirement to use of #ifdefs during initialization. With linker tables +* initialization sequences can be aggregated into a custom ELF section at +* link time, during run time the table can be iterated over and each init +* sequence enabled can be called. A feature's init routine is only added to a +* table when its respective Kconfig symbols has been enabled and therefore +* linked in. Linker tables enable subsystems to completely do away with +* #ifdefs if one is comfortable in accepting all subsystem's feature's +* structural size implications. +* +* To further help with this the Linux build system supports two special +* targets, ``force-obj-y`` and ``force-lib-y``. A subsystem which wants to +* follow the 'build-all selective-link philosophy' can use these targets for a +* feature's kconfig symbol. Using these targets will always require +* compilation of the kconfig's objects if the kconfig symbol's dependencies +* are met but only link the objects into the kernel, and therefore enable the +* feature, if and only if the kconfig symbol has been enabled. +* +* Not all users or build systems may want to opt-in to compile all objects +* following the 'build-all selective-link philosophy', as such the targets +* ``force-obj-y`` and ``force-lib-y`` only force compilation when the kconfig +* symbol ``CONFIG_BUILD_AVOID_BITROT`` has been enabled. Disabling this feature +* makes ``force-obj-y`` and ``force-lib-y`` functionally equivalent to +* ``obj-y`` and ``lib-y`` respectively. +* +* Example use:: +* +* force-obj-$(CONFIG_FEATURE_FOO) += foo.o +*/ + +/** * DOC: Linker table module support * * Modules can use linker tables, however the linker table definition init/Kconfig +15
-0@@ -63,6 +63,28 @@ config CROSS_COMPILE need to set this unless you want the configured kernel build directory to select the cross-compiler automatically. +config BUILD_AVOID_BITROT + bool "Enable force building of force-obj-y and force-lib-y" + default n + help + When enabled objects under the force-obj-y and force-lib-y targets + using a Kconfig symbol will be forced to compile if the Kconfig + symbol's dependencies are met but only linked into the kernel if + the Kconfig symbol is enabled. If a Kconfig symbol on a force-obj-y + or force-lib-y target is disabled, it will be compiled but not linked + into the kernel. + + The force-obj-y and force-lib-y targets can be used by subsystems + which wish to want to follow the 'build-all selective-link philosophy' + documented under include/linux/tables.h. +
init/Kconfig config CROSS_COMPILE · line 90
Quoted 10 lines
init/Kconfig +7
-0+ Say Y if you have a decent build machine and would like to help test + building code for more subsystems. Say N if you do you not have a + good build machine or only want to compile what you've enabled for + your kernel. + + Enabling this option never increases the size of your kernel. + config COMPILE_TEST bool "Compile also drivers which will not load" depends on !UML
Pleaase use COMPILE_TEST here, we've already marked almost all drivers with it today. We also have really good build tools, including cross compilers that you can use to test-build stuff on all different arches if you feel you are somehow not building things you need to test-build.
I fail to see how this is going to do anything different from what we have today, so why add it and have to maintain it? Have you enabled it on subsystems that currently do not get properly build tested and found any issues? What subsystems were they and why are they not in our current build tests?
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH v7 06/14] firmware/Makefile: force recompilation if makefile changes
In reply to Luis R. RodriguezQuoted 18 lines · Luis R. Rodriguez
If you modify the target asm we currently do not force the recompilation of the firmware files. The target asm is in the
firmware/Makefile, peg this file as a dependency to require re-compilation of firmware targets when the asm changes.v3: introduced in this series
Signed-off-by Luis R. Rodriguez <[email protected]>--- firmware/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)firmware/Makefile +0
-0
firmware/Makefile quiet_cmd_fwbin = MK_FW $@ · line 183
Quoted 9 lines
firmware/Makefile +2
-1@@ -176,7 +176,8 @@ quiet_cmd_fwbin = MK_FW $@ wordsize_deps := $(wildcard include/config/64bit.h include/config/32bit.h \ include/config/ppc32.h include/config/ppc64.h \ include/config/superh32.h include/config/superh64.h \ - include/config/x86_32.h include/config/x86_64.h) + include/config/x86_32.h include/config/x86_64.h \ + firmware/Makefile) $(patsubst %,$(obj)/%.gen.S, $(fw-shipped-y)): %: $(wordsize_deps) $(call cmd,fwbin,$(patsubst %.gen.S,%,$@))
I don't understand why this patch is in this series :(
Greg KH
maintainerRe: [PATCH v7 08/14] jump_label: move guard #endif down where it belongs
In reply to Luis R. RodriguezQuoted 23 lines · Luis R. Rodriguez
The ending header guard is misplaced. This has no
functional change, this is just an eye-sore.Signed-off-by Luis R. Rodriguez <[email protected]>--- include/linux/jump_label.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/linux/jump_label.h +2
-2@@ -402,6 +402,6 @@ extern bool ____wrong_branch_error(void);#define static_branch_enable (x) static_key_enable(&(x)->key)#define static_branch_disable (x) static_key_disable(&(x)->key) -#endif /* _LINUX_JUMP_LABEL_H */ -#endif /* __ASSEMBLY__ */ + +#endif /* _LINUX_JUMP_LABEL_H */ Signature · 1 line
2.11.0
Why is this in this patch series?
Greg KH
maintainerRe: [PATCH v7 09/14] jump_label: port __jump_table to linker tables
In reply to Luis R. RodriguezQuoted 78 lines · Luis R. Rodriguez
Move the
__jump_tablefrom the a custom section solution to a generic solution, this avoiding extravmlinux.lds.hcustomizations.This also demos the use of the .data linker table and of the shared asm call
push_section_tbl().Built-in kernel functionality was tested with
CONFIG_STATIC_KEYS_SELFTEST. Moduler kernel functionality was tested withCONFIG_TEST_STATIC_KEYS. Both work as expected.Since
__jump_tablesections are also supported per module this also required expandingmodule-common.lds.Sto capture and fold all .data.tlb.__jump_table.* onto the the section__jump_table-- in this case for modules need to keep a reference in place, given the alternative is to useDEFINE_LINKTABLE(struct jump_entry, __jump_table)per module -- and later through macro hacks instantiate the jump entries per module upon init. This is doable but we'd loose out on the sorting of the table using the linker, to sort we'd always still need to expand the module common linker script. An alternative mechanism is possible which would make these custom module sections extensions dynamic without requiring manual changes, this however is best done later through a separate evolution once linker tables are in place.A careful reviewer may note that some architectures use "\n\t" to separate asm code, while others just use a new line. Upon review last time it was deemed reasonable to for all architectures to just use "\n", this is defined as
ASM_CMD_SEP, and if an architecture needs to override they can do so on their architecturesections.hprior to includingasm-generic/sections.hv6: rename table macro as suggested by Andy Shevchenko
v5:
o Use ..tbl instead of .tbl as suggested by Nicholas Piggin. This is the typical way to avoid clash with compiler generated section.
o Replace section macros with section names
o Use
LINKTABLE_START()andLINKTABLE_END()o fixed tile jump label port -- tile got jump label support as of commit
65a792e84f25d1("tile/jump_label: add jump label support for TILE-Gx"), as such we just needed to adjust the asm to account for the new linker table API use. This commit was merged as of v4.5-rc1.v4:
o Some architectures allow linker scripts to follow including header files, some others do not, so if you need a helper on a linker script you need to explicitly include it. So for instance although
scripts/module-common.lds.Sincludes <asm/tables.h> and this file includes <asm/section-core.h>, you still need to explicitly include it on the linker script. This issue is present on ARM.o as per Josh Poimboeuf open code the section table name instead of including the kernel section headers, the simplicity and independence from the kernel is preferred.
v3:
o More elaborate tests performed
o first modular support use case, module tested wasCONFIG_TEST_STATIC_KEYS(lib/test_static_keys.ko), this required us to extendmodule-common.lds.S
o use genericpush_section_tbl_any()for all architectures
o Makes use ofASM_CMD_SEPto enable architectures to override later if needed
o guardtables.hinclusion and table definition with__KERNEL__v2: introduced in this series
Signed-off-by Luis R. Rodriguez <[email protected]>
Quoted 15 lines
--- arch/arm/include/asm/jump_label.h | 6 ++++-- arch/arm64/include/asm/jump_label.h | 6 ++++-- arch/mips/include/asm/jump_label.h | 6 ++++-- arch/powerpc/include/asm/jump_label.h | 8 +++++--- arch/s390/include/asm/jump_label.h | 6 ++++-- arch/sparc/include/asm/jump_label.h | 6 ++++-- arch/tile/include/asm/jump_label.h | 5 +++-- arch/x86/include/asm/jump_label.h | 10 ++++++---- include/asm-generic/vmlinux.lds.h | 5 ----- include/linux/jump_label.h | 4 ++-- kernel/jump_label.c | 17 ++++++++++------- scripts/module-common.lds | 1 + tools/objtool/special.c | 2 +- 13 files changed, 48 insertions(+), 34 deletions(-)
meta-comment. This new infrastructure doesn't seem to save any code when you need to have a new "link table". Yes, the macros seem a bit nicer, but it feels like unneeded churn. I haven't seen any patches in this series that makes me go "oh yeah, now I see why he did this work, it's so much simpler and easy to understand now!"
What am I missing? What wonderful new things are going to happen, or where is the code savings going to come from with this series to justify all of the work to create and review this?
thanks,
greg k-h
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Luis R. Rodriguez
maintainerRe: [PATCH v7 06/14] firmware/Makefile: force recompilation if makefile changes
In reply to Greg KHQuoted 26 lines · Greg KH
Quoted 25 lines · Luis R. Rodriguez
If you modify the target asm we currently do not force the recompilation of the firmware files. The target asm is in the
firmware/Makefile, peg this file as a dependency to require re-compilation of firmware targets when the asm changes.v3: introduced in this series
Signed-off-by Luis R. Rodriguez <[email protected]>--- firmware/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)firmware/Makefile +2
-1@@ -176,7 +176,8 @@ quiet_cmd_fwbin = MK_FW $@ wordsize_deps := $(wildcard include/config/64bit.h include/config/32bit.h \ include/config/ppc32.h include/config/ppc64.h \ include/config/superh32.h include/config/superh64.h \ - include/config/x86_32.h include/config/x86_64.h) + include/config/x86_32.h include/config/x86_64.h \ + firmware/Makefile)
Quoted 4 lines
firmware/Makefile quiet_cmd_fwbin = MK_FW $@ · line 183
Quoted 2 lines
firmware/Makefile +0
-0$(patsubst %,$(obj)/%.gen.S, $(fw-shipped-y)): %: $(wordsize_deps) $(call cmd,fwbin,$(patsubst %.gen.S,%,$@))I don't understand why this patch is in this series :(
I've taken it out and it has now been routed via kbuild folks as you requested.
Thanks!
Luis
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Luis R. Rodriguez
maintainerRe: [PATCH v4 14/16] kprobes: move kprobe declarations to asm-generic/kprobes.h
In reply to Masami HiramatsuQuoted 47 lines · Masami Hiramatsu
Quoted 36 lines · On Tue, 23 Aug 2016 18:31:05 +0200 "Luis R. Rodriguez" <[email protected]>…
Quoted 30 lines · Masami Hiramatsu
Quoted 27 lines · On Fri, 19 Aug 2016 14:34:12 -0700 [email protected] wrote:
From: "Luis R. Rodriguez" <[email protected]>
Often all is needed is these small helpers, instead of
compiler.hor a fullkprobes.h. This is important for asm helpers, in fact even someasm/kprobes.hmake use of these helpers... instead just keep a generic asm file with helpers useful for asm code with the least amount of clutter as possible.Likewise we need now to also address what to do about this file for both when architectures have
CONFIG_HAVE_KPROBES, and when they do not. Then for when architectures haveCONFIG_HAVE_KPROBESbut have disabledCONFIG_KPROBES.Right now most
asm/kprobes.hdo not have guards againstCONFIG_KPROBES, this means most architecture code cannot includeasm/kprobes.hsafely. Correct this and add guards for architectures missing them. Additionally provide architectures that not have kprobes support with the default asm-generic solution. This lets us forceasm/kprobes.hon the headerinclude/linux/kprobes.halways, but most importantly we can now safely include justasm/kprobes.hon architecture code without bringing the full kitchen sink of header files.Two architectures already provided a guard against
CONFIG_KPROBESon itskprobes.h: sh, arch. The rest of the architectures needed gaurds added. We avoid including any not-needed headers onasm/kprobes.hunless kprobes have been enabled.Quoted 4 lines
Quoted 2 lines
In a subsequent atomic change we can try now to remove
compiler.hfrominclude/linux/kprobes.h.Hmm, this looks a bit overkill... I rather like move it into
linux/table.h.Quoted 7 lines
That's the thing, we can't reasonably expect every table to add an entry into
table.h, this should be up to each user. Moving it totables.hjust prolongs what needs to be done. In this case the change is justifiable given kprobe annotations are required for some architectures early in architecture code, and includingcompiler.hon early architecture code blows up. There is no easy fix to this, and this this was *actually* the cleanest solution I could devise without much changes.
Quoted 4 lines
Aah, I misread your patch, it is
asm-generic/kprobes.h, notasm/kprobes.h. I think it is OK now.Acked-by Masami Hiramatsu <[email protected]>
I'm going to send this patch out separately shortly as its independent.
Luis