linux/arch/x86/kernel
Peter Zijlstra d54191b85e Kprobe smoke test lockdep warning
On Mon, 2008-04-21 at 18:54 -0400, Masami Hiramatsu wrote:
> Thank you for reporting.
>
> Actually, kprobes tries to fixup thread's flags in post_kprobe_handler
> (which is called from kprobe_exceptions_notify) by
> trace_hardirqs_fixup_flags(pt_regs->flags). However, even the irq flag
> is set in pt_regs->flags, true hardirq is still off until returning
> from do_debug. Thus, lockdep assumes that hardirq is off without annotation.
>
> IMHO, one possible solution is that fixing hardirq flags right after
> notify_die in do_debug instead of in post_kprobe_handler.

My reply to BZ 10489:

> [    2.707509] Kprobe smoke test started
> [    2.709300] ------------[ cut here ]------------
> [    2.709420] WARNING: at kernel/lockdep.c:2658 check_flags+0x4d/0x12c()
> [    2.709541] Modules linked in:
> [    2.709588] Pid: 1, comm: swapper Not tainted 2.6.25.jml.057 #1
> [    2.709588]  [<c0126acc>] warn_on_slowpath+0x41/0x51
> [    2.709588]  [<c010bafc>] ? save_stack_trace+0x1d/0x3b
> [    2.709588]  [<c0140a83>] ? save_trace+0x37/0x89
> [    2.709588]  [<c011987d>] ? kernel_map_pages+0x103/0x11c
> [    2.709588]  [<c0109803>] ? native_sched_clock+0xca/0xea
> [    2.709588]  [<c0142958>] ? mark_held_locks+0x41/0x5c
> [    2.709588]  [<c0382580>] ? kprobe_exceptions_notify+0x322/0x3af
> [    2.709588]  [<c0142aff>] ? trace_hardirqs_on+0xf1/0x119
> [    2.709588]  [<c03825b3>] ? kprobe_exceptions_notify+0x355/0x3af
> [    2.709588]  [<c0140823>] check_flags+0x4d/0x12c
> [    2.709588]  [<c0143c9d>] lock_release+0x58/0x195
> [    2.709588]  [<c038347c>] ? __atomic_notifier_call_chain+0x0/0x80
> [    2.709588]  [<c03834d6>] __atomic_notifier_call_chain+0x5a/0x80
> [    2.709588]  [<c0383508>] atomic_notifier_call_chain+0xc/0xe
> [    2.709588]  [<c013b6d4>] notify_die+0x2d/0x2f
> [    2.709588]  [<c038168a>] do_debug+0x67/0xfe
> [    2.709588]  [<c0381287>] debug_stack_correct+0x27/0x30
> [    2.709588]  [<c01564c0>] ? kprobe_target+0x1/0x34
> [    2.709588]  [<c0156572>] ? init_test_probes+0x50/0x186
> [    2.709588]  [<c04fae48>] init_kprobes+0x85/0x8c
> [    2.709588]  [<c04e947b>] kernel_init+0x13d/0x298
> [    2.709588]  [<c04e933e>] ? kernel_init+0x0/0x298
> [    2.709588]  [<c04e933e>] ? kernel_init+0x0/0x298
> [    2.709588]  [<c0105ef7>] kernel_thread_helper+0x7/0x10
> [    2.709588]  =======================
> [    2.709588] ---[ end trace 778e504de7e3b1e3 ]---
> [    2.709588] possible reason: unannotated irqs-off.
> [    2.709588] irq event stamp: 370065
> [    2.709588] hardirqs last  enabled at (370065): [<c0382580>] kprobe_exceptions_notify+0x322/0x3af
> [    2.709588] hardirqs last disabled at (370064): [<c0381bb7>] do_int3+0x1d/0x7d
> [    2.709588] softirqs last  enabled at (370050): [<c012b464>] __do_softirq+0xfa/0x100
> [    2.709588] softirqs last disabled at (370045): [<c0107438>] do_softirq+0x74/0xd9
> [    2.714751] Kprobe smoke test passed successfully

how I love this stuff...

Ok, do_debug() is a trap, this can happen at any time regardless of the
machine's IRQ state. So the first thing we do is fix up the IRQ state.
Then we call this die notifier stuff; and return with messed up IRQ
state... YAY.

So, kprobes fudges it..

  notify_die(DIE_DEBUG)
    kprobe_exceptions_notify()
      post_kprobe_handler()
        modify regs->flags
        trace_hardirqs_fixup_flags(regs->flags);  <--- must be it

So what's the use of modifying flags if they're not meant to take effect
at some point.

/me tries to reproduce issue; enable kprobes test thingy && boot

OK, that reproduces..

So the below makes it work - but I'm not getting this code; at the time
I wrote that stuff I CC'ed each and every kprobe maintainer listed in
the usual places but got no reposonse - can some please explain this
stuff to me?

Are the saved flags only for the TF bit or are they made in full effect
later (and if so, where) ?

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-15 11:18:03 +02:00
..
acpi x86: I/O APIC: remove an IRQ2-mask hack 2008-07-13 11:43:48 +02:00
cpu Merge branch 'bkl-removal' of git://git.lwn.net/linux-2.6 2008-07-14 14:48:31 -07:00
.gitignore arch/x86/kernel/.gitignore: Added vmlinux.lds to .gitignore file because it shouldn't be tracked. 2008-07-10 10:13:51 -07:00
alternative.c x86: fix SMP alternatives: use mutex instead of spinlock, text_poke is sleepable 2008-05-23 21:56:52 +02:00
amd_iommu_init.c x86, AMD IOMMU: remove unnecessary code from the iommu_enable function 2008-07-04 11:44:44 +02:00
amd_iommu.c x86, AMD IOMMU: flush domain TLB when there is more than one page to flush 2008-07-04 11:44:40 +02:00
aperture_64.c x86: remove end_pfn in 64bit 2008-07-08 13:10:38 +02:00
apic_32.c x86, VisWS: turn into generic arch, make VisWS boot on a regular PC 2008-07-10 18:55:32 +02:00
apic_64.c x86: nmi_watchdog - use NMI_NONE by default 2008-07-08 12:51:41 +02:00
apm_32.c Merge branch 'bkl-removal' of git://git.lwn.net/linux-2.6 2008-07-14 14:48:31 -07:00
asm-offsets_32.c x86/paravirt: split sysret and sysexit 2008-07-08 13:13:15 +02:00
asm-offsets_64.c x86: rename threadinfo to TI. 2008-07-09 09:14:02 +02:00
asm-offsets.c
audit_64.c
bootflag.c
cpuid.c x86: cdev lock_kernel() pushdown 2008-05-18 15:43:40 -06:00
crash_dump_32.c
crash_dump_64.c
crash.c x86: allow machine_crash_shutdown to be replaced 2008-04-27 12:00:29 +03:00
doublefault_32.c
ds.c x86: debug Store - call kfree if only we really need it 2008-04-17 17:41:34 +02:00
e820.c x86, e820: remove end_user_pfn 2008-07-13 08:19:40 +02:00
early_printk.c x86, generic: mark early_printk as asmlinkage 2008-06-18 13:11:01 +02:00
early-quirks.c x86: remove end_pfn in 64bit 2008-07-08 13:10:38 +02:00
efi_32.c x86: fix Intel Mac booting with EFI 2008-07-03 08:19:18 +02:00
efi_64.c x86: add flags parameter to reserve_bootmem_generic() 2008-07-08 11:49:49 +02:00
efi_stub_32.S
efi_stub_64.S
efi.c x86: introduce max_low_pfn_mapped for 64-bit 2008-07-11 10:24:04 +02:00
entry_32.S Merge branch 'auto-ftrace-next' into tracing/for-linus 2008-07-14 16:11:52 +02:00
entry_64.S Merge branch 'auto-ftrace-next' into tracing/for-linus 2008-07-14 16:11:52 +02:00
ftrace.c ftrace: store mcount address in rec->ip 2008-06-23 22:10:56 +02:00
genapic_64.c x86: introduce max_physical_apicid for bigsmp switching 2008-06-10 11:32:09 +02:00
genapic_flat_64.c x86: use cpumask_of_cpu() 2008-04-17 17:41:36 +02:00
genx2apic_uv_x.c x86: map UV chipset space - UV support 2008-07-09 07:43:23 +02:00
geode_32.c x86, geode: add a VSA2 ID for General Software 2008-06-19 14:19:03 +02:00
head32.c x86: extract common part of head32.c and head64.c into head.c 2008-06-05 15:10:02 +02:00
head64.c x86: move reserve_setup_data to setup.c 2008-07-08 13:16:14 +02:00
head_32.S x86: boot secondary cpus through initial_code 2008-07-08 12:48:18 +02:00
head_64.S x86: always set _PAGE_GLOBAL in _PAGE_KERNEL* flags 2008-07-08 13:16:28 +02:00
head.c x86: move reserve_setup_data to setup.c 2008-07-08 13:16:14 +02:00
hpet.c x86: make 64bit hpet_set_mapping to use ioremap too, v2 2008-07-14 09:24:17 +02:00
i386_ksyms_32.c ftrace: store mcount address in rec->ip 2008-06-23 22:10:56 +02:00
i387.c x86 ptrace: fix PTRACE_GETFPXREGS error 2008-07-01 11:03:31 +02:00
i8237.c
i8253.c x86: cleanup div_sc() usage 2008-04-26 17:35:47 +02:00
i8259.c i8259: fix final ugliness 2008-06-02 11:55:52 +02:00
init_task.c [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
io_apic_32.c x86: I/O APIC: remove an IRQ2-mask hack 2008-07-13 11:43:48 +02:00
io_apic_64.c x86: I/O APIC: remove an IRQ2-mask hack 2008-07-13 11:43:48 +02:00
io_delay.c x86: add dmi quirk for io_delay 2008-03-26 22:23:40 +01:00
ioport.c x86: refactor ioport unification 2008-01-30 13:33:10 +01:00
ipi.c x86: ipi.c: removed duplicated include 2008-05-25 08:58:32 +02:00
irq_32.c Merge branch 'x86/irq' into x86/devel 2008-07-08 09:53:57 +02:00
irq_64.c x86: make /proc/stat account for all interrupts 2008-05-25 07:11:49 +02:00
irqinit_32.c x86: rename the i8259_32/64.c leftovers to irqinit_32/64.c 2008-05-24 16:47:39 +02:00
irqinit_64.c x86: rename the i8259_32/64.c leftovers to irqinit_32/64.c 2008-05-24 16:47:39 +02:00
k8.c
kdebugfs.c x86, boot: export linked list of struct setup_data via debugfs 2008-04-26 21:34:42 +02:00
kgdb.c x86: KGDB build fix 2008-04-19 19:19:54 +02:00
kprobes.c Kprobe smoke test lockdep warning 2008-07-15 11:18:03 +02:00
kvm.c x86: KVM guest: hypercall batching 2008-04-27 12:00:28 +03:00
kvmclock.c x86: KVM guest: Use the paravirt clocksource structs and functions 2008-06-24 21:02:33 +03:00
ldt.c x86: avoid re-loading LDT in unrelated address spaces 2008-05-22 19:11:20 +02:00
machine_kexec_32.c Merge branch 'auto-ftrace-next' into tracing/for-linus 2008-07-14 16:11:52 +02:00
machine_kexec_64.c Merge branch 'auto-ftrace-next' into tracing/for-linus 2008-07-14 16:11:52 +02:00
Makefile Merge branch 'auto-ftrace-next' into tracing/for-linus 2008-07-14 16:11:52 +02:00
mca_32.c x86: coding style fixes to arch/x86/kernel/mca_32.c 2008-04-17 17:40:49 +02:00
mfgpt_32.c geode: fix modular build 2008-06-12 21:25:51 +02:00
microcode.c Merge branch 'for-2.6.27' of git://git.infradead.org/users/dwmw2/firmware-2.6 2008-07-14 16:54:07 -07:00
mmconf-fam10h_64.c x86: move mmconfig declarations to header 2008-05-30 15:45:17 -07:00
module_32.c
module_64.c
mpparse.c x86: add early quirk support 2008-07-10 18:55:31 +02:00
msr.c x86: cdev lock_kernel() pushdown 2008-05-18 15:43:40 -06:00
nmi.c x86: Recover timer_ack lost in the merge of the NMI watchdog 2008-07-11 20:54:03 +02:00
numaq_32.c x86: fix numaq_tsc_disable calling 2008-07-13 08:19:45 +02:00
olpc.c x86: olpc: add One Laptop Per Child architecture support 2008-04-29 08:06:07 -07:00
paravirt_patch_32.c x86/paravirt: split sysret and sysexit 2008-07-08 13:13:15 +02:00
paravirt_patch_64.c x86/paravirt: add sysret/sysexit pvops for returning to 32-bit compatibility userspace 2008-07-08 13:15:52 +02:00
paravirt.c x86: rename paravirtualized TSC functions 2008-07-09 07:43:28 +02:00
pci-calgary_64.c x86: remove end_pfn in 64bit 2008-07-08 13:10:38 +02:00
pci-dma.c x86: remove end_pfn in 64bit 2008-07-08 13:10:38 +02:00
pci-gart_64.c x86: max_low_pfn_mapped fix #4 2008-07-14 09:24:16 +02:00
pci-nommu.c x86: unify pci-nommu 2008-04-19 19:19:57 +02:00
pci-swiotlb_64.c x86: remove end_pfn in 64bit 2008-07-08 13:10:38 +02:00
pcspeaker.c
pmtimer_64.c
probe_roms_32.c x86: seperate probe_roms into another file 2008-07-08 12:50:05 +02:00
process_32.c Merge branch 'auto-ftrace-next' into tracing/for-linus 2008-07-14 16:11:52 +02:00
process_64.c Merge branch 'auto-ftrace-next' into tracing/for-linus 2008-07-14 16:11:52 +02:00
process.c x86: add C1E aware idle function, fix 2008-07-08 07:47:37 +02:00
ptrace.c x86 ptrace: fix PTRACE_GETFPXREGS error 2008-07-01 11:03:31 +02:00
pvclock.c x86: Add structs and functions for paravirt clocksource 2008-06-24 21:02:31 +03:00
quirks.c x86: add another PCI ID for ICH6 force hpet. 2008-06-05 15:11:35 +02:00
reboot_fixups_32.c x86: constify data in reboot.c 2008-05-25 08:58:30 +02:00
reboot.c x86: constify data in reboot.c 2008-05-25 08:58:30 +02:00
relocate_kernel_32.S x86: relocate_kernel - use predefined macroses for page attributes 2008-04-17 17:41:29 +02:00
relocate_kernel_64.S x86: relocate_kernel - use predefined macroses for page attributes 2008-04-17 17:41:29 +02:00
rtc.c provide rtc_cmos platform device 2008-06-12 18:05:42 -07:00
scx200_32.c x86: fix sparse warning in kernel/scx200_32.c 2008-01-31 22:05:45 +01:00
setup_percpu.c x86: change _node_to_cpumask_ptr to return const ptr 2008-07-13 19:11:58 +02:00
setup.c x86: fix numaq_tsc_disable calling 2008-07-13 08:19:45 +02:00
sigframe.h x86: move struct definitions to unifed sigframe.h 2008-04-17 17:40:46 +02:00
signal_32.c signals: x86 TS_RESTORE_SIGMASK 2008-04-30 08:29:37 -07:00
signal_64.c signals: x86 TS_RESTORE_SIGMASK 2008-04-30 08:29:37 -07:00
smp.c x86: fix app crashes after SMP resume 2008-05-13 19:36:12 +02:00
smpboot.c arch/x86/kernel/smpboot.c: fix warning 2008-07-09 08:18:39 +02:00
smpcommon_32.c x86: create smpcommon.c 2008-04-17 17:40:55 +02:00
smpcommon.c x86: create smpcommon.c 2008-04-17 17:40:55 +02:00
stacktrace.c x86: don't save unreliable stack trace entries 2008-02-26 12:55:58 +01:00
step.c x86: prevent unconditional writes to DebugCtl MSR 2008-04-17 17:40:58 +02:00
summit_32.c x86: make generic arch support NUMAQ 2008-06-10 11:34:42 +02:00
sys_i386_32.c x86: coding style fixes to arch/x86/kernel/sys_i386_32.c 2008-06-10 12:34:54 +02:00
sys_x86_64.c unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
syscall_64.c x86: coding style fixes to arch/x86/kernel/syscall_64.c 2008-04-17 17:40:48 +02:00
syscall_table_32.S timerfd: wire the new timerfd API to the x86 family 2008-02-05 09:44:07 -08:00
tce_64.c
test_nx.c x86: Explicitly include required header files. 2008-04-17 17:41:15 +02:00
test_rodata.c x86: include proper prototypes for rodata_test 2008-02-14 23:30:20 +01:00
time_32.c x86: merge sched_clock handling 2008-07-09 07:43:25 +02:00
time_64.c x86: merge tsc_init and clocksource code 2008-07-09 07:43:27 +02:00
tlb_32.c x86: create tlb files 2008-04-17 17:40:56 +02:00
tlb_64.c SGI UV: TLB shootdown using broadcast assist unit, cleanups 2008-07-08 12:23:24 +02:00
tlb_uv.c x86, SGI UV: uv_ptc_proc_write fix 2008-07-08 12:23:31 +02:00
tls.c asmlinkage_protect replaces prevent_tail_call 2008-04-10 17:28:26 -07:00
tls.h
topology.c x86: fix section mismatch warning in topology.c:arch_register_cpu 2008-02-19 16:18:30 +01:00
trampoline_32.S x86: trampoline_32.S - switch to .cpuinit.data 2008-04-26 17:35:47 +02:00
trampoline_64.S x86: move suspend wakeup code to C 2008-04-17 17:41:37 +02:00
trampoline.c x86: extend e820 ealy_res support 32bit 2008-05-25 10:55:11 +02:00
traps_32.c x86: traps_xx: various small changes 2008-07-09 08:18:31 +02:00
traps_64.c Merge branch 'x86/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-07-14 13:43:24 -07:00
tsc_sync.c x86: add warning to check_tsc_warp() 2008-01-30 13:33:24 +01:00
tsc.c x86: remove duplicate call to use_tsc_delay 2008-07-10 19:47:55 +02:00
verify_cpu_64.S
visws_quirks.c x86, VisWS: build fix 2008-07-10 19:45:01 +02:00
vm86_32.c x86: replace most VM86 flags with flags from processor-flags.h 2008-04-17 17:41:33 +02:00
vmi_32.c x86: rename paravirtualized TSC functions 2008-07-09 07:43:28 +02:00
vmiclock_32.c x86: rename paravirtualized TSC functions 2008-07-09 07:43:28 +02:00
vmlinux_32.lds.S Merge branch 'core/rodata' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-07-14 15:28:10 -07:00
vmlinux_64.lds.S Merge branch 'core/rodata' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-07-14 15:28:10 -07:00
vmlinux.lds.S
vsmp_64.c x86: vsmp_64 add missing includes 2008-05-25 08:58:24 +02:00
vsyscall_64.c Merge branch 'auto-ftrace-next' into tracing/for-linus 2008-07-14 16:11:52 +02:00
x8664_ksyms_64.c Merge branch 'auto-ftrace-next' into tracing/for-linus 2008-07-14 16:11:52 +02:00