x86/idt: Remove the tracing IDT completely
authorThomas Gleixner <tglx@linutronix.de>
Mon, 28 Aug 2017 06:47:31 +0000 (08:47 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 29 Aug 2017 09:42:28 +0000 (11:42 +0200)
No more users of the tracing IDT. All exception tracepoints have been moved
into the regular handlers. Get rid of the mess which shouldn't have been
created in the first place.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/20170828064957.378851687@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/entry/entry_32.S
arch/x86/entry/entry_64.S
arch/x86/include/asm/desc.h
arch/x86/include/asm/hw_irq.h
arch/x86/include/asm/segment.h
arch/x86/kernel/tracepoint.c
arch/x86/kernel/traps.c

index 0092da1c056f2b8d0525f83103486ed7abe0b332..8a13d468635a8f56f772a6879d3e907a1945dd6a 100644 (file)
@@ -673,16 +673,8 @@ ENTRY(name)                                \
        jmp     ret_from_intr;          \
 ENDPROC(name)
 
-
-#ifdef CONFIG_TRACING
-# define TRACE_BUILD_INTERRUPT(name, nr)       BUILD_INTERRUPT3(trace_##name, nr, smp_trace_##name)
-#else
-# define TRACE_BUILD_INTERRUPT(name, nr)
-#endif
-
 #define BUILD_INTERRUPT(name, nr)              \
        BUILD_INTERRUPT3(name, nr, smp_##name); \
-       TRACE_BUILD_INTERRUPT(name, nr)
 
 /* The include is where all of the SMP etc. interrupts come from */
 #include <asm/entry_arch.h>
@@ -880,14 +872,14 @@ ENTRY(xen_failsafe_callback)
 ENDPROC(xen_failsafe_callback)
 
 BUILD_INTERRUPT3(xen_hvm_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
-               xen_evtchn_do_upcall)
+                xen_evtchn_do_upcall)
 
 #endif /* CONFIG_XEN */
 
 #if IS_ENABLED(CONFIG_HYPERV)
 
 BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
-       hyperv_vector_handler)
+                hyperv_vector_handler)
 
 #endif /* CONFIG_HYPERV */
 
index 2731b94717706230fd5122f3bcf1cee7d2bf2d04..7a1d383c219280d34d7fad78b7c1ea5d66949386 100644 (file)
@@ -748,18 +748,6 @@ ENTRY(\sym)
 END(\sym)
 .endm
 
-#ifdef CONFIG_TRACING
-#define trace(sym) trace_##sym
-#define smp_trace(sym) smp_trace_##sym
-
-.macro trace_apicinterrupt num sym
-apicinterrupt3 \num trace(\sym) smp_trace(\sym)
-.endm
-#else
-.macro trace_apicinterrupt num sym do_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"
@@ -772,7 +760,6 @@ apicinterrupt3 \num trace(\sym) smp_trace(\sym)
 .macro apicinterrupt num sym do_sym
 PUSH_SECTION_IRQENTRY
 apicinterrupt3 \num \sym \do_sym
-trace_apicinterrupt \num \sym
 POP_SECTION_IRQENTRY
 .endm
 
index 71094f208673fae2bcff6973bb619f9e6de762f2..d18a604a0941c0613b5cdc6b69675a665e3245bd 100644 (file)
@@ -421,35 +421,7 @@ static inline void set_nmi_gate(int gate, void *addr)
 }
 #endif
 
