Re: [uml-devel] Re: [PATCH 07/10] uml: avoid fixing faults whileatomic

From: Andrew Morton
Date: Thu Sep 22 2005 - 14:59:34 EST


Blaisorblade <blaisorblade@xxxxxxxx> wrote:
>
> On Wednesday 21 September 2005 22:47, Andrew Morton wrote:
> > Blaisorblade <blaisorblade@xxxxxxxx> wrote:
> > > On Wednesday 21 September 2005 21:49, Andrew Morton wrote:
> > > > "Paolo 'Blaisorblade' Giarrusso" <blaisorblade@xxxxxxxx> wrote:
> > > > > From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@xxxxxxxx>
>
> > > > It has accidental side-effects,
> > > > such as making copy_to_user() fail if inside spinlocks when
> > > > CONFIG_PREEMPT=y.
>
> > > Sorry, but should it ever succeed inside spinlocks? I mean, should it
> > > ever call down() inside spinlocks? (We never do down_trylock, and ever if
> > > we did the x86 trick, that wouldn't make the whole thing safe at all -
> > > they still take the spinlock and potentially sleep. And it's legal only
> > > if no spinlock is held).
>
> > Not sure what you're asking here.
>
> > copy_to/from_user() will fail inside spinlock if CONFIG_PREMPT=y and if the
> > copy happens to cause a fault.
>
> > Otherwise it will succeed inside spinlock,
> > and it won't spew a sleeping-while-atomic warning, because that uses
> > in_atomic() too.
>
> > It might deadlock if we schedule away and try to retake
> > the same lock.
> Exactly - the point is: is it legal to call copy_from_user() while holding a
> spinlock (which is my original question)? Or should copy_from_user try to
> satisfy the fault, instead of seeing in_atomic() or something similar and
> fail?

No, it is not legal to call copy_*_user() while holding a spinlock.

If CONFIG_PREEMPT=n, do_page_fault() has no way of knowing that the caller
holds a spinlock.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/