irq: Make irqentry text section unconditional
Subsystems (6)
PATCH v7 1/2 irq: Make irqentry text section unconditional
Generate irqentry and softirqentry text sections without any configs. This will add above extra sections, but no performace impact.
---
Changes in v7:
- fix arch/x86/kernel/unwind_frame.c too
--- arch/arm/include/asm/traps.h | 7 ------- arch/arm64/include/asm/traps.h | 7 ------- arch/x86/entry/entry_64.S | 9 ++------- arch/x86/kernel/unwind_frame.c | 2 -- include/asm-generic/sections.h | 4 ++++ include/asm-generic/vmlinux.lds.h | 8 -------- include/linux/interrupt.h | 14 +------------- 7 files changed, 7 insertions(+), 44 deletions(-)
arch/arm/include/asm/traps.h +0 -7
@@ -18,7 +18,6 @@ struct undef_hook {void register_undef_hook (struct undef_hook *hook);void unregister_undef_hook (struct undef_hook *hook); -#ifdef CONFIG_FUNCTION_GRAPH_TRACER static inline int __in_irqentry_text (unsigned long ptr) {extern char __irqentry_text_start[];
@@ -27,12 +26,6 @@ static inline int __in_irqentry_text(unsigned long ptr)return ptr >= (unsigned long )&__irqentry_text_start && ptr < (unsigned long )&__irqentry_text_end; } -#else -static inline int __in_irqentry_text (unsigned long ptr) -{ -return 0 ; -} -#endif static inline int in_exception_text (unsigned long ptr) {
arch/arm64/include/asm/traps.h +0 -7
@@ -37,18 +37,11 @@ void unregister_undef_hook(struct undef_hook *hook);void arm64_notify_segfault (struct pt_regs *regs,unsigned long addr); -#ifdef CONFIG_FUNCTION_GRAPH_TRACER static inline int __in_irqentry_text (unsigned long ptr) {return ptr >= (unsigned long )&__irqentry_text_start && ptr < (unsigned long )&__irqentry_text_end; } -#else -static inline int __in_irqentry_text (unsigned long ptr) -{ -return 0 ; -} -#endif static inline int in_exception_text (unsigned long ptr) {
arch/x86/entry/entry_64.S +2 -7
@@ -766,13 +766,8 @@ apicinterrupt3 \num trace(\sym) smp_trace(\sym) #endif /* Make sure APIC interrupt handlers end up in the irqentry section: */ -#if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN) -# define PUSH_SECTION_IRQENTRY .pushsection .irqentry.text, "ax" -# define POP_SECTION_IRQENTRY .popsection -#else -# define PUSH_SECTION_IRQENTRY -# define POP_SECTION_IRQENTRY -#endif +#define PUSH_SECTION_IRQENTRY .pushsection .irqentry.text, "ax" +#define POP_SECTION_IRQENTRY .popsection .macro apicinterrupt num sym do_sym PUSH_SECTION_IRQENTRY
arch/x86/kernel/unwind_frame.c +0 -2
@@ -84,10 +84,8 @@ static bool in_entry_code(unsigned long ip)if (addr >= __entry_text_start && addr < __entry_text_end)return true; -#if defined(CONFIG_FUNCTION_GRAPH_TRACER ) || defined(CONFIG_KASAN )if (addr >= __irqentry_text_start && addr < __irqentry_text_end)return true; -#endif return false; }
include/asm-generic/sections.h +4 -0
@@ -27,6 +27,8 @@* __kprobes_text_start, __kprobes_text_end * __entry_text_start, __entry_text_end * __ctors_start, __ctors_end +* __irqentry_text_start, __irqentry_text_end +* __softirqentry_text_start, __softirqentry_text_end */ extern char _text[], _stext[], _etext[];extern char _data[], _sdata[], _edata[];
@@ -39,6 +41,8 @@ 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[]; +extern char __irqentry_text_start[], __irqentry_text_end[]; +extern char __softirqentry_text_start[], __softirqentry_text_end[];/* Start and end of .ctors section - used for constructor calls. */ extern char __ctors_start[], __ctors_end[];
include/asm-generic/vmlinux.lds.h +0 -8
@@ -483,25 +483,17 @@ *(.entry.text) \ VMLINUX_SYMBOL(__entry_text_end) = .; -#if defined(CONFIG_FUNCTION_GRAPH_TRACER ) || defined(CONFIG_KASAN )#define IRQENTRY_TEXT \ ALIGN_FUNCTION(); \ VMLINUX_SYMBOL(__irqentry_text_start) = .; \ *(.irqentry.text) \ VMLINUX_SYMBOL(__irqentry_text_end) = .; -#else -#define IRQENTRY_TEXT -#endif -#if defined(CONFIG_FUNCTION_GRAPH_TRACER ) || defined(CONFIG_KASAN )#define SOFTIRQENTRY_TEXT \ ALIGN_FUNCTION(); \ VMLINUX_SYMBOL(__softirqentry_text_start) = .; \ *(.softirqentry.text) \ VMLINUX_SYMBOL(__softirqentry_text_end) = .; -#else -#define SOFTIRQENTRY_TEXT -#endif /* Section used for early init (in .S files) */ #define HEAD_TEXT *(.head.text)
include/linux/interrupt.h +1 -13
@@ -18,6 +18,7 @@#include <linux/atomic.h> #include <asm/ptrace.h> #include <asm/irq.h> +#include <asm/sections.h> /* * These correspond to the IORESOURCE_IRQ_* defines in
@@ -726,7 +727,6 @@ extern int early_irq_init(void);extern int arch_probe_nr_irqs (void );extern int arch_early_irq_init (void ); -#if defined(CONFIG_FUNCTION_GRAPH_TRACER ) || defined(CONFIG_KASAN )/* * We want to know which function is an entrypoint of a hardirq or a softirq. */
@@ -734,16 +734,4 @@ extern int arch_early_irq_init(void);#define __softirq_entry \ __attribute__((__section__(".softirqentry.text"))) -/* Limits of hardirq entrypoints */ -extern char __irqentry_text_start[]; -extern char __irqentry_text_end[]; -/* Limits of softirq entrypoints */ -extern char __softirqentry_text_start[]; -extern char __softirqentry_text_end[]; - -#else -#define __irq_entry -#define __softirq_entry -#endif -#endif
PATCH v7 2/2 kprobes/x86: Do not jump-optimize kprobes on irq entry code
Since the kernel segment registers are not prepared at the entry of irq-entry code, if a kprobe on such code is jump-optimized, accessing per-cpu variables may cause kernel panic.
However, if the kprobe is not optimized, it kicks int3 exception and set segment registers correctly.
This checks probe-address and if it is in irq-entry code, it prohibits optimizing such kprobes. This means we can continuously probing such interrupt handlers by kprobes but it is not optimized anymore.
--- arch/x86/kernel/kprobes/opt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/x86/kernel/kprobes/opt.c +6 -3
@@ -39,6 +39,7 @@#include <asm/insn.h> #include <asm/debugreg.h> #include <asm/set_memory.h> +#include <asm/sections.h> #include "common.h"
@@ -251,10 +252,12 @@ static int can_optimize(unsigned long paddr)/* * Do not optimize in the entry code due to the unstable -* stack handling. +* stack handling and registers setup. */ -if ((paddr >= (unsigned long )__entry_text_start) && - (paddr < (unsigned long )__entry_text_end)) +if (((paddr >= (unsigned long )__entry_text_start) && + (paddr < (unsigned long )__entry_text_end)) || + ((paddr >= (unsigned long )__irqentry_text_start) && + (paddr < (unsigned long )__irqentry_text_end)))return 0 ;/* Check there is enough space for a relative jump. */
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Masami-Hiramatsu/irq-Make-irqentry-text-section-unconditional/20170729-170710 config: h8300-h8300h-sim_defconfig (attached as .config) compiler…
Hi Masami,
[auto build test ERROR on tip/x86/core]
[also build test ERROR on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Masami-Hiramatsu/irq-Make-irqentry-text-section-unconditional/20170729-170710
config: h8300-h8300h-sim_defconfig (attached as .config)
compiler: h8300-linux-gcc (GCC) 6.2.0
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=h8300
All errors (new ones prefixed by >>):
In file included from arch/h8300/kernel/process.c:45:0:
>> arch/h8300/include/asm/traps.h:36:21: error: conflicting types for '_etext'
extern char _start, _etext;
^~~~~~
In file included from ./arch/h8300/include/generated/asm/sections.h:1:0,
from include/linux/interrupt.h:21,
from arch/h8300/kernel/process.c:38:
include/asm-generic/sections.h:33:32: note: previous declaration of '_etext' was here
extern char _text[], _stext[], _etext[];
^~~~~~vim +/_etext +36 arch/h8300/include/asm/traps.h
d2a5f499 Yoshinori Sato 2015-05-11 35
d2a5f499 Yoshinori Sato 2015-05-11 @36 extern char _start, _etext; d2a5f499 Yoshinori Sato 2015-05-11 37 #define check_kernel_text(addr) \ d2a5f499 Yoshinori Sato 2015-05-11 38 ((addr >= (unsigned long)(&_start)) && \ bf24eec3 Yoshinori Sato 2016-01-15 39 (addr < (unsigned long)(&_etext)) && !(addr & 1))
d2a5f499 Yoshinori Sato 2015-05-11 40
:::::: The code at line 36 was first introduced by commit :::::: d2a5f4999f6c211adf30d9788349e13988d6f2a7 h8300: Assembly headers
:::::: TO: Yoshinori Sato <[email protected]> :::::: CC: Yoshinori Sato <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 19 lines · On Sat, 29 Jul 2017 19:11:23 +0800 kbuild test robot <[email protected]> wrote:
Hi Masami,
[auto build test ERROR on tip/x86/core]
[also build test ERROR on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]url: https://github.com/0day-ci/linux/commits/Masami-Hiramatsu/irq-Make-irqentry-text-section-unconditional/20170729-170710
config: h8300-h8300h-sim_defconfig (attached as .config)
compiler: h8300-linux-gcc (GCC) 6.2.0
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=h8300All errors (new ones prefixed by >>):
In file included from arch/h8300/kernel/process.c:45:0:Quoted 1 line
Quoted 1 line
arch/h8300/include/asm/traps.h:36:21: error: conflicting types for '_etext'
Quoted 8 lines
extern char _start, _etext;
^~~~~~
In file included from ./arch/h8300/include/generated/asm/sections.h:1:0,
from include/linux/interrupt.h:21,
from arch/h8300/kernel/process.c:38:
include/asm-generic/sections.h:33:32: note: previous declaration of '_etext' was here
extern char _text[], _stext[], _etext[];
^~~~~~OK, it is like opening a pandra's box, but I would like to fix arch/h8300/kernel/process.c because include/asm-generic/sections.h is a generic header and will be used anywhere.
Thanks,
Quoted 19 lines
vim +/_etext +36
arch/h8300/include/asm/traps.h
d2a5f499Yoshinori Sato 2015-05-11 35d2a5f499 Yoshinori Sato 2015-05-11 @36 extern char _start, _etext; d2a5f499 Yoshinori Sato 2015-05-11 37 #define check_kernel_text(addr) \ d2a5f499 Yoshinori Sato 2015-05-11 38 ((addr >= (unsigned long)(&_start)) && \ bf24eec3 Yoshinori Sato 2016-01-15 39 (addr < (unsigned long)(&_etext)) && !(addr & 1))
d2a5f499Yoshinori Sato 2015-05-11 40:::::: The code at line 36 was first introduced by commit ::::::
d2a5f4999f6c211adf30d9788349e13988d6f2a7h8300: Assembly headers:::::: TO: Yoshinori Sato <[email protected]> :::::: CC: Yoshinori Sato <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Signature · 1 line
Masami Hiramatsu <[email protected]>
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Masami-Hiramatsu/irq-Make-irqentry-text-section-unconditional/20170729-170710 config: xtensa-common_defconfig (attached as .config) compiler…
Hi Masami,
[auto build test ERROR on tip/x86/core]
[also build test ERROR on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Masami-Hiramatsu/irq-Make-irqentry-text-section-unconditional/20170729-170710
config: xtensa-common_defconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa
All errors (new ones prefixed by >>):
>> arch/xtensa/kernel/setup.c:276:13: error: conflicting types for '_end'
extern char _end;
^
In file included from ./arch/xtensa/include/generated/asm/sections.h:1:0,
from include/linux/interrupt.h:21,
from include/linux/pci.h:31,
from arch/xtensa/include/asm/platform.h:15,
from arch/xtensa/kernel/setup.c:43:
include/asm-generic/sections.h:39:13: note: previous declaration of '_end' was here
extern char _end[];
^
>> arch/xtensa/kernel/setup.c:277:13: error: conflicting types for '_stext'
extern char _stext;
^
In file included from ./arch/xtensa/include/generated/asm/sections.h:1:0,
from include/linux/interrupt.h:21,
from include/linux/pci.h:31,
from arch/xtensa/include/asm/platform.h:15,
from arch/xtensa/kernel/setup.c:43:
include/asm-generic/sections.h:33:22: note: previous declaration of '_stext' was here
extern char _text[], _stext[], _etext[];
^vim +/_stext +277 arch/xtensa/kernel/setup.c
5a0015d62 Chris Zankel 2005-06-23 271 5a0015d62 Chris Zankel 2005-06-23 272 /* 5a0015d62 Chris Zankel 2005-06-23 273 * Initialize system. Setup memory and reserve regions. 5a0015d62 Chris Zankel 2005-06-23 274 */ 5a0015d62 Chris Zankel 2005-06-23 275 5a0015d62 Chris Zankel 2005-06-23 @276 extern char _end; 5a0015d62 Chris Zankel 2005-06-23 @277 extern char _stext; 5a0015d62 Chris Zankel 2005-06-23 278 extern char _WindowVectors_text_start; 5a0015d62 Chris Zankel 2005-06-23 279 extern char _WindowVectors_text_end; 5a0015d62 Chris Zankel 2005-06-23 280 extern char _DebugInterruptVector_literal_start; 5a0015d62 Chris Zankel 2005-06-23 281 extern char _DebugInterruptVector_text_end; 5a0015d62 Chris Zankel 2005-06-23 282 extern char _KernelExceptionVector_literal_start; 5a0015d62 Chris Zankel 2005-06-23 283 extern char _KernelExceptionVector_text_end; 5a0015d62 Chris Zankel 2005-06-23 284 extern char _UserExceptionVector_literal_start; 5a0015d62 Chris Zankel 2005-06-23 285 extern char _UserExceptionVector_text_end; 5a0015d62 Chris Zankel 2005-06-23 286 extern char _DoubleExceptionVector_literal_start; 5a0015d62 Chris Zankel 2005-06-23 287 extern char _DoubleExceptionVector_text_end; 2d1c645cc Marc Gauthier 2013-01-05 288 #if XCHAL_EXCM_LEVEL >= 2 2d1c645cc Marc Gauthier 2013-01-05 289 extern char _Level2InterruptVector_text_start; 2d1c645cc Marc Gauthier 2013-01-05 290 extern char _Level2InterruptVector_text_end; 2d1c645cc Marc Gauthier 2013-01-05 291 #endif 2d1c645cc Marc Gauthier 2013-01-05 292 #if XCHAL_EXCM_LEVEL >= 3 2d1c645cc Marc Gauthier 2013-01-05 293 extern char _Level3InterruptVector_text_start; 2d1c645cc Marc Gauthier 2013-01-05 294 extern char _Level3InterruptVector_text_end; 2d1c645cc Marc Gauthier 2013-01-05 295 #endif 2d1c645cc Marc Gauthier 2013-01-05 296 #if XCHAL_EXCM_LEVEL >= 4 2d1c645cc Marc Gauthier 2013-01-05 297 extern char _Level4InterruptVector_text_start; 2d1c645cc Marc Gauthier 2013-01-05 298 extern char _Level4InterruptVector_text_end; 2d1c645cc Marc Gauthier 2013-01-05 299 #endif 2d1c645cc Marc Gauthier 2013-01-05 300 #if XCHAL_EXCM_LEVEL >= 5 2d1c645cc Marc Gauthier 2013-01-05 301 extern char _Level5InterruptVector_text_start; 2d1c645cc Marc Gauthier 2013-01-05 302 extern char _Level5InterruptVector_text_end; 2d1c645cc Marc Gauthier 2013-01-05 303 #endif 2d1c645cc Marc Gauthier 2013-01-05 304 #if XCHAL_EXCM_LEVEL >= 6 2d1c645cc Marc Gauthier 2013-01-05 305 extern char _Level6InterruptVector_text_start; 2d1c645cc Marc Gauthier 2013-01-05 306 extern char _Level6InterruptVector_text_end; 2d1c645cc Marc Gauthier 2013-01-05 307 #endif ab45fb145 Max Filippov 2015-10-16 308 #ifdef CONFIG_SMP ab45fb145 Max Filippov 2015-10-16 309 extern char _SecondaryResetVector_text_start; ab45fb145 Max Filippov 2015-10-16 310 extern char _SecondaryResetVector_text_end; ab45fb145 Max Filippov 2015-10-16 311 #endif 5a0015d62 Chris Zankel 2005-06-23 312
:::::: The code at line 277 was first introduced by commit
:::::: 5a0015d62668e64c8b6e02e360fbbea121bfd5e6 [PATCH] xtensa: Architecture support for Tensilica Xtensa Part 3
:::::: TO: Chris Zankel <[email protected]> :::::: CC: Linus Torvalds <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation