diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2009-01-13 17:36:34 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-15 04:46:13 -0500 |
commit | be716615fe596ee117292dc615e95f707fb67fd1 (patch) | |
tree | b814b0298bf34c0ee59db1bc29192f55c7e59bdd /arch/x86 | |
parent | e49590b6dd356f8ef10ba3531a29e5086f6f2e3a (diff) |
x86, vm86: fix preemption bug
Commit 3d2a71a596bd9c761c8487a2178e95f8a61da083 ("x86, traps: converge
do_debug handlers") changed the preemption disable logic of do_debug()
so vm86_handle_trap() is called with preemption disabled resulting in:
BUG: sleeping function called from invalid context at include/linux/kernel.h:155
in_atomic(): 1, irqs_disabled(): 0, pid: 3005, name: dosemu.bin
Pid: 3005, comm: dosemu.bin Tainted: G W 2.6.29-rc1 #51
Call Trace:
[<c050d669>] copy_to_user+0x33/0x108
[<c04181f4>] save_v86_state+0x65/0x149
[<c0418531>] handle_vm86_trap+0x20/0x8f
[<c064e345>] do_debug+0x15b/0x1a4
[<c064df1f>] debug_stack_correct+0x27/0x2c
[<c040365b>] sysenter_do_call+0x12/0x2f
BUG: scheduling while atomic: dosemu.bin/3005/0x10000001
Restore the original calling convention and reenable preemption before
calling handle_vm86_trap().
Reported-by: Michal Suchanek <hramrach@centrum.cz>
Cc: stable@kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/traps.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 7932338d7cb3..a9e7548e1790 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c | |||
@@ -99,6 +99,12 @@ static inline void preempt_conditional_sti(struct pt_regs *regs) | |||
99 | local_irq_enable(); | 99 | local_irq_enable(); |
100 | } | 100 | } |
101 | 101 | ||
102 | static inline void conditional_cli(struct pt_regs *regs) | ||
103 | { | ||
104 | if (regs->flags & X86_EFLAGS_IF) | ||
105 | local_irq_disable(); | ||
106 | } | ||
107 | |||
102 | static inline void preempt_conditional_cli(struct pt_regs *regs) | 108 | static inline void preempt_conditional_cli(struct pt_regs *regs) |
103 | { | 109 | { |
104 | if (regs->flags & X86_EFLAGS_IF) | 110 | if (regs->flags & X86_EFLAGS_IF) |
@@ -626,8 +632,10 @@ clear_dr7: | |||
626 | 632 | ||
627 | #ifdef CONFIG_X86_32 | 633 | #ifdef CONFIG_X86_32 |
628 | debug_vm86: | 634 | debug_vm86: |
635 | /* reenable preemption: handle_vm86_trap() might sleep */ | ||
636 | dec_preempt_count(); | ||
629 | handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, 1); | 637 | handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, 1); |
630 | preempt_conditional_cli(regs); | 638 | conditional_cli(regs); |
631 | return; | 639 | return; |
632 | #endif | 640 | #endif |
633 | 641 | ||