From: Matt Mackall <mpm@selenic.com>
To: "Randy.Dunlap" <rddunlap@osdl.org>
Cc: akpm@osdl.org, davej@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: Debug: sleeping function called from invalid context
Date: Mon, 18 Aug 2003 23:26:44 -0500 [thread overview]
Message-ID: <20030819042644.GJ16387@waste.org> (raw)
In-Reply-To: <32829.4.4.25.4.1061264369.squirrel@www.osdl.org>
On Mon, Aug 18, 2003 at 08:39:29PM -0700, Randy.Dunlap wrote:
> > "Randy.Dunlap" <rddunlap@osdl.org> wrote:
> >>
> >> Debug: sleeping function called with interrupts disabled at
> >> include/asm/uaccess.h:473
> >
> > OK, now my vague understanding of what's going on is that the app has chosen
> > to disable local interupts (via iopl()) and has taken a vm86 trap. I guess
> > we'd see the same thing if the app performed some sleeping syscall while
> > interrupts are disabled.
> >
> > If that is correct then it really is just a false positive.
> >
> > It could also point at a bug in the application; it is presumably disabling
> > interrupts for some form of locking, atomicity or timing guarantee. But it
> > will not lock against other CPUs and the fact that it trapped into the
> > kernel indicates tat it may not be getting the atomicity which it desires.
>
> Call Trace:
> [<c0120d93>] __might_sleep+0x53/0x74
> [<c010d001>] save_v86_state+0x71/0x1f0
> [<c010dbd5>] handle_vm86_fault+0xc5/0xa90
> [<c019cac8>] ext3_file_write+0x28/0xc0
> [<c011cd96>] __change_page_attr+0x26/0x220
> [<c010b310>] do_general_protection+0x0/0x90
> [<c010a69d>] error_code+0x2d/0x40
> [<c0109657>] syscall_call+0x7/0xb
>
> My (more) vague understanding is that X(?) got the kernel to
> do_general_protection() somehow, but change_page_attr() does this:
> spin_lock_irqsave(&cpa_lock, flags);
> in arch/i386/mm/pageattr.c (I'm on a UP box),
> so irqs are disabled by the kernel and then we calls put_user()
> with a spinlock held.
My suspicion is that the X driver (MGA, right?) copies its BIOS into
its address space, sets up io permissions for it to fiddle with your
card, and then calls sys_vm86 with the appropriate registers to call
into the interrupt handler when sys_vm86 swaps those registers in and
does "jmp resume_userspace". When the video BIOS software interrupt
handler does iret, we get the fault, copy the registers to our 32-bit
usermode (tripping might_sleep), and then swap the 32-bit registers
back in for another jump to resume_userspace.
The fix is making return_to_32_bit return back to the end of
do_sys_vm86 rather than straight to userspace, at which point we can
safely handle the registers.
--
Matt Mackall : http://www.selenic.com : of or relating to the moon
next prev parent reply other threads:[~2003-08-19 4:27 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-15 17:18 Debug: sleeping function called from invalid context Randy.Dunlap
2003-08-15 17:32 ` Dave Jones
2003-08-15 17:42 ` Randy.Dunlap
2003-08-15 19:30 ` Randy.Dunlap
2003-08-16 7:06 ` Matt Mackall
2003-08-18 21:07 ` Randy.Dunlap
2003-08-18 21:26 ` Matt Mackall
2003-08-19 0:13 ` Dave Jones
2003-08-19 0:15 ` Randy.Dunlap
2003-08-19 1:02 ` Zwane Mwaikambo
2003-08-19 0:15 ` Andrew Morton
2003-08-19 1:27 ` Matt Mackall
2003-08-19 3:24 ` Randy.Dunlap
2003-08-19 3:35 ` Andrew Morton
2003-08-19 3:39 ` Randy.Dunlap
2003-08-19 4:26 ` Matt Mackall [this message]
2003-08-19 4:29 ` Andrew Morton
2003-08-19 4:14 ` Matt Mackall
2003-08-19 5:14 ` Matt Mackall
2003-08-19 1:01 ` Matt Mackall
2003-08-19 1:04 ` Dave Jones
2003-08-19 1:09 ` Matt Mackall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030819042644.GJ16387@waste.org \
--to=mpm@selenic.com \
--cc=akpm@osdl.org \
--cc=davej@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rddunlap@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox