Skip to contentSkip to conversation

x86, kasan, ftrace: Put APIC interrupt handlers into .irqentry.text

PATCH In review Alexander Potapenko 2 participants 3 messages Jul 15, 2016 – Aug 10, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86, kasan, ftrace: Put APIC interrupt handlers into .irqentry.text

When building with CONFIG_FUNCTION_GRAPH_TRACER or CONFIG_KASAN, put the APIC interrupt handlers into the .irqentry.text section. This is needed because both KASAN and function graph tracer use __irqentry_text_start and __irqentry_text_end to determine whether a function is an IRQ entry point.

Dmitry Vyukov has reported unexpected KASAN stackdepot growth
(https://github.com/google/kasan/issues/36), which had been caused by the APIC handlers not being present in .irqentry.text.

---
v2: - fixed kbuild warning (incorrect #if directive)

---
 arch/x86/entry/entry_64.S | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/x86/entry/entry_64.S +11 -0
index 9ee0da1..2ef4f0b 100644
@@ -601,9 +601,20 @@ apicinterrupt3 \num trace(\sym) smp_trace(\sym)
 .endm
 #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
+
 .macro apicinterrupt num sym do_sym
+PUSH_SECTION_IRQENTRY
 apicinterrupt3 \num \sym \do_sym
 trace_apicinterrupt \num \sym
+POP_SECTION_IRQENTRY
 .endm
 
 #ifdef CONFIG_SMP
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw
Quoted 43 lines · Alexander Potapenko

When building with CONFIG_FUNCTION_GRAPH_TRACER or CONFIG_KASAN, put the APIC interrupt handlers into the .irqentry.text section. This is needed because both KASAN and function graph tracer use __irqentry_text_start and __irqentry_text_end to determine whether a function is an IRQ entry point.

Dmitry Vyukov has reported unexpected KASAN stackdepot growth
(https://github.com/google/kasan/issues/36), which had been caused by the APIC handlers not being present in .irqentry.text.

---
v2: - fixed kbuild warning (incorrect #if directive)

---
 arch/x86/entry/entry_64.S | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/x86/entry/entry_64.S +11 -1
index 9ee0da1..2ef4f0b 100644
@@ -601,9 +601,20 @@ apicinterrupt3 \num trace(\sym) smp_trace(\sym)
 .endm
 #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
+
 .macro apicinterrupt num sym do_sym
+PUSH_SECTION_IRQENTRY
 apicinterrupt3 \num \sym \do_sym
 trace_apicinterrupt \num \sym
+POP_SECTION_IRQENTRY
 .endm
 
 #ifdef CONFIG_SMP
--
Quoted 2 lines

2.8.0.rc3.226.g39d4020

A friendly ping.

Signature · 10 lines
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
#2 lore raw
In reply to Alexander Potapenko
x86, kasan, ftrace: Put APIC interrupt handlers into .irqentry.text
Commit-ID:  469f00231278da68062a809306df0bac95a27507
Gitweb:     http://git.kernel.org/tip/469f00231278da68062a809306df0bac95a27507
Author:     Alexander Potapenko <[email protected]>
AuthorDate: Fri, 15 Jul 2016 11:42:43 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 10 Aug 2016 14:19:33 +0200

x86, kasan, ftrace: Put APIC interrupt handlers into .irqentry.text

Dmitry Vyukov has reported unexpected KASAN stackdepot growth:

https://github.com/google/kasan/issues/36

... which is caused by the APIC handlers not being present in .irqentry.text:

When building with CONFIG_FUNCTION_GRAPH_TRACER=y or CONFIG_KASAN=y, put the APIC interrupt handlers into the .irqentry.text section. This is needed because both KASAN and function graph tracer use __irqentry_text_start and __irqentry_text_end to determine whether a function is an IRQ entry point.

---
 arch/x86/entry/entry_64.S | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/x86/entry/entry_64.S +11 -0
index b846875..9f85827 100644
@@ -601,9 +601,20 @@ apicinterrupt3 \num trace(\sym) smp_trace(\sym)
 .endm
 #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
+
 .macro apicinterrupt num sym do_sym
+PUSH_SECTION_IRQENTRY
 apicinterrupt3 \num \sym \do_sym
 trace_apicinterrupt \num \sym
+POP_SECTION_IRQENTRY
 .endm
 
 #ifdef CONFIG_SMP