-#ifdef CONFIG_TRACING
-extern struct desc_ptr trace_idt_descr;
-extern gate_desc trace_idt_table[];
-static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
-{
-       write_idt_entry(trace_idt_table, entry, gate);
-}
-
-static inline void _trace_set_gate(int gate, unsigned type, void *addr,
-                                  unsigned dpl, unsigned ist, unsigned seg)
-{
-       gate_desc s;
-
-       pack_gate(&s, type, (unsigned long)addr, dpl, ist, seg);
-       /*
-        * does not need to be atomic because it is only done once at
-        * setup time
-        */
-       write_trace_idt_entry(gate, &s);
-}
-#else
-static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
-{
-}
-
-#define _trace_set_gate(gate, type, addr, dpl, ist, seg)
-#endif
-
-static inline void _set_gate(int gate, unsigned type, void *addr,
+static inline void _set_gate(int gate, unsigned type, const void *addr,
                             unsigned dpl, unsigned ist, unsigned seg)
 {
        gate_desc s;
@@ -460,28 +432,13 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
         * setup time
         */
        write_idt_entry(idt_table, gate, &s);
-       write_trace_idt_entry(gate, &s);
 }
 
-/*
- * This needs to use 'idt_table' rather than 'idt', and
- * thus use the _nonmapped_ version of the IDT, as the
- * Pentium F0 0F bugfix can have resulted in the mapped
- * IDT being write-protected.
- */
-#define set_intr_gate_notrace(n, addr)                                 \
-       do {                                                            \
-               BUG_ON((unsigned)n > 0xFF);                             \
-               _set_gate(n, GATE_INTERRUPT, (void *)addr, 0, 0,        \
-                         __KERNEL_CS);                                 \
-       } while (0)
-
-#define set_intr_gate(n, addr)                                         \
-       do {                                                            \
-               set_intr_gate_notrace(n, addr);                         \
-               _trace_set_gate(n, GATE_INTERRUPT, (void *)trace_##addr,\
-                               0, 0, __KERNEL_CS);                     \
-       } while (0)
+static inline void set_intr_gate(unsigned int n, const void *addr)
+{
+       BUG_ON(n > 0xFF);
+       _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
+}
 
 extern unsigned long used_vectors[];
 
@@ -565,31 +522,6 @@ static inline void load_debug_idt(void)
 }
 #endif
 
-#ifdef CONFIG_TRACING
-extern atomic_t trace_idt_ctr;
-static inline bool is_trace_idt_enabled(void)
-{
-       if (atomic_read(&trace_idt_ctr))
-               return true;
-
-       return false;
-}
-
-static inline void load_trace_idt(void)
-{
-       load_idt((const struct desc_ptr *)&trace_idt_descr);
-}
-#else
-static inline bool is_trace_idt_enabled(void)
-{
-       return false;
-}
-
-static inline void load_trace_idt(void)
-{
-}
-#endif
-
 /*
  * The load_current_idt() must be called with interrupts disabled
  * to avoid races. That way the IDT will always be set back to the expected
@@ -601,8 +533,6 @@ static inline void load_current_idt(void)
 {
        if (is_debug_idt_enabled())
                load_debug_idt();
-       else if (is_trace_idt_enabled())
-               load_trace_idt();
        else
                load_idt((const struct desc_ptr *)&idt_descr);
 }
index 4626f8790ce78db61e52ce34e2f3651701959d39..6dfe366a8804576719196970e8e6c92f84fb1408 100644 (file)
@@ -46,26 +46,6 @@ extern asmlinkage void deferred_error_interrupt(void);
 extern asmlinkage void call_function_interrupt(void);
 extern asmlinkage void call_function_single_interrupt(void);
 
-#ifdef CONFIG_TRACING
-/* Interrupt handlers registered during init_IRQ */
-#define trace_reschedule_interrupt     reschedule_interrupt
-#define trace_call_function_interrupt  call_function_interrupt
-#define trace_call_function_single_interrupt   call_function_single_interrupt
-#define trace_thermal_interrupt        thermal_interrupt
-#define trace_threshold_interrupt      threshold_interrupt
-#define trace_deferred_error_interrupt deferred_error_interrupt
-#define trace_irq_work_interrupt irq_work_interrupt
-#define trace_error_interrupt error_interrupt
-#define trace_spurious_interrupt spurious_interrupt
-#define trace_x86_platform_ipi x86_platform_ipi
-#define trace_apic_timer_interrupt     apic_timer_interrupt
-#define trace_irq_move_cleanup_interrupt  irq_move_cleanup_interrupt
-#define trace_reboot_interrupt  reboot_interrupt
-#define trace_kvm_posted_intr_ipi kvm_posted_intr_ipi
-#define trace_kvm_posted_intr_wakeup_ipi kvm_posted_intr_wakeup_ipi
-#define trace_kvm_posted_intr_nested_ipi kvm_posted_intr_nested_ipi
-#endif /* CONFIG_TRACING */
-
 #ifdef CONFIG_X86_LOCAL_APIC
 struct irq_data;
 struct pci_dev;
index 1549caa098f0828e6c533f714f22a7f97532427e..5a602d6e874dcbc9e8fb419bf33eb26294ce4300 100644 (file)
 #ifndef __ASSEMBLY__
 
 extern const char early_idt_handler_array[NUM_EXCEPTION_VECTORS][EARLY_IDT_HANDLER_SIZE];
-#ifdef CONFIG_TRACING
-# define trace_early_idt_handler_array early_idt_handler_array
-#endif
 
 /*
  * Load a segment. Fall back on loading the zero segment if something goes
index dd4aa04bb95cdc74d5c6ffab1d698144659d2c71..4cae92f1549505cbdafe5f991a8520e8521c48a3 100644 (file)
 #include <asm/hw_irq.h>
 #include <asm/desc.h>
 
-atomic_t trace_idt_ctr = ATOMIC_INIT(0);
-struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
-                               (unsigned long) trace_idt_table };
-
-/* No need to be aligned, but done to keep all IDTs defined the same way. */
-gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
-
 DEFINE_STATIC_KEY_FALSE(trace_irqvectors_key);
-static int trace_irq_vector_refcount;
-static DEFINE_MUTEX(irq_vector_mutex);
-
-static void set_trace_idt_ctr(int val)
-{
-       atomic_set(&trace_idt_ctr, val);
-       /* Ensure the trace_idt_ctr is set before sending IPI */
-       wmb();
-}
-
-static void switch_idt(void *arg)
-{
-       unsigned long flags;
-
-       local_irq_save(flags);
-       load_current_idt();
-       local_irq_restore(flags);
-}
 
 int trace_irq_vector_regfunc(void)
 {
        static_branch_inc(&trace_irqvectors_key);
-
-       mutex_lock(&irq_vector_mutex);
-       if (!trace_irq_vector_refcount) {
-               set_trace_idt_ctr(1);
-               smp_call_function(switch_idt, NULL, 0);
-               switch_idt(NULL);
-       }
-       trace_irq_vector_refcount++;
-       mutex_unlock(&irq_vector_mutex);
        return 0;
 }
 
 void trace_irq_vector_unregfunc(void)
 {
        static_branch_dec(&trace_irqvectors_key);
-
-       mutex_lock(&irq_vector_mutex);
-       trace_irq_vector_refcount--;
-       if (!trace_irq_vector_refcount) {
-               set_trace_idt_ctr(0);
-               smp_call_function(switch_idt, NULL, 0);
-               switch_idt(NULL);
-       }
-       mutex_unlock(&irq_vector_mutex);
 }
index 309532451d949f6711b32a3553b248db27ee8174..36c583625328b41b5ecb6f68a4a69693c7fec3cd 100644 (file)
@@ -939,12 +939,8 @@ void __init early_trap_init(void)
         * stack.  Using the original stack works well enough at this
         * early stage. DEBUG_STACK will be equipped after cpu_init() in
         * trap_init().
-        *
-        * We don't need to set trace_idt_table like set_intr_gate(),
-        * since we don't have trace_debug and it will be reset to
-        * 'debug' in trap_init() by set_intr_gate_ist().
         */
-       set_intr_gate_notrace(X86_TRAP_DB, debug);
+       set_intr_gate(X86_TRAP_DB, debug);
        /* int3 can be called from all */
        set_system_intr_gate(X86_TRAP_BP, &int3);
 #ifdef CONFIG_X86_32